step4_controller.js 22 KB

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