step8_controller.js 73 KB

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