step8_controller.js 71 KB

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