step4_controller.js 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  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. * 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': ['webhcat-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. 'HISTORYSERVER': ['mapred-site']
  501. },
  502. /**
  503. * construct URL parameters for config call
  504. * @param componentName
  505. * @param data
  506. * @return {Array}
  507. */
  508. getConfigUrlParams: function (componentName, data) {
  509. var urlParams = [];
  510. this.get('serviceToConfigSiteMap')[componentName].forEach(function(site){
  511. urlParams.push('(type=' + site + '&tag=' + data.Clusters.desired_configs[site].tag + ')');
  512. });
  513. // specific cases for NameNode component
  514. if (componentName === 'NAMENODE') {
  515. if (App.Service.find().someProperty('serviceName', 'HBASE')) {
  516. urlParams.push('(type=hbase-site&tag=' + data.Clusters.desired_configs['hbase-site'].tag + ')');
  517. }
  518. if (App.Service.find().someProperty('serviceName', 'ACCUMULO')) {
  519. urlParams.push('(type=accumulo-site&tag=' + data.Clusters.desired_configs['accumulo-site'].tag + ')');
  520. }
  521. if (App.Service.find().someProperty('serviceName', 'HAWQ')) {
  522. urlParams.push('(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')');
  523. urlParams.push('(type=hdfs-client&tag=' + data.Clusters.desired_configs['hdfs-client'].tag + ')');
  524. }
  525. }
  526. if (componentName === 'RESOURCEMANAGER') {
  527. if (App.Service.find().someProperty('serviceName', 'HAWQ')) {
  528. urlParams.push('(type=hawq-site&tag=' + data.Clusters.desired_configs['hawq-site'].tag + ')');
  529. urlParams.push('(type=yarn-client&tag=' + data.Clusters.desired_configs['yarn-client'].tag + ')');
  530. }
  531. }
  532. return urlParams;
  533. },
  534. onLoadConfigsTags: function (data) {
  535. var urlParams = this.getConfigUrlParams(this.get('content.reassign.component_name'), data);
  536. App.ajax.send({
  537. name: 'reassign.load_configs',
  538. sender: this,
  539. data: {
  540. urlParams: urlParams.join('|')
  541. },
  542. success: 'onLoadConfigs',
  543. error: 'onTaskError'
  544. });
  545. },
  546. /**
  547. *
  548. * @returns {extendedTopologyLocalDB}
  549. * @private
  550. * @method _prepareTopologyDB
  551. */
  552. _prepareTopologyDB: function () {
  553. var ret = this.get('content').getProperties(['masterComponentHosts', 'slaveComponentHosts', 'hosts']);
  554. ret.installedServices = App.Service.find().mapProperty('serviceName');
  555. return ret;
  556. },
  557. /**
  558. * Create dependencies for Config Initializers
  559. *
  560. * @param {object} additionalDependencies some additional information that should be added
  561. * @returns {reassignComponentDependencies}
  562. * @private
  563. * @method _prepareDependencies
  564. */
  565. _prepareDependencies: function (additionalDependencies) {
  566. additionalDependencies = additionalDependencies || {};
  567. var ret = {};
  568. ret.sourceHostName = this.get('content.reassignHosts.source');
  569. ret.targetHostName = this.get('content.reassignHosts.target');
  570. return Em.merge(ret, additionalDependencies);
  571. },
  572. /**
  573. * Get additional dependencies-data for App.MoveRmConfigInitializer
  574. *
  575. * @param {object} configs
  576. * @returns {object}
  577. * @private
  578. * @method _getRmAdditionalDependencies
  579. */
  580. _getRmAdditionalDependencies: function (configs) {
  581. var ret = {};
  582. var rm1 = configs['yarn-site']['yarn.resourcemanager.hostname.rm1'];
  583. if (rm1) {
  584. ret.rm1 = rm1;
  585. }
  586. var rm2 = configs['yarn-site']['yarn.resourcemanager.hostname.rm2'];
  587. if (rm2) {
  588. ret.rm2 = rm2;
  589. }
  590. return ret;
  591. },
  592. /**
  593. * Settings used to the App.MoveOSConfigInitializer setup
  594. *
  595. * @param {object} configs
  596. * @returns {object}
  597. * @private
  598. * @method _getOsInitializerSettings
  599. */
  600. _getOsInitializerSettings: function (configs) {
  601. var ret = {};
  602. var cfg = configs['oozie-env']['oozie_user'];
  603. if (cfg) {
  604. ret.oozieUser = cfg;
  605. }
  606. return ret;
  607. },
  608. /**
  609. * Get additional dependencies-data for App.MoveNameNodeConfigInitializer
  610. *
  611. * @param {object} configs
  612. * @returns {object}
  613. * @private
  614. * @method _getNnInitializerSettings
  615. */
  616. _getNnInitializerSettings: function (configs) {
  617. var ret = {};
  618. if (App.get('isHaEnabled')) {
  619. ret.namespaceId = configs['hdfs-site']['dfs.nameservices'];
  620. ret.suffix = (configs['hdfs-site']['dfs.namenode.http-address.' + ret.namespaceId + '.nn1'] === this.get('content.reassignHosts.source') + ':50070') ? 'nn1' : 'nn2';
  621. }
  622. return ret;
  623. },
  624. /**
  625. * Settings used to the App.MoveHsConfigInitializer and App.MoveHmConfigInitializer setup
  626. *
  627. * @param {object} configs
  628. * @returns {{hiveUser: string, webhcatUser: string}}
  629. * @private
  630. * @method _getHiveInitializerSettings
  631. */
  632. _getHiveInitializerSettings: function (configs) {
  633. return {
  634. hiveUser: configs['hive-env']['hive_user'],
  635. webhcatUser: configs['hive-env']['webhcat_user']
  636. };
  637. },
  638. /**
  639. * Settings used to the App.MoveRmConfigInitializer setup
  640. *
  641. * @param {object} configs
  642. * @returns {{suffix: string}}
  643. * @private
  644. * @method _getRmInitializerSettings
  645. */
  646. _getRmInitializerSettings: function (configs) {
  647. return {
  648. suffix: configs['yarn-site']['yarn.resourcemanager.hostname.rm1'] === this.get('content.reassignHosts.source') ? 'rm1': 'rm2'
  649. };
  650. },
  651. onLoadConfigs: function (data) {
  652. // Find hawq-site.xml location
  653. var hawqSiteIndex = -1;
  654. for(var i = 0; i < data.items.length; i++){
  655. if(data.items[i].type == 'hawq-site'){
  656. hawqSiteIndex = i;
  657. break;
  658. }
  659. }
  660. // if certain services are deployed, include related site files to additionalConfigsMap and relatedServicesMap.
  661. if(hawqSiteIndex >= 0){ // if HAWQ is deployed
  662. var hawqSiteProperties = {
  663. 'hawq_rm_yarn_address': '<replace-value>:8050',
  664. 'hawq_rm_yarn_scheduler_address': '<replace-value>:8030'
  665. }
  666. var rmComponent = this.get('additionalConfigsMap').findProperty('componentName', "RESOURCEMANAGER");
  667. rmComponent.configs["hawq-site"] = hawqSiteProperties;
  668. if(data.items[hawqSiteIndex].properties["hawq_global_rm_type"].toLowerCase() === "yarn"){
  669. this.get('relatedServicesMap')['RESOURCEMANAGER'].append('HAWQ');
  670. }
  671. }
  672. var componentName = this.get('content.reassign.component_name');
  673. var targetHostName = this.get('content.reassignHosts.target');
  674. var configs = {};
  675. var secureConfigs = [];
  676. data.items.forEach(function (item) {
  677. configs[item.type] = item.properties;
  678. }, this);
  679. this.setAdditionalConfigs(configs, componentName, targetHostName);
  680. this.setSecureConfigs(secureConfigs, configs, componentName);
  681. switch (componentName) {
  682. case 'NAMENODE':
  683. App.MoveNameNodeConfigInitializer.setup(this._getNnInitializerSettings(configs));
  684. configs = this.setDynamicConfigs(configs, App.MoveNameNodeConfigInitializer);
  685. App.MoveNameNodeConfigInitializer.cleanup();
  686. break;
  687. case 'RESOURCEMANAGER':
  688. App.MoveRmConfigInitializer.setup(this._getRmInitializerSettings(configs));
  689. var additionalDependencies = this._getRmAdditionalDependencies(configs);
  690. configs = this.setDynamicConfigs(configs, App.MoveRmConfigInitializer, additionalDependencies);
  691. App.MoveRmConfigInitializer.cleanup();
  692. break;
  693. case 'HIVE_METASTORE':
  694. App.MoveHmConfigInitializer.setup(this._getHiveInitializerSettings(configs));
  695. configs = this.setDynamicConfigs(configs, App.MoveHmConfigInitializer);
  696. App.MoveHmConfigInitializer.cleanup();
  697. break;
  698. case 'HIVE_SERVER':
  699. App.MoveHsConfigInitializer.setup(this._getHiveInitializerSettings(configs));
  700. configs = this.setDynamicConfigs(configs, App.MoveHsConfigInitializer);
  701. App.MoveHsConfigInitializer.cleanup();
  702. break;
  703. case 'OOZIE_SERVER':
  704. App.MoveOSConfigInitializer.setup(this._getOsInitializerSettings(configs));
  705. configs = this.setDynamicConfigs(configs, App.MoveOSConfigInitializer);
  706. App.MoveOSConfigInitializer.cleanup();
  707. }
  708. this.saveClusterStatus(secureConfigs, this.getComponentDir(configs, componentName));
  709. this.saveConfigsToServer(configs);
  710. this.saveServiceProperties(configs);
  711. },
  712. /**
  713. * Set config values according to the new cluster topology
  714. *
  715. * @param {object} configs
  716. * @param {MoveComponentConfigInitializerClass} initializer
  717. * @param {object} [additionalDependencies={}]
  718. * @returns {object}
  719. * @method setDynamicConfigs
  720. */
  721. setDynamicConfigs: function (configs, initializer, additionalDependencies) {
  722. additionalDependencies = additionalDependencies || {};
  723. var topologyDB = this._prepareTopologyDB();
  724. var dependencies = this._prepareDependencies(additionalDependencies);
  725. Em.keys(configs).forEach(function (site) {
  726. Em.keys(configs[site]).forEach(function (config) {
  727. // temporary object for initializer
  728. var cfg = {
  729. name: config,
  730. filename: site,
  731. value: configs[site][config]
  732. };
  733. configs[site][config] = initializer.initialValue(cfg, topologyDB, dependencies).value;
  734. });
  735. });
  736. return configs;
  737. },
  738. /**
  739. * make PUT call to save configs to server
  740. * @param configs
  741. */
  742. saveConfigsToServer: function (configs) {
  743. App.ajax.send({
  744. name: 'common.across.services.configurations',
  745. sender: this,
  746. data: {
  747. data: '[' + this.getServiceConfigData(configs).toString() + ']'
  748. },
  749. success: 'onSaveConfigs',
  750. error: 'onTaskError'
  751. });
  752. },
  753. /**
  754. * gather and format config data before sending to server
  755. * @param configs
  756. * @return {Array}
  757. * @method getServiceConfigData
  758. */
  759. getServiceConfigData: function (configs) {
  760. var componentName = this.get('content.reassign.component_name');
  761. var tagName = 'version' + (new Date).getTime();
  762. var configData = Object.keys(configs).map(function (_siteName) {
  763. return {
  764. type: _siteName,
  765. tag: tagName,
  766. properties: configs[_siteName],
  767. service_config_version_note: Em.I18n.t('services.reassign.step4.save.configuration.note').format(App.format.role(componentName, false))
  768. }
  769. });
  770. var allConfigData = [];
  771. App.Service.find().forEach(function (service) {
  772. var stackService = App.StackService.find().findProperty('serviceName', service.get('serviceName'));
  773. if (stackService) {
  774. var serviceConfigData = [];
  775. Object.keys(stackService.get('configTypesRendered')).forEach(function (type) {
  776. var serviceConfigTag = configData.findProperty('type', type);
  777. if (serviceConfigTag) {
  778. serviceConfigData.pushObject(serviceConfigTag);
  779. }
  780. }, this);
  781. allConfigData.pushObject(JSON.stringify({
  782. Clusters: {
  783. desired_config: serviceConfigData
  784. }
  785. }));
  786. }
  787. }, this);
  788. return allConfigData;
  789. },
  790. /**
  791. * Get the web address port when RM HA is enabled.
  792. * @param configs
  793. * @param webAddressKey (http vs https)
  794. * */
  795. getWebAddressPort: function (configs, webAddressKey){
  796. var result = null;
  797. var rmWebAddressValue = configs['yarn-site'][webAddressKey];
  798. if(rmWebAddressValue){
  799. var tokens = rmWebAddressValue.split(":");
  800. if(tokens.length > 1){
  801. result = tokens[1];
  802. result = result.replace(/^\s+|\s+$/g, '');
  803. }
  804. }
  805. if(result) //only return non-empty result
  806. return result;
  807. else
  808. return null;
  809. },
  810. /**
  811. * set secure configs for component
  812. * @param secureConfigs
  813. * @param configs
  814. * @param componentName
  815. * @return {Boolean}
  816. */
  817. setSecureConfigs: function (secureConfigs, configs, componentName) {
  818. var securityEnabled = App.get('isKerberosEnabled');
  819. var component = this.get('secureConfigsMap').findProperty('componentName', componentName);
  820. if (Em.isNone(component) || !securityEnabled) return false;
  821. component.configs.forEach(function (config) {
  822. secureConfigs.push({
  823. keytab: configs[config.site][config.keytab],
  824. principal: configs[config.site][config.principal]
  825. });
  826. });
  827. return true;
  828. },
  829. /**
  830. * derive component directory from configurations
  831. * @param configs
  832. * @param componentName
  833. * @return {String}
  834. */
  835. getComponentDir: function (configs, componentName) {
  836. if (componentName === 'NAMENODE') {
  837. return configs['hdfs-site']['dfs.namenode.name.dir'];
  838. } else if (componentName === 'SECONDARY_NAMENODE') {
  839. return configs['hdfs-site']['dfs.namenode.checkpoint.dir'];
  840. }
  841. return '';
  842. },
  843. /**
  844. * save cluster status to server
  845. *
  846. * @param secureConfigs
  847. * @param componentDir
  848. * @return {Boolean}
  849. */
  850. saveClusterStatus: function (secureConfigs, componentDir) {
  851. if (componentDir || secureConfigs.length) {
  852. App.router.get(this.get('content.controllerName')).saveComponentDir(componentDir);
  853. App.router.get(this.get('content.controllerName')).saveSecureConfigs(secureConfigs);
  854. App.clusterStatus.setClusterStatus({
  855. clusterName: this.get('content.cluster.name'),
  856. clusterState: this.get('clusterDeployState'),
  857. wizardControllerName: this.get('content.controllerName'),
  858. localdb: App.db.data
  859. });
  860. return true;
  861. }
  862. return false;
  863. },
  864. onSaveConfigs: function () {
  865. this.onTaskCompleted();
  866. },
  867. startZooKeeperServers: function () {
  868. var components = this.get('content.masterComponentHosts').filterProperty('component', 'ZOOKEEPER_SERVER');
  869. this.updateComponent('ZOOKEEPER_SERVER', components.mapProperty('hostName'), "ZOOKEEPER", "Start");
  870. },
  871. startNameNode: function () {
  872. var components = this.get('content.masterComponentHosts').filterProperty('component', 'NAMENODE');
  873. this.updateComponent('NAMENODE', components.mapProperty('hostName').without(this.get('content.reassignHosts.source')), "HDFS", "Start");
  874. },
  875. /**
  876. * make server call to start services
  877. */
  878. startRequiredServices: function () {
  879. var relatedServices = this.get('relatedServicesMap')[this.get('content.reassign.component_name')];
  880. if (relatedServices) {
  881. this.startServices(false, relatedServices, true);
  882. } else {
  883. this.startServices(true);
  884. }
  885. },
  886. /**
  887. * make DELETE call for each host component on host
  888. */
  889. deleteHostComponents: function () {
  890. var hostComponents = this.get('hostComponents');
  891. var hostName = this.get('content.reassignHosts.source');
  892. this.set('multiTaskCounter', hostComponents.length);
  893. for (var i = 0; i < hostComponents.length; i++) {
  894. App.ajax.send({
  895. name: 'common.delete.host_component',
  896. sender: this,
  897. data: {
  898. hostName: hostName,
  899. componentName: hostComponents[i]
  900. },
  901. success: 'onComponentsTasksSuccess',
  902. error: 'onDeleteHostComponentsError'
  903. });
  904. }
  905. },
  906. onDeleteHostComponentsError: function (error) {
  907. if (error.responseText.indexOf('org.apache.ambari.server.controller.spi.NoSuchResourceException') !== -1) {
  908. this.onComponentsTasksSuccess();
  909. } else {
  910. this.onTaskError();
  911. }
  912. },
  913. done: function () {
  914. if (!this.get('isSubmitDisabled')) {
  915. this.removeObserver('tasks.@each.status', this, 'onTaskStatusChange');
  916. if (this.get('content.hasManualSteps')) {
  917. App.router.send('next');
  918. } else {
  919. App.router.send('complete');
  920. }
  921. }
  922. },
  923. /**
  924. * make server call to clean MYSQL
  925. */
  926. cleanMySqlServer: function () {
  927. var hostname = App.HostComponent.find().findProperty('componentName', 'MYSQL_SERVER').get('hostName');
  928. if (this.get('content.reassign.component_name') === 'MYSQL_SERVER') {
  929. hostname = this.get('content.reassignHosts.target');
  930. }
  931. App.ajax.send({
  932. name: 'service.mysql.clean',
  933. sender: this,
  934. data: {
  935. host: hostname
  936. },
  937. success: 'startPolling',
  938. error: 'onTaskError'
  939. });
  940. },
  941. /**
  942. * make server call to configure MYSQL
  943. */
  944. configureMySqlServer : 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.configure',
  951. sender: this,
  952. data: {
  953. host: hostname
  954. },
  955. success: 'startPolling',
  956. error: 'onTaskError'
  957. });
  958. },
  959. startMySqlServer: function() {
  960. App.ajax.send({
  961. name: 'common.host.host_component.update',
  962. sender: this,
  963. data: {
  964. context: "Start MySQL Server",
  965. hostName: App.HostComponent.find().findProperty('componentName', 'MYSQL_SERVER').get('hostName'),
  966. serviceName: "HIVE",
  967. componentName: "MYSQL_SERVER",
  968. HostRoles: {
  969. state: "STARTED"
  970. }
  971. },
  972. success: 'startPolling',
  973. error: 'onTaskError'
  974. });
  975. },
  976. restartMySqlServer: function() {
  977. var context = "Restart MySql Server";
  978. var resource_filters = {
  979. component_name: "MYSQL_SERVER",
  980. hosts: App.HostComponent.find().filterProperty('componentName', 'MYSQL_SERVER').get('firstObject.hostName'),
  981. service_name: "HIVE"
  982. };
  983. var operation_level = {
  984. level: "HOST_COMPONENT",
  985. cluster_name: this.get('content.cluster.name'),
  986. service_name: "HIVE",
  987. hostcomponent_name: "MYSQL_SERVER"
  988. };
  989. App.ajax.send({
  990. name: 'restart.hostComponents',
  991. sender: this,
  992. data: {
  993. context: context,
  994. resource_filters: [resource_filters],
  995. operation_level: operation_level
  996. },
  997. success: 'startPolling',
  998. error: 'onTaskError'
  999. });
  1000. },
  1001. startNewMySqlServer: function() {
  1002. App.ajax.send({
  1003. name: 'common.host.host_component.update',
  1004. sender: this,
  1005. data: {
  1006. context: "Start MySQL Server",
  1007. hostName: this.get('content.reassignHosts.target'),
  1008. serviceName: "HIVE",
  1009. componentName: "MYSQL_SERVER",
  1010. HostRoles: {
  1011. state: "STARTED"
  1012. }
  1013. },
  1014. success: 'startPolling',
  1015. error: 'onTaskError'
  1016. });
  1017. },
  1018. testDBConnection: function() {
  1019. this.prepareDBCheckAction();
  1020. },
  1021. isComponentWithDB: function() {
  1022. return ['HIVE_SERVER', 'HIVE_METASTORE', 'OOZIE_SERVER'].contains(this.get('content.reassign.component_name'));
  1023. },
  1024. /** @property {Object} propertiesPattern - check pattern according to type of connection properties **/
  1025. propertiesPattern: function() {
  1026. return {
  1027. user_name: /(username|dblogin)$/ig,
  1028. user_passwd: /(dbpassword|password)$/ig,
  1029. db_connection_url: /jdbc\.url|connectionurl/ig,
  1030. driver_class: /ConnectionDriverName|jdbc\.driver/ig,
  1031. schema_name: /db\.schema\.name/ig
  1032. };
  1033. }.property(),
  1034. /** @property {Object} connectionProperties - service specific config values mapped for custom action request **/
  1035. connectionProperties: function() {
  1036. var propObj = {};
  1037. for (var key in this.get('propertiesPattern')) {
  1038. propObj[key] = this.getConnectionProperty(this.get('propertiesPattern')[key]);
  1039. }
  1040. return propObj;
  1041. }.property('propertiesPattern'),
  1042. getConnectionProperty: function(regexp) {
  1043. var propertyName = this.get('requiredProperties').filter(function(item) {
  1044. return regexp.test(item);
  1045. })[0];
  1046. return this.get('content.serviceProperties')[propertyName];
  1047. },
  1048. /**
  1049. * Properties that stores in local storage used for handling
  1050. * last success connection.
  1051. *
  1052. * @property {Object} preparedDBProperties
  1053. **/
  1054. preparedDBProperties: function() {
  1055. var propObj = {};
  1056. for (var key in this.get('propertiesPattern')) {
  1057. var propValue = this.getConnectionProperty(this.get('propertiesPattern')[key]);
  1058. propObj[key] = propValue;
  1059. }
  1060. return propObj;
  1061. }.property(),
  1062. /** @property {object} requiredProperties - properties that necessary for database connection **/
  1063. requiredProperties: function() {
  1064. var propertiesMap = {
  1065. 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'],
  1066. HIVE: ['ambari.hive.db.schema.name','javax.jdo.option.ConnectionUserName','javax.jdo.option.ConnectionPassword','javax.jdo.option.ConnectionDriverName','javax.jdo.option.ConnectionURL']
  1067. };
  1068. return propertiesMap[this.get('content.reassign.service_id')];
  1069. }.property(),
  1070. dbType: function() {
  1071. var databaseTypes = /MySQL|PostgreS|Oracle|Derby|MSSQL|Anywhere/gi;
  1072. var databaseProp = this.get('content.serviceProperties')[Em.getWithDefault(this.get('dbPropertyMap'), this.get('content.reassign.component_name'), null)];
  1073. return databaseProp.match(databaseTypes)[0];
  1074. }.property(),
  1075. prepareDBCheckAction: function() {
  1076. var params = this.get('preparedDBProperties');
  1077. var ambariProperties = App.router.get('clusterController.ambariProperties');
  1078. params['db_name'] = this.get('dbType');
  1079. params['jdk_location'] = ambariProperties['jdk_location'];
  1080. params['jdk_name'] = ambariProperties['jdk.name'];
  1081. params['java_home'] = ambariProperties['java.home'];
  1082. params['threshold'] = 60;
  1083. params['ambari_server_host'] = location.hostname;
  1084. params['check_execute_list'] = "db_connection_check";
  1085. App.ajax.send({
  1086. name: 'cluster.custom_action.create',
  1087. sender: this,
  1088. data: {
  1089. requestInfo: {
  1090. "context": "Check host",
  1091. "action": "check_host",
  1092. "parameters": params
  1093. },
  1094. filteredHosts: [this.get('content.reassignHosts.target')]
  1095. },
  1096. success: 'onCreateActionSuccess',
  1097. error: 'onTaskError'
  1098. });
  1099. },
  1100. onCreateActionSuccess: function(data) {
  1101. this.set('checkDBRequestId', data.Requests.id);
  1102. App.ajax.send({
  1103. name: 'custom_action.request',
  1104. sender: this,
  1105. data: {
  1106. requestId: this.get('checkDBRequestId')
  1107. },
  1108. success: 'setCheckDBTaskId'
  1109. });
  1110. },
  1111. setCheckDBTaskId: function(data) {
  1112. this.set('checkDBTaskId', data.items[0].Tasks.id);
  1113. this.startDBCheckPolling();
  1114. },
  1115. startDBCheckPolling: function() {
  1116. this.getDBConnTaskInfo();
  1117. },
  1118. getDBConnTaskInfo: function() {
  1119. this.setTaskStatus(this.get('currentTaskId'), 'IN_PROGRESS');
  1120. this.get('tasks').findProperty('id', this.get('currentTaskId')).set('progress', 100);
  1121. this.set('logs', []);
  1122. App.ajax.send({
  1123. name: 'custom_action.request',
  1124. sender: this,
  1125. data: {
  1126. requestId: this.get('checkDBRequestId'),
  1127. taskId: this.get('checkDBTaskId')
  1128. },
  1129. success: 'getDBConnTaskInfoSuccess'
  1130. });
  1131. },
  1132. getDBConnTaskInfoSuccess: function(data) {
  1133. var task = data.Tasks;
  1134. if (task.status === 'COMPLETED') {
  1135. var structuredOut = task.structured_out.db_connection_check;
  1136. if (structuredOut.exit_code != 0) {
  1137. this.showConnectionErrorPopup(structuredOut.message);
  1138. this.onTaskError();
  1139. } else {
  1140. this.onTaskCompleted();
  1141. }
  1142. }
  1143. if (task.status === 'FAILED') {
  1144. this.onTaskError();
  1145. }
  1146. if (/PENDING|QUEUED|IN_PROGRESS/.test(task.status)) {
  1147. Em.run.later(this, function() {
  1148. this.startDBCheckPolling();
  1149. }, 3000);
  1150. }
  1151. },
  1152. showConnectionErrorPopup: function(error) {
  1153. var popup = App.showAlertPopup('Database Connection Error');
  1154. popup.set('body', error);
  1155. },
  1156. testDBRetryTooltip: function() {
  1157. var db_host = this.get('content.serviceProperties.database_hostname');
  1158. var db_type = this.get('dbType');
  1159. var db_props = this.get('preparedDBProperties');
  1160. return Em.I18n.t('services.reassign.step4.tasks.testDBConnection.tooltip').format(
  1161. db_host, db_type, db_props['schema_name'], db_props['user_name'],
  1162. db_props['user_passwd'], db_props['driver_class'], db_props['db_connection_url']
  1163. );
  1164. }.property('dbProperties'),
  1165. saveServiceProperties: function(configs) {
  1166. App.router.get(this.get('content.controllerName')).saveServiceProperties(configs);
  1167. },
  1168. stopHostComponentsInMaintenanceMode: function () {
  1169. var hostComponentsInMM = this.get('content.reassignComponentsInMM');
  1170. var hostName = this.get('content.reassignHosts.source');
  1171. var serviceName = this.get('content.reassign.service_id');
  1172. hostComponentsInMM = hostComponentsInMM.map(function(componentName){
  1173. return {
  1174. hostName: hostName,
  1175. serviceName: serviceName,
  1176. componentName: componentName
  1177. };
  1178. });
  1179. this.set('multiTaskCounter', hostComponentsInMM.length);
  1180. this.updateComponentsState(hostComponentsInMM, 'INSTALLED');
  1181. }
  1182. });