step8_controller.js 70 KB

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