step4_controller.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. if (additionalConfigs.hasOwnProperty(site)) {
  188. for (var property in additionalConfigs[site]) {
  189. if (additionalConfigs[site].hasOwnProperty(property)) {
  190. if (App.get('isHaEnabled') && componentName === 'NAMENODE' && property === 'fs.defaultFS') continue;
  191. configs[site][property] = additionalConfigs[site][property].replace('<replace-value>', replaceValue);
  192. }
  193. }
  194. }
  195. }
  196. return true;
  197. },
  198. /**
  199. * load step info
  200. */
  201. loadStep: function () {
  202. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  203. this.set('hostComponents', ['NAMENODE', 'ZKFC']);
  204. } else {
  205. this.set('hostComponents', [this.get('content.reassign.component_name')]);
  206. }
  207. this.set('serviceName', [this.get('content.reassign.service_id')]);
  208. this._super();
  209. },
  210. /**
  211. * concat host-component names into string
  212. * @return {String}
  213. */
  214. getHostComponentsNames: function () {
  215. var hostComponentsNames = '';
  216. this.get('hostComponents').forEach(function (comp, index) {
  217. hostComponentsNames += index ? '+' : '';
  218. hostComponentsNames += comp === 'ZKFC' ? comp : App.format.role(comp);
  219. }, this);
  220. return hostComponentsNames;
  221. },
  222. /**
  223. * remove unneeded tasks
  224. */
  225. removeUnneededTasks: function () {
  226. if (this.get('content.hasManualSteps')) {
  227. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  228. // Only for reassign NameNode with HA enabled
  229. this.get('tasks').splice(7, 2);
  230. } else {
  231. this.get('tasks').splice(5, 4);
  232. }
  233. } else {
  234. this.get('tasks').splice(5, 2);
  235. }
  236. },
  237. /**
  238. * initialize tasks
  239. */
  240. initializeTasks: function () {
  241. var commands = this.get('commands');
  242. var currentStep = App.router.get('reassignMasterController.currentStep');
  243. var hostComponentsNames = this.getHostComponentsNames();
  244. for (var i = 0; i < commands.length; i++) {
  245. var TaskLabel = i === 3 ? this.get('serviceName') : hostComponentsNames; //For Reconfigure task, show serviceName
  246. var title = Em.I18n.t('services.reassign.step4.task' + i + '.title').format(TaskLabel);
  247. this.get('tasks').pushObject(Ember.Object.create({
  248. title: title,
  249. status: 'PENDING',
  250. id: i,
  251. command: commands[i],
  252. showRetry: false,
  253. showRollback: false,
  254. name: title,
  255. displayName: title,
  256. progress: 0,
  257. isRunning: false,
  258. hosts: []
  259. }));
  260. }
  261. this.removeUnneededTasks();
  262. },
  263. hideRollbackButton: function () {
  264. var failedTask = this.get('tasks').findProperty('showRollback');
  265. if (failedTask) {
  266. failedTask.set('showRollback', false);
  267. }
  268. }.observes('tasks.@each.showRollback'),
  269. onComponentsTasksSuccess: function () {
  270. this.incrementProperty('multiTaskCounter');
  271. if (this.get('multiTaskCounter') >= this.get('hostComponents').length) {
  272. this.onTaskCompleted();
  273. }
  274. },
  275. /**
  276. * compute data for call to stop services
  277. * @return {Object}
  278. */
  279. getStopServicesData: function () {
  280. var data = {
  281. "ServiceInfo": {
  282. "state": "INSTALLED"
  283. }
  284. };
  285. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  286. if (unrelatedServices) {
  287. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  288. return !unrelatedServices.contains(s)
  289. }).join(',');
  290. data.context = "Stop required services";
  291. data.urlParams = "ServiceInfo/service_name.in(" + list + ")";
  292. } else {
  293. data.context = "Stop all services";
  294. }
  295. return data;
  296. },
  297. /**
  298. * make server call to stop services
  299. */
  300. stopServices: function () {
  301. App.ajax.send({
  302. name: 'common.services.update',
  303. sender: this,
  304. data: this.getStopServicesData(),
  305. success: 'startPolling',
  306. error: 'onTaskError'
  307. });
  308. },
  309. createHostComponents: function () {
  310. this.set('multiTaskCounter', 0);
  311. var hostComponents = this.get('hostComponents');
  312. var hostName = this.get('content.reassignHosts.target');
  313. for (var i = 0; i < hostComponents.length; i++) {
  314. this.createComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'));
  315. }
  316. },
  317. onCreateComponent: function () {
  318. this.onComponentsTasksSuccess();
  319. },
  320. putHostComponentsInMaintenanceMode: function () {
  321. this.set('multiTaskCounter', 0);
  322. var hostComponents = this.get('hostComponents');
  323. var hostName = this.get('content.reassignHosts.source');
  324. for (var i = 0; i < hostComponents.length; i++) {
  325. App.ajax.send({
  326. name: 'common.host.host_component.passive',
  327. sender: this,
  328. data: {
  329. hostName: hostName,
  330. passive_state: "ON",
  331. componentName: hostComponents[i]
  332. },
  333. success: 'onComponentsTasksSuccess',
  334. error: 'onTaskError'
  335. });
  336. }
  337. },
  338. installHostComponents: function () {
  339. this.set('multiTaskCounter', 0);
  340. var hostComponents = this.get('hostComponents');
  341. var hostName = this.get('content.reassignHosts.target');
  342. for (var i = 0; i < hostComponents.length; i++) {
  343. this.updateComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'), "Install", hostComponents.length);
  344. }
  345. },
  346. reconfigure: function () {
  347. this.loadConfigsTags();
  348. },
  349. loadConfigsTags: function () {
  350. App.ajax.send({
  351. name: 'config.tags',
  352. sender: this,
  353. success: 'onLoadConfigsTags',
  354. error: 'onTaskError'
  355. });
  356. },
  357. /**
  358. * construct URL parameters for config call
  359. * @param componentName
  360. * @param data
  361. * @return {Array}
  362. */
  363. getConfigUrlParams: function (componentName, data) {
  364. var urlParams = [];
  365. switch (componentName) {
  366. case 'NAMENODE':
  367. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  368. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  369. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  370. urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
  371. }
  372. break;
  373. case 'SECONDARY_NAMENODE':
  374. urlParams.push('(type=hdfs-site&tag=' + data.Clusters.desired_configs['hdfs-site'].tag + ')');
  375. urlParams.push('(type=core-site&tag=' + data.Clusters.desired_configs['core-site'].tag + ')');
  376. break;
  377. case 'JOBTRACKER':
  378. urlParams.push('(type=mapred-site&tag=' + data.Clusters.desired_configs['mapred-site'].tag + ')');
  379. break;
  380. case 'RESOURCEMANAGER':
  381. urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')');
  382. break;
  383. case 'WEBHCAT_SERVER':
  384. urlParams.push('(type=webhcat-site&tag=' + data.Clusters.desired_configs['webhcat-site'].tag + ')');
  385. break;
  386. case 'APP_TIMELINE_SERVER':
  387. urlParams.push('(type=yarn-site&tag=' + data.Clusters.desired_configs['yarn-site'].tag + ')');
  388. break;
  389. case 'OOZIE_SERVER':
  390. urlParams.push('(type=oozie-site&tag=' + data.Clusters.desired_configs['oozie-site'].tag + ')');
  391. break;
  392. case 'WEBHCAT_SERVER':
  393. urlParams.push('(type=webhcat-site&tag=' + data.Clusters.desired_configs['webhcat-site'].tag + ')');
  394. break;
  395. }
  396. return urlParams;
  397. },
  398. onLoadConfigsTags: function (data) {
  399. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  400. App.ajax.send({
  401. name: 'reassign.load_configs',
  402. sender: this,
  403. data: {
  404. urlParams: urlParams.join('|')
  405. },
  406. success: 'onLoadConfigs',
  407. error: 'onTaskError'
  408. });
  409. },
  410. onLoadConfigs: function (data) {
  411. var componentName = this.get('content.reassign.component_name');
  412. var targetHostName = this.get('content.reassignHosts.target');
  413. var configs = {};
  414. var secureConfigs = [];
  415. data.items.forEach(function (item) {
  416. configs[item.type] = item.properties;
  417. }, this);
  418. this.setAdditionalConfigs(configs, componentName, targetHostName);
  419. this.setSecureConfigs(secureConfigs, configs, componentName);
  420. if (componentName === 'NAMENODE') {
  421. this.setSpecificNamenodeConfigs(configs, targetHostName);
  422. }
  423. if (componentName === 'RESOURCEMANAGER') {
  424. this.setSpecificResourceMangerConfigs(configs, targetHostName);
  425. }
  426. this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName));
  427. this.saveConfigsToServer(configs);
  428. },
  429. /**
  430. * make PUT call to save configs to server
  431. * @param configs
  432. */
  433. saveConfigsToServer: function (configs) {
  434. App.ajax.send({
  435. name: 'common.across.services.configurations',
  436. sender: this,
  437. data: {
  438. data: '[' + this.getServiceConfigData(configs).toString() + ']'
  439. },
  440. success: 'onSaveConfigs',
  441. error: 'onTaskError'
  442. });
  443. },
  444. /**
  445. * gather and format config data before sending to server
  446. * @param configs
  447. * @return {Array}
  448. * @method getServiceConfigData
  449. */
  450. getServiceConfigData: function (configs) {
  451. var componentName = this.get('content.reassign.component_name');
  452. var tagName = 'version' + (new Date).getTime();
  453. var configData = Object.keys(configs).map(function (_siteName) {
  454. return {
  455. type: _siteName,
  456. tag: tagName,
  457. properties: configs[_siteName],
  458. service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName))
  459. }
  460. });
  461. var allConfigData = [];
  462. App.Service.find().forEach(function (service) {
  463. var stackService = App.StackService.find().findProperty('serviceName', service.get('serviceName'));
  464. if (stackService) {
  465. var serviceConfigData = [];
  466. Object.keys(stackService.get('configTypesRendered')).forEach(function (type) {
  467. var serviceConfigTag = configData.findProperty('type', type);
  468. if (serviceConfigTag) {
  469. serviceConfigData.pushObject(serviceConfigTag);
  470. }
  471. }, this);
  472. allConfigData.pushObject(JSON.stringify({
  473. Clusters: {
  474. desired_config: serviceConfigData
  475. }
  476. }));
  477. }
  478. }, this);
  479. return allConfigData;
  480. },
  481. /**
  482. * set specific configs which applies only to NameNode component
  483. * @param configs
  484. * @param targetHostName
  485. */
  486. setSpecificNamenodeConfigs: function (configs, targetHostName) {
  487. var sourceHostName = this.get('content.reassignHosts.source');
  488. if (App.get('isHadoop2Stack') && App.get('isHaEnabled')) {
  489. var nameServices = configs['hdfs-site']['dfs.nameservices'];
  490. var suffix = (configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + '.nn1'] === sourceHostName + ':50070') ? '.nn1' : '.nn2';
  491. configs['hdfs-site']['dfs.namenode.http-address.' + nameServices + suffix] = targetHostName + ':50070';
  492. configs['hdfs-site']['dfs.namenode.https-address.' + nameServices + suffix] = targetHostName + ':50470';
  493. configs['hdfs-site']['dfs.namenode.rpc-address.' + nameServices + suffix] = targetHostName + ':8020';
  494. }
  495. if (!App.get('isHaEnabled') && App.Service.find('HBASE').get('isLoaded')) {
  496. configs['hbase-site']['hbase.rootdir'] = configs['hbase-site']['hbase.rootdir'].replace(/\/\/[^\/]*/, '//' + targetHostName + ':8020');
  497. }
  498. },
  499. /**
  500. * set specific configs which applies only to ResourceManager component
  501. * @param configs
  502. * @param targetHostName
  503. */
  504. setSpecificResourceMangerConfigs: function (configs, targetHostName) {
  505. var sourceHostName = this.get('content.reassignHosts.source');
  506. if (App.get('isHadoop2Stack') && App.get('isRMHaEnabled')) {
  507. if (configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === sourceHostName) {
  508. configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] = targetHostName;
  509. } else {
  510. configs['yarn-site']['yarn.resourcemanager.hostname.rm2'] = targetHostName;
  511. }
  512. }
  513. },
  514. /**
  515. * set secure configs for component
  516. * @param secureConfigs
  517. * @param configs
  518. * @param componentName
  519. * @return {Boolean}
  520. */
  521. setSecureConfigs: function (secureConfigs, configs, componentName) {
  522. var securityEnabled = this.get('content.securityEnabled');
  523. var component = this.get('secureConfigsMap').findProperty('componentName', componentName);
  524. if (Em.isNone(component) || !securityEnabled) return false;
  525. component.configs.forEach(function (config) {
  526. secureConfigs.push({
  527. keytab: configs[config.site][config.keytab],
  528. principal: configs[config.site][config.principal]
  529. });
  530. });
  531. return true;
  532. },
  533. /**
  534. * derive component directory from configurations
  535. * @param configs
  536. * @param componentName
  537. * @return {String}
  538. */
  539. getComponentDir: function (configs, componentName) {
  540. if (componentName === 'NAMENODE') {
  541. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.name.dir'] : configs['hdfs-site']['dfs.name.dir'];
  542. }
  543. else if (componentName === 'SECONDARY_NAMENODE') {
  544. return (App.get('isHadoop2Stack')) ? configs['hdfs-site']['dfs.namenode.checkpoint.dir'] : configs['core-site']['fs.checkpoint.dir'];
  545. }
  546. return '';
  547. },
  548. /**
  549. * save cluster status to server
  550. *
  551. * @param secureConfigs
  552. * @param componentDir
  553. * @return {Boolean}
  554. */
  555. saveClusterStatus: function (secureConfigs, componentDir) {
  556. if (componentDir || secureConfigs.length) {
  557. App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
  558. App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
  559. App.clusterStatus.setClusterStatus({
  560. clusterName: this.get('content.cluster.name'),
  561. clusterState: this.get('clusterDeployState'),
  562. wizardControllerName: this.get('content.controllerName'),
  563. localdb: App.db.data
  564. });
  565. return true;
  566. }
  567. return false;
  568. },
  569. onSaveConfigs: function () {
  570. this.onTaskCompleted();
  571. },
  572. startZooKeeperServers: function () {
  573. var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER');
  574. this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start");
  575. },
  576. startNameNode: function () {
  577. var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE');
  578. this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.source')), "HDFS", "Start");
  579. },
  580. /**
  581. * make server call to start services
  582. */
  583. startServices: function () {
  584. App.ajax.send({
  585. name: 'common.services.update',
  586. sender: this,
  587. data: this.getStartServicesData(),
  588. success: 'startPolling',
  589. error: 'onTaskError'
  590. });
  591. },
  592. /**
  593. * compute data for call to start services
  594. * @return {Object}
  595. */
  596. getStartServicesData: function () {
  597. var unrelatedServices = this.get('unrelatedServicesMap')[this.get('content.reassign.component_name')];
  598. var data = {};
  599. if (unrelatedServices) {
  600. var list = App.Service.find().mapProperty("serviceName").filter(function (s) {
  601. return !unrelatedServices.contains(s)
  602. }).join(',');
  603. data = {
  604. "context": "Start required services",
  605. "ServiceInfo": {
  606. "state": "STARTED"
  607. },
  608. "urlParams": "ServiceInfo/service_name.in(" + list + ")"
  609. };
  610. } else {
  611. data = {
  612. "context": "Start all services",
  613. "ServiceInfo": {
  614. "state": "STARTED"
  615. },
  616. "urlParams": "params/run_smoke_test=true"
  617. };
  618. }
  619. return data;
  620. },
  621. /**
  622. * make DELETE call for each host component on host
  623. */
  624. deleteHostComponents: function () {
  625. this.set('multiTaskCounter', 0);
  626. var hostComponents = this.get('hostComponents');
  627. var hostName = this.get('content.reassignHosts.source');
  628. for (var i = 0; i < hostComponents.length; i++) {
  629. App.ajax.send({
  630. name: 'common.delete.host_component',
  631. sender: this,
  632. data: {
  633. hostName: hostName,
  634. componentName: hostComponents[i]
  635. },
  636. success: 'onComponentsTasksSuccess',
  637. error: 'onDeleteHostComponentsError'
  638. });
  639. }
  640. },
  641. onDeleteHostComponentsError: function (error) {
  642. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  643. this.onComponentsTasksSuccess();
  644. } else {
  645. this.onTaskError();
  646. }
  647. },
  648. done: function () {
  649. if (!this.get('isSubmitDisabled')) {
  650. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  651. if (this.get('content.hasManualSteps')) {
  652. App.router.send('next');
  653. } else {
  654. App.router.send('complete');
  655. }
  656. }
  657. }
  658. });