step4_controller.js 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  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. /**
  20. * Additional data that is used in the `Move Component Initializers`
  21. *
  22. * @typedef {object} reassignComponentDependencies
  23. * @property {string} sourceHostName host where component was before moving
  24. * @property {string} targetHostName host where component will be after moving
  25. */
  26. App.ReassignMasterWizardStep4Controller = App.HighAvailabilityProgressPageController.extend(App.WizardEnableDone, {
  27. name: "reassignMasterWizardStep4Controller",
  28. commands: [
  29. 'stopRequiredServices',
  30. 'cleanMySqlServer',
  31. 'createHostComponents',
  32. 'putHostComponentsInMaintenanceMode',
  33. 'reconfigure',
  34. 'installHostComponents',
  35. 'startZooKeeperServers',
  36. 'startNameNode',
  37. 'stopHostComponentsInMaintenanceMode',
  38. 'deleteHostComponents',
  39. 'configureMySqlServer',
  40. 'startMySqlServer',
  41. 'startNewMySqlServer',
  42. 'startRequiredServices'
  43. ],
  44. // custom commands for Components with DB Configuration and Check
  45. commandsForDB: [
  46. 'createHostComponents',
  47. 'installHostComponents',
  48. 'configureMySqlServer',
  49. 'restartMySqlServer',
  50. 'testDBConnection',
  51. 'stopRequiredServices',
  52. 'cleanMySqlServer',
  53. 'putHostComponentsInMaintenanceMode',
  54. 'reconfigure',
  55. 'stopHostComponentsInMaintenanceMode',
  56. 'deleteHostComponents',
  57. 'configureMySqlServer',
  58. 'startRequiredServices'
  59. ],
  60. clusterDeployState: 'REASSIGN_MASTER_INSTALLING',
  61. multiTaskCounter: 0,
  62. hostComponents: [],
  63. /**
  64. * Map with lists of related services.
  65. * Used to define list of services to stop/start.
  66. */
  67. relatedServicesMap: {
  68. 'JOBTRACKER': ['PIG', 'OOZIE'],
  69. 'RESOURCEMANAGER': ['YARN', 'MAPREDUCE2', 'TEZ', 'PIG', 'OOZIE', 'SLIDER', 'SPARK'],
  70. 'APP_TIMELINE_SERVER': ['YARN', 'MAPREDUCE2', 'TEZ', 'OOZIE', 'SLIDER', 'SPARK'],
  71. 'HIVE_SERVER': ['HIVE', 'FALCON', 'ATLAS', 'OOZIE'],
  72. 'HIVE_METASTORE': ['HIVE', 'PIG', 'FALCON', 'ATLAS', 'OOZIE'],
  73. 'WEBHCAT_SERVER': ['HIVE'],
  74. 'OOZIE_SERVER': ['OOZIE', 'FALCON', 'KNOX'],
  75. 'MYSQL_SERVER': ['HIVE', 'OOZIE', 'RANGER', 'RANGER_KMS']
  76. },
  77. dbPropertyMap: {
  78. 'HIVE_SERVER': 'javax.jdo.option.ConnectionDriverName',
  79. 'HIVE_METASTORE': 'javax.jdo.option.ConnectionDriverName',
  80. 'OOZIE_SERVER': 'oozie.service.JPAService.jdbc.url'
  81. },
  82. /**
  83. * additional configs with template values
  84. * Part of value to substitute has following format: "<replace-value>"
  85. */
  86. additionalConfigsMap: [
  87. {
  88. componentName: 'RESOURCEMANAGER',
  89. configs: {
  90. 'yarn-site': {
  91. 'yarn.resourcemanager.address': '<replace-value>:8050',
  92. 'yarn.resourcemanager.admin.address': '<replace-value>:8141',
  93. 'yarn.resourcemanager.resource-tracker.address': '<replace-value>:8025',
  94. 'yarn.resourcemanager.scheduler.address': '<replace-value>:8030',
  95. 'yarn.resourcemanager.webapp.address': '<replace-value>:8088',
  96. 'yarn.resourcemanager.hostname': '<replace-value>'
  97. }
  98. }
  99. },
  100. {
  101. componentName: 'JOBTRACKER',
  102. configs: {
  103. 'mapred-site': {
  104. 'mapred.job.tracker.http.address': '<replace-value>:50030',
  105. 'mapred.job.tracker': '<replace-value>:50300'
  106. }
  107. }
  108. },
  109. {
  110. componentName: 'SECONDARY_NAMENODE',
  111. configs: {
  112. 'hdfs-site': {
  113. 'dfs.secondary.http.address': '<replace-value>:50090'
  114. }
  115. },
  116. configs_Hadoop2: {
  117. 'hdfs-site': {
  118. 'dfs.namenode.secondary.http-address': '<replace-value>:50090'
  119. }
  120. }
  121. },
  122. {
  123. componentName: 'NAMENODE',
  124. configs: {
  125. 'hdfs-site': {
  126. 'dfs.http.address': '<replace-value>:50070',
  127. 'dfs.https.address': '<replace-value>:50470'
  128. },
  129. 'core-site': {
  130. 'fs.default.name': 'hdfs://<replace-value>:8020'
  131. }
  132. },
  133. configs_Hadoop2: {
  134. 'hdfs-site': {
  135. 'dfs.namenode.rpc-address': '<replace-value>:8020',
  136. 'dfs.namenode.http-address': '<replace-value>:50070',
  137. 'dfs.namenode.https-address': '<replace-value>:50470'
  138. },
  139. 'core-site': {
  140. 'fs.defaultFS': 'hdfs://<replace-value>:8020'
  141. }
  142. }
  143. },
  144. {
  145. componentName: 'APP_TIMELINE_SERVER',
  146. configs: {
  147. 'yarn-site': {
  148. 'yarn.timeline-service.webapp.address': '<replace-value>:8188',
  149. 'yarn.timeline-service.webapp.https.address': '<replace-value>:8190',
  150. 'yarn.timeline-service.address': '<replace-value>:10200'
  151. }
  152. }
  153. },
  154. {
  155. componentName: 'OOZIE_SERVER',
  156. configs: {
  157. 'oozie-site': {
  158. 'oozie.base.url': 'http://<replace-value>:11000/oozie'
  159. },
  160. 'core-site': {
  161. 'hadoop.proxyuser.oozie.hosts': '<replace-value>'
  162. }
  163. }
  164. },
  165. {
  166. componentName: 'HIVE_METASTORE',
  167. configs: {
  168. 'hive-site': {}
  169. }
  170. },
  171. {
  172. componentName: 'MYSQL_SERVER',
  173. configs: {
  174. 'hive-site': {
  175. 'javax.jdo.option.ConnectionURL': 'jdbc:mysql://<replace-value>/hive?createDatabaseIfNotExist=true'
  176. }
  177. }
  178. },
  179. {
  180. componentName: 'METRICS_COLLECTOR',
  181. configs: {
  182. 'ams-site': {
  183. 'timeline.metrics.service.webapp.address': '<replace-value>:6188'
  184. }
  185. }
  186. },
  187. {
  188. componentName: 'HISTORYSERVER',
  189. configs: {
  190. 'mapred-site': {
  191. 'mapreduce.jobhistory.webapp.address': '<replace-value>:19888',
  192. 'mapreduce.jobhistory.address': '<replace-value>:10020'
  193. }
  194. }
  195. }
  196. ],
  197. secureConfigsMap: [
  198. {
  199. componentName: 'NAMENODE',
  200. configs: [
  201. {
  202. site: 'hdfs-site',
  203. keytab: 'dfs.namenode.keytab.file',
  204. principal: 'dfs.namenode.kerberos.principal'
  205. },
  206. {
  207. site: 'hdfs-site',
  208. keytab: 'dfs.web.authentication.kerberos.keytab',
  209. principal: 'dfs.web.authentication.kerberos.principal'
  210. }
  211. ]
  212. },
  213. {
  214. componentName: 'SECONDARY_NAMENODE',
  215. configs: [
  216. {
  217. site: 'hdfs-site',
  218. keytab: 'dfs.secondary.namenode.keytab.file',
  219. principal: 'dfs.secondary.namenode.kerberos.principal'
  220. },
  221. {
  222. site: 'hdfs-site',
  223. keytab: 'dfs.web.authentication.kerberos.keytab',
  224. principal: 'dfs.web.authentication.kerberos.principal'
  225. }
  226. ]
  227. },
  228. {
  229. componentName: 'RESOURCEMANAGER',
  230. configs: [
  231. {
  232. site: 'yarn-site',
  233. keytab: 'yarn.resourcemanager.keytab',
  234. principal: 'yarn.resourcemanager.principal'
  235. },
  236. {
  237. site: 'yarn-site',
  238. keytab: 'yarn.resourcemanager.webapp.spnego-keytab-file',
  239. principal: 'yarn.resourcemanager.webapp.spnego-principal'
  240. }
  241. ]
  242. },
  243. {
  244. componentName: 'OOZIE_SERVER',
  245. configs: [
  246. {
  247. site: 'oozie-site',
  248. keytab: 'oozie.authentication.kerberos.keytab',
  249. principal: 'oozie.authentication.kerberos.principal'
  250. },
  251. {
  252. site: 'oozie-site',
  253. keytab: 'oozie.service.HadoopAccessorService.keytab.file',
  254. principal: 'oozie.service.HadoopAccessorService.kerberos.principal'
  255. }
  256. ]
  257. },
  258. {
  259. componentName: 'WEBHCAT_SERVER',
  260. configs: [
  261. {
  262. site: 'webhcat-site',
  263. keytab: 'templeton.kerberos.keytab',
  264. principal: 'templeton.kerberos.principal'
  265. }
  266. ]
  267. },
  268. {
  269. componentName: 'HIVE_SERVER',
  270. configs: [
  271. {
  272. site: 'hive-site',
  273. keytab: 'hive.server2.authentication.kerberos.keytab',
  274. principal: 'hive.server2.authentication.kerberos.principal'
  275. },
  276. {
  277. site: 'hive-site',
  278. keytab: 'hive.server2.authentication.spnego.keytab',
  279. principal: 'hive.server2.authentication.spnego.principal'
  280. }
  281. ]
  282. },
  283. {
  284. componentName: 'HIVE_METASTORE',
  285. configs: [
  286. {
  287. site: 'hive-site',
  288. keytab: 'hive.metastore.kerberos.keytab.file',
  289. principal: 'hive.metastore.kerberos.principal'
  290. }
  291. ]
  292. }
  293. ],
  294. /**
  295. * set additional configs
  296. * configs_Hadoop2 - configs which belongs to Hadoop 2 stack only
  297. * @param configs
  298. * @param componentName
  299. * @param replaceValue
  300. * @return {Boolean}
  301. */
  302. setAdditionalConfigs: function (configs, componentName, replaceValue) {
  303. var component = this.get('additionalConfigsMap').findProperty('componentName', componentName);
  304. if (Em.isNone(component)) return false;
  305. var additionalConfigs = (component.configs_Hadoop2) ? component.configs_Hadoop2 : component.configs;
  306. for (var site in additionalConfigs) {
  307. if (additionalConfigs.hasOwnProperty(site)) {
  308. for (var property in additionalConfigs[site]) {
  309. if (additionalConfigs[site].hasOwnProperty(property)) {
  310. if (App.get('isHaEnabled') && componentName === 'NAMENODE' && (property === 'fs.defaultFS' || property === 'dfs.namenode.rpc-address')) continue;
  311. configs[site][property] = additionalConfigs[site][property].replace('<replace-value>', replaceValue);
  312. }
  313. }
  314. }
  315. }
  316. return true;
  317. },
  318. /**
  319. * load step info
  320. */
  321. loadStep: function () {
  322. if (this.get('content.reassign.component_name') === 'NAMENODE' && App.get('isHaEnabled')) {
  323. this.set('hostComponents', ['NAMENODE', 'ZKFC']);
  324. } else {
  325. this.set('hostComponents', [this.get('content.reassign.component_name')]);
  326. }
  327. this.set('serviceName', [this.get('content.reassign.service_id')]);
  328. this._super();
  329. },
  330. /**
  331. * concat host-component names into string
  332. * @return {String}
  333. */
  334. getHostComponentsNames: function () {
  335. var hostComponentsNames = '';
  336. this.get('hostComponents').forEach(function (comp, index) {
  337. hostComponentsNames += index ? '+' : '';
  338. hostComponentsNames += comp === 'ZKFC' ? comp : App.format.role(comp, false);
  339. }, this);
  340. return hostComponentsNames;
  341. },
  342. /**
  343. * remove unneeded tasks
  344. */
  345. removeUnneededTasks: function () {
  346. var componentName = this.get('content.reassign.component_name');
  347. if (this.isComponentWithDB()) {
  348. var db_type = this.get('content.databaseType');
  349. var is_remote_db = this.get('content.serviceProperties.is_remote_db');
  350. if (is_remote_db || db_type !== 'mysql') {
  351. this.removeTasks(['configureMySqlServer', 'startMySqlServer', 'restartMySqlServer', 'cleanMySqlServer', 'configureMySqlServer']);
  352. }
  353. if (db_type === 'derby') {
  354. this.removeTasks(['testDBConnection']);
  355. }
  356. }
  357. if (componentName !== 'MYSQL_SERVER' && !this.isComponentWithDB()) {
  358. this.removeTasks(['configureMySqlServer', 'startMySqlServer', 'restartMySqlServer', 'cleanMySqlServer', 'startNewMySqlServer', 'configureMySqlServer']);
  359. }
  360. if (componentName === 'MYSQL_SERVER') {
  361. this.removeTasks(['cleanMySqlServer']);
  362. }
  363. if (this.get('content.hasManualSteps')) {
  364. if (componentName === 'NAMENODE' && App.get('isHaEnabled')) {
  365. // Only for reassign NameNode with HA enabled
  366. this.removeTasks(['stopHostComponentsInMaintenanceMode', 'deleteHostComponents', 'startRequiredServices']);
  367. } else {
  368. this.removeTasks(['startZooKeeperServers', 'startNameNode', 'stopHostComponentsInMaintenanceMode', 'deleteHostComponents', 'startRequiredServices']);
  369. }
  370. } else {
  371. this.removeTasks(['startZooKeeperServers', 'startNameNode']);
  372. }
  373. if (!this.get('content.reassignComponentsInMM.length')) {
  374. this.removeTasks(['stopHostComponentsInMaintenanceMode']);
  375. }
  376. },
  377. /**
  378. * remove tasks by command name
  379. */
  380. removeTasks: function(commands) {
  381. var tasks = this.get('tasks');
  382. commands.forEach(function(command) {
  383. var cmd = tasks.filterProperty('command', command);
  384. var index = null;
  385. if (cmd.length === 0) {
  386. return false;
  387. } else {
  388. index = tasks.indexOf( cmd[0] );
  389. }
  390. tasks.splice( index, 1 );
  391. });
  392. },
  393. /**
  394. * initialize tasks
  395. */
  396. initializeTasks: function () {
  397. var commands = this.get('commands');
  398. var currentStep = App.router.get('reassignMasterController.currentStep');
  399. var hostComponentsNames = this.getHostComponentsNames();
  400. if (this.isComponentWithDB()) {
  401. commands = this.get('commandsForDB');
  402. }
  403. for (var i = 0; i < commands.length; i++) {
  404. var TaskLabel = i === 3 ? this.get('serviceName') : hostComponentsNames; //For Reconfigure task, show serviceName
  405. var title = Em.I18n.t('services.reassign.step4.tasks.' + commands[i] + '.title').format(TaskLabel);
  406. this.get('tasks').pushObject(Ember.Object.create({
  407. title: title,
  408. status: 'PENDING',
  409. id: i,
  410. command: commands[i],
  411. showRetry: false,
  412. showRollback: false,
  413. name: title,
  414. displayName: title,
  415. progress: 0,
  416. isRunning: false,
  417. hosts: []
  418. }));
  419. }
  420. this.removeUnneededTasks();
  421. this.set('isLoaded', true);
  422. },
  423. hideRollbackButton: function () {
  424. var failedTask = this.get('tasks').findProperty('showRollback');
  425. if (failedTask) {
  426. failedTask.set('showRollback', false);
  427. }
  428. }.observes('tasks.@each.showRollback'),
  429. onComponentsTasksSuccess: function () {
  430. this.decrementProperty('multiTaskCounter');
  431. if (this.get('multiTaskCounter') <= 0) {
  432. this.onTaskCompleted();
  433. }
  434. },
  435. /**
  436. * make server call to stop services
  437. */
  438. stopRequiredServices: function () {
  439. this.stopServices(this.get('relatedServicesMap')[this.get('content.reassign.component_name')], true);
  440. },
  441. createHostComponents: function () {
  442. var hostComponents = this.get('hostComponents');
  443. var hostName = this.get('content.reassignHosts.target');
  444. this.set('multiTaskCounter', hostComponents.length);
  445. for (var i = 0; i < hostComponents.length; i++) {
  446. this.createComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'));
  447. }
  448. },
  449. onCreateComponent: function () {
  450. this.onComponentsTasksSuccess();
  451. },
  452. putHostComponentsInMaintenanceMode: function () {
  453. var hostComponents = this.get('hostComponents');
  454. var hostName = this.get('content.reassignHosts.source');
  455. this.set('multiTaskCounter', hostComponents.length);
  456. for (var i = 0; i < hostComponents.length; i++) {
  457. App.ajax.send({
  458. name: 'common.host.host_component.passive',
  459. sender: this,
  460. data: {
  461. hostName: hostName,
  462. passive_state: "ON",
  463. componentName: hostComponents[i]
  464. },
  465. success: 'onComponentsTasksSuccess',
  466. error: 'onTaskError'
  467. });
  468. }
  469. },
  470. installHostComponents: function () {
  471. var hostComponents = this.get('hostComponents');
  472. var hostName = this.get('content.reassignHosts.target');
  473. this.set('multiTaskCounter', hostComponents.length);
  474. for (var i = 0; i < hostComponents.length; i++) {
  475. this.updateComponent(hostComponents[i], hostName, this.get('content.reassign.service_id'), "Install", hostComponents.length);
  476. }
  477. },
  478. reconfigure: function () {
  479. this.loadConfigsTags();
  480. },
  481. loadConfigsTags: function () {
  482. App.ajax.send({
  483. name: 'config.tags',
  484. sender: this,
  485. success: 'onLoadConfigsTags',
  486. error: 'onTaskError'
  487. });
  488. },
  489. serviceToConfigSiteMap: {
  490. 'NAMENODE': ['hdfs-site', 'core-site'],
  491. 'SECONDARY_NAMENODE': ['hdfs-site', 'core-site'],
  492. 'JOBTRACKER': ['mapred-site'],
  493. 'RESOURCEMANAGER': ['yarn-site'],
  494. 'WEBHCAT_SERVER': ['hive-env', 'webhcat-site', 'core-site'],
  495. 'APP_TIMELINE_SERVER': ['yarn-site', 'yarn-env'],
  496. 'OOZIE_SERVER': ['oozie-site', 'core-site', 'oozie-env'],
  497. 'HIVE_SERVER': ['hive-site', 'webhcat-site', 'hive-env', 'core-site'],
  498. 'HIVE_METASTORE': ['hive-site', 'webhcat-site', 'hive-env', 'core-site'],
  499. 'MYSQL_SERVER': ['hive-site'],
  500. 'METRICS_COLLECTOR': ['ams-site'],
  501. 'HISTORYSERVER': ['mapred-site']
  502. },
  503. /**
  504. * construct URL parameters for config call
  505. * @param componentName
  506. * @param data
  507. * @return {Array}
  508. */
  509. getConfigUrlParams: function (componentName, data) {
  510. var urlParams = [];
  511. this.get('serviceToConfigSiteMap')[componentName].forEach(function(site){
  512. urlParams.push('(type=' + site + '&tag=' + data.Clusters.desired_configs[site].tag + ')');
  513. });
  514. // specific cases for NameNode component
  515. if (componentName === 'NAMENODE') {
  516. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  517. urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
  518. }
  519. if (App.Service.find().someProperty('serviceName', 'ACCUMULO')) {
  520. urlParams.push('(type=accumulo-site&tag=' + data.Clusters.desired_configs['accumulo-site'].tag + ')');
  521. }
  522. if (App.Service.find().someProperty('serviceName', 'HAWQ')) {
  523. urlParams.push('(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')');
  524. urlParams.push('(type=hdfs-client&tag=' + data.Clusters.desired_configs['hdfs-client'].tag + ')');
  525. }
  526. }
  527. if (componentName === 'RESOURCEMANAGER') {
  528. if (App.Service.find().someProperty('serviceName', 'HAWQ')) {
  529. urlParams.push('(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')');
  530. urlParams.push('(type=yarn-client&tag=' + data.Clusters.desired_configs['yarn-client'].tag + ')');
  531. }
  532. }
  533. return urlParams;
  534. },
  535. onLoadConfigsTags: function (data) {
  536. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  537. App.ajax.send({
  538. name: 'reassign.load_configs',
  539. sender: this,
  540. data: {
  541. urlParams: urlParams.join('|')
  542. },
  543. success: 'onLoadConfigs',
  544. error: 'onTaskError'
  545. });
  546. },
  547. /**
  548. *
  549. * @returns {extendedTopologyLocalDB}
  550. * @private
  551. * @method _prepareTopologyDB
  552. */
  553. _prepareTopologyDB: function () {
  554. var ret = this.get('content').getProperties(['masterComponentHosts', 'slaveComponentHosts', 'hosts']);
  555. ret.installedServices = App.Service.find().mapProperty('serviceName');
  556. return ret;
  557. },
  558. /**
  559. * Create dependencies for Config Initializers
  560. *
  561. * @param {object} additionalDependencies some additional information that should be added
  562. * @returns {reassignComponentDependencies}
  563. * @private
  564. * @method _prepareDependencies
  565. */
  566. _prepareDependencies: function (additionalDependencies) {
  567. additionalDependencies = additionalDependencies || {};
  568. var ret = {};
  569. ret.sourceHostName = this.get('content.reassignHosts.source');
  570. ret.targetHostName = this.get('content.reassignHosts.target');
  571. return Em.merge(ret, additionalDependencies);
  572. },
  573. /**
  574. * Get additional dependencies-data for App.MoveRmConfigInitializer
  575. *
  576. * @param {object} configs
  577. * @returns {object}
  578. * @private
  579. * @method _getRmAdditionalDependencies
  580. */
  581. _getRmAdditionalDependencies: function (configs) {
  582. var ret = {};
  583. var rm1 = configs['yarn-site']['yarn.resourcemanager.hostname.rm1'];
  584. if (rm1) {
  585. ret.rm1 = rm1;
  586. }
  587. var rm2 = configs['yarn-site']['yarn.resourcemanager.hostname.rm2'];
  588. if (rm2) {
  589. ret.rm2 = rm2;
  590. }
  591. return ret;
  592. },
  593. /**
  594. * Settings used to the App.MoveOSConfigInitializer setup
  595. *
  596. * @param {object} configs
  597. * @returns {object}
  598. * @private
  599. * @method _getOsInitializerSettings
  600. */
  601. _getOsInitializerSettings: function (configs) {
  602. var ret = {};
  603. var cfg = configs['oozie-env']['oozie_user'];
  604. if (cfg) {
  605. ret.oozieUser = cfg;
  606. }
  607. return ret;
  608. },
  609. /**
  610. * Get additional dependencies-data for App.MoveNameNodeConfigInitializer
  611. *
  612. * @param {object} configs
  613. * @returns {object}
  614. * @private
  615. * @method _getNnInitializerSettings
  616. */
  617. _getNnInitializerSettings: function (configs) {
  618. var ret = {};
  619. if (App.get('isHaEnabled')) {
  620. ret.namespaceId = configs['hdfs-site']['dfs.nameservices'];
  621. ret.suffix = (configs['hdfs-site']['dfs.namenode.http-address.' + ret.namespaceId + '.nn1'] === this.get('content.reassignHosts.source') + ':50070') ? 'nn1' : 'nn2';
  622. }
  623. return ret;
  624. },
  625. /**
  626. * Settings used to the App.MoveHsConfigInitializer and App.MoveHmConfigInitializer setup
  627. *
  628. * @param {object} configs
  629. * @returns {{hiveUser: string}}
  630. * @private
  631. * @method _getHiveInitializerSettings
  632. */
  633. _getHiveInitializerSettings: function (configs) {
  634. return {
  635. hiveUser: configs['hive-env']['hive_user']
  636. };
  637. },
  638. /**
  639. * Settings used to the App.MoveWsConfigInitializer setup
  640. *
  641. * @param {object} configs
  642. * @returns {{webhcatUser: string}}
  643. * @private
  644. * @method _getWsInitializerSettings
  645. */
  646. _getWsInitializerSettings: function (configs) {
  647. return {
  648. webhcatUser: configs['hive-env']['webhcat_user']
  649. };
  650. },
  651. /**
  652. * Settings used to the App.MoveRmConfigInitializer setup
  653. *
  654. * @param {object} configs
  655. * @returns {{suffix: string}}
  656. * @private
  657. * @method _getRmInitializerSettings
  658. */
  659. _getRmInitializerSettings: function (configs) {
  660. return {
  661. suffix: configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === this.get('content.reassignHosts.source') ? 'rm1': 'rm2'
  662. };
  663. },
  664. onLoadConfigs: function (data) {
  665. // Find hawq-site.xml location
  666. var hawqSiteIndex = -1;
  667. for(var i = 0; i < data.items.length; i++){
  668. if(data.items[i].type == 'hawq-site'){
  669. hawqSiteIndex = i;
  670. break;
  671. }
  672. }
  673. // if certain services are deployed, include related site files to additionalConfigsMap and relatedServicesMap.
  674. if(hawqSiteIndex >= 0){ // if HAWQ is deployed
  675. var hawqSiteProperties = {
  676. 'hawq_rm_yarn_address': '<replace-value>:8050',
  677. 'hawq_rm_yarn_scheduler_address': '<replace-value>:8030'
  678. }
  679. var rmComponent = this.get('additionalConfigsMap').findProperty('componentName', "RESOURCEMANAGER");
  680. rmComponent.configs["hawq-site"] = hawqSiteProperties;
  681. if(data.items[hawqSiteIndex].properties["hawq_global_rm_type"].toLowerCase() === "yarn"){
  682. this.get('relatedServicesMap')['RESOURCEMANAGER'].append('HAWQ');
  683. }
  684. }
  685. var componentName = this.get('content.reassign.component_name');
  686. var targetHostName = this.get('content.reassignHosts.target');
  687. var configs = {};
  688. var secureConfigs = [];
  689. data.items.forEach(function (item) {
  690. configs[item.type] = item.properties;
  691. }, this);
  692. this.setAdditionalConfigs(configs, componentName, targetHostName);
  693. this.setSecureConfigs(secureConfigs, configs, componentName);
  694. switch (componentName) {
  695. case 'NAMENODE':
  696. App.MoveNameNodeConfigInitializer.setup(this._getNnInitializerSettings(configs));
  697. configs = this.setDynamicConfigs(configs, App.MoveNameNodeConfigInitializer);
  698. App.MoveNameNodeConfigInitializer.cleanup();
  699. break;
  700. case 'RESOURCEMANAGER':
  701. App.MoveRmConfigInitializer.setup(this._getRmInitializerSettings(configs));
  702. var additionalDependencies = this._getRmAdditionalDependencies(configs);
  703. configs = this.setDynamicConfigs(configs, App.MoveRmConfigInitializer, additionalDependencies);
  704. App.MoveRmConfigInitializer.cleanup();
  705. break;
  706. case 'HIVE_METASTORE':
  707. App.MoveHmConfigInitializer.setup(this._getHiveInitializerSettings(configs));
  708. configs = this.setDynamicConfigs(configs, App.MoveHmConfigInitializer);
  709. App.MoveHmConfigInitializer.cleanup();
  710. break;
  711. case 'HIVE_SERVER':
  712. App.MoveHsConfigInitializer.setup(this._getHiveInitializerSettings(configs));
  713. configs = this.setDynamicConfigs(configs, App.MoveHsConfigInitializer);
  714. App.MoveHsConfigInitializer.cleanup();
  715. break;
  716. case 'WEBHCAT_SERVER':
  717. App.MoveWsConfigInitializer.setup(this._getWsInitializerSettings(configs));
  718. configs = this.setDynamicConfigs(configs, App.MoveWsConfigInitializer);
  719. App.MoveWsConfigInitializer.cleanup();
  720. break;
  721. case 'OOZIE_SERVER':
  722. App.MoveOSConfigInitializer.setup(this._getOsInitializerSettings(configs));
  723. configs = this.setDynamicConfigs(configs, App.MoveOSConfigInitializer);
  724. App.MoveOSConfigInitializer.cleanup();
  725. }
  726. this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName));
  727. this.saveConfigsToServer(configs);
  728. this.saveServiceProperties(configs);
  729. },
  730. /**
  731. * Set config values according to the new cluster topology
  732. *
  733. * @param {object} configs
  734. * @param {MoveComponentConfigInitializerClass} initializer
  735. * @param {object} [additionalDependencies={}]
  736. * @returns {object}
  737. * @method setDynamicConfigs
  738. */
  739. setDynamicConfigs: function (configs, initializer, additionalDependencies) {
  740. additionalDependencies = additionalDependencies || {};
  741. var topologyDB = this._prepareTopologyDB();
  742. var dependencies = this._prepareDependencies(additionalDependencies);
  743. Em.keys(configs).forEach(function (site) {
  744. Em.keys(configs[site]).forEach(function (config) {
  745. // temporary object for initializer
  746. var cfg = {
  747. name: config,
  748. filename: site,
  749. value: configs[site][config]
  750. };
  751. configs[site][config] = initializer.initialValue(cfg, topologyDB, dependencies).value;
  752. });
  753. });
  754. return configs;
  755. },
  756. /**
  757. * make PUT call to save configs to server
  758. * @param configs
  759. */
  760. saveConfigsToServer: function (configs) {
  761. App.ajax.send({
  762. name: 'common.across.services.configurations',
  763. sender: this,
  764. data: {
  765. data: '[' + this.getServiceConfigData(configs).toString() + ']'
  766. },
  767. success: 'onSaveConfigs',
  768. error: 'onTaskError'
  769. });
  770. },
  771. /**
  772. * gather and format config data before sending to server
  773. * @param configs
  774. * @return {Array}
  775. * @method getServiceConfigData
  776. */
  777. getServiceConfigData: function (configs) {
  778. var componentName = this.get('content.reassign.component_name');
  779. var tagName = 'version' + (new Date).getTime();
  780. var configData = Object.keys(configs).map(function (_siteName) {
  781. return {
  782. type: _siteName,
  783. tag: tagName,
  784. properties: configs[_siteName],
  785. service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName, false))
  786. }
  787. });
  788. var allConfigData = [];
  789. App.Service.find().forEach(function (service) {
  790. var stackService = App.StackService.find().findProperty('serviceName', service.get('serviceName'));
  791. if (stackService) {
  792. var serviceConfigData = [];
  793. Object.keys(stackService.get('configTypesRendered')).forEach(function (type) {
  794. var serviceConfigTag = configData.findProperty('type', type);
  795. if (serviceConfigTag) {
  796. serviceConfigData.pushObject(serviceConfigTag);
  797. }
  798. }, this);
  799. allConfigData.pushObject(JSON.stringify({
  800. Clusters: {
  801. desired_config: serviceConfigData
  802. }
  803. }));
  804. }
  805. }, this);
  806. return allConfigData;
  807. },
  808. /**
  809. * Get the web address port when RM HA is enabled.
  810. * @param configs
  811. * @param webAddressKey (http vs https)
  812. * */
  813. getWebAddressPort: function (configs, webAddressKey){
  814. var result = null;
  815. var rmWebAddressValue = configs['yarn-site'][webAddressKey];
  816. if(rmWebAddressValue){
  817. var tokens = rmWebAddressValue.split(":");
  818. if(tokens.length > 1){
  819. result = tokens[1];
  820. result = result.replace(/^\s+|\s+$/g, '');
  821. }
  822. }
  823. if(result) //only return non-empty result
  824. return result;
  825. else
  826. return null;
  827. },
  828. /**
  829. * set secure configs for component
  830. * @param secureConfigs
  831. * @param configs
  832. * @param componentName
  833. * @return {Boolean}
  834. */
  835. setSecureConfigs: function (secureConfigs, configs, componentName) {
  836. var securityEnabled = App.get('isKerberosEnabled');
  837. var component = this.get('secureConfigsMap').findProperty('componentName', componentName);
  838. if (Em.isNone(component) || !securityEnabled) return false;
  839. component.configs.forEach(function (config) {
  840. secureConfigs.push({
  841. keytab: configs[config.site][config.keytab],
  842. principal: configs[config.site][config.principal]
  843. });
  844. });
  845. return true;
  846. },
  847. /**
  848. * derive component directory from configurations
  849. * @param configs
  850. * @param componentName
  851. * @return {String}
  852. */
  853. getComponentDir: function (configs, componentName) {
  854. if (componentName === 'NAMENODE') {
  855. return configs['hdfs-site']['dfs.namenode.name.dir'];
  856. } else if (componentName === 'SECONDARY_NAMENODE') {
  857. return configs['hdfs-site']['dfs.namenode.checkpoint.dir'];
  858. }
  859. return '';
  860. },
  861. /**
  862. * save cluster status to server
  863. *
  864. * @param secureConfigs
  865. * @param componentDir
  866. * @return {Boolean}
  867. */
  868. saveClusterStatus: function (secureConfigs, componentDir) {
  869. if (componentDir || secureConfigs.length) {
  870. App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
  871. App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
  872. App.clusterStatus.setClusterStatus({
  873. clusterName: this.get('content.cluster.name'),
  874. clusterState: this.get('clusterDeployState'),
  875. wizardControllerName: this.get('content.controllerName'),
  876. localdb: App.db.data
  877. });
  878. return true;
  879. }
  880. return false;
  881. },
  882. onSaveConfigs: function () {
  883. this.onTaskCompleted();
  884. },
  885. startZooKeeperServers: function () {
  886. var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER');
  887. this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start");
  888. },
  889. startNameNode: function () {
  890. var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE');
  891. this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.source')), "HDFS", "Start");
  892. },
  893. /**
  894. * make server call to start services
  895. */
  896. startRequiredServices: function () {
  897. var relatedServices = this.get('relatedServicesMap')[this.get('content.reassign.component_name')];
  898. if (relatedServices) {
  899. this.startServices(false, relatedServices, true);
  900. } else {
  901. this.startServices(true);
  902. }
  903. },
  904. /**
  905. * make DELETE call for each host component on host
  906. */
  907. deleteHostComponents: function () {
  908. var hostComponents = this.get('hostComponents');
  909. var hostName = this.get('content.reassignHosts.source');
  910. this.set('multiTaskCounter', hostComponents.length);
  911. for (var i = 0; i < hostComponents.length; i++) {
  912. App.ajax.send({
  913. name: 'common.delete.host_component',
  914. sender: this,
  915. data: {
  916. hostName: hostName,
  917. componentName: hostComponents[i]
  918. },
  919. success: 'onComponentsTasksSuccess',
  920. error: 'onDeleteHostComponentsError'
  921. });
  922. }
  923. },
  924. onDeleteHostComponentsError: function (error) {
  925. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  926. this.onComponentsTasksSuccess();
  927. } else {
  928. this.onTaskError();
  929. }
  930. },
  931. done: function () {
  932. if (!this.get('isSubmitDisabled')) {
  933. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  934. if (this.get('content.hasManualSteps')) {
  935. App.router.send('next');
  936. } else {
  937. App.router.send('complete');
  938. }
  939. }
  940. },
  941. /**
  942. * make server call to clean MYSQL
  943. */
  944. cleanMySqlServer: function () {
  945. var hostname = App.HostComponent.find().findProperty('componentName', 'MYSQL_SERVER').get('hostName');
  946. if (this.get('content.reassign.component_name') === 'MYSQL_SERVER') {
  947. hostname = this.get('content.reassignHosts.target');
  948. }
  949. App.ajax.send({
  950. name: 'service.mysql.clean',
  951. sender: this,
  952. data: {
  953. host: hostname
  954. },
  955. success: 'startPolling',
  956. error: 'onTaskError'
  957. });
  958. },
  959. /**
  960. * make server call to configure MYSQL
  961. */
  962. configureMySqlServer : function () {
  963. var hostname = App.HostComponent.find().findProperty('componentName', 'MYSQL_SERVER').get('hostName');
  964. if (this.get('content.reassign.component_name') === 'MYSQL_SERVER') {
  965. hostname = this.get('content.reassignHosts.target');
  966. }
  967. App.ajax.send({
  968. name: 'service.mysql.configure',
  969. sender: this,
  970. data: {
  971. host: hostname
  972. },
  973. success: 'startPolling',
  974. error: 'onTaskError'
  975. });
  976. },
  977. startMySqlServer: function() {
  978. App.ajax.send({
  979. name: 'common.host.host_component.update',
  980. sender: this,
  981. data: {
  982. context: "Start MySQL Server",
  983. hostName: App.HostComponent.find().findProperty('componentName', 'MYSQL_SERVER').get('hostName'),
  984. serviceName: "HIVE",
  985. componentName: "MYSQL_SERVER",
  986. HostRoles: {
  987. state: "STARTED"
  988. }
  989. },
  990. success: 'startPolling',
  991. error: 'onTaskError'
  992. });
  993. },
  994. restartMySqlServer: function() {
  995. var context = "Restart MySql Server";
  996. var resource_filters = {
  997. component_name: "MYSQL_SERVER",
  998. hosts: App.HostComponent.find().filterProperty('componentName', 'MYSQL_SERVER').get('firstObject.hostName'),
  999. service_name: "HIVE"
  1000. };
  1001. var operation_level = {
  1002. level: "HOST_COMPONENT",
  1003. cluster_name: this.get('content.cluster.name'),
  1004. service_name: "HIVE",
  1005. hostcomponent_name: "MYSQL_SERVER"
  1006. };
  1007. App.ajax.send({
  1008. name: 'restart.hostComponents',
  1009. sender: this,
  1010. data: {
  1011. context: context,
  1012. resource_filters: [resource_filters],
  1013. operation_level: operation_level
  1014. },
  1015. success: 'startPolling',
  1016. error: 'onTaskError'
  1017. });
  1018. },
  1019. startNewMySqlServer: function() {
  1020. App.ajax.send({
  1021. name: 'common.host.host_component.update',
  1022. sender: this,
  1023. data: {
  1024. context: "Start MySQL Server",
  1025. hostName: this.get('content.reassignHosts.target'),
  1026. serviceName: "HIVE",
  1027. componentName: "MYSQL_SERVER",
  1028. HostRoles: {
  1029. state: "STARTED"
  1030. }
  1031. },
  1032. success: 'startPolling',
  1033. error: 'onTaskError'
  1034. });
  1035. },
  1036. testDBConnection: function() {
  1037. this.prepareDBCheckAction();
  1038. },
  1039. isComponentWithDB: function() {
  1040. return ['HIVE_SERVER', 'HIVE_METASTORE', 'OOZIE_SERVER'].contains(this.get('content.reassign.component_name'));
  1041. },
  1042. /** @property {Object} propertiesPattern - check pattern according to type of connection properties **/
  1043. propertiesPattern: function() {
  1044. return {
  1045. user_name: /(username|dblogin)$/ig,
  1046. user_passwd: /(dbpassword|password)$/ig,
  1047. db_connection_url: /jdbc\.url|connectionurl/ig,
  1048. driver_class: /ConnectionDriverName|jdbc\.driver/ig,
  1049. schema_name: /db\.schema\.name/ig
  1050. };
  1051. }.property(),
  1052. /** @property {Object} connectionProperties - service specific config values mapped for custom action request **/
  1053. connectionProperties: function() {
  1054. var propObj = {};
  1055. for (var key in this.get('propertiesPattern')) {
  1056. propObj[key] = this.getConnectionProperty(this.get('propertiesPattern')[key]);
  1057. }
  1058. return propObj;
  1059. }.property('propertiesPattern'),
  1060. getConnectionProperty: function(regexp) {
  1061. var propertyName = this.get('requiredProperties').filter(function(item) {
  1062. return regexp.test(item);
  1063. })[0];
  1064. return this.get('content.serviceProperties')[propertyName];
  1065. },
  1066. /**
  1067. * Properties that stores in local storage used for handling
  1068. * last success connection.
  1069. *
  1070. * @property {Object} preparedDBProperties
  1071. **/
  1072. preparedDBProperties: function() {
  1073. var propObj = {};
  1074. for (var key in this.get('propertiesPattern')) {
  1075. var propValue = this.getConnectionProperty(this.get('propertiesPattern')[key]);
  1076. propObj[key] = propValue;
  1077. }
  1078. return propObj;
  1079. }.property(),
  1080. /** @property {object} requiredProperties - properties that necessary for database connection **/
  1081. requiredProperties: function() {
  1082. var propertiesMap = {
  1083. OOZIE: ['oozie.db.schema.name','oozie.service.JPAService.jdbc.username','oozie.service.JPAService.jdbc.password','oozie.service.JPAService.jdbc.driver','oozie.service.JPAService.jdbc.url'],
  1084. HIVE: ['ambari.hive.db.schema.name','javax.jdo.option.ConnectionUserName','javax.jdo.option.ConnectionPassword','javax.jdo.option.ConnectionDriverName','javax.jdo.option.ConnectionURL']
  1085. };
  1086. return propertiesMap[this.get('content.reassign.service_id')];
  1087. }.property(),
  1088. dbType: function() {
  1089. var databaseTypes = /MySQL|PostgreS|Oracle|Derby|MSSQL|Anywhere/gi;
  1090. var databaseProp = this.get('content.serviceProperties')[Em.getWithDefault(this.get('dbPropertyMap'), this.get('content.reassign.component_name'), null)];
  1091. return databaseProp.match(databaseTypes)[0];
  1092. }.property(),
  1093. prepareDBCheckAction: function() {
  1094. var params = this.get('preparedDBProperties');
  1095. var ambariProperties = App.router.get('clusterController.ambariProperties');
  1096. params['db_name'] = this.get('dbType');
  1097. params['jdk_location'] = ambariProperties['jdk_location'];
  1098. params['jdk_name'] = ambariProperties['jdk.name'];
  1099. params['java_home'] = ambariProperties['java.home'];
  1100. params['threshold'] = 60;
  1101. params['ambari_server_host'] = location.hostname;
  1102. params['check_execute_list'] = "db_connection_check";
  1103. App.ajax.send({
  1104. name: 'cluster.custom_action.create',
  1105. sender: this,
  1106. data: {
  1107. requestInfo: {
  1108. "context": "Check host",
  1109. "action": "check_host",
  1110. "parameters": params
  1111. },
  1112. filteredHosts: [this.get('content.reassignHosts.target')]
  1113. },
  1114. success: 'onCreateActionSuccess',
  1115. error: 'onTaskError'
  1116. });
  1117. },
  1118. onCreateActionSuccess: function(data) {
  1119. this.set('checkDBRequestId', data.Requests.id);
  1120. App.ajax.send({
  1121. name: 'custom_action.request',
  1122. sender: this,
  1123. data: {
  1124. requestId: this.get('checkDBRequestId')
  1125. },
  1126. success: 'setCheckDBTaskId'
  1127. });
  1128. },
  1129. setCheckDBTaskId: function(data) {
  1130. this.set('checkDBTaskId', data.items[0].Tasks.id);
  1131. this.startDBCheckPolling();
  1132. },
  1133. startDBCheckPolling: function() {
  1134. this.getDBConnTaskInfo();
  1135. },
  1136. getDBConnTaskInfo: function() {
  1137. this.setTaskStatus(this.get('currentTaskId'), 'IN_PROGRESS');
  1138. this.get('tasks').findProperty('id', this.get('currentTaskId')).set('progress', 100);
  1139. this.set('logs', []);
  1140. App.ajax.send({
  1141. name: 'custom_action.request',
  1142. sender: this,
  1143. data: {
  1144. requestId: this.get('checkDBRequestId'),
  1145. taskId: this.get('checkDBTaskId')
  1146. },
  1147. success: 'getDBConnTaskInfoSuccess'
  1148. });
  1149. },
  1150. getDBConnTaskInfoSuccess: function(data) {
  1151. var task = data.Tasks;
  1152. if (task.status === 'COMPLETED') {
  1153. var structuredOut = task.structured_out.db_connection_check;
  1154. if (structuredOut.exit_code != 0) {
  1155. this.showConnectionErrorPopup(structuredOut.message);
  1156. this.onTaskError();
  1157. } else {
  1158. this.onTaskCompleted();
  1159. }
  1160. }
  1161. if (task.status === 'FAILED') {
  1162. this.onTaskError();
  1163. }
  1164. if (/PENDING|QUEUED|IN_PROGRESS/.test(task.status)) {
  1165. Em.run.later(this, function() {
  1166. this.startDBCheckPolling();
  1167. }, 3000);
  1168. }
  1169. },
  1170. showConnectionErrorPopup: function(error) {
  1171. var popup = App.showAlertPopup('Database Connection Error');
  1172. popup.set('body', error);
  1173. },
  1174. testDBRetryTooltip: function() {
  1175. var db_host = this.get('content.serviceProperties.database_hostname');
  1176. var db_type = this.get('dbType');
  1177. var db_props = this.get('preparedDBProperties');
  1178. return Em.I18n.t('services.reassign.step4.tasks.testDBConnection.tooltip').format(
  1179. db_host, db_type, db_props['schema_name'], db_props['user_name'],
  1180. db_props['user_passwd'], db_props['driver_class'], db_props['db_connection_url']
  1181. );
  1182. }.property('dbProperties'),
  1183. saveServiceProperties: function(configs) {
  1184. App.router.get(this.get('content.controllerName')).saveServiceProperties(configs);
  1185. },
  1186. stopHostComponentsInMaintenanceMode: function () {
  1187. var hostComponentsInMM = this.get('content.reassignComponentsInMM');
  1188. var hostName = this.get('content.reassignHosts.source');
  1189. var serviceName = this.get('content.reassign.service_id');
  1190. hostComponentsInMM = hostComponentsInMM.map(function(componentName){
  1191. return {
  1192. hostName: hostName,
  1193. serviceName: serviceName,
  1194. componentName: componentName
  1195. };
  1196. });
  1197. this.set('multiTaskCounter', hostComponentsInMM.length);
  1198. this.updateComponentsState(hostComponentsInMM, 'INSTALLED');
  1199. }
  1200. });