step4_controller.js 41 KB

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