step4_controller.js 41 KB

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