step8_controller.js 73 KB

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