step8_controller.js 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801
  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. var stringUtils = require('utils/string_utils');
  20. App.WizardStep8Controller = Em.Controller.extend({
  21. name: 'wizardStep8Controller',
  22. /**
  23. * List of raw data about cluster that should be displayed
  24. * @type {Array}
  25. */
  26. rawContent: [
  27. {
  28. config_name: 'Admin',
  29. display_name: 'Admin Name',
  30. config_value: ''
  31. },
  32. {
  33. config_name: 'cluster',
  34. display_name: 'Cluster Name',
  35. config_value: ''
  36. },
  37. {
  38. config_name: 'hosts',
  39. display_name: 'Total Hosts',
  40. config_value: ''
  41. },
  42. {
  43. config_name: 'Repo',
  44. display_name: 'Local Repository',
  45. config_value: ''
  46. }
  47. ],
  48. /**
  49. * List of data about cluster (based on formatted <code>rawContent</code>)
  50. * @type {Object[]}
  51. */
  52. clusterInfo: [],
  53. /**
  54. * List of services with components assigned to hosts
  55. * @type {Object[]}
  56. */
  57. services: [],
  58. /**
  59. * @type {Object[]}
  60. */
  61. configs: [],
  62. /**
  63. * @type {Object[]}
  64. */
  65. globals: [],
  66. /**
  67. * All configs
  68. * @type {Array}
  69. */
  70. configMapping: function () {
  71. return App.config.get('configMapping').all(true);
  72. }.property('App.config.configMapping'),
  73. /**
  74. *
  75. */
  76. slaveComponentConfig: null,
  77. /**
  78. * Should Submit button be disabled
  79. * @type {bool}
  80. */
  81. isSubmitDisabled: false,
  82. /**
  83. * Should Back button be disabled
  84. * @type {bool}
  85. */
  86. isBackBtnDisabled: false,
  87. /**
  88. * Is error appears while <code>ajaxQueue</code> executes
  89. * @type {bool}
  90. */
  91. hasErrorOccurred: false,
  92. /**
  93. * Are services installed
  94. * Used to hide Deploy Progress Bar
  95. * @type {bool}
  96. */
  97. servicesInstalled: false,
  98. /**
  99. * List of service config tags
  100. * @type {Object[]}
  101. */
  102. serviceConfigTags: [],
  103. /**
  104. * Ajax-requests queue
  105. * @type {App.ajaxQueue}
  106. */
  107. ajaxRequestsQueue: null,
  108. /**
  109. * Is cluster security enabled
  110. * @type {bool}
  111. */
  112. securityEnabled: function () {
  113. return App.router.get('mainAdminSecurityController.securityEnabled');
  114. }.property('App.router.mainAdminSecurityController.securityEnabled'),
  115. /**
  116. * During page save time, we set the host overrides to the server.
  117. * The new host -> site:tag map is stored below. This will be
  118. * useful during save, to update the host's host components. Also,
  119. * it will be useful in deletion of overrides.
  120. *
  121. * Example:
  122. * {
  123. * 'hostname1': {
  124. * 'global': {
  125. * 'tagName': 'tag3187261938_hostname1',
  126. * 'map': {
  127. * 'hadoop_heapsize': '2048m'
  128. * }
  129. * }
  130. * }
  131. * }
  132. *
  133. * @see loadedHostToOverrideSiteToTagMap
  134. */
  135. savedHostToOverrideSiteToTagMap: {},
  136. /**
  137. * Selected config group
  138. * @type {Object}
  139. */
  140. selectedConfigGroup: null,
  141. /**
  142. * List of config groups
  143. * @type {Object[]}
  144. */
  145. configGroups: [],
  146. /**
  147. * List of selected but not installed services
  148. * @type {Object[]}
  149. */
  150. selectedServices: function () {
  151. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  152. }.property('content.services').cacheable(),
  153. /**
  154. * List of installed and selected services
  155. * @type {Object[]}
  156. */
  157. installedServices: function () {
  158. return this.get('content.services').filterProperty('isSelected').filterProperty('isInstalled');
  159. }.property('content.services').cacheable(),
  160. /**
  161. * Ajax-requests count
  162. * @type {number}
  163. */
  164. ajaxQueueLength: 0,
  165. /**
  166. * Current cluster name
  167. * @type {string}
  168. */
  169. clusterName: function () {
  170. return this.get('content.cluster.name');
  171. }.property('content.cluster.name'),
  172. /**
  173. * List of existing cluster names
  174. * @type {string[]}
  175. */
  176. clusterNames: [],
  177. /**
  178. * Clear current step data
  179. * @method clearStep
  180. */
  181. clearStep: function () {
  182. this.get('services').clear();
  183. this.get('configs').clear();
  184. this.get('globals').clear();
  185. this.get('clusterInfo').clear();
  186. this.get('serviceConfigTags').clear();
  187. this.set('servicesInstalled', false);
  188. this.set('ajaxQueueLength', 0);
  189. this.set('ajaxRequestsQueue', App.ajaxQueue.create());
  190. this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
  191. },
  192. /**
  193. * Load current step data
  194. * @method loadStep
  195. */
  196. loadStep: function () {
  197. console.log("TRACE: Loading step8: Review Page");
  198. if (this.get('content.controllerName') != 'installerController') {
  199. App.router.get('mainAdminSecurityController').setSecurityStatus();
  200. }
  201. this.clearStep();
  202. if (this.get('content.serviceConfigProperties')) {
  203. this.formatProperties();
  204. this.loadGlobals();
  205. this.loadConfigs();
  206. }
  207. this.loadClusterInfo();
  208. this.loadServices();
  209. this.set('isSubmitDisabled', false);
  210. this.set('isBackBtnDisabled', false);
  211. },
  212. /**
  213. * replace whitespace character with coma between directories
  214. * @method formatProperties
  215. */
  216. formatProperties: function () {
  217. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  218. _configProperty.value = App.config.trimProperty(_configProperty, false);
  219. });
  220. },
  221. /**
  222. * Load global configs and remove some of them:
  223. * <ul>
  224. * <li>Unused DB properties for Hive</li>
  225. * <li>Unused DB properties for Oozie</li>
  226. * <ul>
  227. * @method loadGlobals
  228. */
  229. loadGlobals: function () {
  230. var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
  231. if (globals.someProperty('name', 'hive_database')) {
  232. globals = this.removeHiveConfigs(globals);
  233. }
  234. if (globals.someProperty('name', 'oozie_database')) {
  235. globals = this.removeOozieConfigs(globals);
  236. }
  237. this.set('globals', globals);
  238. },
  239. /**
  240. * Remove unused Hive configs
  241. * @param {Ember.Enumerable} globals
  242. * @returns {Ember.Enumerable}
  243. * @method removeHiveConfigs
  244. */
  245. removeHiveConfigs: function (globals) {
  246. var hiveDb = globals.findProperty('name', 'hive_database');
  247. var hiveDbType = {name: 'hive_database_type', value: 'mysql'};
  248. var hive_properties = Em.A([]);
  249. if (hiveDb.value === 'New MySQL Database') {
  250. if (globals.someProperty('name', 'hive_ambari_host')) {
  251. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_ambari_host').value;
  252. hiveDbType.value = 'mysql';
  253. }
  254. hive_properties = Em.A(['hive_existing_mysql_host', 'hive_existing_mysql_database', 'hive_existing_oracle_host',
  255. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
  256. }
  257. else {
  258. if (hiveDb.value === 'Existing MySQL Database') {
  259. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_mysql_host').value;
  260. hiveDbType.value = 'mysql';
  261. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  262. 'hive_existing_oracle_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
  263. }
  264. else {
  265. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  266. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_postgresql_host').value;
  267. hiveDbType.value = 'postgres';
  268. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_oracle_host',
  269. 'hive_existing_oracle_database', 'hive_existing_mysql_host', 'hive_existing_mysql_database']);
  270. }
  271. else { //existing oracle database
  272. globals.findProperty('name', 'hive_hostname').value = globals.findProperty('name', 'hive_existing_oracle_host').value;
  273. hiveDbType.value = 'oracle';
  274. hive_properties = Em.A(['hive_ambari_host', 'hive_ambari_database', 'hive_existing_mysql_host',
  275. 'hive_existing_mysql_database', 'hive_existing_postgresql_host', 'hive_existing_postgresql_database']);
  276. }
  277. }
  278. }
  279. hive_properties.forEach(function (property) {
  280. globals = globals.without(globals.findProperty('name', property));
  281. });
  282. globals.pushObject(hiveDbType);
  283. return globals;
  284. },
  285. /**
  286. * Remove unused Oozie configs
  287. * @param {Ember.Enumerable} globals
  288. * @returns {Ember.Enumerable}
  289. * @method removeOozieConfigs
  290. */
  291. removeOozieConfigs: function (globals) {
  292. var oozieDb = globals.findProperty('name', 'oozie_database');
  293. var oozieDbType = {name: 'oozie_database_type'};
  294. var oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database']);
  295. if (oozieDb.value === 'New Derby Database') {
  296. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_ambari_host').value;
  297. oozieDbType.value = 'derby';
  298. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  299. 'oozie_existing_mysql_database', 'oozie_existing_oracle_host', 'oozie_existing_oracle_database',
  300. 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']);
  301. }
  302. else {
  303. if (oozieDb.value === 'Existing MySQL Database') {
  304. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_mysql_host').value;
  305. oozieDbType.value = 'mysql';
  306. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  307. 'oozie_existing_oracle_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']);
  308. }
  309. else {
  310. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  311. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_postgresql_host').value;
  312. oozieDbType.value = 'postgresql';
  313. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_oracle_host',
  314. 'oozie_existing_oracle_database', 'oozie_existing_mysql_host', 'oozie_existing_mysql_database']);
  315. }
  316. else { // existing oracle database
  317. globals.findProperty('name', 'oozie_hostname').value = globals.findProperty('name', 'oozie_existing_oracle_host').value;
  318. oozieDbType.value = 'oracle';
  319. oozie_properties = Em.A(['oozie_ambari_host', 'oozie_ambari_database', 'oozie_existing_mysql_host',
  320. 'oozie_existing_mysql_database', 'oozie_derby_database', 'oozie_existing_postgresql_host', 'oozie_existing_postgresql_database']);
  321. }
  322. }
  323. }
  324. oozie_properties.forEach(function (property) {
  325. globals = globals.without(globals.findProperty('name', property));
  326. });
  327. globals.pushObject(oozieDbType);
  328. return globals;
  329. },
  330. /**
  331. * Load all site properties
  332. * @method loadConfigs
  333. */
  334. loadConfigs: function () {
  335. //storedConfigs contains custom configs as well
  336. var serviceConfigProperties = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
  337. serviceConfigProperties.forEach(function (_config) {
  338. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  339. });
  340. var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
  341. var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
  342. this.set('configs', serviceConfigProperties.concat(uiConfigs));
  343. },
  344. /**
  345. * Load UI configs
  346. * @param {Array} configMapping
  347. * @return {Array}
  348. * @method loadUiSideConfigs
  349. */
  350. loadUiSideConfigs: function (configMapping) {
  351. var uiConfig = [];
  352. var configs = configMapping.filterProperty('foreignKey', null);
  353. this.addDynamicProperties(configs);
  354. configs.forEach(function (_config) {
  355. var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
  356. uiConfig.pushObject({
  357. "id": "site property",
  358. "name": _config.name,
  359. "value": valueWithOverrides.value,
  360. "filename": _config.filename,
  361. "overrides": valueWithOverrides.overrides
  362. });
  363. }, this);
  364. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  365. dependentConfig.forEach(function (_config) {
  366. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
  367. uiConfig.pushObject({
  368. "id": "site property",
  369. "name": _config._name || _config.name,
  370. "value": _config.value,
  371. "filename": _config.filename
  372. });
  373. }, this);
  374. return uiConfig;
  375. },
  376. /**
  377. * Add dynamic properties to configs
  378. * @param {Array} configs
  379. * @method addDynamicProperties
  380. */
  381. addDynamicProperties: function (configs) {
  382. var templetonHiveProperty = this.get('content.serviceConfigProperties').someProperty('name', 'templeton.hive.properties');
  383. if (!templetonHiveProperty) {
  384. configs.pushObject({
  385. "name": "templeton.hive.properties",
  386. "templateName": ["hivemetastore_host"],
  387. "foreignKey": null,
  388. "value": "hive.metastore.local=false,hive.metastore.uris=thrift://<templateName[0]>:9083,hive.metastore.sasl.enabled=yes,hive.metastore.execute.setugi=true,hive.metastore.warehouse.dir=/apps/hive/warehouse",
  389. "filename": "webhcat-site.xml"
  390. });
  391. }
  392. },
  393. /**
  394. * Format <code>content.hosts</code> from Object to Array
  395. * @returns {Array}
  396. * @method getRegisteredHosts
  397. */
  398. getRegisteredHosts: function () {
  399. var allHosts = this.get('content.hosts');
  400. var hosts = [];
  401. for (var hostName in allHosts) {
  402. if (allHosts.hasOwnProperty(hostName)) {
  403. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  404. allHosts[hostName].hostName = allHosts[hostName].name;
  405. hosts.pushObject(allHosts[hostName]);
  406. }
  407. }
  408. }
  409. return hosts;
  410. },
  411. /**
  412. * Set all site property that are derived from other puppet-variable
  413. * @param {String} templateName
  414. * @param {String} expression
  415. * @param {String} name
  416. * @return {Object}
  417. * example: <code>{
  418. * value: '...',
  419. * overrides: [
  420. * {
  421. * value: 'v1',
  422. * hosts: ['h1', 'h2']
  423. * },
  424. * {
  425. * value: 'v2',
  426. * hosts: ['h2', 'h3']
  427. * },
  428. * ....
  429. * ]
  430. * }</code>
  431. * @method getGlobConfigValueWithOverrides
  432. */
  433. getGlobConfigValueWithOverrides: function (templateName, expression, name) {
  434. var express = expression.match(/<(.*?)>/g);
  435. var value = expression;
  436. if (express == null) {
  437. return { value: expression, overrides: []}; // if site property do not map any global property then return the value
  438. }
  439. var overrideHostToValue = {};
  440. express.forEach(function (_express) {
  441. //console.log("The value of template is: " + _express);
  442. var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
  443. if (this.get('globals').someProperty('name', templateName[index])) {
  444. //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
  445. var globalObj = this.get('globals').findProperty('name', templateName[index]);
  446. var globValue = globalObj.value;
  447. // Hack for templeton.zookeeper.hosts
  448. var preReplaceValue = null;
  449. if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
  450. preReplaceValue = value;
  451. value = this._replaceConfigValues(name, _express, value, globValue);
  452. }
  453. if (globalObj.overrides != null) {
  454. globalObj.overrides.forEach(function (override) {
  455. var ov = override.value;
  456. var hostsArray = override.hosts;
  457. hostsArray.forEach(function (host) {
  458. if (!(host in overrideHostToValue)) {
  459. overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
  460. } else {
  461. overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
  462. }
  463. }, this);
  464. }, this);
  465. }
  466. } else {
  467. /*
  468. console.log("ERROR: The variable name is: " + templateName[index]);
  469. console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
  470. "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
  471. "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
  472. */
  473. value = null;
  474. }
  475. }, this);
  476. var valueWithOverrides = {
  477. value: value,
  478. overrides: []
  479. };
  480. var overrideValueToHostMap = {};
  481. if (!jQuery.isEmptyObject(overrideHostToValue)) {
  482. for (var host in overrideHostToValue) {
  483. var hostVal = overrideHostToValue[host];
  484. if (!(hostVal in overrideValueToHostMap)) {
  485. overrideValueToHostMap[hostVal] = [];
  486. }
  487. overrideValueToHostMap[hostVal].push(host);
  488. }
  489. }
  490. for (var val in overrideValueToHostMap) {
  491. valueWithOverrides.overrides.push({
  492. value: val,
  493. hosts: overrideValueToHostMap[val]
  494. });
  495. }
  496. return valueWithOverrides;
  497. },
  498. /**
  499. * replace some values in config property
  500. * @param {string} name
  501. * @param {string} express
  502. * @param {string} value
  503. * @param {string} globValue
  504. * @return {string}
  505. * @private
  506. * @method _replaceConfigValues
  507. */
  508. _replaceConfigValues: function (name, express, value, globValue) {
  509. return value.replace(express, globValue);
  510. },
  511. /**
  512. * Load all info about cluster to <code>clusterInfo</code> variable
  513. * @method loadClusterInfo
  514. */
  515. loadClusterInfo: function () {
  516. //Admin name
  517. var admin = this.rawContent.findProperty('config_name', 'Admin');
  518. admin.config_value = App.db.getLoginName();
  519. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  520. if (admin.config_value) {
  521. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  522. }
  523. // cluster name
  524. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  525. cluster.config_value = this.get('content.cluster.name');
  526. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  527. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  528. //hosts
  529. var newHostsCount = 0;
  530. var totalHostsCount = 0;
  531. var hosts = this.get('content.hosts');
  532. for (var hostName in hosts) {
  533. newHostsCount += ~~(!hosts[hostName].isInstalled);
  534. totalHostsCount++;
  535. }
  536. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  537. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  538. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  539. //repo
  540. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  541. this.loadRepoInfo();
  542. } else {
  543. // from install wizard
  544. var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
  545. var allRepos = [];
  546. if (selectedStack && selectedStack.operatingSystems) {
  547. selectedStack.operatingSystems.forEach(function (os) {
  548. if (os.selected) {
  549. allRepos.push(Em.Object.create({
  550. base_url: os.baseUrl,
  551. os_type: os.osType,
  552. repo_id: os.repoId
  553. }));
  554. }
  555. }, this);
  556. }
  557. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  558. this.get('clusterInfo').set('repoInfo', allRepos);
  559. }
  560. },
  561. /**
  562. * Load repo info for add Service/Host wizard review page
  563. * @return {$.ajax|null}
  564. * @method loadRepoInfo
  565. */
  566. loadRepoInfo: function () {
  567. var nameVersionCombo = App.get('currentStackVersion').split('-');
  568. return App.ajax.send({
  569. name: 'cluster.load_repositories',
  570. sender: this,
  571. data: {
  572. stackName: nameVersionCombo[0],
  573. stackVersion: nameVersionCombo[1]
  574. },
  575. success: 'loadRepoInfoSuccessCallback',
  576. error: 'loadRepoInfoErrorCallback'
  577. });
  578. },
  579. /**
  580. * Save all repo base URL of all OS type to <code>repoInfo<code>
  581. * @param {object} data
  582. * @method loadRepoInfoSuccessCallback
  583. */
  584. loadRepoInfoSuccessCallback: function (data) {
  585. var allRepos = [];
  586. data.items.forEach(function (os) {
  587. if (!App.supports.ubuntu && os.OperatingSystems.os_type == 'debian12') return; // @todo: remove after Ubuntu support confirmation
  588. os.repositories.forEach(function (repository) {
  589. allRepos.push(Em.Object.create({
  590. base_url: repository.Repositories.base_url,
  591. os_type: repository.Repositories.os_type,
  592. repo_id: repository.Repositories.repo_id
  593. }));
  594. });
  595. }, this);
  596. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  597. this.get('clusterInfo').set('repoInfo', allRepos);
  598. },
  599. /**
  600. * @param {object} request
  601. * @method loadRepoInfoErrorCallback
  602. */
  603. loadRepoInfoErrorCallback: function (request) {
  604. console.log('Error message is: ' + request.responseText);
  605. var allRepos = [];
  606. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  607. this.get('clusterInfo').set('repoInfo', allRepos);
  608. },
  609. /**
  610. * Load all info about services to <code>services</code> variable
  611. * @method loadServices
  612. */
  613. loadServices: function () {
  614. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  615. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  616. var serviceObj = Em.Object.create({
  617. service_name: service.get('serviceName'),
  618. display_name: service.get('displayNameOnSelectServicePage'),
  619. service_components: Em.A([])
  620. });
  621. service.get('serviceComponents').forEach(function(component) {
  622. // show clients for services that have only clients components
  623. if ((component.get('isClient') || component.get('isClientBehavior')) && !service.get('isClientOnlyService')) return;
  624. // skip components that was hide on assign master page
  625. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  626. // no HA component
  627. if (App.get('isHaEnabled') && component.get('isHAComponentOnly')) return;
  628. var displayName;
  629. if (component.get('isClient')) {
  630. displayName = Em.I18n.t('common.clients')
  631. } else {
  632. // remove service name from component display name
  633. displayName = component.get('displayName').replace(new RegExp('^' + service.get('serviceName') + '\\s','i'), '');
  634. }
  635. serviceObj.get('service_components').pushObject(Em.Object.create({
  636. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  637. display_name: displayName,
  638. component_value: this.assignComponentHosts(component)
  639. }));
  640. }, this);
  641. if (service.get('customReviewHandler')) {
  642. for (var displayName in service.get('customReviewHandler')) {
  643. serviceObj.get('service_components').pushObject(Em.Object.create({
  644. display_name: displayName,
  645. component_value: this.assignComponentHosts(Em.Object.create({
  646. customHandler: service.get('customReviewHandler.' + displayName)
  647. }))
  648. }));
  649. }
  650. }
  651. this.get('services').pushObject(serviceObj);
  652. }, this);
  653. },
  654. /**
  655. * Set <code>component_value</code> property to <code>component</code>
  656. * @param {Em.Object} component
  657. * @return {String}
  658. * @method assignComponentHosts
  659. */
  660. assignComponentHosts: function (component) {
  661. var componentValue;
  662. if (component.get('customHandler')) {
  663. componentValue = this[component.get('customHandler')].call(this, component);
  664. }
  665. else {
  666. if (component.get('isMaster') || component.get('isMasterBehavior')) {
  667. componentValue = this.getMasterComponentValue(component.get('componentName'));
  668. }
  669. else {
  670. console.log(' --- ---INFO: step8: NOT component isMaster');
  671. var hostsLength = this.get('content.slaveComponentHosts')
  672. .findProperty('componentName', component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'))
  673. .hosts.length;
  674. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  675. }
  676. }
  677. return componentValue;
  678. },
  679. getMasterComponentValue: function(componentName) {
  680. var masterComponents = this.get('content.masterComponentHosts');
  681. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  682. return stringUtils.pluralize(hostsCount,
  683. masterComponents.findProperty('component', componentName).hostName,
  684. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  685. },
  686. /**
  687. * Set dispalyed Hive DB value based on DB type
  688. * @param {Ember.Object} dbComponent
  689. * @method loadHiveDbValue
  690. */
  691. loadHiveDbValue: function () {
  692. var db,
  693. serviceConfigPreoprties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  694. hiveDb = serviceConfigPreoprties.findProperty('name', 'hive_database');
  695. if (hiveDb.value === 'New MySQL Database') {
  696. return 'MySQL (New Database)';
  697. }
  698. else {
  699. if (hiveDb.value === 'Existing MySQL Database') {
  700. db = serviceConfigPreoprties .findProperty('name', 'hive_existing_mysql_database');
  701. return db.value + ' (' + hiveDb.value + ')';
  702. }
  703. else {
  704. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  705. db = serviceConfigPreoprties .findProperty('name', 'hive_existing_postgresql_database');
  706. return db.value + ' (' + hiveDb.value + ')';
  707. }
  708. else { // existing oracle database
  709. db = serviceConfigPreoprties .findProperty('name', 'hive_existing_oracle_database');
  710. return db.value + ' (' + hiveDb.value + ')';
  711. }
  712. }
  713. }
  714. },
  715. /**
  716. * Set displayed HBase master value
  717. * @param {Object} hbaseMaster
  718. * @method loadHbaseMasterValue
  719. */
  720. loadHbaseMasterValue: function (hbaseMaster) {
  721. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  722. if (hbaseHostName.length == 1) {
  723. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  724. } else {
  725. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  726. }
  727. },
  728. /**
  729. * Set displayed ZooKeeper Server value
  730. * @param {Object} serverComponent
  731. * @method loadZkServerValue
  732. */
  733. loadZkServerValue: function (serverComponent) {
  734. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  735. var hostSuffix;
  736. if (zkHostNames === 1) {
  737. hostSuffix = Em.I18n.t('installer.step8.host');
  738. } else {
  739. hostSuffix = Em.I18n.t('installer.step8.hosts');
  740. }
  741. serverComponent.set('component_value', zkHostNames + hostSuffix);
  742. },
  743. /**
  744. * Set displayed Oozie DB value based on DB type
  745. * @param {Object} dbComponent
  746. * @method loadOozieDbValue
  747. */
  748. loadOozieDbValue: function () {
  749. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  750. if (oozieDb.value === 'New Derby Database') {
  751. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  752. return db.value + ' (' + oozieDb.value + ')';
  753. }
  754. else {
  755. if (oozieDb.value === 'Existing MySQL Database') {
  756. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  757. return db.value + ' (' + oozieDb.value + ')';
  758. }
  759. else {
  760. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  761. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  762. return db.value + ' (' + oozieDb.value + ')';
  763. }
  764. else { // existing oracle database
  765. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  766. return db.value + ' (' + oozieDb.value + ')';
  767. }
  768. }
  769. }
  770. },
  771. /**
  772. * Set displayed Nagion Admin value
  773. * @param {Object} nagiosAdmin
  774. * @method loadNagiosAdminValue
  775. */
  776. loadNagiosAdminValue: function () {
  777. var config = this.get('content.serviceConfigProperties');
  778. var adminLoginName = config.findProperty('name', 'nagios_web_login');
  779. var adminEmail = config.findProperty('name', 'nagios_contact');
  780. return adminLoginName.value + ' / (' + adminEmail.value + ')';
  781. },
  782. /**
  783. * Onclick handler for <code>next</code> button
  784. * @method submit
  785. * @return {App.ModalPopup|null}
  786. */
  787. submit: function () {
  788. if (this.get('isSubmitDisabled')) return null;
  789. if ((this.get('content.controllerName') == 'addHostController') && this.get('securityEnabled')) {
  790. var self = this;
  791. return App.showConfirmationPopup(function () {
  792. self.submitProceed();
  793. }, Em.I18n.t('installer.step8.securityConfirmationPopupBody'));
  794. }
  795. else {
  796. return this.submitProceed();
  797. }
  798. },
  799. /**
  800. * Update configurations for installed services.
  801. * Do separated PUT-request for each siteName for each service
  802. *
  803. * @param {Array} configsToUpdate - configs need to update
  804. * Format:
  805. * <code>
  806. * [
  807. * {serviceName: 's1', id: 'site property', filename: 'f1.xml', name: 'n1', value: 'v1'},
  808. * {serviceName: 's2', id: 'site property', filename: 'f1.xml', name: 'n2', value: 'v2'},
  809. * {serviceName: 's2', id: '', filename: 'f2.xml', name: 'n3', value: 'v3'}
  810. * ]
  811. * </code>
  812. * @method updateConfigurations
  813. */
  814. updateConfigurations: function (configsToUpdate) {
  815. var configurationController = App.router.get('mainServiceInfoConfigsController');
  816. var serviceNames = configsToUpdate.mapProperty('serviceName').uniq();
  817. serviceNames.forEach(function (serviceName) {
  818. var configs = configsToUpdate.filterProperty('serviceName', serviceName);
  819. configurationController.setNewTagNames(configs);
  820. var tagName = configs.objectAt(0).newTagName;
  821. var siteConfigs = configs.filterProperty('id', 'site property');
  822. siteConfigs.mapProperty('filename').uniq().forEach(function (siteName) {
  823. var formattedConfigs = configurationController.createSiteObj(siteName.replace(".xml", ""), tagName, configs.filterProperty('filename', siteName));
  824. configurationController.doPUTClusterConfigurationSite(formattedConfigs);
  825. });
  826. });
  827. },
  828. /**
  829. * Prepare <code>ajaxQueue</code> and start to execute it
  830. * @method submitProceed
  831. */
  832. submitProceed: function () {
  833. this.set('isSubmitDisabled', true);
  834. this.set('isBackBtnDisabled', true);
  835. if (this.get('content.controllerName') == 'addHostController') {
  836. App.router.get('addHostController').setLowerStepsDisable(4);
  837. }
  838. // checkpoint the cluster status on the server so that the user can resume from where they left off
  839. switch (this.get('content.controllerName')) {
  840. case 'installerController':
  841. App.clusterStatus.setClusterStatus({
  842. clusterName: this.get('clusterName'),
  843. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  844. wizardControllerName: this.get('content.controllerName'),
  845. localdb: App.db.data
  846. });
  847. break;
  848. case 'addHostController':
  849. App.clusterStatus.setClusterStatus({
  850. clusterName: this.get('clusterName'),
  851. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  852. wizardControllerName: this.get('content.controllerName'),
  853. localdb: App.db.data
  854. });
  855. break;
  856. case 'addServiceController':
  857. App.clusterStatus.setClusterStatus({
  858. clusterName: this.get('clusterName'),
  859. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  860. wizardControllerName: this.get('content.controllerName'),
  861. localdb: App.db.data
  862. });
  863. break;
  864. default:
  865. break;
  866. }
  867. // delete any existing clusters to start from a clean slate
  868. // before creating a new cluster in install wizard
  869. // TODO: modify for multi-cluster support
  870. var clusterNames = this.getExistingClusterNames();
  871. if (this.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  872. this.deleteClusters(clusterNames);
  873. } else {
  874. this.deleteClustersCallback(null, null, {isLast: true});
  875. }
  876. },
  877. /**
  878. * Get list of existing cluster names
  879. * @returns {string[]}
  880. * returns an array of existing cluster names.
  881. * returns an empty array if there are no existing clusters.
  882. * @method getExistingClusterNames
  883. */
  884. getExistingClusterNames: function () {
  885. App.ajax.send({
  886. name: 'wizard.step8.existing_cluster_names',
  887. sender: this,
  888. success: 'getExistingClusterNamesSuccessCallBack',
  889. error: 'getExistingClusterNamesErrorCallback'
  890. });
  891. return this.get('clusterNames');
  892. },
  893. /**
  894. * Save received list to <code>clusterNames</code>
  895. * @param {Object} data
  896. * @method getExistingClusterNamesSuccessCallBack
  897. */
  898. getExistingClusterNamesSuccessCallBack: function (data) {
  899. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  900. console.log("Got existing cluster names: " + clusterNames);
  901. this.set('clusterNames', clusterNames);
  902. },
  903. /**
  904. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  905. * @method getExistingClusterNamesErrorCallback
  906. */
  907. getExistingClusterNamesErrorCallback: function () {
  908. console.log("Failed to get existing cluster names");
  909. this.set('clusterNames', []);
  910. },
  911. /**
  912. * Delete cluster by name
  913. * One request for one cluster!
  914. * @param {string[]} clusterNames
  915. * @method deleteClusters
  916. */
  917. deleteClusters: function (clusterNames) {
  918. clusterNames.forEach(function (clusterName, index) {
  919. App.ajax.send({
  920. name: 'common.delete.cluster',
  921. sender: this,
  922. data: {
  923. name: clusterName,
  924. isLast: index == clusterNames.length - 1
  925. },
  926. success: 'deleteClustersCallback',
  927. error: 'deleteClustersCallback'
  928. });
  929. }, this);
  930. },
  931. deleteClustersCallback: function (response, request, data) {
  932. if (data.isLast) {
  933. if (this.get('wizardController').getDBProperty('configsToUpdate')) {
  934. this.updateConfigurations(this.get('wizardController').getDBProperty('configsToUpdate'));
  935. }
  936. this.setLocalRepositories();
  937. this.createCluster();
  938. this.createSelectedServices();
  939. if (this.get('content.controllerName') !== 'addHostController') {
  940. this.createConfigurations();
  941. this.applyConfigurationsToCluster();
  942. }
  943. this.createComponents();
  944. this.registerHostsToCluster();
  945. if (App.get('supports.hostOverridesInstaller')) {
  946. this.createConfigurationGroups();
  947. }
  948. this.createMasterHostComponents();
  949. this.createSlaveAndClientsHostComponents();
  950. this.createAdditionalHostComponents();
  951. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  952. this.get('ajaxRequestsQueue').start();
  953. }
  954. },
  955. /**
  956. * Updates local repositories for the Ambari server.
  957. * @method setLocalRepositories
  958. * @return {bool} true - requests are sent, false - requests not sent
  959. */
  960. setLocalRepositories: function () {
  961. if (this.get('content.controllerName') !== 'installerController' || !App.get('supports.localRepositories')) return false;
  962. var self = this,
  963. stack = this.get('content.stacks').findProperty('isSelected', true);
  964. stack.operatingSystems.forEach(function (os) {
  965. if (os.baseUrl !== os.originalBaseUrl) {
  966. console.log("Updating local repository URL from " + os.originalBaseUrl + " -> " + os.baseUrl + ". ", os);
  967. self.addRequestToAjaxQueue({
  968. name: 'wizard.step8.set_local_repos',
  969. data: {
  970. osType: os.osType,
  971. repoId: os.repoId,
  972. stackVersionURL: App.get('stackVersionURL'),
  973. data: JSON.stringify({
  974. "Repositories": {
  975. "base_url": os.baseUrl,
  976. "verify_base_url": false
  977. }
  978. })
  979. }
  980. });
  981. }
  982. });
  983. return true;
  984. },
  985. /**
  986. * *******************************************************************
  987. * The following create* functions are called upon submitting Step 8.
  988. * *******************************************************************
  989. */
  990. /**
  991. * Create cluster using selected stack version
  992. * Queued request
  993. * @method createCluster
  994. */
  995. createCluster: function () {
  996. if (this.get('content.controllerName') !== 'installerController') return;
  997. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  998. this.addRequestToAjaxQueue({
  999. name: 'wizard.step8.create_cluster',
  1000. data: {
  1001. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  1002. },
  1003. success: 'createClusterSuccess'
  1004. });
  1005. },
  1006. createClusterSuccess: function(data, xhr, params) {
  1007. App.set('clusterName', params.cluster)
  1008. },
  1009. /**
  1010. * Create selected to install services
  1011. * Queued request
  1012. * Skipped if no services where selected!
  1013. * @method createSelectedServices
  1014. */
  1015. createSelectedServices: function () {
  1016. var data = this.createSelectedServicesData();
  1017. if (!data.length) return;
  1018. this.addRequestToAjaxQueue({
  1019. name: 'wizard.step8.create_selected_services',
  1020. data: {
  1021. data: JSON.stringify(data)
  1022. }
  1023. });
  1024. },
  1025. /**
  1026. * Format data for <code>createSelectedServices</code> request
  1027. * @returns {Object[]}
  1028. * @method createSelectedServicesData
  1029. */
  1030. createSelectedServicesData: function () {
  1031. return this.get('selectedServices').map(function (_service) {
  1032. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  1033. });
  1034. },
  1035. /**
  1036. * Create components for selected services
  1037. * Queued requests
  1038. * One request for each service!
  1039. * @method createComponents
  1040. */
  1041. createComponents: function () {
  1042. var serviceComponents = App.StackServiceComponent.find();
  1043. this.get('selectedServices').forEach(function (_service) {
  1044. var serviceName = _service.get('serviceName');
  1045. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1046. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1047. });
  1048. // Service must be specified in terms of a query for creating multiple components at the same time.
  1049. // See AMBARI-1018.
  1050. this.addRequestToAjaxQueue({
  1051. name: 'wizard.step8.create_components',
  1052. data: {
  1053. data: JSON.stringify({"components": componentsData}),
  1054. serviceName: serviceName
  1055. }
  1056. });
  1057. }, this);
  1058. },
  1059. /**
  1060. * Error callback for new service component request
  1061. * So, if component doesn't exist we should create it
  1062. * @param {object} request
  1063. * @param {object} ajaxOptions
  1064. * @param {string} error
  1065. * @param {object} opt
  1066. * @param {object} params
  1067. * @method newServiceComponentErrorCallback
  1068. */
  1069. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1070. this.addRequestToAjaxQueue({
  1071. name: 'wizard.step8.create_components',
  1072. data: {
  1073. serviceName: params.serviceName,
  1074. data: JSON.stringify({
  1075. "components": [
  1076. {
  1077. "ServiceComponentInfo": {
  1078. "component_name": params.componentName
  1079. }
  1080. }
  1081. ]
  1082. })
  1083. }
  1084. });
  1085. },
  1086. /**
  1087. * Register hosts
  1088. * Queued request
  1089. * @method registerHostsToCluster
  1090. */
  1091. registerHostsToCluster: function () {
  1092. var data = this.createRegisterHostData();
  1093. if (!data.length) return;
  1094. this.addRequestToAjaxQueue({
  1095. name: 'wizard.step8.register_host_to_cluster',
  1096. data: {
  1097. data: JSON.stringify(data)
  1098. }
  1099. });
  1100. },
  1101. /**
  1102. * Format request-data for <code>registerHostsToCluster</code>
  1103. * @returns {Object}
  1104. * @method createRegisterHostData
  1105. */
  1106. createRegisterHostData: function () {
  1107. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1108. return {"Hosts": { "host_name": host.hostName}};
  1109. });
  1110. },
  1111. /**
  1112. * Register new master components
  1113. * @uses registerHostsToComponent
  1114. * @method createMasterHostComponents
  1115. */
  1116. createMasterHostComponents: function () {
  1117. // create master components for only selected services.
  1118. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1119. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1120. }, this);
  1121. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1122. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1123. this.registerHostsToComponent(hostNames, component);
  1124. }, this);
  1125. },
  1126. getClientsToMasterMap: function () {
  1127. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1128. clientsMap = {},
  1129. dependedComponents = App.StackServiceComponent.find().filterProperty('isMaster');
  1130. clientNames.forEach(function(clientName) {
  1131. clientsMap[clientName] = Em.A([]);
  1132. dependedComponents.forEach(function(component) {
  1133. if (component.get('dependencies').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1134. });
  1135. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1136. });
  1137. return clientsMap;
  1138. },
  1139. /**
  1140. * Register slave components and clients
  1141. * @uses registerHostsToComponent
  1142. * @method createSlaveAndClientsHostComponents
  1143. */
  1144. createSlaveAndClientsHostComponents: function () {
  1145. var masterHosts = this.get('content.masterComponentHosts'),
  1146. slaveHosts = this.get('content.slaveComponentHosts'),
  1147. clients = this.get('content.clients');
  1148. /**
  1149. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1150. * @type {Object}
  1151. * Format:
  1152. * <code>
  1153. * {
  1154. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1155. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1156. * ...
  1157. * }
  1158. * </code>
  1159. */
  1160. var clientsToMasterMap = this.getClientsToMasterMap();
  1161. slaveHosts.forEach(function (_slave) {
  1162. if (_slave.componentName !== 'CLIENT') {
  1163. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1164. this.registerHostsToComponent(hostNames, _slave.componentName);
  1165. }
  1166. else {
  1167. clients.forEach(function (_client) {
  1168. var hostNames = _slave.hosts.mapProperty('hostName');
  1169. if (clientsToMasterMap[_client.component_name]) {
  1170. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1171. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1172. hostNames.pushObject(_masterHost.hostName);
  1173. });
  1174. });
  1175. }
  1176. hostNames = hostNames.uniq();
  1177. if (_client.isInstalled) {
  1178. /**
  1179. * check whether clients are already installed on selected master hosts!!!
  1180. */
  1181. var clientHosts = [];
  1182. var installedHosts = this.get('content.hosts');
  1183. for (var hostName in installedHosts) {
  1184. if (installedHosts[hostName].isInstalled &&
  1185. installedHosts[hostName].hostComponents.filterProperty('HostRoles.state', 'INSTALLED').mapProperty('HostRoles.component_name').contains(_client.component_name)) {
  1186. clientHosts.push(hostName);
  1187. }
  1188. }
  1189. if (clientHosts.length > 0) {
  1190. clientHosts.forEach(function (hostName) {
  1191. if (hostNames.contains(hostName)) {
  1192. hostNames.splice(hostNames.indexOf(hostName), 1);
  1193. }
  1194. }, this);
  1195. }
  1196. /**
  1197. * For Add Service Only
  1198. * if client is not added to host or is not installed add Object
  1199. * {
  1200. * componentName: {String},
  1201. * hostName: {String}
  1202. * }
  1203. * to content.additionalClients
  1204. * later it will be used to install client on host before installing new services
  1205. */
  1206. if (this.get('content.controllerName') === 'addServiceController' && hostNames.length > 0) {
  1207. hostNames.forEach(function (hostName) {
  1208. this.get('content.additionalClients').push(Em.Object.create({
  1209. componentName: _client.component_name, hostName: hostName
  1210. }))
  1211. }, this)
  1212. }
  1213. }
  1214. this.registerHostsToComponent(hostNames, _client.component_name);
  1215. }, this);
  1216. }
  1217. }, this);
  1218. },
  1219. /**
  1220. * Register additional components
  1221. * Based on availability of some services
  1222. * @uses registerHostsToComponent
  1223. * @method createAdditionalHostComponents
  1224. */
  1225. createAdditionalHostComponents: function () {
  1226. var masterHosts = this.get('content.masterComponentHosts');
  1227. // add MySQL Server if Hive is selected
  1228. // add Ganglia Monitor (Slave) to all hosts if Ganglia service is selected
  1229. var gangliaService = this.get('content.services').filterProperty('isSelected').findProperty('serviceName', 'GANGLIA');
  1230. if (gangliaService) {
  1231. var hosts = this.getRegisteredHosts();
  1232. if (gangliaService.get('isInstalled')) {
  1233. hosts = hosts.filterProperty('isInstalled', false);
  1234. }
  1235. if (hosts.length) {
  1236. this.registerHostsToComponent(hosts.mapProperty('hostName'), 'GANGLIA_MONITOR');
  1237. }
  1238. }
  1239. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1240. if (hiveService) {
  1241. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1242. if (hiveDb.value == "New MySQL Database") {
  1243. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1244. }
  1245. }
  1246. },
  1247. /**
  1248. * Register component to hosts
  1249. * Queued request
  1250. * @param {String[]} hostNames
  1251. * @param {String} componentName
  1252. * @method registerHostsToComponent
  1253. */
  1254. registerHostsToComponent: function (hostNames, componentName) {
  1255. if (!hostNames.length) return;
  1256. var queryStr = '';
  1257. hostNames.forEach(function (hostName) {
  1258. queryStr += 'Hosts/host_name=' + hostName + '|';
  1259. });
  1260. //slice off last symbol '|'
  1261. queryStr = queryStr.slice(0, -1);
  1262. var data = {
  1263. "RequestInfo": {
  1264. "query": queryStr
  1265. },
  1266. "Body": {
  1267. "host_components": [
  1268. {
  1269. "HostRoles": {
  1270. "component_name": componentName
  1271. }
  1272. }
  1273. ]
  1274. }
  1275. };
  1276. this.addRequestToAjaxQueue({
  1277. name: 'wizard.step8.register_host_to_component',
  1278. data: {
  1279. data: JSON.stringify(data)
  1280. }
  1281. });
  1282. },
  1283. /**
  1284. * Create config objects for cluster and services
  1285. * @method createConfigurations
  1286. */
  1287. createConfigurations: function () {
  1288. var self = this;
  1289. var selectedServices = this.get('selectedServices');
  1290. var coreSiteObject = this.createCoreSiteObj();
  1291. var tag = 'version1';
  1292. if (this.get('content.controllerName') == 'installerController') {
  1293. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1294. this.get('serviceConfigTags').pushObject(this.createSiteObj('hdfs-site', false, tag));
  1295. this.get('serviceConfigTags').pushObject(this.createLog4jObj('hdfs', tag));
  1296. }
  1297. var globalSiteObj = this.createGlobalSiteObj(tag);
  1298. if (this.get('content.controllerName') == 'addServiceController') {
  1299. tag = 'version' + (new Date).getTime();
  1300. globalSiteObj.tag = tag;
  1301. coreSiteObject.tag = tag;
  1302. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1303. //for Add Service save config of new and installed services either
  1304. selectedServices = selectedServices.concat(this.get('installedServices'));
  1305. }
  1306. this.get('serviceConfigTags').pushObject(globalSiteObj);
  1307. var objMap = {
  1308. MAPREDUCE: {site: [
  1309. {filename: 'mapred-site', isXmlFile: true}
  1310. ], log4j: ['mapreduce']},
  1311. MAPREDUCE2: {site: [
  1312. {filename: 'mapred-site', isXmlFile: true}
  1313. ], log4j: ['mapreduce2']},
  1314. YARN: {site: [
  1315. {filename: 'yarn-site', isXmlFile: true},
  1316. {filename: 'capacity-scheduler', isXmlFile: true}
  1317. ], log4j: ['yarn']},
  1318. HBASE: {site: [
  1319. {filename: 'hbase-site', isXmlFile: true}
  1320. ], log4j: ['hbase']},
  1321. OOZIE: {site: [
  1322. {filename: 'oozie-site', isXmlFile: true}
  1323. ], log4j: ['oozie']},
  1324. HIVE: {site: [
  1325. {filename: 'hive-site', isXmlFile: true}
  1326. ], log4j: ['hive', 'hive-exec']},
  1327. WEBHCAT: {site: [
  1328. {filename: 'webhcat-site', isXmlFile: true}
  1329. ], log4j: []},
  1330. HUE: {site: [
  1331. {filename: 'hue-site', isXmlFile: true}
  1332. ], log4j: []},
  1333. PIG: {site: [
  1334. {filename: 'pig-properties', isXmlFile: false}
  1335. ], log4j: ['pig']},
  1336. FALCON: {site: [
  1337. {filename: 'falcon-startup.properties', isXmlFile: false},
  1338. {filename: 'falcon-runtime.properties', isXmlFile: false}
  1339. ], log4j: []},
  1340. TEZ: {site: [
  1341. {filename: 'tez-site', isXmlFile: true}
  1342. ], log4j: []},
  1343. ZOOKEEPER: {site: [], log4j: ['zookeeper']},
  1344. FLUME: {site: [
  1345. {filename: 'flume-conf', isXmlFile: false}
  1346. ], log4j: []}
  1347. };
  1348. if (App.supports.capacitySchedulerUi) {
  1349. objMap['MAPREDUCE'].site.pushObjects([
  1350. {filename: 'capacity-scheduler', isXmlFile: true},
  1351. {filename: 'mapred-queue-acls', isXmlFile: true}
  1352. ]);
  1353. }
  1354. for (var serviceName in objMap) {
  1355. if (objMap.hasOwnProperty(serviceName)) {
  1356. if (selectedServices.someProperty('serviceName', serviceName)) {
  1357. objMap[serviceName].site.forEach(function (site) {
  1358. self.get('serviceConfigTags').pushObject(self.createSiteObj(site.filename, !site.isXmlFile, tag));
  1359. });
  1360. objMap[serviceName].log4j.forEach(function (log4j) {
  1361. self.get('serviceConfigTags').pushObject(self.createLog4jObj(log4j, tag));
  1362. });
  1363. }
  1364. }
  1365. }
  1366. if (selectedServices.someProperty('serviceName', 'STORM')) {
  1367. this.get('serviceConfigTags').pushObject(this.createStormSiteObj(tag));
  1368. }
  1369. if (selectedServices.someProperty('serviceName', 'ZOOKEEPER')) {
  1370. this.get('serviceConfigTags').pushObject(this.createZooCfgObj(tag));
  1371. }
  1372. },
  1373. /**
  1374. * Send <code>serviceConfigTags</code> to server
  1375. * Queued request
  1376. * One request for each service config tag
  1377. * @method applyConfigurationsToCluster
  1378. */
  1379. applyConfigurationsToCluster: function () {
  1380. var configData = this.get('serviceConfigTags').map(function (_serviceConfig) {
  1381. return JSON.stringify({
  1382. Clusters: {
  1383. desired_config: {
  1384. type: _serviceConfig.type,
  1385. tag: _serviceConfig.tag,
  1386. properties: _serviceConfig.properties
  1387. }
  1388. }
  1389. });
  1390. }, this).toString();
  1391. this.addRequestToAjaxQueue({
  1392. name: 'wizard.step8.apply_configuration_to_cluster',
  1393. data: {
  1394. data: '[' + configData + ']'
  1395. }
  1396. });
  1397. },
  1398. /**
  1399. * Create and update config groups
  1400. * @method createConfigurationGroups
  1401. */
  1402. createConfigurationGroups: function () {
  1403. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1404. var clusterName = this.get('clusterName');
  1405. var sendData = [];
  1406. var updateData = [];
  1407. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1408. var timeTag = (new Date).getTime();
  1409. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1410. if (groupsToDelete && groupsToDelete.length > 0) {
  1411. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1412. }
  1413. configGroups.forEach(function (configGroup) {
  1414. var groupConfigs = [];
  1415. var groupData = {
  1416. "cluster_name": clusterName,
  1417. "group_name": configGroup.name,
  1418. "tag": configGroup.service.id,
  1419. "description": configGroup.description,
  1420. "hosts": [],
  1421. "desired_configs": []
  1422. };
  1423. configGroup.hosts.forEach(function (hostName) {
  1424. groupData.hosts.push({"host_name": hostName});
  1425. });
  1426. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1427. configGroup.properties.forEach(function (property) {
  1428. groupConfigs.push(Em.Object.create(property));
  1429. });
  1430. groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
  1431. // check for group from installed service
  1432. if (configGroup.isForUpdate === true) {
  1433. // if group is a new one, create it
  1434. if (!configGroup.id) {
  1435. sendData.push({"ConfigGroup": groupData});
  1436. } else {
  1437. // update an existing group
  1438. groupData.id = configGroup.id;
  1439. updateData.push({"ConfigGroup": groupData});
  1440. }
  1441. } else {
  1442. sendData.push({"ConfigGroup": groupData});
  1443. }
  1444. //each group should have unique tag to prevent overriding configs from common sites
  1445. timeTag++;
  1446. }, this);
  1447. if (sendData.length > 0) {
  1448. this.applyConfigurationGroups(sendData);
  1449. }
  1450. if (updateData.length > 0) {
  1451. this.applyInstalledServicesConfigurationGroup(updateData);
  1452. }
  1453. },
  1454. /**
  1455. * Create new config groups request
  1456. * Queued request
  1457. * @param {Object[]} sendData
  1458. * @method applyConfigurationGroups
  1459. */
  1460. applyConfigurationGroups: function (sendData) {
  1461. this.addRequestToAjaxQueue({
  1462. name: 'wizard.step8.apply_configuration_groups',
  1463. data: {
  1464. data: JSON.stringify(sendData)
  1465. }
  1466. });
  1467. },
  1468. /**
  1469. * Update existed config groups
  1470. * Separated request for each group
  1471. * @param {Object[]} updateData
  1472. * @method applyInstalledServicesConfigurationGroup
  1473. */
  1474. applyInstalledServicesConfigurationGroup: function (updateData) {
  1475. updateData.forEach(function (item) {
  1476. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1477. });
  1478. },
  1479. /**
  1480. * Delete selected config groups
  1481. * @param {Object[]} groupsToDelete
  1482. * @method removeInstalledServicesConfigurationGroups
  1483. */
  1484. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1485. groupsToDelete.forEach(function (item) {
  1486. App.config.deleteConfigGroup(Em.Object.create(item));
  1487. });
  1488. },
  1489. /**
  1490. * Create Global Site object
  1491. * @returns {{type: string, tag: string, properties: {}}}
  1492. * @method createGlobalSiteObj
  1493. */
  1494. createGlobalSiteObj: function (tag) {
  1495. var globalSiteProperties = {};
  1496. var globalSiteObj = this.get('globals');
  1497. var isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1498. // screen out the GLUSTERFS-specific global config entries when they are not required
  1499. if (!isGLUSTERFSSelected) {
  1500. globalSiteObj = globalSiteObj.filter(function (_config) {
  1501. return !_config.name.contains("fs_glusterfs");
  1502. });
  1503. }
  1504. globalSiteObj.forEach(function (globalConfig) {
  1505. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize'];
  1506. // do not pass any globals whose name ends with _host or _hosts
  1507. if (globalConfig.isRequiredByAgent !== false) {
  1508. // append "m" to JVM memory options except for heapsizeExtensions
  1509. if (/_heapsize|_newsize|_maxnewsize$/.test(globalConfig.name) && !heapsizeExceptions.contains(globalConfig.name)) {
  1510. globalSiteProperties[globalConfig.name] = globalConfig.value + "m";
  1511. } else {
  1512. globalSiteProperties[globalConfig.name] = App.config.escapeXMLCharacters(globalConfig.value);
  1513. }
  1514. }
  1515. }, this);
  1516. // we don't expose gmond_user to the user; it needs to be the same as gmetad_user
  1517. globalSiteProperties['gmond_user'] = globalSiteProperties['gmetad_user'];
  1518. return {"type": "global", "tag": tag, "properties": globalSiteProperties};
  1519. },
  1520. /**
  1521. * Create Core Site object
  1522. * @returns {{type: string, tag: string, properties: {}}}
  1523. * @method createCoreSiteObj
  1524. */
  1525. createCoreSiteObj: function () {
  1526. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1527. coreSiteProperties = {},
  1528. // some configs needs to be skipped if services are not selected
  1529. isOozieSelected = this.get('selectedServices').someProperty('serviceName', 'OOZIE'),
  1530. oozieUser = this.get('globals').someProperty('name', 'oozie_user') ? this.get('globals').findProperty('name', 'oozie_user').value : null,
  1531. isHiveSelected = this.get('selectedServices').someProperty('serviceName', 'HIVE'),
  1532. hiveUser = this.get('globals').someProperty('name', 'hive_user') ? this.get('globals').findProperty('name', 'hive_user').value : null,
  1533. isHcatSelected = this.get('selectedServices').someProperty('serviceName', 'WEBHCAT'),
  1534. hcatUser = this.get('globals').someProperty('name', 'hcat_user') ? this.get('globals').findProperty('name', 'hcat_user').value : null,
  1535. isGLUSTERFSSelected = this.get('selectedServices').someProperty('serviceName', 'GLUSTERFS');
  1536. // screen out the GLUSTERFS-specific core-site.xml entries when they are not needed
  1537. if (!isGLUSTERFSSelected) {
  1538. coreSiteObj = coreSiteObj.filter(function (_config) {
  1539. return !_config.name.contains("fs.glusterfs");
  1540. });
  1541. }
  1542. coreSiteObj.forEach(function (_coreSiteObj) {
  1543. // exclude some configs if service wasn't selected
  1544. if (
  1545. (isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) &&
  1546. (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) &&
  1547. (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
  1548. coreSiteProperties[_coreSiteObj.name] = App.config.escapeXMLCharacters(_coreSiteObj.value);
  1549. }
  1550. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1551. coreSiteProperties[_coreSiteObj.name] =
  1552. this.get('globals').someProperty('name', 'fs_glusterfs_default_name') ?
  1553. App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'fs_glusterfs_default_name').value) : null;
  1554. }
  1555. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1556. coreSiteProperties[_coreSiteObj.name] =
  1557. this.get('globals').someProperty('name', 'glusterfs_defaultFS_name') ?
  1558. App.config.escapeXMLCharacters(this.get('globals').findProperty('name', 'glusterfs_defaultFS_name').value) : null;
  1559. }
  1560. }, this);
  1561. return {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1562. },
  1563. /**
  1564. * Create siteObj for custom service with it own configs
  1565. * @param {string} site
  1566. * @param {bool} isNonXmlFile
  1567. * @param tag
  1568. * @returns {{type: string, tag: string, properties: {}}}
  1569. * @method createSiteObj
  1570. */
  1571. createSiteObj: function (site, isNonXmlFile, tag) {
  1572. var properties = {};
  1573. if (!!isNonXmlFile) {
  1574. this.get('configs').filterProperty('filename', site + '.xml').forEach(function (_configProperty) {
  1575. properties[_configProperty.name] = _configProperty.value;
  1576. }, this);
  1577. } else {
  1578. this.get('configs').filterProperty('filename', site + '.xml').forEach(function (_configProperty) {
  1579. properties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1580. }, this);
  1581. }
  1582. return {"type": site, "tag": tag, "properties": properties };
  1583. },
  1584. /**
  1585. * Create log4j object for custom service with it own configs
  1586. * @param {string} site
  1587. * @param {string} tag
  1588. * @returns {{type: string, tag: string, properties: {}}}
  1589. * @method createLog4jObj
  1590. */
  1591. createLog4jObj: function (site, tag) {
  1592. return this.createSiteObj(site + '-log4j', true, tag);
  1593. },
  1594. /**
  1595. * Create ZooKeeper Cfg Object
  1596. * @param tag
  1597. * @returns {{type: string, tag: string, properties: {}}}
  1598. * @method createZooCfgObj
  1599. */
  1600. createZooCfgObj: function (tag) {
  1601. var configs = this.get('configs').filterProperty('filename', 'zoo.cfg');
  1602. var csProperties = {};
  1603. configs.forEach(function (_configProperty) {
  1604. csProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1605. }, this);
  1606. return {type: 'zoo.cfg', tag: tag, properties: csProperties};
  1607. },
  1608. /**
  1609. * Create site obj for Storm
  1610. * Some config-properties should be modified in custom way
  1611. * @param tag
  1612. * @returns {{type: string, tag: string, properties: {}}}
  1613. * @method createStormSiteObj
  1614. */
  1615. createStormSiteObj: function (tag) {
  1616. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1617. var stormProperties = {};
  1618. var specialProperties = ["storm.zookeeper.servers", "nimbus.childopts", "supervisor.childopts", "worker.childopts"];
  1619. configs.forEach(function (_configProperty) {
  1620. if (specialProperties.contains(_configProperty.name)) {
  1621. if (_configProperty.name == "storm.zookeeper.servers") {
  1622. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1623. } else {
  1624. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "");
  1625. }
  1626. } else {
  1627. stormProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
  1628. }
  1629. }, this);
  1630. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1631. },
  1632. /**
  1633. * Navigate to next step after all requests are sent
  1634. * @method ajaxQueueFinished
  1635. */
  1636. ajaxQueueFinished: function () {
  1637. console.log('everything is loaded');
  1638. App.router.send('next');
  1639. },
  1640. /**
  1641. * We need to do a lot of ajax calls async in special order. To do this,
  1642. * generate array of ajax objects and then send requests step by step. All
  1643. * ajax objects are stored in <code>ajaxRequestsQueue</code>
  1644. *
  1645. * @param {Object} params object with ajax-request parameters like url, type, data etc
  1646. * @method addRequestToAjaxQueue
  1647. */
  1648. addRequestToAjaxQueue: function (params) {
  1649. if (App.get('testMode')) return;
  1650. params = jQuery.extend({
  1651. sender: this,
  1652. error: 'ajaxQueueRequestErrorCallback'
  1653. }, params);
  1654. params.data['cluster'] = this.get('clusterName');
  1655. this.get('ajaxRequestsQueue').addRequest(params);
  1656. },
  1657. /**
  1658. * Error callback for each queued ajax-request
  1659. * @param {object} xhr
  1660. * @param {string} status
  1661. * @param {string} error
  1662. * @method ajaxQueueRequestErrorCallback
  1663. */
  1664. ajaxQueueRequestErrorCallback: function (xhr, status, error) {
  1665. var responseText = JSON.parse(xhr.responseText);
  1666. var controller = App.router.get(App.clusterStatus.wizardControllerName);
  1667. controller.registerErrPopup(Em.I18n.t('common.error'), responseText.message);
  1668. this.set('hasErrorOccurred', true);
  1669. // an error will break the ajax call chain and allow submission again
  1670. this.set('isSubmitDisabled', false);
  1671. this.set('isBackBtnDisabled', false);
  1672. App.router.get(this.get('content.controllerName')).setStepsEnable();
  1673. }
  1674. });