step8_controller.js 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907
  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. var dataManipulationUtils = require('utils/data_manipulation');
  21. App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wizardDeployProgressControllerMixin, App.ConfigOverridable, {
  22. name: 'wizardStep8Controller',
  23. /**
  24. * List of raw data about cluster that should be displayed
  25. * @type {Array}
  26. */
  27. rawContent: [
  28. {
  29. config_name: 'Admin',
  30. display_name: 'Admin Name',
  31. config_value: ''
  32. },
  33. {
  34. config_name: 'cluster',
  35. display_name: 'Cluster Name',
  36. config_value: ''
  37. },
  38. {
  39. config_name: 'hosts',
  40. display_name: 'Total Hosts',
  41. config_value: ''
  42. },
  43. {
  44. config_name: 'Repo',
  45. display_name: 'Local Repository',
  46. config_value: ''
  47. }
  48. ],
  49. /**
  50. * List of data about cluster (based on formatted <code>rawContent</code>)
  51. * @type {Object[]}
  52. */
  53. clusterInfo: [],
  54. /**
  55. * List of services with components assigned to hosts
  56. * @type {Object[]}
  57. */
  58. services: [],
  59. /**
  60. * @type {Object[]}
  61. */
  62. configs: [],
  63. /**
  64. * True if Kerberos is installed on the cluster and the kdc_type on the server is set to "none"
  65. * @type {Boolean}
  66. */
  67. isManualKerberos: function () {
  68. return App.get('router.mainAdminKerberosController.kdc_type') === 'none';
  69. }.property('App.router.mainAdminKerberosController.kdc_type'),
  70. /**
  71. * All configs
  72. * @type {Array}
  73. */
  74. configMapping: function () {
  75. return App.config.get('configMapping').all(true);
  76. }.property('App.config.configMapping'),
  77. /**
  78. *
  79. */
  80. slaveComponentConfig: null,
  81. /**
  82. * Should Submit button be disabled
  83. * @type {bool}
  84. */
  85. isSubmitDisabled: false,
  86. /**
  87. * Should Back button be disabled
  88. * @type {bool}
  89. */
  90. isBackBtnDisabled: false,
  91. /**
  92. * Is error appears while <code>ajaxQueue</code> executes
  93. * @type {bool}
  94. */
  95. hasErrorOccurred: false,
  96. /**
  97. * Are services installed
  98. * Used to hide Deploy Progress Bar
  99. * @type {bool}
  100. */
  101. servicesInstalled: false,
  102. /**
  103. * List of service config tags
  104. * @type {Object[]}
  105. */
  106. serviceConfigTags: [],
  107. /**
  108. * Selected config group
  109. * @type {Object}
  110. */
  111. selectedConfigGroup: null,
  112. /**
  113. * List of config groups
  114. * @type {Object[]}
  115. */
  116. configGroups: [],
  117. /**
  118. * List of selected but not installed services
  119. * @type {Object[]}
  120. */
  121. selectedServices: function () {
  122. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false);
  123. }.property('content.services.@each.isSelected','content.services.@each.isInstalled').cacheable(),
  124. /**
  125. * List of installed services
  126. * @type {Object[]}
  127. */
  128. installedServices: function () {
  129. return this.get('content.services').filterProperty('isInstalled');
  130. }.property('content.services').cacheable(),
  131. /**
  132. * Current cluster name
  133. * @type {string}
  134. */
  135. clusterName: function () {
  136. return this.get('content.cluster.name');
  137. }.property('content.cluster.name'),
  138. /**
  139. * List of existing cluster names
  140. * @type {string[]}
  141. */
  142. clusterNames: [],
  143. /**
  144. * Number of completed cluster delete requests
  145. * @type {number}
  146. */
  147. clusterDeleteRequestsCompleted: 0,
  148. /**
  149. * Indicates if all cluster delete requests are completed
  150. * @type {boolean}
  151. */
  152. isAllClusterDeleteRequestsCompleted: function () {
  153. return this.get('clusterDeleteRequestsCompleted') == this.get('clusterNames.length');
  154. }.property('clusterDeleteRequestsCompleted'),
  155. /**
  156. * Error popup body views for clusters that couldn't be deleted
  157. * @type {App.AjaxDefaultErrorPopupBodyView[]}
  158. */
  159. clusterDeleteErrorViews: [],
  160. /**
  161. * Clear current step data
  162. * @method clearStep
  163. */
  164. clearStep: function () {
  165. this.get('services').clear();
  166. this.get('configs').clear();
  167. this.get('clusterInfo').clear();
  168. this.get('serviceConfigTags').clear();
  169. this.set('servicesInstalled', false);
  170. this.set('ajaxQueueLength', 0);
  171. this.set('ajaxRequestsQueue', App.ajaxQueue.create());
  172. this.set('ajaxRequestsQueue.finishedCallback', this.ajaxQueueFinished);
  173. this.get('clusterDeleteErrorViews').clear();
  174. this.set('clusterDeleteRequestsCompleted', 0);
  175. },
  176. /**
  177. * Load current step data
  178. * @method loadStep
  179. */
  180. loadStep: function () {
  181. console.log("TRACE: Loading step8: Review Page");
  182. this.clearStep();
  183. if (this.get('content.serviceConfigProperties')) {
  184. this.formatProperties();
  185. this.loadConfigs();
  186. }
  187. this.loadClusterInfo();
  188. this.loadServices();
  189. this.set('isSubmitDisabled', false);
  190. this.set('isBackBtnDisabled', false);
  191. },
  192. /**
  193. * replace whitespace character with coma between directories
  194. * @method formatProperties
  195. */
  196. formatProperties: function () {
  197. this.get('content.serviceConfigProperties').forEach(function (_configProperty) {
  198. _configProperty.value = App.config.trimProperty(_configProperty, false);
  199. });
  200. },
  201. /**
  202. * Remove unused Hive configs
  203. * @param {Ember.Enumerable} configs
  204. * @returns {Ember.Enumerable}
  205. * @method removeHiveConfigs
  206. */
  207. removeHiveConfigs: function (configs) {
  208. var hiveDb = configs.findProperty('name', 'hive_database');
  209. var hiveDbType = configs.findProperty('name', 'hive_database_type');
  210. if (hiveDbType) {
  211. var hive_properties = Em.A([]);
  212. switch (hiveDb.value) {
  213. case 'New MySQL Database':
  214. if (configs.someProperty('name', 'hive_ambari_host')) {
  215. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  216. }
  217. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  218. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  219. break;
  220. case 'New PostgreSQL Database':
  221. if (configs.someProperty('name', 'hive_ambari_host')) {
  222. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_ambari_host').value;
  223. }
  224. hive_properties = Em.A(['hive_existing_mysql_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database']);
  225. break;
  226. case 'Existing MySQL Database':
  227. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mysql_host').value;
  228. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  229. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  230. break;
  231. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  232. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_postgresql_host').value;
  233. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_mysql_database',
  234. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  235. break;
  236. case 'Existing MSSQL Server database with SQL authentication':
  237. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_host').value;
  238. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  239. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_database']);
  240. break;
  241. case 'Existing MSSQL Server database with integrated authentication':
  242. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_mssql_server_2_host').value;
  243. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_oracle_database', 'hive_existing_postgresql_database',
  244. 'hive_existing_mysql_database', 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  245. break;
  246. default:
  247. configs.findProperty('name', 'hive_hostname').value = configs.findProperty('name', 'hive_existing_oracle_host').value;
  248. hive_properties = Em.A(['hive_ambari_database', 'hive_existing_mysql_database', 'hive_existing_postgresql_database',
  249. 'hive_existing_mssql_server_database', 'hive_existing_mssql_server_2_database']);
  250. break;
  251. }
  252. hive_properties.push('hive_master_hosts');
  253. configs = dataManipulationUtils.rejectPropertyValues(configs, 'name', hive_properties);
  254. }
  255. return configs;
  256. },
  257. /**
  258. * Remove unused Oozie configs
  259. * @param {Ember.Enumerable} configs
  260. * @returns {Ember.Enumerable}
  261. * @method removeOozieConfigs
  262. */
  263. removeOozieConfigs: function (configs) {
  264. var oozieDb = configs.findProperty('name', 'oozie_database');
  265. if (oozieDb) {
  266. var oozie_properties = Em.A(['oozie_ambari_database']);
  267. switch (oozieDb.value) {
  268. case 'New Derby Database':
  269. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_ambari_host').value;
  270. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_existing_oracle_database',
  271. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  272. break;
  273. case 'Existing MySQL Database':
  274. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mysql_host').value;
  275. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_derby_database',
  276. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  277. break;
  278. case Em.I18n.t('services.service.config.hive.oozie.postgresql'):
  279. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_postgresql_host').value;
  280. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_oracle_database', 'oozie_existing_mysql_database',
  281. 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  282. break;
  283. case 'Existing MSSQL Server database with SQL authentication':
  284. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mssql_server_host').value;
  285. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  286. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  287. break;
  288. case 'Existing MSSQL Server database with integrated authentication':
  289. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_mssql_server_2_host').value;
  290. oozie_properties = Em.A(['oozie_existing_oracle_database', 'oozie_existing_postgresql_database',
  291. 'oozie_existing_mysql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_database']);
  292. break;
  293. default:
  294. configs.findProperty('name', 'oozie_hostname').value = configs.findProperty('name', 'oozie_existing_oracle_host').value;
  295. oozie_properties = Em.A(['oozie_ambari_database', 'oozie_existing_mysql_database', 'oozie_derby_database',
  296. 'oozie_existing_postgresql_database', 'oozie_existing_mssql_server_database', 'oozie_existing_mssql_server_2_database']);
  297. break;
  298. }
  299. configs = dataManipulationUtils.rejectPropertyValues(configs, 'name', oozie_properties);
  300. }
  301. return configs;
  302. },
  303. /**
  304. * Load all site properties
  305. * @method loadConfigs
  306. */
  307. loadConfigs: function () {
  308. //storedConfigs contains custom configs as well
  309. var configs = this.get('content.serviceConfigProperties');
  310. if (configs.someProperty('name', 'hive_database')) {
  311. configs = this.removeHiveConfigs(configs);
  312. }
  313. if (configs.someProperty('name', 'oozie_database')) {
  314. configs = this.removeOozieConfigs(configs);
  315. }
  316. configs.forEach(function (_config) {
  317. _config.value = (typeof _config.value === "boolean") ? _config.value.toString() : _config.value;
  318. });
  319. var mappedConfigs = App.config.excludeUnsupportedConfigs(this.get('configMapping'), this.get('selectedServices').mapProperty('serviceName'));
  320. var uiConfigs = this.loadUiSideConfigs(mappedConfigs);
  321. var customGroupConfigs = [];
  322. var allConfigs = configs.concat(uiConfigs).filter(function (config) {
  323. if (config.group) {
  324. customGroupConfigs.push(config);
  325. return false;
  326. } else {
  327. return true;
  328. }
  329. });
  330. this.set('customNonDefaultGroupConfigs', customGroupConfigs);
  331. this.set('configs', allConfigs);
  332. },
  333. /**
  334. * Load UI configs
  335. * @param {Array} configMapping
  336. * @return {Array}
  337. * @method loadUiSideConfigs
  338. */
  339. loadUiSideConfigs: function (configMapping) {
  340. var uiConfig = [];
  341. var dependentConfig = $.extend(true, [], configMapping.filterProperty('foreignKey'));
  342. dependentConfig.forEach(function (_config) {
  343. App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config);
  344. // generated config name using template for example `hadoop.proxyuser.hive.hosts`
  345. var configName = _config._name || _config.name;
  346. // property from <code>content.serviceConfigProperties</code>. This property can be added in custom-site.xml
  347. // with the same name as propety from defined config mapping. In this case property from config mapping
  348. // object should be ignored.
  349. var isPropertyDefined = this.get('content.serviceConfigProperties')
  350. .filterProperty('filename', _config.filename).someProperty('name', configName);
  351. // ignore config mapping property if no matches for template was found or property already added by user
  352. if(!_config.noMatchSoSkipThisConfig && !isPropertyDefined) {
  353. uiConfig.pushObject({
  354. "id": "site property",
  355. "name": configName,
  356. "value": _config.value,
  357. "filename": _config.filename
  358. });
  359. }
  360. }, this);
  361. return uiConfig;
  362. },
  363. /**
  364. * Format <code>content.hosts</code> from Object to Array
  365. * @returns {Array}
  366. * @method getRegisteredHosts
  367. */
  368. getRegisteredHosts: function () {
  369. var allHosts = this.get('content.hosts');
  370. var hosts = [];
  371. for (var hostName in allHosts) {
  372. if (allHosts.hasOwnProperty(hostName)) {
  373. if (allHosts[hostName].bootStatus == 'REGISTERED') {
  374. allHosts[hostName].hostName = allHosts[hostName].name;
  375. hosts.pushObject(allHosts[hostName]);
  376. }
  377. }
  378. }
  379. return hosts;
  380. },
  381. /**
  382. * Load all info about cluster to <code>clusterInfo</code> variable
  383. * @method loadClusterInfo
  384. */
  385. loadClusterInfo: function () {
  386. //Admin name
  387. var admin = this.rawContent.findProperty('config_name', 'Admin');
  388. admin.config_value = App.db.getLoginName();
  389. console.log("STEP8: the value of content cluster name: " + App.db.getLoginName());
  390. if (admin.config_value) {
  391. this.get('clusterInfo').pushObject(Ember.Object.create(admin));
  392. }
  393. // cluster name
  394. var cluster = this.rawContent.findProperty('config_name', 'cluster');
  395. cluster.config_value = this.get('content.cluster.name');
  396. console.log("STEP8: the value of content cluster name: " + this.get('content.cluster.name'));
  397. this.get('clusterInfo').pushObject(Ember.Object.create(cluster));
  398. //hosts
  399. var newHostsCount = 0;
  400. var totalHostsCount = 0;
  401. var hosts = this.get('content.hosts');
  402. for (var hostName in hosts) {
  403. newHostsCount += ~~(!hosts[hostName].isInstalled);
  404. totalHostsCount++;
  405. }
  406. var totalHostsObj = this.rawContent.findProperty('config_name', 'hosts');
  407. totalHostsObj.config_value = totalHostsCount + ' (' + newHostsCount + ' new)';
  408. this.get('clusterInfo').pushObject(Em.Object.create(totalHostsObj));
  409. //repo
  410. if (['addHostController', 'addServiceController'].contains(this.get('content.controllerName'))) {
  411. this.loadRepoInfo();
  412. } else {
  413. // from install wizard
  414. var selectedStack = App.Stack.find().findProperty('isSelected');
  415. var allRepos = [];
  416. if (selectedStack && selectedStack.get('operatingSystems')) {
  417. selectedStack.get('operatingSystems').forEach(function (os) {
  418. if (os.get('isSelected')) {
  419. os.get('repositories').forEach(function(repo) {
  420. allRepos.push(Em.Object.create({
  421. base_url: repo.get('baseUrl'),
  422. os_type: repo.get('osType'),
  423. repo_id: repo.get('repoId')
  424. }));
  425. }, this);
  426. }
  427. }, this);
  428. }
  429. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  430. this.get('clusterInfo').set('repoInfo', allRepos);
  431. }
  432. },
  433. /**
  434. * Load repo info for add Service/Host wizard review page
  435. * @return {$.ajax|null}
  436. * @method loadRepoInfo
  437. */
  438. loadRepoInfo: function () {
  439. var currentRepoVersion = App.StackVersion.find().findProperty('state', 'CURRENT').get('repositoryVersion.repositoryVersion');
  440. var stackName = App.get('currentStackName');
  441. return App.ajax.send({
  442. name: 'cluster.load_repo_version',
  443. sender: this,
  444. data: {
  445. stackName: stackName,
  446. repositoryVersion: currentRepoVersion
  447. },
  448. success: 'loadRepoInfoSuccessCallback',
  449. error: 'loadRepoInfoErrorCallback'
  450. });
  451. },
  452. /**
  453. * Save all repo base URL of all OS type to <code>repoInfo<code>
  454. * @param {object} data
  455. * @method loadRepoInfoSuccessCallback
  456. */
  457. loadRepoInfoSuccessCallback: function (data) {
  458. var allRepos = [];
  459. Em.assert('Current repo-version may be only one', data.items.length === 1);
  460. data.items[0].repository_versions[0].operating_systems.forEach(function (os) {
  461. os.repositories.forEach(function (repository) {
  462. allRepos.push(Em.Object.create({
  463. base_url: repository.Repositories.base_url,
  464. os_type: repository.Repositories.os_type,
  465. repo_id: repository.Repositories.repo_id
  466. }));
  467. });
  468. });
  469. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  470. this.get('clusterInfo').set('repoInfo', allRepos);
  471. },
  472. /**
  473. * @param {object} request
  474. * @method loadRepoInfoErrorCallback
  475. */
  476. loadRepoInfoErrorCallback: function (request) {
  477. console.log('Error message is: ' + request.responseText);
  478. var allRepos = [];
  479. allRepos.set('display_name', Em.I18n.t("installer.step8.repoInfo.displayName"));
  480. this.get('clusterInfo').set('repoInfo', allRepos);
  481. },
  482. /**
  483. * Load all info about services to <code>services</code> variable
  484. * @method loadServices
  485. */
  486. loadServices: function () {
  487. this.get('selectedServices').filterProperty('isHiddenOnSelectServicePage', false).forEach(function (service) {
  488. console.log('INFO: step8: Name of the service from getService function: ' + service.get('serviceName'));
  489. var serviceObj = Em.Object.create({
  490. service_name: service.get('serviceName'),
  491. display_name: service.get('displayNameOnSelectServicePage'),
  492. service_components: Em.A([])
  493. });
  494. service.get('serviceComponents').forEach(function (component) {
  495. // show clients for services that have only clients components
  496. if ((component.get('isClient') || component.get('isRequiredOnAllHosts')) && !service.get('isClientOnlyService')) return;
  497. // skip components that was hide on assign master page
  498. if (component.get('isMaster') && !component.get('isShownOnInstallerAssignMasterPage')) return;
  499. // no HA component
  500. if (component.get('isHAComponentOnly')) return;
  501. var displayName;
  502. if (component.get('isClient')) {
  503. displayName = Em.I18n.t('common.clients')
  504. } else {
  505. // remove service name from component display name
  506. displayName = App.format.role(component.get('componentName')).replace(new RegExp('^' + service.get('serviceName') + '\\s', 'i'), '');
  507. }
  508. serviceObj.get('service_components').pushObject(Em.Object.create({
  509. component_name: component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName'),
  510. display_name: displayName,
  511. component_value: this.assignComponentHosts(component)
  512. }));
  513. }, this);
  514. if (service.get('customReviewHandler')) {
  515. for (var displayName in service.get('customReviewHandler')) {
  516. serviceObj.get('service_components').pushObject(Em.Object.create({
  517. display_name: displayName,
  518. component_value: this.assignComponentHosts(Em.Object.create({
  519. customHandler: service.get('customReviewHandler.' + displayName)
  520. }))
  521. }));
  522. }
  523. }
  524. this.get('services').pushObject(serviceObj);
  525. }, this);
  526. },
  527. /**
  528. * Set <code>component_value</code> property to <code>component</code>
  529. * @param {Em.Object} component
  530. * @return {String}
  531. * @method assignComponentHosts
  532. */
  533. assignComponentHosts: function (component) {
  534. var componentValue;
  535. if (component.get('customHandler')) {
  536. componentValue = this[component.get('customHandler')].call(this, component);
  537. }
  538. else {
  539. if (component.get('isMaster')) {
  540. componentValue = this.getMasterComponentValue(component.get('componentName'));
  541. }
  542. else {
  543. console.log(' --- ---INFO: step8: NOT component isMaster');
  544. var componentName = component.get('isClient') ? Em.I18n.t('common.client').toUpperCase() : component.get('componentName');
  545. var hostsLength = this.get('content.slaveComponentHosts')
  546. .findProperty('componentName', componentName).hosts.length;
  547. componentValue = hostsLength + Em.I18n.t('installer.step8.host' + ((hostsLength > 1) ? 's' : ''));
  548. }
  549. }
  550. return componentValue;
  551. },
  552. getMasterComponentValue: function (componentName) {
  553. var masterComponents = this.get('content.masterComponentHosts');
  554. var hostsCount = masterComponents.filterProperty('component', componentName).length;
  555. return stringUtils.pluralize(hostsCount,
  556. masterComponents.findProperty('component', componentName).hostName,
  557. hostsCount + ' ' + Em.I18n.t('installer.step8.hosts'));
  558. },
  559. /**
  560. * Set displayed Hive DB value based on DB type
  561. * @method loadHiveDbValue
  562. */
  563. loadHiveDbValue: function () {
  564. var db, serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties'),
  565. hiveDb = serviceConfigProperties.findProperty('name', 'hive_database');
  566. if (hiveDb.value === 'New MySQL Database') {
  567. return 'MySQL (New Database)';
  568. } else if (hiveDb.value === 'New PostgreSQL Database') {
  569. return 'Postgres (New Database)';
  570. }
  571. else {
  572. if (hiveDb.value === 'Existing MySQL Database') {
  573. db = serviceConfigProperties.findProperty('name', 'hive_existing_mysql_database');
  574. return db.value + ' (' + hiveDb.value + ')';
  575. }
  576. else {
  577. if (hiveDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  578. db = serviceConfigProperties.findProperty('name', 'hive_existing_postgresql_database');
  579. return db.value + ' (' + hiveDb.value + ')';
  580. }
  581. else {
  582. if (hiveDb.value === 'Existing MSSQL Server database with SQL authentication') {
  583. db = serviceConfigProperties.findProperty('name', 'hive_existing_mssql_server_database');
  584. return db.value + ' (' + hiveDb.value + ')';
  585. }
  586. else {
  587. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  588. db = serviceConfigProperties.findProperty('name', 'hive_existing_mssql_server_2_database');
  589. return db.value + ' (' + hiveDb.value + ')';
  590. }
  591. else {
  592. // existing oracle database
  593. db = serviceConfigProperties.findProperty('name', 'hive_existing_oracle_database');
  594. return db.value + ' (' + hiveDb.value + ')';
  595. }
  596. }
  597. }
  598. }
  599. }
  600. },
  601. /**
  602. * Set displayed HBase master value
  603. * @param {Object} hbaseMaster
  604. * @method loadHbaseMasterValue
  605. */
  606. loadHbaseMasterValue: function (hbaseMaster) {
  607. var hbaseHostName = this.get('content.masterComponentHosts').filterProperty('component', hbaseMaster.component_name);
  608. if (hbaseHostName.length == 1) {
  609. hbaseMaster.set('component_value', hbaseHostName[0].hostName);
  610. } else {
  611. hbaseMaster.set('component_value', hbaseHostName[0].hostName + " " + Em.I18n.t('installer.step8.other').format(hbaseHostName.length - 1));
  612. }
  613. },
  614. /**
  615. * Set displayed ZooKeeper Server value
  616. * @param {Object} serverComponent
  617. * @method loadZkServerValue
  618. */
  619. loadZkServerValue: function (serverComponent) {
  620. var zkHostNames = this.get('content.masterComponentHosts').filterProperty('component', serverComponent.component_name).length;
  621. var hostSuffix;
  622. if (zkHostNames === 1) {
  623. hostSuffix = Em.I18n.t('installer.step8.host');
  624. } else {
  625. hostSuffix = Em.I18n.t('installer.step8.hosts');
  626. }
  627. serverComponent.set('component_value', zkHostNames + hostSuffix);
  628. },
  629. /**
  630. * Set displayed Oozie DB value based on DB type
  631. * @method loadOozieDbValue
  632. */
  633. loadOozieDbValue: function () {
  634. var db, oozieDb = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_database');
  635. if (oozieDb.value === 'New Derby Database') {
  636. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_derby_database');
  637. return db.value + ' (' + oozieDb.value + ')';
  638. }
  639. else {
  640. if (oozieDb.value === 'Existing MySQL Database') {
  641. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mysql_database');
  642. return db.value + ' (' + oozieDb.value + ')';
  643. }
  644. else {
  645. if (oozieDb.value === Em.I18n.t('services.service.config.hive.oozie.postgresql')) {
  646. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_postgresql_database');
  647. return db.value + ' (' + oozieDb.value + ')';
  648. }
  649. else {
  650. if (oozieDb.value === 'Existing MSSQL Server database with SQL authentication') {
  651. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_database');
  652. return db.value + ' (' + oozieDb.value + ')';
  653. }
  654. else {
  655. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  656. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_mssql_server_2_database');
  657. return db.value + ' (' + oozieDb.value + ')';
  658. }
  659. else {
  660. // existing oracle database
  661. db = this.get('wizardController').getDBProperty('serviceConfigProperties').findProperty('name', 'oozie_existing_oracle_database');
  662. return db.value + ' (' + oozieDb.value + ')';
  663. }
  664. }
  665. }
  666. }
  667. }
  668. },
  669. /**
  670. * Onclick handler for <code>next</code> button
  671. * @method submit
  672. * @return {void}
  673. */
  674. submit: function () {
  675. var self = this;
  676. var wizardController;
  677. if (!this.get('isSubmitDisabled')) {
  678. wizardController = App.router.get(this.get('content.controllerName'));
  679. this.set('isSubmitDisabled', true);
  680. this.set('isBackBtnDisabled', true);
  681. wizardController.setLowerStepsDisable(wizardController.get('currentStep'));
  682. if (this.get('content.controllerName') != 'installerController' && App.get('isKerberosEnabled') && !this.get('isManualKerberos')) {
  683. App.get('router.mainAdminKerberosController').getKDCSessionState(this.submitProceed.bind(this), function () {
  684. self.set('isSubmitDisabled', false);
  685. self.set('isBackBtnDisabled', false);
  686. wizardController.setStepsEnable();
  687. if (self.get('content.controllerName') === 'addServiceController') {
  688. wizardController.setSkipSlavesStep(wizardController.getDBProperty('selectedServiceNames'), 3);
  689. }
  690. });
  691. } else {
  692. this.submitProceed();
  693. }
  694. }
  695. },
  696. /**
  697. * Update configurations for installed services.
  698. * Do separated PUT-request for each siteName for each service
  699. *
  700. * @param {Array} fileNamesToUpdate - file names that should be updated
  701. * @method updateConfigurations
  702. */
  703. updateConfigurations: function (fileNamesToUpdate) {
  704. var configurationController = App.router.get('mainServiceInfoConfigsController');
  705. var configs = this.get('configs').slice(0);
  706. var configsMap = [];
  707. fileNamesToUpdate.forEach(function (fileName) {
  708. // TODO - Temporarily commented out before refactoring should clean it more properly
  709. // if (!fileName || /^(core)/.test(fileName)) return;
  710. var tagName = 'version' + (new Date).getTime();
  711. var configsToSave = configs.filterProperty('filename', fileName);
  712. configsToSave.forEach(function (item) {
  713. item.value = App.config.trimProperty(item, false);
  714. });
  715. configsMap.push(configurationController.createSiteObj(fileName.replace(".xml", ""), tagName, configsToSave));
  716. }, this);
  717. if (!configsMap.length) return;
  718. this.applyConfigurationsToCluster(configsMap);
  719. },
  720. /**
  721. * Prepare <code>ajaxQueue</code> and start to execute it
  722. * @method submitProceed
  723. */
  724. submitProceed: function () {
  725. var self = this;
  726. this.set('clusterDeleteRequestsCompleted', 0);
  727. this.get('clusterDeleteErrorViews').clear();
  728. if (this.get('content.controllerName') == 'addHostController') {
  729. App.router.get('addHostController').setLowerStepsDisable(4);
  730. }
  731. // checkpoint the cluster status on the server so that the user can resume from where they left off
  732. switch (this.get('content.controllerName')) {
  733. case 'installerController':
  734. App.clusterStatus.setClusterStatus({
  735. clusterName: this.get('clusterName'),
  736. clusterState: 'CLUSTER_DEPLOY_PREP_2',
  737. wizardControllerName: this.get('content.controllerName'),
  738. localdb: App.db.data
  739. });
  740. break;
  741. case 'addHostController':
  742. App.clusterStatus.setClusterStatus({
  743. clusterName: this.get('clusterName'),
  744. clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
  745. wizardControllerName: this.get('content.controllerName'),
  746. localdb: App.db.data
  747. });
  748. break;
  749. case 'addServiceController':
  750. App.clusterStatus.setClusterStatus({
  751. clusterName: this.get('clusterName'),
  752. clusterState: 'ADD_SERVICES_DEPLOY_PREP_2',
  753. wizardControllerName: this.get('content.controllerName'),
  754. localdb: App.db.data
  755. });
  756. break;
  757. default:
  758. break;
  759. }
  760. // delete any existing clusters to start from a clean slate
  761. // before creating a new cluster in install wizard
  762. // TODO: modify for multi-cluster support
  763. this.getExistingClusterNames().complete(function () {
  764. var clusterNames = self.get('clusterNames');
  765. if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
  766. self.deleteClusters(clusterNames);
  767. } else {
  768. self.startDeploy();
  769. }
  770. });
  771. },
  772. /**
  773. * Get list of existing cluster names
  774. * @returns {object|null}
  775. * returns an array of existing cluster names.
  776. * returns an empty array if there are no existing clusters.
  777. * @method getExistingClusterNames
  778. */
  779. getExistingClusterNames: function () {
  780. return App.ajax.send({
  781. name: 'wizard.step8.existing_cluster_names',
  782. sender: this,
  783. success: 'getExistingClusterNamesSuccessCallBack',
  784. error: 'getExistingClusterNamesErrorCallback'
  785. });
  786. },
  787. /**
  788. * Save received list to <code>clusterNames</code>
  789. * @param {Object} data
  790. * @method getExistingClusterNamesSuccessCallBack
  791. */
  792. getExistingClusterNamesSuccessCallBack: function (data) {
  793. var clusterNames = data.items.mapProperty('Clusters.cluster_name');
  794. console.log("Got existing cluster names: " + clusterNames);
  795. this.set('clusterNames', clusterNames);
  796. },
  797. /**
  798. * If error appears, set <code>clusterNames</code> to <code>[]</code>
  799. * @method getExistingClusterNamesErrorCallback
  800. */
  801. getExistingClusterNamesErrorCallback: function () {
  802. console.log("Failed to get existing cluster names");
  803. this.set('clusterNames', []);
  804. },
  805. /**
  806. * Delete cluster by name
  807. * One request for one cluster!
  808. * @param {string[]} clusterNames
  809. * @method deleteClusters
  810. */
  811. deleteClusters: function (clusterNames) {
  812. this.get('clusterDeleteErrorViews').clear();
  813. clusterNames.forEach(function (clusterName, index) {
  814. App.ajax.send({
  815. name: 'common.delete.cluster',
  816. sender: this,
  817. data: {
  818. name: clusterName,
  819. isLast: index == clusterNames.length - 1
  820. },
  821. success: 'deleteClusterSuccessCallback',
  822. error: 'deleteClusterErrorCallback'
  823. });
  824. }, this);
  825. },
  826. /**
  827. * Method to execute after successful cluster deletion
  828. * @method deleteClusterSuccessCallback
  829. */
  830. deleteClusterSuccessCallback: function () {
  831. this.incrementProperty('clusterDeleteRequestsCompleted');
  832. if (this.get('isAllClusterDeleteRequestsCompleted')) {
  833. if (this.get('clusterDeleteErrorViews.length')) {
  834. this.showDeleteClustersErrorPopup();
  835. } else {
  836. this.startDeploy();
  837. }
  838. }
  839. },
  840. /**
  841. * Method to execute after failed cluster deletion
  842. * @param {object} request
  843. * @param {string} ajaxOptions
  844. * @param {string} error
  845. * @param {object} opt
  846. * @method deleteClusterErrorCallback
  847. */
  848. deleteClusterErrorCallback: function (request, ajaxOptions, error, opt) {
  849. this.incrementProperty('clusterDeleteRequestsCompleted');
  850. try {
  851. var json = $.parseJSON(request.responseText);
  852. var message = json.message;
  853. } catch (err) {
  854. }
  855. this.get('clusterDeleteErrorViews').pushObject(App.AjaxDefaultErrorPopupBodyView.create({
  856. url: opt.url,
  857. type: opt.type,
  858. status: request.status,
  859. message: message
  860. }));
  861. if (this.get('isAllClusterDeleteRequestsCompleted')) {
  862. this.showDeleteClustersErrorPopup();
  863. }
  864. },
  865. /**
  866. * Show error popup if cluster deletion failed
  867. * @method showDeleteClustersErrorPopup
  868. */
  869. showDeleteClustersErrorPopup: function () {
  870. var self = this;
  871. this.setProperties({
  872. isSubmitDisabled: false,
  873. isBackBtnDisabled: false
  874. });
  875. App.ModalPopup.show({
  876. header: Em.I18n.t('common.error'),
  877. secondary: false,
  878. onPrimary: function () {
  879. this.hide();
  880. },
  881. bodyClass: Em.ContainerView.extend({
  882. childViews: self.get('clusterDeleteErrorViews')
  883. })
  884. });
  885. },
  886. /**
  887. * updates kerberosDescriptorConfigs
  888. * @method updateKerberosDescriptor
  889. */
  890. updateKerberosDescriptor: function(instant) {
  891. var kerberosDescriptor = App.db.get('KerberosWizard', 'kerberosDescriptorConfigs');
  892. var ajaxOpts = {
  893. name: 'admin.kerberos.cluster.artifact.update',
  894. data: {
  895. artifactName: 'kerberos_descriptor',
  896. data: {
  897. artifact_data: kerberosDescriptor
  898. }
  899. }
  900. };
  901. if (instant) {
  902. ajaxOpts.sender = this;
  903. App.ajax.send(ajaxOpts);
  904. } else {
  905. this.addRequestToAjaxQueue(ajaxOpts);
  906. }
  907. },
  908. /**
  909. * Start deploy process
  910. * @method startDeploy
  911. */
  912. startDeploy: function () {
  913. this.createCluster();
  914. this.createSelectedServices();
  915. if (this.get('content.controllerName') !== 'addHostController') {
  916. if (this.get('content.controllerName') === 'addServiceController') {
  917. // for manually enabled Kerberos descriptor was updated on transition to this step
  918. if (App.get('isKerberosEnabled') && !this.get('isManualKerberos')) {
  919. this.updateKerberosDescriptor();
  920. }
  921. }
  922. if (this.get('wizardController').getDBProperty('fileNamesToUpdate') && this.get('wizardController').getDBProperty('fileNamesToUpdate').length) {
  923. this.updateConfigurations(this.get('wizardController').getDBProperty('fileNamesToUpdate'));
  924. }
  925. this.createConfigurations();
  926. this.applyConfigurationsToCluster(this.get('serviceConfigTags'));
  927. }
  928. this.createComponents();
  929. this.registerHostsToCluster();
  930. this.createConfigurationGroups();
  931. this.createMasterHostComponents();
  932. this.createSlaveAndClientsHostComponents();
  933. if (this.get('content.controllerName') === 'addServiceController') {
  934. this.createAdditionalClientComponents();
  935. }
  936. this.createAdditionalHostComponents();
  937. this.set('ajaxQueueLength', this.get('ajaxRequestsQueue.queue.length'));
  938. this.get('ajaxRequestsQueue').start();
  939. this.showLoadingIndicator();
  940. },
  941. /**
  942. * *******************************************************************
  943. * The following create* functions are called upon submitting Step 8.
  944. * *******************************************************************
  945. */
  946. /**
  947. * Create cluster using selected stack version
  948. * Queued request
  949. * @method createCluster
  950. */
  951. createCluster: function () {
  952. if (this.get('content.controllerName') !== 'installerController') return;
  953. var stackVersion = (this.get('content.installOptions.localRepo')) ? App.currentStackVersion.replace(/(-\d+(\.\d)*)/ig, "Local$&") : App.currentStackVersion;
  954. this.addRequestToAjaxQueue({
  955. name: 'wizard.step8.create_cluster',
  956. data: {
  957. data: JSON.stringify({ "Clusters": {"version": stackVersion }})
  958. },
  959. success: 'createClusterSuccess'
  960. });
  961. },
  962. createClusterSuccess: function (data, xhr, params) {
  963. App.set('clusterName', params.cluster)
  964. },
  965. /**
  966. * Create selected to install services
  967. * Queued request
  968. * Skipped if no services where selected!
  969. * @method createSelectedServices
  970. */
  971. createSelectedServices: function () {
  972. var data = this.createSelectedServicesData();
  973. if (!data.length) return;
  974. this.addRequestToAjaxQueue({
  975. name: 'wizard.step8.create_selected_services',
  976. data: {
  977. data: JSON.stringify(data)
  978. }
  979. });
  980. },
  981. /**
  982. * Format data for <code>createSelectedServices</code> request
  983. * @returns {Object[]}
  984. * @method createSelectedServicesData
  985. */
  986. createSelectedServicesData: function () {
  987. return this.get('selectedServices').map(function (_service) {
  988. return {"ServiceInfo": { "service_name": _service.get('serviceName') }};
  989. });
  990. },
  991. /**
  992. * Create components for selected services
  993. * Queued requests
  994. * One request for each service!
  995. * @method createComponents
  996. */
  997. createComponents: function () {
  998. var serviceComponents = App.StackServiceComponent.find();
  999. this.get('selectedServices').forEach(function (_service) {
  1000. var serviceName = _service.get('serviceName');
  1001. var componentsData = serviceComponents.filterProperty('serviceName', serviceName).map(function (_component) {
  1002. return { "ServiceComponentInfo": { "component_name": _component.get('componentName') } };
  1003. });
  1004. // Service must be specified in terms of a query for creating multiple components at the same time.
  1005. // See AMBARI-1018.
  1006. this.addRequestToCreateComponent(componentsData, serviceName);
  1007. }, this);
  1008. if (this.get('content.controllerName') === 'addHostController') {
  1009. var allServiceComponents = [];
  1010. var services = App.Service.find().mapProperty('serviceName');
  1011. services.forEach(function(_service){
  1012. var _serviceComponents = App.Service.find(_service).get('serviceComponents');
  1013. allServiceComponents = allServiceComponents.concat(_serviceComponents);
  1014. }, this);
  1015. this.get('content.slaveComponentHosts').forEach(function (component) {
  1016. if (component.componentName !== 'CLIENT' && !allServiceComponents.contains(component.componentName)) {
  1017. this.addRequestToCreateComponent(
  1018. [{"ServiceComponentInfo": {"component_name": component.componentName}}],
  1019. App.StackServiceComponent.find().findProperty('componentName', component.componentName).get('serviceName')
  1020. );
  1021. }
  1022. }, this);
  1023. this.get('content.clients').forEach(function (component) {
  1024. if (!allServiceComponents.contains(component.component_name)) {
  1025. this.addRequestToCreateComponent(
  1026. [{"ServiceComponentInfo": {"component_name": component.component_name}}],
  1027. App.StackServiceComponent.find().findProperty('componentName', component.component_name).get('serviceName')
  1028. );
  1029. }
  1030. }, this);
  1031. }
  1032. },
  1033. /**
  1034. * Add request to ajax queue to create service component
  1035. * @param componentsData
  1036. * @param serviceName
  1037. */
  1038. addRequestToCreateComponent: function (componentsData, serviceName) {
  1039. this.addRequestToAjaxQueue({
  1040. name: 'wizard.step8.create_components',
  1041. data: {
  1042. data: JSON.stringify({"components": componentsData}),
  1043. serviceName: serviceName
  1044. }
  1045. });
  1046. },
  1047. /**
  1048. * Error callback for new service component request
  1049. * So, if component doesn't exist we should create it
  1050. * @param {object} request
  1051. * @param {object} ajaxOptions
  1052. * @param {string} error
  1053. * @param {object} opt
  1054. * @param {object} params
  1055. * @method newServiceComponentErrorCallback
  1056. */
  1057. newServiceComponentErrorCallback: function (request, ajaxOptions, error, opt, params) {
  1058. this.addRequestToAjaxQueue({
  1059. name: 'wizard.step8.create_components',
  1060. data: {
  1061. serviceName: params.serviceName,
  1062. data: JSON.stringify({
  1063. "components": [
  1064. {
  1065. "ServiceComponentInfo": {
  1066. "component_name": params.componentName
  1067. }
  1068. }
  1069. ]
  1070. })
  1071. }
  1072. });
  1073. },
  1074. /**
  1075. * Register hosts
  1076. * Queued request
  1077. * @method registerHostsToCluster
  1078. */
  1079. registerHostsToCluster: function () {
  1080. var data = this.createRegisterHostData();
  1081. if (!data.length) return;
  1082. this.addRequestToAjaxQueue({
  1083. name: 'wizard.step8.register_host_to_cluster',
  1084. data: {
  1085. data: JSON.stringify(data)
  1086. }
  1087. });
  1088. },
  1089. /**
  1090. * Format request-data for <code>registerHostsToCluster</code>
  1091. * @returns {Object}
  1092. * @method createRegisterHostData
  1093. */
  1094. createRegisterHostData: function () {
  1095. return this.getRegisteredHosts().filterProperty('isInstalled', false).map(function (host) {
  1096. return {"Hosts": { "host_name": host.hostName}};
  1097. });
  1098. },
  1099. /**
  1100. * Register new master components
  1101. * @uses registerHostsToComponent
  1102. * @method createMasterHostComponents
  1103. */
  1104. createMasterHostComponents: function () {
  1105. // create master components for only selected services.
  1106. var selectedMasterComponents = this.get('content.masterComponentHosts').filter(function (_component) {
  1107. return this.get('selectedServices').mapProperty('serviceName').contains(_component.serviceId)
  1108. }, this);
  1109. selectedMasterComponents.mapProperty('component').uniq().forEach(function (component) {
  1110. var hostNames = selectedMasterComponents.filterProperty('component', component).filterProperty('isInstalled', false).mapProperty('hostName');
  1111. this.registerHostsToComponent(hostNames, component);
  1112. }, this);
  1113. },
  1114. getClientsMap: function (flag) {
  1115. var clientNames = App.StackServiceComponent.find().filterProperty('isClient').mapProperty('componentName'),
  1116. clientsMap = {},
  1117. dependedComponents = flag ? App.StackServiceComponent.find().filterProperty(flag) : App.StackServiceComponent.find();
  1118. clientNames.forEach(function (clientName) {
  1119. clientsMap[clientName] = Em.A([]);
  1120. dependedComponents.forEach(function (component) {
  1121. if (component.get('dependencies').mapProperty('componentName').contains(clientName)) clientsMap[clientName].push(component.get('componentName'));
  1122. });
  1123. if (!clientsMap[clientName].length) delete clientsMap[clientName];
  1124. });
  1125. return clientsMap;
  1126. },
  1127. /**
  1128. * Register slave components and clients
  1129. * @uses registerHostsToComponent
  1130. * @method createSlaveAndClientsHostComponents
  1131. */
  1132. createSlaveAndClientsHostComponents: function () {
  1133. var masterHosts = this.get('content.masterComponentHosts');
  1134. var slaveHosts = this.get('content.slaveComponentHosts');
  1135. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1136. /**
  1137. * Determines on which hosts client should be installed (based on availability of master components on hosts)
  1138. * @type {Object}
  1139. * Format:
  1140. * <code>
  1141. * {
  1142. * CLIENT1: Em.A([MASTER1, MASTER2, ...]),
  1143. * CLIENT2: Em.A([MASTER3, MASTER1, ...])
  1144. * ...
  1145. * }
  1146. * </code>
  1147. */
  1148. var clientsToMasterMap = this.getClientsMap('isMaster');
  1149. slaveHosts.forEach(function (_slave) {
  1150. if (_slave.componentName !== 'CLIENT') {
  1151. var hostNames = _slave.hosts.filterProperty('isInstalled', false).mapProperty('hostName');
  1152. this.registerHostsToComponent(hostNames, _slave.componentName);
  1153. }
  1154. else {
  1155. clients.forEach(function (_client) {
  1156. var hostNames = _slave.hosts.mapProperty('hostName');
  1157. // The below logic to install clients to existing/New master hosts should not be applied to Add Host wizard.
  1158. // This is with the presumption that Add Host controller does not add any new Master component to the cluster
  1159. if (this.get('content.controllerName') !== 'addHostController') {
  1160. if (clientsToMasterMap[_client.component_name]) {
  1161. clientsToMasterMap[_client.component_name].forEach(function (componentName) {
  1162. masterHosts.filterProperty('component', componentName).forEach(function (_masterHost) {
  1163. hostNames.pushObject(_masterHost.hostName);
  1164. });
  1165. });
  1166. }
  1167. }
  1168. hostNames = hostNames.uniq();
  1169. this.registerHostsToComponent(hostNames, _client.component_name);
  1170. }, this);
  1171. }
  1172. }, this);
  1173. },
  1174. /**
  1175. * This function is specific to addServiceController
  1176. * Newly introduced master components requires some existing client components to be hosted along with them
  1177. */
  1178. createAdditionalClientComponents: function () {
  1179. var masterHosts = this.get('content.masterComponentHosts');
  1180. var clientHosts = [];
  1181. if (this.get('content.slaveComponentHosts').someProperty('componentName', 'CLIENT')) {
  1182. clientHosts = this.get('content.slaveComponentHosts').findProperty('componentName', 'CLIENT').hosts;
  1183. }
  1184. var clients = this.get('content.clients').filterProperty('isInstalled', false);
  1185. var clientsToMasterMap = this.getClientsMap('isMaster');
  1186. var clientsToClientMap = this.getClientsMap('isClient');
  1187. var installedClients = [];
  1188. // Get all the installed Client components
  1189. this.get('content.services').filterProperty('isInstalled').forEach(function (_service) {
  1190. var serviceClients = App.StackServiceComponent.find().filterProperty('serviceName', _service.get('serviceName')).filterProperty('isClient');
  1191. serviceClients.forEach(function (client) {
  1192. installedClients.push(client.get('componentName'));
  1193. }, this);
  1194. }, this);
  1195. // Check if there is a dependency for being co-hosted between existing client and selected new master
  1196. installedClients.forEach(function (_clientName) {
  1197. if (clientsToMasterMap[_clientName] || clientsToClientMap[_clientName]) {
  1198. var hostNames = [];
  1199. if (clientsToMasterMap[_clientName]) {
  1200. clientsToMasterMap[_clientName].forEach(function (componentName) {
  1201. masterHosts.filterProperty('component', componentName).filterProperty('isInstalled', false).forEach(function (_masterHost) {
  1202. hostNames.pushObject(_masterHost.hostName);
  1203. }, this);
  1204. }, this);
  1205. }
  1206. if (clientsToClientMap[_clientName]) {
  1207. clientsToClientMap[_clientName].forEach(function (componentName) {
  1208. clientHosts.forEach(function (_clientHost) {
  1209. var host = this.get('content.hosts')[_clientHost.hostName];
  1210. if (host.isInstalled && !host.hostComponents.someProperty('HostRoles.component_name', componentName)) {
  1211. hostNames.pushObject(_clientHost.hostName);
  1212. }
  1213. }, this);
  1214. }, this);
  1215. }
  1216. hostNames = hostNames.uniq();
  1217. if (hostNames.length > 0) {
  1218. // If a dependency for being co-hosted is derived between existing client and selected new master but that
  1219. // dependency is already satisfied in the cluster then disregard the derived dependency
  1220. this.removeClientsFromList(_clientName, hostNames);
  1221. this.registerHostsToComponent(hostNames, _clientName);
  1222. if(hostNames.length > 0) {
  1223. this.get('content.additionalClients').pushObject({hostNames: hostNames, componentName: _clientName});
  1224. }
  1225. }
  1226. }
  1227. }, this);
  1228. },
  1229. /**
  1230. *
  1231. * @param clientName
  1232. * @param hostList
  1233. */
  1234. removeClientsFromList: function (clientName, hostList) {
  1235. var clientHosts = [];
  1236. var installedHosts = this.get('content.hosts');
  1237. for (var hostName in installedHosts) {
  1238. if (installedHosts[hostName].isInstalled) {
  1239. if (installedHosts[hostName].hostComponents.mapProperty('HostRoles.component_name').contains(clientName)) {
  1240. clientHosts.push(hostName);
  1241. }
  1242. }
  1243. }
  1244. if (clientHosts.length > 0) {
  1245. clientHosts.forEach(function (hostName) {
  1246. if (hostList.contains(hostName)) {
  1247. hostList.splice(hostList.indexOf(hostName), 1);
  1248. }
  1249. }, this);
  1250. }
  1251. },
  1252. /**
  1253. * Register additional components
  1254. * Based on availability of some services
  1255. * @uses registerHostsToComponent
  1256. * @method createAdditionalHostComponents
  1257. */
  1258. createAdditionalHostComponents: function () {
  1259. var masterHosts = this.get('content.masterComponentHosts');
  1260. // add all components with cardinality == ALL of selected services
  1261. var registeredHosts = this.getRegisteredHosts();
  1262. var notInstalledHosts = registeredHosts.filterProperty('isInstalled', false);
  1263. this.get('content.services').filterProperty('isSelected').forEach(function (service) {
  1264. service.get('serviceComponents').filterProperty('isRequiredOnAllHosts').forEach(function (component) {
  1265. if (service.get('isInstalled') && notInstalledHosts.length) {
  1266. this.registerHostsToComponent(notInstalledHosts.mapProperty('hostName'), component.get('componentName'));
  1267. } else if (!service.get('isInstalled') && registeredHosts.length) {
  1268. this.registerHostsToComponent(registeredHosts.mapProperty('hostName'), component.get('componentName'));
  1269. }
  1270. }, this);
  1271. }, this);
  1272. // add MySQL Server if Hive is selected
  1273. var hiveService = this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).findProperty('serviceName', 'HIVE');
  1274. if (hiveService) {
  1275. var hiveDb = this.get('content.serviceConfigProperties').findProperty('name', 'hive_database');
  1276. if (hiveDb.value == "New MySQL Database") {
  1277. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'MYSQL_SERVER');
  1278. } else if (hiveDb.value === "New PostgreSQL Database") {
  1279. this.registerHostsToComponent(masterHosts.filterProperty('component', 'HIVE_SERVER').mapProperty('hostName'), 'POSTGRESQL_SERVER');
  1280. }
  1281. }
  1282. },
  1283. /**
  1284. * Register component to hosts
  1285. * Queued request
  1286. * @param {String[]} hostNames
  1287. * @param {String} componentName
  1288. * @method registerHostsToComponent
  1289. */
  1290. registerHostsToComponent: function (hostNames, componentName) {
  1291. if (!hostNames.length) return;
  1292. var queryStr = '';
  1293. hostNames.forEach(function (hostName) {
  1294. queryStr += 'Hosts/host_name=' + hostName + '|';
  1295. });
  1296. //slice off last symbol '|'
  1297. queryStr = queryStr.slice(0, -1);
  1298. var data = {
  1299. "RequestInfo": {
  1300. "query": queryStr
  1301. },
  1302. "Body": {
  1303. "host_components": [
  1304. {
  1305. "HostRoles": {
  1306. "component_name": componentName
  1307. }
  1308. }
  1309. ]
  1310. }
  1311. };
  1312. this.addRequestToAjaxQueue({
  1313. name: 'wizard.step8.register_host_to_component',
  1314. data: {
  1315. data: JSON.stringify(data)
  1316. }
  1317. });
  1318. },
  1319. /**
  1320. * Compare generated config object with current configs that were filled
  1321. * on "Customize Services" page.
  1322. *
  1323. * @param {Object} properties - generated by createSiteObj|createCoreSiteObj
  1324. * @param {Array} configs - current configs to compare
  1325. * @return {Boolean}
  1326. * @method isConfigsChanged
  1327. **/
  1328. isConfigsChanged: function (properties, configs) {
  1329. var isChanged = false;
  1330. for (var property in properties) {
  1331. var config = configs.findProperty('name', property);
  1332. // if config not found then it's looks like a new config
  1333. if (!config) {
  1334. isChanged = true;
  1335. } else {
  1336. if (!config.hasInitialValue || config.isNotDefaultValue) {
  1337. isChanged = true;
  1338. }
  1339. }
  1340. }
  1341. return isChanged;
  1342. },
  1343. /**
  1344. * Create config objects for cluster and services
  1345. * @method createConfigurations
  1346. */
  1347. createConfigurations: function () {
  1348. var selectedServices = this.get('selectedServices');
  1349. var coreSiteObject = this.createCoreSiteObj();
  1350. var tag = 'version1';
  1351. var clusterSiteObj = this.createSiteObj('cluster-env', tag);
  1352. if (this.get('content.controllerName') == 'installerController') {
  1353. this.get('serviceConfigTags').pushObject(clusterSiteObj);
  1354. }
  1355. if (this.get('content.controllerName') == 'addServiceController') {
  1356. tag = 'version' + (new Date).getTime();
  1357. coreSiteObject.tag = tag;
  1358. var coreSiteConfigs = this.get('configs').filterProperty('filename', 'core-site.xml');
  1359. if (this.isConfigsChanged(coreSiteObject.properties, coreSiteConfigs)) {
  1360. coreSiteObject.service_config_version_note = Em.I18n.t('dashboard.configHistory.table.notes.addService');
  1361. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1362. }
  1363. }
  1364. selectedServices.forEach(function (service) {
  1365. Object.keys(service.get('configTypes')).forEach(function (type) {
  1366. if (!this.get('serviceConfigTags').someProperty('type', type)) {
  1367. var serviceVersionNotes = Em.I18n.t('dashboard.configHistory.table.notes.default').format(service.get('displayName'));
  1368. if (type === 'core-site') {
  1369. coreSiteObject.service_config_version_note = serviceVersionNotes;
  1370. this.get('serviceConfigTags').pushObject(coreSiteObject);
  1371. } else if (type === 'storm-site') {
  1372. var obj = this.createStormSiteObj(tag);
  1373. obj.service_config_version_note = serviceVersionNotes;
  1374. this.get('serviceConfigTags').pushObject(obj);
  1375. } else {
  1376. var obj = this.createSiteObj(type, tag);
  1377. obj.service_config_version_note = serviceVersionNotes;
  1378. this.get('serviceConfigTags').pushObject(obj);
  1379. }
  1380. }
  1381. }, this);
  1382. }, this);
  1383. this.createNotification();
  1384. },
  1385. /**
  1386. * Send <code>serviceConfigTags</code> to server
  1387. * Queued request
  1388. * One request for each service config tag
  1389. * @param serviceConfigTags
  1390. * @method applyConfigurationsToCluster
  1391. */
  1392. applyConfigurationsToCluster: function (serviceConfigTags) {
  1393. var allServices = this.get('installedServices').concat(this.get('selectedServices'));
  1394. var allConfigData = [];
  1395. allServices.forEach(function (service) {
  1396. var serviceConfigData = [];
  1397. Object.keys(service.get('configTypesRendered')).forEach(function (type) {
  1398. var serviceConfigTag = serviceConfigTags.findProperty('type', type);
  1399. if (serviceConfigTag) {
  1400. serviceConfigData.pushObject(serviceConfigTag);
  1401. }
  1402. }, this);
  1403. if (serviceConfigData.length) {
  1404. allConfigData.pushObject(JSON.stringify({
  1405. Clusters: {
  1406. desired_config: serviceConfigData
  1407. }
  1408. }));
  1409. }
  1410. }, this);
  1411. var clusterConfig = serviceConfigTags.findProperty('type', 'cluster-env');
  1412. if (clusterConfig) {
  1413. allConfigData.pushObject(JSON.stringify({
  1414. Clusters: {
  1415. desired_config: [clusterConfig]
  1416. }
  1417. }));
  1418. }
  1419. this.addRequestToAjaxQueue({
  1420. name: 'common.across.services.configurations',
  1421. data: {
  1422. data: '[' + allConfigData.toString() + ']'
  1423. }
  1424. });
  1425. },
  1426. /**
  1427. * Create and update config groups
  1428. * @method createConfigurationGroups
  1429. */
  1430. createConfigurationGroups: function () {
  1431. var configGroups = this.get('content.configGroups').filterProperty('isDefault', false);
  1432. var clusterName = this.get('clusterName');
  1433. var sendData = [];
  1434. var updateData = [];
  1435. var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
  1436. var timeTag = (new Date).getTime();
  1437. var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
  1438. if (groupsToDelete && groupsToDelete.length > 0) {
  1439. this.removeInstalledServicesConfigurationGroups(groupsToDelete);
  1440. }
  1441. configGroups.forEach(function (configGroup) {
  1442. var groupConfigs = [];
  1443. var groupData = {
  1444. "cluster_name": clusterName,
  1445. "group_name": configGroup.name,
  1446. "tag": configGroup.service.id,
  1447. "description": configGroup.description,
  1448. "hosts": [],
  1449. "desired_configs": []
  1450. };
  1451. configGroup.hosts.forEach(function (hostName) {
  1452. groupData.hosts.push({"host_name": hostName});
  1453. });
  1454. // get properties that was created for non-default config group
  1455. configGroup.properties = configGroup.properties.concat(this.get('customNonDefaultGroupConfigs').filterProperty('group', configGroup.name));
  1456. //wrap properties into Em.Object to make them compatible with buildGroupDesiredConfigs method
  1457. configGroup.properties.forEach(function (property) {
  1458. groupConfigs.push(Em.Object.create(property));
  1459. });
  1460. groupData.desired_configs = this.buildGroupDesiredConfigs(groupConfigs, timeTag);
  1461. // check for group from installed service
  1462. if (configGroup.isForInstalledService === true) {
  1463. // if group is a new one, create it
  1464. if (!configGroup.id) {
  1465. sendData.push({"ConfigGroup": groupData});
  1466. } else if (configGroup.isForUpdate){
  1467. // update an existing group
  1468. groupData.id = configGroup.id;
  1469. updateData.push({"ConfigGroup": groupData});
  1470. }
  1471. } else {
  1472. sendData.push({"ConfigGroup": groupData});
  1473. }
  1474. //each group should have unique tag to prevent overriding configs from common sites
  1475. timeTag++;
  1476. }, this);
  1477. if (sendData.length > 0) {
  1478. this.applyConfigurationGroups(sendData);
  1479. }
  1480. if (updateData.length > 0) {
  1481. this.applyInstalledServicesConfigurationGroup(updateData);
  1482. }
  1483. },
  1484. /**
  1485. * construct desired_configs for config groups from overriden properties
  1486. * @param configs
  1487. * @param timeTag
  1488. * @return {Array}
  1489. * @private
  1490. * @method buildGroupDesiredConfigs
  1491. */
  1492. buildGroupDesiredConfigs: function (configs, timeTag) {
  1493. var sites = [];
  1494. var time = timeTag || (new Date).getTime();
  1495. var siteFileNames = configs.mapProperty('filename').uniq();
  1496. sites = siteFileNames.map(function (filename) {
  1497. return {
  1498. type: filename.replace('.xml', ''),
  1499. tag: 'version' + time,
  1500. properties: []
  1501. };
  1502. });
  1503. configs.forEach(function (config) {
  1504. var type = config.get('filename').replace('.xml', '');
  1505. var site = sites.findProperty('type', type);
  1506. site.properties.push(config);
  1507. });
  1508. return sites.map(function (site) {
  1509. return App.router.get('mainServiceInfoConfigsController').createSiteObj(site.type, site.tag, site.properties);
  1510. }, this);
  1511. },
  1512. /**
  1513. * Create new config groups request
  1514. * Queued request
  1515. * @param {Object[]} sendData
  1516. * @method applyConfigurationGroups
  1517. */
  1518. applyConfigurationGroups: function (sendData) {
  1519. this.addRequestToAjaxQueue({
  1520. name: 'wizard.step8.apply_configuration_groups',
  1521. data: {
  1522. data: JSON.stringify(sendData)
  1523. }
  1524. });
  1525. },
  1526. /**
  1527. * Update existed config groups
  1528. * Separated request for each group
  1529. * @param {Object[]} updateData
  1530. * @method applyInstalledServicesConfigurationGroup
  1531. */
  1532. applyInstalledServicesConfigurationGroup: function (updateData) {
  1533. updateData.forEach(function (item) {
  1534. App.router.get('mainServiceInfoConfigsController').putConfigGroupChanges(item);
  1535. });
  1536. },
  1537. /**
  1538. * Delete selected config groups
  1539. * @param {Object[]} groupsToDelete
  1540. * @method removeInstalledServicesConfigurationGroups
  1541. */
  1542. removeInstalledServicesConfigurationGroups: function (groupsToDelete) {
  1543. var self = this;
  1544. groupsToDelete.forEach(function (item) {
  1545. self.deleteConfigurationGroup(Em.Object.create(item));
  1546. });
  1547. },
  1548. /**
  1549. * proxyuser configs which depend on service
  1550. * @type {{serviceName: string, user: string}[]}
  1551. */
  1552. optionalCoreSiteConfigs: [
  1553. {
  1554. serviceName: 'OOZIE',
  1555. user: 'oozie_user'
  1556. },
  1557. {
  1558. serviceName: 'HIVE',
  1559. user: 'hive_user'
  1560. },
  1561. {
  1562. serviceName: 'HIVE',
  1563. user: 'hcat_user'
  1564. },
  1565. {
  1566. serviceName: 'FALCON',
  1567. user: 'falcon_user'
  1568. }
  1569. ],
  1570. /**
  1571. * push proxyuser properties to core-site if they required by dependencies
  1572. * @param coreSiteObj
  1573. * @param installedAndSelectedServices
  1574. * @return {Object}
  1575. */
  1576. resolveProxyuserDependecies: function (coreSiteObj, installedAndSelectedServices) {
  1577. var coreSiteProperties = {};
  1578. var optionalCoreSiteConfigs = this.get('optionalCoreSiteConfigs');
  1579. var proxyuserGroup = this.get('configs').findProperty('name', 'proxyuser_group');
  1580. coreSiteObj.forEach(function (_coreSiteObj) {
  1581. //proxyuser_group property should be added only if proxyuser properties are used
  1582. if (proxyuserGroup && _coreSiteObj.name === proxyuserGroup.name) return;
  1583. // exclude some configs if service wasn't selected
  1584. var addProperty = optionalCoreSiteConfigs.every(function (config) {
  1585. var userValue = this.get('configs').someProperty('name', config.user) ? this.get('configs').findProperty('name', config.user).value : null
  1586. return (installedAndSelectedServices.someProperty('serviceName', config.serviceName) ||
  1587. (_coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + userValue + '.groups'))
  1588. }, this);
  1589. if (addProperty) {
  1590. coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
  1591. }
  1592. }, this);
  1593. if (!App.isEmptyObject(coreSiteProperties) && proxyuserGroup) {
  1594. coreSiteProperties[proxyuserGroup.name] = proxyuserGroup.value;
  1595. }
  1596. return coreSiteProperties;
  1597. },
  1598. /**
  1599. * Create Core Site object
  1600. * @returns {{type: string, tag: string, properties: {}}}
  1601. * @method createCoreSiteObj
  1602. */
  1603. createCoreSiteObj: function () {
  1604. var installedAndSelectedServices = Em.A([]);
  1605. installedAndSelectedServices.pushObjects(this.get('installedServices'));
  1606. installedAndSelectedServices.pushObjects(this.get('selectedServices'));
  1607. var coreSiteObj = this.get('configs').filterProperty('filename', 'core-site.xml'),
  1608. coreSiteProperties = this.resolveProxyuserDependecies(coreSiteObj, installedAndSelectedServices),
  1609. isGLUSTERFSSelected = installedAndSelectedServices.someProperty('serviceName', 'GLUSTERFS');
  1610. coreSiteObj.forEach(function (_coreSiteObj) {
  1611. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.default.name") {
  1612. coreSiteProperties[_coreSiteObj.name] =
  1613. this.get('configs').someProperty('name', 'fs_glusterfs_default_name') ?
  1614. this.get('configs').findProperty('name', 'fs_glusterfs_default_name').value : null;
  1615. }
  1616. if (isGLUSTERFSSelected && _coreSiteObj.name == "fs.defaultFS") {
  1617. coreSiteProperties[_coreSiteObj.name] =
  1618. this.get('configs').someProperty('name', 'glusterfs_defaultFS_name') ?
  1619. this.get('configs').findProperty('name', 'glusterfs_defaultFS_name').value : null;
  1620. }
  1621. }, this);
  1622. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(coreSiteObj);
  1623. var configObj = {"type": "core-site", "tag": "version1", "properties": coreSiteProperties};
  1624. if (attributes) {
  1625. configObj['properties_attributes'] = attributes;
  1626. }
  1627. return configObj;
  1628. },
  1629. /**
  1630. * Create siteObj for custom service with it own configs
  1631. * @param {string} site
  1632. * @param tag
  1633. * @returns {{type: string, tag: string, properties: {}}}
  1634. * @method createSiteObj
  1635. */
  1636. createSiteObj: function (site, tag) {
  1637. var properties = {};
  1638. var configs = this.get('configs').filterProperty('filename', site + '.xml');
  1639. var attributes = App.router.get('mainServiceInfoConfigsController').getConfigAttributes(configs);
  1640. configs.forEach(function (_configProperty) {
  1641. var heapsizeExceptions = ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize', 'nfsgateway_heapsize', 'accumulo_master_heapsize', 'accumulo_tserver_heapsize', 'accumulo_monitor_heapsize', 'accumulo_gc_heapsize', 'accumulo_other_heapsize'];
  1642. // do not pass any globals whose name ends with _host or _hosts
  1643. if (_configProperty.isRequiredByAgent !== false) {
  1644. // append "m" to JVM memory options except for heapsizeExtensions
  1645. if (/_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/.test(_configProperty.name) && !heapsizeExceptions.contains(_configProperty.name) && !(_configProperty.value).endsWith("m")) {
  1646. properties[_configProperty.name] = _configProperty.value + "m";
  1647. } else {
  1648. properties[_configProperty.name] = _configProperty.value;
  1649. }
  1650. }
  1651. }, this);
  1652. var configObj = {"type": site, "tag": tag, "properties": properties };
  1653. if (attributes) {
  1654. configObj['properties_attributes'] = attributes;
  1655. }
  1656. return configObj;
  1657. },
  1658. /**
  1659. * Create site obj for Storm
  1660. * Some config-properties should be modified in custom way
  1661. * @param tag
  1662. * @returns {{type: string, tag: string, properties: {}}}
  1663. * @method createStormSiteObj
  1664. */
  1665. createStormSiteObj: function (tag) {
  1666. var configs = this.get('configs').filterProperty('filename', 'storm-site.xml');
  1667. var stormProperties = {};
  1668. configs.forEach(function (_configProperty) {
  1669. if (["nimbus.seeds", "storm.zookeeper.servers"].contains(_configProperty.name)) {
  1670. stormProperties[_configProperty.name] = JSON.stringify(_configProperty.value).replace(/"/g, "'");
  1671. } else {
  1672. stormProperties[_configProperty.name] = _configProperty.value;
  1673. }
  1674. }, this);
  1675. return {type: 'storm-site', tag: tag, properties: stormProperties};
  1676. },
  1677. /**
  1678. * Create one Alert Notification (if user select this on step7)
  1679. * Only for Install Wizard and stack
  1680. * @method createNotification
  1681. */
  1682. createNotification: function () {
  1683. if (this.get('content.controllerName') !== 'installerController') return;
  1684. var miscConfigs = this.get('configs').filterProperty('serviceName', 'MISC'),
  1685. createNotification = miscConfigs.findProperty('name', 'create_notification').value;
  1686. if (createNotification !== 'yes') return;
  1687. var predefinedNotificationConfigNames = require('data/HDP2/site_properties').configProperties.filterProperty('filename', 'alert_notification').mapProperty('name'),
  1688. configsForNotification = this.get('configs').filterProperty('filename', 'alert_notification');
  1689. var properties = {},
  1690. names = [
  1691. 'ambari.dispatch.recipients',
  1692. 'mail.smtp.host',
  1693. 'mail.smtp.port',
  1694. 'mail.smtp.from',
  1695. 'mail.smtp.starttls.enable',
  1696. 'mail.smtp.startssl.enable'
  1697. ];
  1698. if (miscConfigs.findProperty('name', 'smtp_use_auth').value == 'true') { // yes, it's not converted to boolean
  1699. names.pushObjects(['ambari.dispatch.credential.username', 'ambari.dispatch.credential.password']);
  1700. }
  1701. names.forEach(function (name) {
  1702. properties[name] = miscConfigs.findProperty('name', name).value;
  1703. });
  1704. properties['ambari.dispatch.recipients'] = properties['ambari.dispatch.recipients'].replace(/\s/g, '').split(',');
  1705. configsForNotification.forEach(function (config) {
  1706. if (predefinedNotificationConfigNames.contains(config.name)) return;
  1707. properties[config.name] = config.value;
  1708. });
  1709. var apiObject = {
  1710. AlertTarget: {
  1711. name: 'Initial Notification',
  1712. description: 'Notification created during cluster installing',
  1713. global: true,
  1714. notification_type: 'EMAIL',
  1715. alert_states: ['OK', 'WARNING', 'CRITICAL', 'UNKNOWN'],
  1716. properties: properties
  1717. }
  1718. };
  1719. this.addRequestToAjaxQueue({
  1720. name: 'alerts.create_alert_notification',
  1721. data: {
  1722. urlParams: 'overwrite_existing=true',
  1723. data: apiObject
  1724. }
  1725. });
  1726. },
  1727. /**
  1728. * Should ajax-queue progress bar be displayed
  1729. * @method showLoadingIndicator
  1730. */
  1731. showLoadingIndicator: function () {
  1732. return App.ModalPopup.show({
  1733. header: '',
  1734. showFooter: false,
  1735. showCloseButton: false,
  1736. bodyClass: Em.View.extend({
  1737. templateName: require('templates/wizard/step8/step8_log_popup'),
  1738. controllerBinding: 'App.router.wizardStep8Controller',
  1739. /**
  1740. * Css-property for progress-bar
  1741. * @type {string}
  1742. */
  1743. barWidth: '',
  1744. /**
  1745. * Popup-message
  1746. * @type {string}
  1747. */
  1748. message: '',
  1749. /**
  1750. * Set progress bar width and popup message when ajax-queue requests are proccessed
  1751. * @method ajaxQueueChangeObs
  1752. */
  1753. ajaxQueueChangeObs: function () {
  1754. var length = this.get('controller.ajaxQueueLength');
  1755. var left = this.get('controller.ajaxRequestsQueue.queue.length');
  1756. this.set('barWidth', 'width: ' + ((length - left) / length * 100) + '%;');
  1757. this.set('message', Em.I18n.t('installer.step8.deployPopup.message').format((length - left), length));
  1758. }.observes('controller.ajaxQueueLength', 'controller.ajaxRequestsQueue.queue.length'),
  1759. /**
  1760. * Hide popup when ajax-queue is finished
  1761. * @method autoHide
  1762. */
  1763. autoHide: function () {
  1764. if (this.get('controller.servicesInstalled')) {
  1765. this.get('parentView').hide();
  1766. }
  1767. }.observes('controller.servicesInstalled')
  1768. })
  1769. });
  1770. }
  1771. });