step8_controller.js 64 KB

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