step4_controller.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. * @return {Object}
  252. */
  253. getStopServicesData: function () {
  254. var data = {
  255. "ServiceInfo": {
  256. "state": "INSTALLED"
  257. }
  258. };
  259. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  260. if (unrelatedServices) {
  261. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  262. return !unrelatedServices.contains(s)
  263. }).join(',');
  264. data.context = "Stop required services";
  265. data.urlParams = "ServiceInfo/service_name.in(" + list + ")";
  266. } else {
  267. data.context = "Stop all services";
  268. }
  269. return data;
  270. },
  271. /**
  272. * make server call to stop services
  273. */
  274. stopServices: function () {
  275. App.ajax.send({
  276. name: 'common.services.update',
  277. sender: this,
  278. data: this.getStopServicesData(),
  279. success: 'startPolling',
  280. error: 'onTaskError'
  281. });
  282. },
  283. createHostComponents: function () {
  284. this.set('multiTaskCounter', 0);
  285. var hostComponents = this.get('hostComponents');
  286. var hostName = this.get('content.reassignHosts.target');
  287. for (var i = 0; i < hostComponents.length; i++) {
  288. this.createComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'));
  289. }
  290. },
  291. onCreateComponent: function () {
  292. this.onComponentsTasksSuccess();
  293. },
  294. putHostComponentsInMaintenanceMode: function () {
  295. this.set('multiTaskCounter', 0);
  296. var hostComponents = this.get('hostComponents');
  297. var hostName = this.get('content.reassignHosts.source');
  298. for (var i = 0; i < hostComponents.length; i++) {
  299. App.ajax.send({
  300. name: 'common.host.host_component.passive',
  301. sender: this,
  302. data: {
  303. hostName: hostName,
  304. passive_state: "ON",
  305. componentName: hostComponents[i]
  306. },
  307. success: 'onComponentsTasksSuccess',
  308. error: 'onTaskError'
  309. });
  310. }
  311. },
  312. installHostComponents: function () {
  313. this.set('multiTaskCounter', 0);
  314. var hostComponents = this.get('hostComponents');
  315. var hostName = this.get('content.reassignHosts.target');
  316. for (var i = 0; i < hostComponents.length; i++) {
  317. this.updateComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'), "Install", hostComponents.length);
  318. }
  319. },
  320. reconfigure: function () {
  321. this.loadConfigsTags();
  322. },
  323. loadConfigsTags: function () {
  324. App.ajax.send({
  325. name: 'config.tags',
  326. sender: this,
  327. success: 'onLoadConfigsTags',
  328. error: 'onTaskError'
  329. });
  330. },
  331. /**
  332. * construct URL parameters for config call
  333. * @param componentName
  334. * @param data
  335. * @return {Array}
  336. */
  337. getConfigUrlParams: function (componentName, data) {
  338. var urlParams = [];
  339. switch (componentName) {
  340. case 'NAMENODE':
  341. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  342. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  343. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  344. urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
  345. }
  346. break;
  347. case 'SECONDARY_NAMENODE':
  348. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  349. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  350. break;
  351. case 'JOBTRACKER':
  352. urlParams.push('(type=mapred-site&tag=' + data.Clusters.desired_configs['mapred-site'].tag + ')');
  353. break;
  354. case 'RESOURCEMANAGER':
  355. urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')');
  356. break;
  357. }
  358. return urlParams;
  359. },
  360. onLoadConfigsTags: function (data) {
  361. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  362. App.ajax.send({
  363. name: 'reassign.load_configs',
  364. sender: this,
  365. data: {
  366. urlParams: urlParams.join('|')
  367. },
  368. success: 'onLoadConfigs',
  369. error: 'onTaskError'
  370. });
  371. },
  372. onLoadConfigs: function (data) {
  373. var componentName = this.get('content.reassign.component_name');
  374. var targetHostName = this.get('content.reassignHosts.target');
  375. var configs = {};
  376. var secureConfigs = [];
  377. data.items.forEach(function (item) {
  378. configs[item.type] = item.properties;
  379. }, this);
  380. this.setAdditionalConfigs(configs, componentName, targetHostName);
  381. this.setSecureConfigs(secureConfigs, configs, componentName);
  382. if (componentName === 'NAMENODE') {
  383. this.setSpecificNamenodeConfigs(configs, targetHostName);
  384. }
  385. if (componentName === 'RESOURCEMANAGER') {
  386. this.setSpecificResourceMangerConfigs(configs, targetHostName);
  387. }
  388. this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName));
  389. this.saveConfigsToServer(configs);
  390. },
  391. /**
  392. * make PUT call to save configs to server
  393. * @param configs
  394. */
  395. saveConfigsToServer: function (configs) {
  396. App.ajax.send({
  397. name: 'common.across.services.configurations',
  398. sender: this,
  399. data: {
  400. data: '[' + this.getServiceConfigData(configs).toString() + ']'
  401. },
  402. success: 'onSaveConfigs',
  403. error: 'onTaskError'
  404. });
  405. },
  406. /**
  407. * gather and format config data before sending to server
  408. * @param configs
  409. * @return {Array}
  410. * @method getServiceConfigData
  411. */
  412. getServiceConfigData: function (configs) {
  413. var componentName = this.get('content.reassign.component_name');
  414. var tagName = 'version' + (new Date).getTime();
  415. var configData = Object.keys(configs).map(function (_siteName) {
  416. return {
  417. type: _siteName,
  418. tag: tagName,
  419. properties: configs[_siteName],
  420. service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName))
  421. }
  422. });
  423. var allConfigData = [];
  424. App.Service.find().forEach(function (service) {
  425. var stackService = App.StackService.find().findProperty('serviceName', service.get('serviceName'));
  426. if (stackService) {
  427. var serviceConfigData = [];
  428. Object.keys(stackService.get('configTypesRendered')).forEach(function (type) {
  429. var serviceConfigTag = configData.findProperty('type', type);
  430. if (serviceConfigTag) {
  431. serviceConfigData.pushObject(serviceConfigTag);
  432. }
  433. }, this);
  434. allConfigData.pushObject(JSON.stringify({
  435. Clusters: {
  436. desired_config: serviceConfigData
  437. }
  438. }));
  439. }
  440. }, this);
  441. return allConfigData;
  442. },
  443. /**
  444. * set specific configs which applies only to NameNode component
  445. * @param configs
  446. * @param targetHostName
  447. */
  448. setSpecificNamenodeConfigs: function (configs, targetHostName) {
  449. var sourceHostName = this.get('content.reassignHosts.source');
  450. if (App.get('isHadoop2Stack') && App.get('isHaEnabled')) {
  451. var nameServices = configs['hdfs-site']['dfs.nameservices'];
  452. var suffix = (configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] === sourceHostName + ':50070') ? '.nn1' : '.nn2';
  453. configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + suffix] = targetHostName + ':50070';
  454. configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + suffix] = targetHostName + ':50470';
  455. configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + suffix] = targetHostName + ':8020';
  456. }
  457. if (!App.get('isHaEnabled') && App.Service.find('HBASE').get('isLoaded')) {
  458. configs['hbase-site']['hbase.rootdir'] = configs['hbase-site']['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + targetHostName + ':8020');
  459. }
  460. },
  461. /**
  462. * set specific configs which applies only to ResourceManager component
  463. * @param configs
  464. * @param targetHostName
  465. */
  466. setSpecificResourceMangerConfigs: function (configs, targetHostName) {
  467. var sourceHostName = this.get('content.reassignHosts.source');
  468. if (App.get('isHadoop2Stack') && App.get('isRMHaEnabled')) {
  469. if (configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === sourceHostName) {
  470. configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] = targetHostName;
  471. } else {
  472. configs['yarn-site']['yarn.resourcemanager.hostname.rm2'] = targetHostName;
  473. }
  474. }
  475. },
  476. /**
  477. * set secure configs for component
  478. * @param secureConfigs
  479. * @param configs
  480. * @param componentName
  481. * @return {Boolean}
  482. */
  483. setSecureConfigs: function (secureConfigs, configs, componentName) {
  484. var securityEnabled = this.get('content.securityEnabled');
  485. var component = this.get('secureConfigsMap').findProperty('componentName', componentName);
  486. if (Em.isNone(component) || !securityEnabled) return false;
  487. component.configs.forEach(function (config) {
  488. secureConfigs.push({
  489. keytab: configs[config.site][config.keytab],
  490. principal: configs[config.site][config.principal]
  491. });
  492. });
  493. return true;
  494. },
  495. /**
  496. * derive component directory from configurations
  497. * @param configs
  498. * @param componentName
  499. * @return {String}
  500. */
  501. getComponentDir: function (configs, componentName) {
  502. if (componentName === 'NAMENODE') {
  503. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.name.dir'] : configs['hdfs-site']['dfs.name.dir'];
  504. }
  505. else if (componentName === 'SECONDARY_NAMENODE') {
  506. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.checkpoint.dir'] : configs['core-site']['fs.checkpoint.dir'];
  507. }
  508. return '';
  509. },
  510. /**
  511. * save cluster status to server
  512. *
  513. * @param secureConfigs
  514. * @param componentDir
  515. * @return {Boolean}
  516. */
  517. saveClusterStatus: function (secureConfigs, componentDir) {
  518. if (componentDir || secureConfigs.length) {
  519. App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
  520. App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
  521. App.clusterStatus.setClusterStatus({
  522. clusterName: this.get('content.cluster.name'),
  523. clusterState: this.get('clusterDeployState'),
  524. wizardControllerName: this.get('content.controllerName'),
  525. localdb: App.db.data
  526. });
  527. return true;
  528. }
  529. return false;
  530. },
  531. onSaveConfigs: function () {
  532. this.onTaskCompleted();
  533. },
  534. startZooKeeperServers: function () {
  535. var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER');
  536. this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start");
  537. },
  538. startNameNode: function () {
  539. var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE');
  540. this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.source')), "HDFS", "Start");
  541. },
  542. /**
  543. * make server call to start services
  544. */
  545. startServices: function () {
  546. App.ajax.send({
  547. name: 'common.services.update',
  548. sender: this,
  549. data: this.getStartServicesData(),
  550. success: 'startPolling',
  551. error: 'onTaskError'
  552. });
  553. },
  554. /**
  555. * compute data for call to start services
  556. * @return {Object}
  557. */
  558. getStartServicesData: function () {
  559. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  560. var data = {};
  561. if (unrelatedServices) {
  562. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  563. return !unrelatedServices.contains(s)
  564. }).join(',');
  565. data = {
  566. "context": "Start required services",
  567. "ServiceInfo": {
  568. "state": "STARTED"
  569. },
  570. "urlParams": "ServiceInfo/service_name.in(" + list + ")"
  571. };
  572. } else {
  573. data = {
  574. "context": "Start all services",
  575. "ServiceInfo": {
  576. "state": "STARTED"
  577. },
  578. "urlParams": "params/run_smoke_test=true"
  579. };
  580. }
  581. return data;
  582. },
  583. /**
  584. * make DELETE call for each host component on host
  585. */
  586. deleteHostComponents: function () {
  587. this.set('multiTaskCounter', 0);
  588. var hostComponents = this.get('hostComponents');
  589. var hostName = this.get('content.reassignHosts.source');
  590. for (var i = 0; i < hostComponents.length; i++) {
  591. App.ajax.send({
  592. name: 'common.delete.host_component',
  593. sender: this,
  594. data: {
  595. hostName: hostName,
  596. componentName: hostComponents[i]
  597. },
  598. success: 'onComponentsTasksSuccess',
  599. error: 'onDeleteHostComponentsError'
  600. });
  601. }
  602. },
  603. onDeleteHostComponentsError: function (error) {
  604. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  605. this.onComponentsTasksSuccess();
  606. } else {
  607. this.onTaskError();
  608. }
  609. },
  610. done: function () {
  611. if (!this.get('isSubmitDisabled')) {
  612. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  613. if (this.get('content.hasManualSteps')) {
  614. App.router.send('next');
  615. } else {
  616. App.router.send('complete');
  617. }
  618. }
  619. }
  620. });