step4_controller.js 22 KB

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