step4_controller.js 22 KB

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