step4_controller.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageController.extend({
  20. isReassign: true,
  21. commands: ['stopServices', 'createHostComponents', 'putHostComponentsInMaintenanceMode', 'reconfigure', 'installHostComponents', 'startZooKeeperServers', 'startNameNode', 'deleteHostComponents', 'startServices'],
  22. clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
  23. multiTaskCounter: 0,
  24. hostComponents: [],
  25. /**
  26. * Map with lists of unrelated services.
  27. * Used to define list of services to stop/start.
  28. */
  29. unrelatedServicesMap: {
  30. 'JOBTRACKER': ['HDFS', 'ZOOKEEPER', 'HBASE', 'FLUME', 'SQOOP', 'STORM'],
  31. 'RESOURCEMANAGER': ['HDFS', 'ZOOKEEPER', 'HBASE', 'FLUME', 'SQOOP', 'STORM']
  32. },
  33. /**
  34. * additional configs with template values
  35. * Part of value to substitute has following format: "<replace-value>"
  36. */
  37. additionalConfigsMap: [
  38. {
  39. componentName: 'RESOURCEMANAGER',
  40. configs: {
  41. 'yarn-site': {
  42. 'yarn.resourcemanager.address': '<replace-value>:8050',
  43. 'yarn.resourcemanager.admin.address': '<replace-value>:8141',
  44. 'yarn.resourcemanager.resource-tracker.address': '<replace-value>:8025',
  45. 'yarn.resourcemanager.scheduler.address': '<replace-value>:8030',
  46. 'yarn.resourcemanager.webapp.address': '<replace-value>:8088',
  47. 'yarn.resourcemanager.hostname': '<replace-value>'
  48. }
  49. }
  50. },
  51. {
  52. componentName: 'JOBTRACKER',
  53. configs: {
  54. 'mapred-site': {
  55. 'mapred.job.tracker.http.address': '<replace-value>:50030',
  56. 'mapred.job.tracker': '<replace-value>:50300'
  57. }
  58. }
  59. },
  60. {
  61. componentName: 'SECONDARY_NAMENODE',
  62. configs: {
  63. 'hdfs-site': {
  64. 'dfs.secondary.http.address': '<replace-value>:50090'
  65. }
  66. },
  67. configs_Hadoop2: {
  68. 'hdfs-site': {
  69. 'dfs.namenode.secondary.http-address': '<replace-value>:50090'
  70. }
  71. }
  72. },
  73. {
  74. componentName: 'NAMENODE',
  75. configs: {
  76. 'hdfs-site': {
  77. 'dfs.http.address': '<replace-value>:50070',
  78. 'dfs.https.address': '<replace-value>:50470'
  79. },
  80. 'core-site': {
  81. 'fs.default.name': 'hdfs://<replace-value>:8020'
  82. }
  83. },
  84. configs_Hadoop2: {
  85. 'hdfs-site': {
  86. 'dfs.namenode.http-address': '<replace-value>:50070',
  87. 'dfs.namenode.https-address': '<replace-value>:50470'
  88. },
  89. 'core-site': {
  90. 'fs.defaultFS': 'hdfs://<replace-value>:8020'
  91. }
  92. }
  93. }
  94. ],
  95. secureConfigsMap: [
  96. {
  97. componentName: 'NAMENODE',
  98. configs: [
  99. {
  100. site: 'hdfs-site',
  101. keytab: 'dfs.namenode.keytab.file',
  102. principal: 'dfs.namenode.kerberos.principal'
  103. },
  104. {
  105. site: 'hdfs-site',
  106. keytab: 'dfs.web.authentication.kerberos.keytab',
  107. principal: 'dfs.web.authentication.kerberos.principal'
  108. }
  109. ]
  110. },
  111. {
  112. componentName: 'SECONDARY_NAMENODE',
  113. configs: [
  114. {
  115. site: 'hdfs-site',
  116. keytab: 'dfs.secondary.namenode.keytab.file',
  117. principal: 'dfs.secondary.namenode.kerberos.principal'
  118. },
  119. {
  120. site: 'hdfs-site',
  121. keytab: 'dfs.web.authentication.kerberos.keytab',
  122. principal: 'dfs.web.authentication.kerberos.principal'
  123. }
  124. ]
  125. },
  126. {
  127. componentName: 'RESOURCEMANAGER',
  128. configs: [
  129. {
  130. site: 'yarn-site',
  131. keytab: 'yarn.resourcemanager.keytab',
  132. principal: 'yarn.resourcemanager.principal'
  133. },
  134. {
  135. site: 'yarn-site',
  136. keytab: 'yarn.resourcemanager.webapp.spnego-keytab-file',
  137. principal: 'yarn.resourcemanager.webapp.spnego-principal'
  138. }
  139. ]
  140. },
  141. {
  142. componentName: 'JOBTRACKER',
  143. configs: [
  144. {
  145. site: 'mapred-site',
  146. keytab: 'mapreduce.jobtracker.keytab.file',
  147. principal: 'mapreduce.jobtracker.kerberos.principal'
  148. }
  149. ]
  150. }
  151. ],
  152. /**
  153. * set additional configs
  154. * configs_Hadoop2 - configs which belongs to Hadoop 2 stack only
  155. * @param configs
  156. * @param componentName
  157. * @param replaceValue
  158. * @return {Boolean}
  159. */
  160. setAdditionalConfigs: function (configs, componentName, replaceValue) {
  161. var isHadoop2Stack = App.get('isHadoop2Stack');
  162. var component = this.get('additionalConfigsMap').findProperty('componentName', componentName);
  163. if (Em.isNone(component)) return false;
  164. var additionalConfigs = (component.configs_Hadoop2 && isHadoop2Stack) ? component.configs_Hadoop2 : component.configs;
  165. for (var site in additionalConfigs) {
  166. for (var property in additionalConfigs[site]) {
  167. configs[site][property] = additionalConfigs[site][property].replace('<replace-value>', replaceValue);
  168. }
  169. }
  170. return true;
  171. },
  172. /**
  173. * load step info
  174. */
  175. loadStep: function () {
  176. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  177. this.set('hostComponents', ['NAMENODE', 'ZKFC']);
  178. } else {
  179. this.set('hostComponents', [this.get('content.reassign.component_name')]);
  180. }
  181. this.set('serviceName', [this.get('content.reassign.service_id')]);
  182. this._super();
  183. },
  184. /**
  185. * concat host-component names into string
  186. * @return {String}
  187. */
  188. getHostComponentsNames: function () {
  189. var hostComponentsNames = '';
  190. this.get('hostComponents').forEach(function (comp, index) {
  191. hostComponentsNames += index ? '+' : '';
  192. hostComponentsNames += comp === 'ZKFC' ? comp : App.format.role(comp);
  193. }, this);
  194. return hostComponentsNames;
  195. },
  196. /**
  197. * remove unneeded tasks
  198. */
  199. removeUnneededTasks: function () {
  200. if (this.get('content.hasManualSteps')) {
  201. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  202. // Only for reassign NameNode with HA enabled
  203. this.get('tasks').splice(7, 2);
  204. } else {
  205. this.get('tasks').splice(5, 4);
  206. }
  207. } else {
  208. this.get('tasks').splice(5, 2);
  209. }
  210. },
  211. /**
  212. * initialize tasks
  213. */
  214. initializeTasks: function () {
  215. var commands = this.get('commands');
  216. var currentStep = App.router.get('reassignMasterController.currentStep');
  217. var hostComponentsNames = this.getHostComponentsNames();
  218. for (var i = 0; i < commands.length; i++) {
  219. var TaskLabel = i === 3 ? this.get('serviceName') : hostComponentsNames; //For Reconfigure task, show serviceName
  220. var title = Em.I18n.t('services.reassign.step4.task' + i + '.title').format(TaskLabel);
  221. this.get('tasks').pushObject(Ember.Object.create({
  222. title: title,
  223. status: 'PENDING',
  224. id: i,
  225. command: commands[i],
  226. showRetry: false,
  227. showRollback: false,
  228. name: title,
  229. displayName: title,
  230. progress: 0,
  231. isRunning: false,
  232. hosts: []
  233. }));
  234. }
  235. this.removeUnneededTasks();
  236. },
  237. hideRollbackButton: function () {
  238. var failedTask = this.get('tasks').findProperty('showRollback');
  239. if (failedTask) {
  240. failedTask.set('showRollback', false);
  241. }
  242. }.observes('tasks.@each.showRollback'),
  243. onComponentsTasksSuccess: function () {
  244. this.incrementProperty('multiTaskCounter');
  245. if (this.get('multiTaskCounter') >= this.get('hostComponents').length) {
  246. this.onTaskCompleted();
  247. }
  248. },
  249. /**
  250. * compute data for call to stop services
  251. */
  252. getStopServicesData: function () {
  253. var data = {
  254. "ServiceInfo": {
  255. "state": "INSTALLED"
  256. }
  257. };
  258. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  259. if (unrelatedServices) {
  260. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  261. return !unrelatedServices.contains(s)
  262. }).join(',');
  263. data.context = "Stop required services";
  264. data.urlParams = "ServiceInfo/service_name.in(" + list + ")";
  265. } else {
  266. data.context = "Stop all services";
  267. }
  268. return data;
  269. },
  270. /**
  271. * make server call to stop services
  272. */
  273. stopServices: function () {
  274. App.ajax.send({
  275. name: 'common.services.update',
  276. sender: this,
  277. data: this.getStopServicesData(),
  278. success: 'startPolling',
  279. error: 'onTaskError'
  280. });
  281. },
  282. createHostComponents: function () {
  283. this.set('multiTaskCounter', 0);
  284. var hostComponents = this.get('hostComponents');
  285. var hostName = this.get('content.reassignHosts.target');
  286. for (var i = 0; i < hostComponents.length; i++) {
  287. this.createComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'));
  288. }
  289. },
  290. onCreateComponent: function () {
  291. this.onComponentsTasksSuccess();
  292. },
  293. putHostComponentsInMaintenanceMode: function () {
  294. this.set('multiTaskCounter', 0);
  295. var hostComponents = this.get('hostComponents');
  296. var hostName = this.get('content.reassignHosts.source');
  297. for (var i = 0; i < hostComponents.length; i++) {
  298. App.ajax.send({
  299. name: 'common.host.host_component.passive',
  300. sender: this,
  301. data: {
  302. hostName: hostName,
  303. passive_state: "ON",
  304. componentName: hostComponents[i]
  305. },
  306. success: 'onComponentsTasksSuccess',
  307. error: 'onTaskError'
  308. });
  309. }
  310. },
  311. installHostComponents: function () {
  312. this.set('multiTaskCounter', 0);
  313. var hostComponents = this.get('hostComponents');
  314. var hostName = this.get('content.reassignHosts.target');
  315. for (var i = 0; i < hostComponents.length; i++) {
  316. this.updateComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'), "Install", hostComponents.length);
  317. }
  318. },
  319. reconfigure: function () {
  320. this.loadConfigsTags();
  321. },
  322. loadConfigsTags: function () {
  323. App.ajax.send({
  324. name: 'config.tags',
  325. sender: this,
  326. success: 'onLoadConfigsTags',
  327. error: 'onTaskError'
  328. });
  329. },
  330. /**
  331. * construct URL parameters for config call
  332. * @param componentName
  333. * @param data
  334. * @return {Array}
  335. */
  336. getConfigUrlParams: function (componentName, data) {
  337. var urlParams = [];
  338. switch (componentName) {
  339. case 'NAMENODE':
  340. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  341. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  342. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  343. urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
  344. }
  345. break;
  346. case 'SECONDARY_NAMENODE':
  347. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  348. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  349. break;
  350. case 'JOBTRACKER':
  351. urlParams.push('(type=mapred-site&tag=' + data.Clusters.desired_configs['mapred-site'].tag + ')');
  352. break;
  353. case 'RESOURCEMANAGER':
  354. urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')');
  355. break;
  356. }
  357. return urlParams;
  358. },
  359. onLoadConfigsTags: function (data) {
  360. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  361. App.ajax.send({
  362. name: 'reassign.load_configs',
  363. sender: this,
  364. data: {
  365. urlParams: urlParams.join('|')
  366. },
  367. success: 'onLoadConfigs',
  368. error: 'onTaskError'
  369. });
  370. },
  371. onLoadConfigs: function (data) {
  372. var componentName = this.get('content.reassign.component_name');
  373. var targetHostName = this.get('content.reassignHosts.target');
  374. var configs = {};
  375. var secureConfigs = [];
  376. data.items.forEach(function (item) {
  377. configs[item.type] = item.properties;
  378. }, this);
  379. this.setAdditionalConfigs(configs, componentName, targetHostName);
  380. this.setSecureConfigs(secureConfigs, configs, componentName);
  381. if (componentName === 'NAMENODE') {
  382. this.setSpecificNamenodeConfigs(configs, targetHostName);
  383. }
  384. if (componentName === 'RESOURCEMANAGER') {
  385. this.setSpecificResourceMangerConfigs(configs, targetHostName);
  386. }
  387. this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName));
  388. this.saveConfigsToServer(configs);
  389. },
  390. /**
  391. * make PUT call to save configs to server
  392. * @param configs
  393. */
  394. saveConfigsToServer: function (configs) {
  395. var componentName = this.get('content.reassign.component_name');
  396. var tagName = 'version' + (new Date).getTime();
  397. var configData = Object.keys(configs).map(function (_siteName) {
  398. return {
  399. type: _siteName,
  400. tag: tagName,
  401. properties: configs[_siteName],
  402. service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName))
  403. }
  404. });
  405. var installedServices = App.Service.find();
  406. var allConfigData = [];
  407. installedServices.forEach(function (service) {
  408. var stackService = App.StackService.find().findProperty('serviceName', service.get('serviceName'));
  409. if (stackService) {
  410. var serviceConfigData = [];
  411. Object.keys(stackService.get('configTypesRendered')).forEach(function (type) {
  412. var serviceConfigTag = configData.findProperty('type', type);
  413. if (serviceConfigTag) {
  414. serviceConfigData.pushObject(serviceConfigTag);
  415. }
  416. }, this);
  417. allConfigData.pushObject(JSON.stringify({
  418. Clusters: {
  419. desired_config: serviceConfigData
  420. }
  421. }));
  422. }
  423. }, this);
  424. App.ajax.send({
  425. name: 'common.across.services.configurations',
  426. sender: this,
  427. data: {
  428. data: '[' + allConfigData.toString() + ']'
  429. },
  430. success: 'onSaveConfigs',
  431. error: 'onTaskError'
  432. });
  433. },
  434. /**
  435. * set specific configs which applies only to NameNode component
  436. * @param configs
  437. * @param targetHostName
  438. */
  439. setSpecificNamenodeConfigs: function (configs, targetHostName) {
  440. var sourceHostName = this.get('content.reassignHosts.source');
  441. if (App.get('isHadoop2Stack') && App.get('isHaEnabled')) {
  442. var nameServices = configs['hdfs-site']['dfs.nameservices'];
  443. if (configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] === sourceHostName + ':50070') {
  444. configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] = targetHostName + ':50070';
  445. configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + '.nn1'] = targetHostName + ':50470';
  446. configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + '.nn1'] = targetHostName + ':8020';
  447. } else {
  448. configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn2'] = targetHostName + ':50070';
  449. configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + '.nn2'] = targetHostName + ':50470';
  450. configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + '.nn2'] = targetHostName + ':8020';
  451. }
  452. }
  453. if (!App.get('isHaEnabled') && App.Service.find('HBASE').get('isLoaded')) {
  454. configs['hbase-site']['hbase.rootdir'] = configs['hbase-site']['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + targetHostName + ':8020');
  455. }
  456. },
  457. /**
  458. * set specific configs which applies only to ResourceManager component
  459. * @param configs
  460. * @param targetHostName
  461. */
  462. setSpecificResourceMangerConfigs: function (configs, targetHostName) {
  463. var sourceHostName = this.get('content.reassignHosts.source');
  464. if (App.get('isHadoop2Stack') && App.get('isRMHaEnabled')) {
  465. if (configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === sourceHostName) {
  466. configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] = targetHostName;
  467. } else {
  468. configs['yarn-site']['yarn.resourcemanager.hostname.rm2'] = targetHostName;
  469. }
  470. }
  471. },
  472. /**
  473. * set secure configs for component
  474. * @param secureConfigs
  475. * @param configs
  476. * @param componentName
  477. * @return {Boolean}
  478. */
  479. setSecureConfigs: function (secureConfigs, configs, componentName) {
  480. var securityEnabled = this.get('content.securityEnabled');
  481. var component = this.get('secureConfigsMap').findProperty('componentName', componentName);
  482. if (Em.isNone(component) || !securityEnabled) return false;
  483. component.configs.forEach(function (config) {
  484. secureConfigs.push({
  485. keytab: configs[config.site][config.keytab],
  486. principal: configs[config.site][config.principal]
  487. });
  488. });
  489. return true;
  490. },
  491. /**
  492. * derive component directory from configurations
  493. * @param configs
  494. * @param componentName
  495. * @return {String}
  496. */
  497. getComponentDir: function (configs, componentName) {
  498. if (componentName === 'NAMENODE') {
  499. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.name.dir'] : configs['hdfs-site']['dfs.name.dir'];
  500. }
  501. else if (componentName === 'SECONDARY_NAMENODE') {
  502. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.checkpoint.dir'] : configs['core-site']['fs.checkpoint.dir'];
  503. }
  504. return '';
  505. },
  506. /**
  507. * save cluster status to server
  508. *
  509. * @param secureConfigs
  510. * @param componentDir
  511. * @return {Boolean}
  512. */
  513. saveClusterStatus: function (secureConfigs, componentDir) {
  514. if (componentDir || secureConfigs.length) {
  515. App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
  516. App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
  517. App.clusterStatus.setClusterStatus({
  518. clusterName: this.get('content.cluster.name'),
  519. clusterState: this.get('clusterDeployState'),
  520. wizardControllerName: this.get('content.controllerName'),
  521. localdb: App.db.data
  522. });
  523. return true;
  524. }
  525. return false;
  526. },
  527. onSaveConfigs: function () {
  528. this.onTaskCompleted();
  529. },
  530. startZooKeeperServers: function () {
  531. var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER');
  532. this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start");
  533. },
  534. startNameNode: function () {
  535. var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE');
  536. this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.source')), "HDFS", "Start");
  537. },
  538. startServices: function () {
  539. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  540. if (unrelatedServices) {
  541. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  542. return !unrelatedServices.contains(s)
  543. }).join(',');
  544. var conf = {
  545. name: 'common.services.update',
  546. sender: this,
  547. data: {
  548. "context": "Start required services",
  549. "ServiceInfo": {
  550. "state": "STARTED"
  551. },
  552. urlParams: "ServiceInfo/service_name.in(" + list + ")"},
  553. success: 'startPolling',
  554. error: 'onTaskError'
  555. };
  556. App.ajax.send(conf);
  557. } else {
  558. App.ajax.send({
  559. name: 'common.services.update',
  560. sender: this,
  561. data: {
  562. "context": "Start all services",
  563. "ServiceInfo": {
  564. "state": "STARTED"
  565. },
  566. urlParams: "params/run_smoke_test=true"
  567. },
  568. success: 'startPolling',
  569. error: 'onTaskError'
  570. });
  571. }
  572. },
  573. deleteHostComponents: function () {
  574. this.set('multiTaskCounter', 0);
  575. var hostComponents = this.get('hostComponents');
  576. var hostName = this.get('content.reassignHosts.source');
  577. for (var i = 0; i < hostComponents.length; i++) {
  578. App.ajax.send({
  579. name: 'common.delete.host_component',
  580. sender: this,
  581. data: {
  582. hostName: hostName,
  583. componentName: hostComponents[i]
  584. },
  585. success: 'onComponentsTasksSuccess',
  586. error: 'onDeleteHostComponentsError'
  587. });
  588. }
  589. },
  590. onDeleteHostComponentsError: function (error) {
  591. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  592. this.onComponentsTasksSuccess();
  593. } else {
  594. this.onTaskError();
  595. }
  596. },
  597. done: function () {
  598. if (!this.get('isSubmitDisabled')) {
  599. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  600. if (this.get('content.hasManualSteps')) {
  601. App.router.send('next');
  602. } else {
  603. App.router.send('complete');
  604. }
  605. }
  606. }
  607. });