step7_controller.js 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632
  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. /**
  20. * By Step 7, we have the following information stored in App.db and set on this
  21. * controller by the router.
  22. *
  23. * selectedServices: App.db.selectedServices (the services that the user selected in Step 4)
  24. * masterComponentHosts: App.db.masterComponentHosts (master-components-to-hosts mapping the user selected in Step 5)
  25. * slaveComponentHosts: App.db.slaveComponentHosts (slave-components-to-hosts mapping the user selected in Step 6)
  26. *
  27. */
  28. /**
  29. * @typedef {object} masterComponentHost
  30. * @property {string} component
  31. * @property {string} hostName
  32. * @property {boolean} isInstalled is component already installed on the this host or just going to be installed
  33. */
  34. /**
  35. * @typedef {object} topologyLocalDB
  36. * @property {object[]} hosts list of hosts with information of their disks usage and dirs
  37. * @property {masterComponentHost[]} masterComponentHosts
  38. * @property {?object[]} slaveComponentHosts
  39. */
  40. App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, {
  41. name: 'wizardStep7Controller',
  42. /**
  43. * Contains all field properties that are viewed in this step
  44. * @type {object[]}
  45. */
  46. stepConfigs: [],
  47. hash: null,
  48. selectedService: null,
  49. addMiscTabToPage: true,
  50. /**
  51. * Is Submit-click processing now
  52. * @type {bool}
  53. */
  54. submitButtonClicked: false,
  55. isRecommendedLoaded: false,
  56. /**
  57. * used in services_config.js view to mark a config with security icon
  58. */
  59. secureConfigs: require('data/HDP2/secure_mapping'),
  60. /**
  61. * If configChangeObserver Modal is shown
  62. * @type {bool}
  63. */
  64. miscModalVisible: false,
  65. overrideToAdd: null,
  66. /**
  67. * Is installer controller used
  68. * @type {bool}
  69. */
  70. isInstaller: true,
  71. /**
  72. * List of config groups
  73. * @type {object[]}
  74. */
  75. configGroups: [],
  76. /**
  77. * List of config group to be deleted
  78. * @type {object[]}
  79. */
  80. groupsToDelete: [],
  81. preSelectedConfigGroup: null,
  82. /**
  83. * Currently selected config group
  84. * @type {object}
  85. */
  86. selectedConfigGroup: null,
  87. /**
  88. * Config tags of actually installed services
  89. * @type {array}
  90. */
  91. serviceConfigTags: [],
  92. /**
  93. * Are applied to service configs loaded
  94. * @type {bool}
  95. */
  96. isAppliedConfigLoaded: true,
  97. isConfigsLoaded: Em.computed.and('wizardController.stackConfigsLoaded', 'isAppliedConfigLoaded'),
  98. transitionInProgress: Em.computed.alias('App.router.btnClickInProgress'),
  99. /**
  100. * PreInstall Checks allowed only for Install
  101. * @type {boolean}
  102. */
  103. supportsPreInstallChecks: function () {
  104. return App.get('supports.preInstallChecks') && 'installerController' === this.get('content.controllerName');
  105. }.property('App.supports.preInstallChecks', 'wizardController.name'),
  106. /**
  107. * Number of errors in the configs in the selected service
  108. * @type {number}
  109. */
  110. errorsCount: function() {
  111. return this.get('selectedService.configsWithErrors').filter(function(c) {
  112. return Em.isNone(c.get('widget'));
  113. }).length;
  114. }.property('selectedService.configsWithErrors.length'),
  115. /**
  116. * Should Next-button be disabled
  117. * @type {bool}
  118. */
  119. isSubmitDisabled: function () {
  120. if (!this.get('stepConfigs.length')) return true;
  121. if (this.get('submitButtonClicked')) return true;
  122. if (App.get('router.btnClickInProgress')) return true;
  123. return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible");
  124. }.property('stepConfigs.@each.errorCount', 'miscModalVisible', 'submitButtonClicked', 'App.router.btnClickInProgress'),
  125. /**
  126. * List of selected to install service names
  127. * @type {string[]}
  128. */
  129. selectedServiceNames: function () {
  130. return this.get('content.services').filterProperty('isSelected', true).filterProperty('isInstalled', false).mapProperty('serviceName');
  131. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  132. /**
  133. * List of installed and selected to install service names
  134. * @type {string[]}
  135. */
  136. allSelectedServiceNames: function () {
  137. return this.get('content.services').filter(function (service) {
  138. return service.get('isInstalled') || service.get('isSelected');
  139. }).mapProperty('serviceName');
  140. }.property('content.services', 'content.services.@each.isSelected', 'content.services.@each.isInstalled', 'content.stacks.@each.isSelected').cacheable(),
  141. /**
  142. * List of installed service names
  143. * @type {string[]}
  144. */
  145. installedServiceNames: function () {
  146. var serviceNames = this.get('content.services').filterProperty('isInstalled').mapProperty('serviceName');
  147. if (this.get('content.controllerName') !== 'installerController') {
  148. serviceNames = serviceNames.filter(function (_serviceName) {
  149. return !App.get('services.noConfigTypes').contains(_serviceName);
  150. });
  151. }
  152. return serviceNames;
  153. }.property('content.services').cacheable(),
  154. installedServices: function () {
  155. var self = this;
  156. return App.StackService.find().toArray().toMapByCallback('serviceName', function (item) {
  157. return self.get('installedServiceNames').contains(item.get('serviceName'));
  158. });
  159. }.property('installedServiceNames.length'),
  160. /**
  161. * List of master components
  162. * @type {Ember.Enumerable}
  163. */
  164. masterComponentHosts: Em.computed.alias('content.masterComponentHosts'),
  165. /**
  166. * List of slave components
  167. * @type {Ember.Enumerable}
  168. */
  169. slaveComponentHosts: Em.computed.alias('content.slaveGroupProperties'),
  170. /**
  171. * Filter text will be located here
  172. * @type {string}
  173. */
  174. filter: '',
  175. /**
  176. * Defines if configs can be editable
  177. * @type {boolean}
  178. */
  179. canEdit: true,
  180. /**
  181. * list of dependencies that are user to set init value of config
  182. *
  183. * @type {Object}
  184. */
  185. configDependencies: function() {
  186. var dependencies = {};
  187. var hiveMetastore = App.configsCollection.getConfigByName('hive.metastore.uris', 'hive-site.xml');
  188. var clientPort = App.configsCollection.getConfigByName('clientPort', 'zoo.cfg.xml');
  189. var atlasTls = App.configsCollection.getConfigByName('atlas.enableTLS', 'application-properties.xml');
  190. var atlasHttpPort = App.configsCollection.getConfigByName('atlas.server.http.port', 'application-properties.xml');
  191. var atlasHttpsPort = App.configsCollection.getConfigByName('atlas.server.https.port', 'application-properties.xml');
  192. if (hiveMetastore) dependencies['hive.metastore.uris'] = hiveMetastore.recommendedValue;
  193. if (clientPort) dependencies.clientPort = clientPort.recommendedValue;
  194. if (atlasTls) dependencies['atlas.enableTLS'] = atlasTls.recommendedValue;
  195. if (atlasHttpPort) dependencies['atlas.server.http.port'] = atlasHttpPort.recommendedValue;
  196. if (atlasHttpsPort) dependencies['atlas.server.https.port'] = atlasHttpsPort.recommendedValue;
  197. return dependencies;
  198. }.property(),
  199. /**
  200. * List of filters for config properties to populate filter combobox
  201. */
  202. propertyFilters: [
  203. {
  204. attributeName: 'isOverridden',
  205. attributeValue: true,
  206. caption: 'common.combobox.dropdown.overridden'
  207. },
  208. {
  209. attributeName: 'isFinal',
  210. attributeValue: true,
  211. caption: 'common.combobox.dropdown.final'
  212. },
  213. {
  214. attributeName: 'hasIssues',
  215. attributeValue: true,
  216. caption: 'common.combobox.dropdown.issues'
  217. }
  218. ],
  219. issuesFilterText: function () {
  220. return !this.get('transitionInProgress') && this.get('issuesFilterSelected') ?
  221. Em.I18n.t('installer.step7.showingPropertiesWithIssues') : '';
  222. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  223. /**
  224. * @type {string}
  225. */
  226. issuesFilterLinkText: function () {
  227. var issuesAttrSelected = this.get('issuesFilterSelected');
  228. if (!this.get('transitionInProgress')) {
  229. if (issuesAttrSelected) {
  230. return Em.I18n.t('installer.step7.showAllProperties');
  231. }
  232. if (this.get('hasStepConfigIssues')) {
  233. return Em.I18n.t('installer.step7.showPropertiesWithIssues');
  234. }
  235. }
  236. return '';
  237. }.property('isSubmitDisabled', 'submitButtonClicked', 'filterColumns.@each.selected'),
  238. /**
  239. * Dropdown menu items in filter combobox
  240. */
  241. filterColumns: function () {
  242. return this.get('propertyFilters').map(function (filter) {
  243. return Ember.Object.create({
  244. attributeName: filter.attributeName,
  245. attributeValue: filter.attributeValue,
  246. name: this.t(filter.caption),
  247. selected: false
  248. });
  249. }, this);
  250. }.property('propertyFilters'),
  251. /**
  252. * Clear controller's properties:
  253. * <ul>
  254. * <li>stepConfigs</li>
  255. * <li>filter</li>
  256. * </ul>
  257. * and deselect all <code>filterColumns</code>
  258. * @method clearStep
  259. */
  260. clearStep: function () {
  261. this.setProperties({
  262. configValidationGlobalMessage: [],
  263. submitButtonClicked: false,
  264. isSubmitDisabled: true,
  265. isRecommendedLoaded: false,
  266. initialRecommendations: []
  267. });
  268. this.get('stepConfigs').clear();
  269. this.set('filter', '');
  270. this.get('filterColumns').setEach('selected', false);
  271. },
  272. /**
  273. * Generate "finger-print" for current <code>stepConfigs[0]</code>
  274. * Used to determine, if user has some unsaved changes (comparing with <code>hash</code>)
  275. * @returns {string|null}
  276. * @method getHash
  277. */
  278. getHash: function () {
  279. if (!this.get('stepConfigs')[0]) {
  280. return null;
  281. }
  282. var hash = {};
  283. this.get('stepConfigs').forEach(function(stepConfig){
  284. stepConfig.configs.forEach(function (config) {
  285. hash[config.get('name')] = {value: config.get('value'), overrides: [], isFinal: config.get('isFinal')};
  286. if (!config.get('overrides')) return;
  287. if (!config.get('overrides.length')) return;
  288. config.get('overrides').forEach(function (override) {
  289. hash[config.get('name')].overrides.push(override.get('value'));
  290. });
  291. });
  292. });
  293. return JSON.stringify(hash);
  294. },
  295. /**
  296. * Are some changes available
  297. */
  298. hasChanges: function () {
  299. return this.get('hash') !== this.getHash();
  300. },
  301. /**
  302. * load all overrides for all config groups
  303. *
  304. * @returns {*|$.ajax}
  305. */
  306. loadOverrides: function() {
  307. return App.ajax.send({
  308. name: 'service.serviceConfigVersions.get.current.not.default',
  309. sender: this,
  310. success: 'parseOverrides'
  311. })
  312. },
  313. /**
  314. * add overriden configs to stepConfigs
  315. *
  316. * @param data
  317. */
  318. parseOverrides: function(data) {
  319. var self = this;
  320. data.items.forEach(function(group) {
  321. var stepConfig = self.get('stepConfigs').findProperty('serviceName', group.service_name),
  322. serviceConfigs = stepConfig.get('configs'),
  323. configGroup = App.ServiceConfigGroup.find().filterProperty('serviceName', group.service_name).findProperty('name', group.group_name);
  324. var isEditable = self.get('canEdit') && configGroup.get('name') === stepConfig.get('selectedConfigGroup.name');
  325. group.configurations.forEach(function (config) {
  326. for (var prop in config.properties) {
  327. var fileName = App.config.getOriginalFileName(config.type);
  328. var serviceConfig = serviceConfigs.filterProperty('name', prop).findProperty('filename', fileName);
  329. if (serviceConfig) {
  330. var value = App.config.formatPropertyValue(serviceConfig, config.properties[prop]);
  331. var isFinal = !!(config.properties_attributes && config.properties_attributes.final && config.properties_attributes.final[prop]);
  332. App.config.createOverride(serviceConfig, {
  333. "value": value,
  334. "savedValue": value,
  335. "isFinal": isFinal,
  336. "savedIsFinal": isFinal,
  337. "isEditable": isEditable
  338. }, configGroup);
  339. } else {
  340. serviceConfigs.push(App.config.createCustomGroupConfig({
  341. propertyName: prop,
  342. filename: fileName,
  343. value: config.properties[prop],
  344. savedValue: config.properties[prop],
  345. isEditable: isEditable
  346. }, configGroup));
  347. }
  348. }
  349. });
  350. });
  351. this.onLoadOverrides();
  352. },
  353. onLoadOverrides: function () {
  354. this.get('stepConfigs').forEach(function(stepConfig) {
  355. stepConfig.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', stepConfig.get('serviceName')));
  356. stepConfig.get('configGroups').filterProperty('isDefault', false).forEach(function (configGroup) {
  357. configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
  358. }, this);
  359. this.addOverride(stepConfig);
  360. // override if a property isRequired or not
  361. this.overrideConfigIsRequired(stepConfig);
  362. }, this);
  363. console.timeEnd('loadConfigGroups execution time: ');
  364. },
  365. /**
  366. * Set <code>isEditable</code>-property to <code>serviceConfigProperty</code>
  367. * Based on user's permissions and selected config group
  368. * @param {Ember.Object} serviceConfigProperty
  369. * @param {bool} defaultGroupSelected
  370. * @returns {Ember.Object} Updated config-object
  371. * @method _updateIsEditableFlagForConfig
  372. */
  373. _updateIsEditableFlagForConfig: function (serviceConfigProperty, defaultGroupSelected) {
  374. if (App.isAuthorized('AMBARI.ADD_DELETE_CLUSTERS')) {
  375. if (App.get('isKerberosEnabled') && serviceConfigProperty.get('isConfigIdentity')) {
  376. serviceConfigProperty.set('isEditable', false);
  377. } else if (defaultGroupSelected && !Em.get(serviceConfigProperty, 'group')) {
  378. if (serviceConfigProperty.get('serviceName') === 'MISC') {
  379. var service = App.config.get('serviceByConfigTypeMap')[App.config.getConfigTagFromFileName(serviceConfigProperty.get('filename'))];
  380. serviceConfigProperty.set('isEditable', service && !this.get('installedServiceNames').contains(service.get('serviceName')));
  381. } else {
  382. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isEditable') && serviceConfigProperty.get('isReconfigurable'));
  383. }
  384. } else if (!(Em.get(serviceConfigProperty, 'group') && Em.get(serviceConfigProperty, 'group.name') === this.get('selectedConfigGroup.name'))) {
  385. serviceConfigProperty.set('isEditable', false);
  386. }
  387. } else {
  388. serviceConfigProperty.set('isEditable', false);
  389. }
  390. return serviceConfigProperty;
  391. },
  392. /**
  393. * Set configs with overrides, recommended defaults to stepConfig
  394. * @param {Ember.Object} stepConfig
  395. * @method loadComponentConfigs
  396. */
  397. addOverride: function (stepConfig) {
  398. var overrideToAdd = this.get('overrideToAdd');
  399. if (overrideToAdd) {
  400. overrideToAdd = stepConfig.get('configs').filterProperty('filename', overrideToAdd.filename)
  401. .findProperty('name', overrideToAdd.name);
  402. if (overrideToAdd) {
  403. App.config.createOverride(overrideToAdd, {isEditable: true}, stepConfig.get('selectedConfigGroup'));
  404. this.set('overrideToAdd', null);
  405. }
  406. }
  407. },
  408. /**
  409. * On load function
  410. * @method loadStep
  411. */
  412. loadStep: function () {
  413. if (!this.get('isConfigsLoaded')) {
  414. return;
  415. }
  416. console.time('wizard loadStep: ');
  417. this.clearStep();
  418. var self = this;
  419. App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
  420. var configs = this.getInitialConfigs(this.get('content.serviceConfigProperties'));
  421. this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
  422. if (this.get('wizardController.name') === 'addServiceController' && !this.get('content.serviceConfigProperties.length')) {
  423. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
  424. configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
  425. self.applyServicesConfigs(configs);
  426. });
  427. } else {
  428. this.applyServicesConfigs(configs);
  429. }
  430. },
  431. /**
  432. * If configs are saved in store returns stored configs merged with stack
  433. * otherwise return stack configs
  434. * @returns {Object[]}
  435. */
  436. getInitialConfigs: function(storedConfigs) {
  437. if (storedConfigs && storedConfigs.length) {
  438. var mergedConfigs = [];
  439. storedConfigs.forEach(function (c) {
  440. mergedConfigs.push($.extend({}, App.configsCollection.getConfigByName(c.name, c.filename), c));
  441. });
  442. return mergedConfigs;
  443. }
  444. return App.configsCollection.getAll();
  445. },
  446. /**
  447. * Update hawq configuration depending on the state of the cluster
  448. * @param {Array} configs
  449. */
  450. updateHawqConfigs: function (configs) {
  451. if (this.get('wizardController.name') === 'addServiceController') {
  452. if (App.get('isHaEnabled')) this.addHawqConfigsOnNnHa(configs);
  453. if (App.get('isRMHaEnabled')) this.addHawqConfigsOnRMHa(configs);
  454. }
  455. if (this.get('content.hosts') && Object.keys(this.get('content.hosts')).length === 1) this.removeHawqStandbyHostAddressConfig(configs);
  456. return configs
  457. },
  458. /**
  459. * Remove hawq_standby_address_host config from HAWQ configs
  460. * @param {Array} configs
  461. */
  462. removeHawqStandbyHostAddressConfig: function(configs) {
  463. var hawqStandbyAddressHostIndex = configs.indexOf(configs.findProperty('name', 'hawq_standby_address_host'));
  464. if (hawqStandbyAddressHostIndex > -1) configs.removeAt(hawqStandbyAddressHostIndex) ;
  465. return configs
  466. },
  467. applyServicesConfigs: function (configs) {
  468. console.time('applyServicesConfigs execution time: ');
  469. if (!this.get('installedServiceNames').contains('HAWQ') && this.get('allSelectedServiceNames').contains('HAWQ')) {
  470. this.updateHawqConfigs(configs);
  471. }
  472. if (App.get('isKerberosEnabled') && this.get('wizardController.name') === 'addServiceController') {
  473. this.addKerberosDescriptorConfigs(configs, this.get('wizardController.kerberosDescriptorConfigs') || []);
  474. }
  475. App.configTheme.resolveConfigThemeConditions(configs);
  476. var stepConfigs = this.createStepConfigs();
  477. var serviceConfigs = this.renderConfigs(stepConfigs, configs);
  478. // if HA is enabled -> Make some reconfigurations
  479. if (this.get('wizardController.name') === 'addServiceController') {
  480. this.updateComponentActionConfigs(configs, serviceConfigs);
  481. if (App.get('isHaEnabled')) {
  482. serviceConfigs = this._reconfigureServicesOnNnHa(serviceConfigs);
  483. }
  484. }
  485. this.set('stepConfigs', serviceConfigs);
  486. this.checkHostOverrideInstaller();
  487. this.selectProperService();
  488. var rangerService = App.StackService.find().findProperty('serviceName', 'RANGER');
  489. if (rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected')) {
  490. App.config.removeRangerConfigs(this.get('stepConfigs'));
  491. }
  492. console.timeEnd('applyServicesConfigs execution time: ');
  493. console.time('loadConfigRecommendations execution time: ');
  494. this.loadConfigRecommendations(null, this.completeConfigLoading.bind(this));
  495. },
  496. /**
  497. *
  498. * Makes installed service's configs resulting into component actions (add/delete) non editable on Add Service Wizard
  499. * @param configs Object[]
  500. * @param stepConfigs Object[]
  501. * @private
  502. * @method updateComponentActionConfigs
  503. */
  504. updateComponentActionConfigs: function(configs, stepConfigs) {
  505. App.ConfigAction.find().forEach(function(item){
  506. var configName = item.get('configName');
  507. var fileName = item.get('fileName');
  508. var config = configs.filterProperty('filename', fileName).findProperty('name', configName);
  509. if (config) {
  510. var isServiceInstalled = App.Service.find().findProperty('serviceName', config.serviceName);
  511. // service already installed or is being added in add service wizard
  512. if (isServiceInstalled || stepConfigs.someProperty("serviceName", config.serviceName)) {
  513. var serviceConfigs = stepConfigs.findProperty('serviceName', config.serviceName).get('configs');
  514. var serviceConfig = serviceConfigs.filterProperty('filename', fileName).findProperty('name', configName);
  515. var notEditableText = " " + Em.I18n.t('installer.step7.addWizard.notEditable');
  516. serviceConfig.set('description', serviceConfig.get('description') + notEditableText);
  517. serviceConfig.set('isReconfigurable', false);
  518. serviceConfig.set('isEditable', false);
  519. serviceConfig.set('disabledAsComponentAction', true);
  520. config.isReconfigurable = false;
  521. config.isEditable = false;
  522. config.disabledAsComponentActio = true;
  523. }
  524. }
  525. }, this);
  526. },
  527. completeConfigLoading: function() {
  528. this.clearRecommendationsByServiceName(App.StackService.find().filter(function (s) {
  529. return s.get('isSelected') && !s.get('isInstalled');
  530. }).mapProperty('serviceName'));
  531. this.saveInitialRecommendations();
  532. this.set('isRecommendedLoaded', true);
  533. console.timeEnd('loadConfigRecommendations execution time: ');
  534. console.timeEnd('wizard loadStep: ');
  535. if (this.get('content.skipConfigStep')) {
  536. App.router.send('next');
  537. }
  538. this.set('hash', this.getHash());
  539. },
  540. /**
  541. * Update initialValues only while loading recommendations first time
  542. *
  543. * @param serviceName
  544. * @returns {boolean}
  545. * @override
  546. */
  547. updateInitialOnRecommendations: function(serviceName) {
  548. return this._super(serviceName) && !this.get('isRecommendedLoaded');
  549. },
  550. /**
  551. * Mark descriptor properties in configuration object.
  552. *
  553. * @param {Object[]} configs - config properties to change
  554. * @param {App.ServiceConfigProperty[]} descriptor - parsed kerberos descriptor
  555. * @method addKerberosDescriptorConfigs
  556. */
  557. addKerberosDescriptorConfigs: function (configs, descriptor) {
  558. descriptor.forEach(function (item) {
  559. var property = configs.findProperty('name', item.get('name'));
  560. if (property) {
  561. Em.setProperties(property, {
  562. isSecureConfig: true,
  563. displayName: Em.get(item, 'name'),
  564. isUserProperty: false,
  565. isOverridable: false,
  566. isConfigIdentity: Em.get(item, 'isConfigIdentity'),
  567. description: Em.get(item, 'isConfigIdentity')
  568. ? App.config.kerberosIdentitiesDescription(Em.get(property, 'description'))
  569. : Em.get(property, 'description'),
  570. category: 'Advanced ' + Em.get(item, 'filename')
  571. });
  572. }
  573. });
  574. },
  575. /**
  576. * Load config groups
  577. * and (if some services are already installed) load config groups for installed services
  578. * @method checkHostOverrideInstaller
  579. */
  580. checkHostOverrideInstaller: function () {
  581. if (this.get('wizardController.name') !== 'kerberosWizardController' && this.get('content.configGroups.length')) {
  582. this.restoreConfigGroups(this.get('content.configGroups'));
  583. } else {
  584. if (this.get('installedServiceNames').length > 0 && !this.get('wizardController.areInstalledConfigGroupsLoaded')) {
  585. console.time('loadConfigGroups execution time: ');
  586. this.loadConfigGroups(this.get('allSelectedServiceNames')).done(this.loadOverrides.bind(this));
  587. } else {
  588. App.store.commit();
  589. App.configGroupsMapper.map(null, false, this.get('allSelectedServiceNames'));
  590. this.onLoadOverrides();
  591. }
  592. }
  593. },
  594. /**
  595. * Create stepConfigs array with all info except configs list
  596. *
  597. * @return {Object[]}
  598. * @method createStepConfigs
  599. */
  600. createStepConfigs: function() {
  601. var stepConfigs = [];
  602. App.config.get('preDefinedServiceConfigs').forEach(function (service) {
  603. var serviceName = service.get('serviceName');
  604. if (['MISC'].concat(this.get('allSelectedServiceNames')).contains(serviceName)) {
  605. var serviceConfig = App.config.createServiceConfig(serviceName);
  606. serviceConfig.set('showConfig', App.StackService.find(serviceName).get('isInstallable'));
  607. if (this.get('wizardController.name') === 'addServiceController') {
  608. serviceConfig.set('selected', !this.get('installedServiceNames').concat('MISC').contains(serviceName));
  609. if (serviceName === 'MISC') {
  610. serviceConfig.set('configCategories', serviceConfig.get('configCategories').rejectProperty('name', 'Notifications'));
  611. }
  612. } else if (this.get('wizardController.name') === 'kerberosWizardController') {
  613. serviceConfig.set('showConfig', true);
  614. }
  615. stepConfigs.pushObject(serviceConfig);
  616. }
  617. }, this);
  618. return stepConfigs;
  619. },
  620. /**
  621. * For Namenode HA, HAWQ service requires additional config parameters in hdfs-client.xml
  622. * This method ensures that these additional parameters are added to hdfs-client.xml
  623. * @param configs existing configs on cluster
  624. * @returns {Object[]} existing configs + additional config parameters in hdfs-client.xml
  625. */
  626. addHawqConfigsOnNnHa: function(configs) {
  627. var nameService = configs.findProperty('id', App.config.configId('dfs.nameservices', 'hdfs-site')).value;
  628. var propertyNames = [
  629. 'dfs.nameservices',
  630. 'dfs.ha.namenodes.' + nameService,
  631. 'dfs.namenode.rpc-address.'+ nameService +'.nn1',
  632. 'dfs.namenode.rpc-address.'+ nameService +'.nn2',
  633. 'dfs.namenode.http-address.'+ nameService +'.nn1',
  634. 'dfs.namenode.http-address.'+ nameService +'.nn2'
  635. ];
  636. propertyNames.forEach(function(propertyName, propertyIndex) {
  637. var propertyFromHdfs = configs.findProperty('id', App.config.configId(propertyName, 'hdfs-site'));
  638. var newProperty = App.config.createDefaultConfig(propertyName, 'hdfs-client.xml', true);
  639. Em.setProperties(newProperty, {
  640. serviceName: 'HAWQ',
  641. description: propertyFromHdfs.description,
  642. displayName: propertyFromHdfs.displayName,
  643. displayType: 'string',
  644. index: propertyIndex,
  645. isOverridable: false,
  646. isReconfigurable: false,
  647. value: propertyFromHdfs.value,
  648. recommendedValue: propertyFromHdfs.recommendedValue
  649. });
  650. configs.push(App.ServiceConfigProperty.create(newProperty));
  651. });
  652. return configs;
  653. },
  654. /**
  655. * For ResourceManager HA, HAWQ service requires additional config parameters in yarn-client.xml
  656. * This method ensures that these additional parameters are added to yarn-client.xml
  657. * @param configs existing configs on cluster
  658. * @returns {Object[]} existing configs + additional config parameters in yarn-client.xml
  659. */
  660. addHawqConfigsOnRMHa: function(configs) {
  661. var rmHost1 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm1', 'yarn-site')).value ;
  662. var rmHost2 = configs.findProperty('id', App.config.configId('yarn.resourcemanager.hostname.rm2', 'yarn-site')).value ;
  663. var yarnConfigToBeAdded = [
  664. {
  665. name: 'yarn.resourcemanager.ha',
  666. displayName: 'yarn.resourcemanager.ha',
  667. description: 'Comma separated yarn resourcemanager host addresses with port',
  668. port: '8032'
  669. },
  670. {
  671. name: 'yarn.resourcemanager.scheduler.ha',
  672. displayName: 'yarn.resourcemanager.scheduler.ha',
  673. description: 'Comma separated yarn resourcemanager scheduler addresses with port',
  674. port: '8030'
  675. }
  676. ];
  677. yarnConfigToBeAdded.forEach(function(propertyDetails) {
  678. var newProperty = App.config.createDefaultConfig(propertyDetails.name, 'yarn-client.xml', true);
  679. var value = rmHost1 + ':' + propertyDetails.port + ',' + rmHost2 + ':' + propertyDetails.port;
  680. Em.setProperties(newProperty, {
  681. serviceName: 'HAWQ',
  682. description: propertyDetails.description,
  683. displayName: propertyDetails.displayName,
  684. isOverridable: false,
  685. isReconfigurable: false,
  686. value: value,
  687. recommendedValue: value
  688. });
  689. configs.push(App.ServiceConfigProperty.create(newProperty));
  690. });
  691. return configs;
  692. },
  693. /**
  694. * render configs, distribute them by service
  695. * and wrap each in ServiceConfigProperty object
  696. * @param stepConfigs
  697. * @param configs
  698. * @return {App.ServiceConfig[]}
  699. */
  700. renderConfigs: function (stepConfigs, configs) {
  701. var localDB = {
  702. hosts: this.get('wizardController.content.hosts'),
  703. masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
  704. slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts'),
  705. selectedStack: {}
  706. };
  707. var selectedRepoVersion,
  708. repoVersion;
  709. if (this.get('wizardController.name') === 'addServiceController') {
  710. repoVersion = App.RepositoryVersion.find().filter(function(i) {
  711. return i.get('stackVersionType') === App.get('currentStackName') &&
  712. i.get('stackVersionNumber') === App.get('currentStackVersionNumber');
  713. })[0];
  714. if (repoVersion) {
  715. selectedRepoVersion = Em.get(repoVersion, 'repositoryVersion').split('-')[0];
  716. }
  717. } else {
  718. selectedRepoVersion = Em.getWithDefault(App.Stack.find().findProperty('isSelected', true) || {}, 'repositoryVersion', false);
  719. }
  720. if (selectedRepoVersion) {
  721. localDB.selectedStack = selectedRepoVersion;
  722. }
  723. var configsByService = {}, dependencies = this.get('configDependencies');
  724. configs.forEach(function (_config) {
  725. if (!configsByService[_config.serviceName]) {
  726. configsByService[_config.serviceName] = [];
  727. }
  728. var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
  729. this.updateHostOverrides(serviceConfigProperty, _config);
  730. if (this.get('wizardController.name') === 'addServiceController') {
  731. this._updateIsEditableFlagForConfig(serviceConfigProperty, true);
  732. }
  733. if (!this.get('content.serviceConfigProperties.length') && !serviceConfigProperty.get('hasInitialValue')) {
  734. App.ConfigInitializer.initialValue(serviceConfigProperty, localDB, dependencies);
  735. }
  736. configsByService[_config.serviceName].pushObject(serviceConfigProperty);
  737. }, this);
  738. stepConfigs.forEach(function (service) {
  739. if (service.get('serviceName') === 'YARN') {
  740. configsByService[service.get('serviceName')] = App.config.addYarnCapacityScheduler(configsByService[service.get('serviceName')]);
  741. }
  742. service.set('configs', configsByService[service.get('serviceName')] || []);
  743. if (['addServiceController', 'installerController'].contains(this.get('wizardController.name'))) {
  744. this.addHostNamesToConfigs(service, localDB.masterComponentHosts, localDB.slaveComponentHosts);
  745. }
  746. }, this);
  747. return stepConfigs;
  748. },
  749. /**
  750. * Add host name properties to appropriate categories (for installer and add service)
  751. *
  752. * @param {Object} serviceConfig
  753. * @param {Object[]} masterComponents - info from localStorage
  754. * @param {Object[]} slaveComponents - info from localStorage
  755. */
  756. addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) {
  757. serviceConfig.get('configCategories').forEach(function(c) {
  758. if (c.showHost) {
  759. var componentName = c.name;
  760. var value = this.getComponentHostValue(componentName, masterComponents, slaveComponents);
  761. var stackComponent = App.StackServiceComponent.find(componentName);
  762. var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
  763. var newConfigName = Em.get(hProperty, 'name');
  764. if (!serviceConfig.get('configs').someProperty('name', newConfigName)) {
  765. serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
  766. }
  767. }
  768. }, this);
  769. },
  770. /**
  771. * Method to get host for master or slave component
  772. *
  773. * @param componentName
  774. * @param masterComponents
  775. * @param slaveComponents
  776. * @returns {Array}
  777. */
  778. getComponentHostValue: function(componentName, masterComponents, slaveComponents) {
  779. var value = [];
  780. var masters = masterComponents && masterComponents.filterProperty('component', componentName);
  781. if (masters.length) {
  782. value = masters.mapProperty('hostName');
  783. } else {
  784. var slaves = slaveComponents && slaveComponents.findProperty('componentName', componentName);
  785. if (slaves) {
  786. value = slaves.hosts.mapProperty('hostName');
  787. }
  788. }
  789. return value || [];
  790. },
  791. /**
  792. * create new child configs from overrides, attach them to parent config
  793. * override - value of config, related to particular host(s)
  794. * @param configProperty
  795. * @param storedConfigProperty
  796. */
  797. updateHostOverrides: function (configProperty, storedConfigProperty) {
  798. if (!Em.isEmpty(storedConfigProperty.overrides)) {
  799. var overrides = [];
  800. storedConfigProperty.overrides.forEach(function (overrideEntry) {
  801. // create new override with new value
  802. var newSCP = App.ServiceConfigProperty.create(configProperty);
  803. newSCP.set('value', overrideEntry.value);
  804. newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
  805. newSCP.set('parentSCP', configProperty);
  806. overrides.pushObject(newSCP);
  807. });
  808. configProperty.set('overrides', overrides);
  809. }
  810. },
  811. /**
  812. * When NameNode HA is enabled some configs based on <code>dfs.nameservices</code> should be changed
  813. * This happens only if service is added AFTER NN HA is enabled
  814. *
  815. * @param {App.ServiceConfig[]} serviceConfigs
  816. * @method _reconfigureServiceOnNnHa
  817. * @private
  818. * @returns {App.ServiceConfig[]}
  819. */
  820. _reconfigureServicesOnNnHa: function (serviceConfigs) {
  821. var selectedServiceNames = this.get('selectedServiceNames');
  822. var nameServiceId = serviceConfigs.findProperty('serviceName', 'HDFS').configs.findProperty('name', 'dfs.nameservices');
  823. if (nameServiceId) {
  824. Em.A([
  825. {
  826. serviceName: 'HBASE',
  827. configToUpdate: 'hbase.rootdir'
  828. },
  829. {
  830. serviceName: 'ACCUMULO',
  831. configToUpdate: 'instance.volumes'
  832. },
  833. {
  834. serviceName: 'HAWQ',
  835. configToUpdate: 'hawq_dfs_url',
  836. regexPattern: /(^.*:[0-9]+)(?=\/)/,
  837. replacementValue: nameServiceId.get('value')
  838. }
  839. ]).forEach(function (c) {
  840. if (selectedServiceNames.contains(c.serviceName) && nameServiceId) {
  841. var cfg = serviceConfigs.findProperty('serviceName', c.serviceName).configs.findProperty('name', c.configToUpdate);
  842. var regexPattern = /\/\/.*:[0-9]+/i;
  843. var replacementValue = '//' + nameServiceId.get('value');
  844. if (!Em.isNone(c.regexPattern) && !Em.isNone(c.replacementValue)) {
  845. regexPattern = c.regexPattern;
  846. replacementValue = c.replacementValue;
  847. }
  848. var newValue = cfg.get('value').replace(regexPattern, replacementValue);
  849. cfg.setProperties({
  850. value: newValue,
  851. recommendedValue: newValue
  852. });
  853. }
  854. });
  855. }
  856. return serviceConfigs;
  857. },
  858. /**
  859. * Select first addable service for <code>addServiceWizard</code>
  860. * Select first service at all in other cases
  861. * @method selectProperService
  862. */
  863. selectProperService: function () {
  864. if (this.get('wizardController.name') === 'addServiceController') {
  865. this.set('selectedService', this.get('stepConfigs').filterProperty('selected', true).get('firstObject'));
  866. } else {
  867. this.set('selectedService', this.get('stepConfigs').filterProperty('showConfig', true).objectAt(0));
  868. }
  869. },
  870. /**
  871. * Load config tags
  872. * @return {$.ajax|null}
  873. * @method getConfigTags
  874. */
  875. getConfigTags: function () {
  876. this.set('isAppliedConfigLoaded', false);
  877. return App.ajax.send({
  878. name: 'config.tags',
  879. sender: this,
  880. success: 'getConfigTagsSuccess'
  881. });
  882. },
  883. /**
  884. * Success callback for config tags request
  885. * Updates <code>serviceConfigTags</code> with tags received from server
  886. * @param {object} data
  887. * @method getConfigTagsSuccess
  888. */
  889. getConfigTagsSuccess: function (data) {
  890. var installedServiceSites = [];
  891. App.StackService.find().filterProperty('isInstalled').forEach(function (service) {
  892. if (!service.get('configTypes')) return;
  893. var configTypes = Object.keys(service.get('configTypes'));
  894. installedServiceSites = installedServiceSites.concat(configTypes);
  895. }, this);
  896. installedServiceSites = installedServiceSites.uniq();
  897. var serviceConfigTags = [];
  898. for (var site in data.Clusters.desired_configs) {
  899. if (data.Clusters.desired_configs.hasOwnProperty(site)) {
  900. if (installedServiceSites.contains(site) || site === 'cluster-env') {
  901. serviceConfigTags.push({
  902. siteName: site,
  903. tagName: data.Clusters.desired_configs[site].tag,
  904. newTagName: null
  905. });
  906. }
  907. }
  908. }
  909. this.set('serviceConfigTags', serviceConfigTags);
  910. this.set('isAppliedConfigLoaded', true);
  911. },
  912. /**
  913. * set configs actual values from server
  914. * @param configs
  915. * @param configsByTags
  916. * @param installedServiceNames
  917. * @method setInstalledServiceConfigs
  918. */
  919. setInstalledServiceConfigs: function (configs, configsByTags, installedServiceNames) {
  920. var configsMap = {};
  921. configsByTags.forEach(function (configSite) {
  922. configsMap[configSite.type] = configSite.properties || {};
  923. });
  924. var allConfigs = configs.filter(function (_config) {
  925. // filter out alert_notification configs on add service //TODO find better place for this!
  926. if (_config.filename === 'alert_notification') return false;
  927. if (['MISC'].concat(installedServiceNames).contains(_config.serviceName)) {
  928. var type = _config.filename ? App.config.getConfigTagFromFileName(_config.filename) : null;
  929. var mappedConfigValue = type && configsMap[type] ? configsMap[type][_config.name] : null;
  930. if (Em.isNone(mappedConfigValue)) {
  931. //for now ranger plugin properties are not sending by recommendations if they are missed - it should be added
  932. return _config.serviceName === 'MISC' || /^ranger-/.test(_config.filename);
  933. }
  934. if (_config.savedValue != mappedConfigValue) {
  935. _config.savedValue = App.config.formatPropertyValue(_config, mappedConfigValue);
  936. }
  937. _config.value = App.config.formatPropertyValue(_config, mappedConfigValue);
  938. _config.hasInitialValue = true;
  939. this.updateDependencies(_config);
  940. delete configsMap[type][_config.name];
  941. return true;
  942. }
  943. return true;
  944. }, this);
  945. //add user properties
  946. Em.keys(configsMap).forEach(function (filename) {
  947. Em.keys(configsMap[filename]).forEach(function (propertyName) {
  948. allConfigs.push(App.config.createDefaultConfig(propertyName, App.config.getOriginalFileName(filename), false, {
  949. value: configsMap[filename][propertyName],
  950. savedValue: configsMap[filename][propertyName],
  951. hasInitialValue: true
  952. }));
  953. });
  954. });
  955. return allConfigs;
  956. },
  957. /**
  958. * update dependencies according to current config value
  959. *
  960. * @param config
  961. */
  962. updateDependencies: function(config) {
  963. if (config.filename === 'hive-site.xml') {
  964. if (config.name === 'hive.metastore.uris') {
  965. this.get('configDependencies')['hive.metastore.uris'] = config.savedValue;
  966. }
  967. else
  968. if (config.name === 'clientPort') {
  969. this.get('configDependencies').clientPort = config.savedValue;
  970. }
  971. }
  972. if (config.filename === 'application-properties.xml') {
  973. if (this.get('configDependencies').hasOwnProperty(config.name)) {
  974. this.get('configDependencies')[config.name] = config.savedValue;
  975. }
  976. }
  977. },
  978. /**
  979. * Add group ids to <code>groupsToDelete</code>
  980. * Also save <code>groupsToDelete</code> to local storage
  981. * @param {Ember.Object[]} groups
  982. * @method setGroupsToDelete
  983. */
  984. setGroupsToDelete: function (groups) {
  985. var groupsToDelete = this.get('groupsToDelete');
  986. groups.forEach(function (group) {
  987. if (!group.get('isTemporary')) {
  988. groupsToDelete.push({
  989. id: group.get('id')
  990. });
  991. }
  992. });
  993. this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
  994. },
  995. /**
  996. * Update <code>configGroups</code> with selected service configGroups
  997. * Also set default group to first position
  998. * Update <code>selectedConfigGroup</code> with new default group
  999. * @method selectedServiceObserver
  1000. */
  1001. selectedServiceObserver: function () {
  1002. if (this.get('selectedService') && this.get('selectedService.serviceName') !== 'MISC') {
  1003. var serviceGroups = this.get('selectedService.configGroups');
  1004. serviceGroups.forEach(function (item, index, array) {
  1005. if (item.isDefault) {
  1006. array.unshift(item);
  1007. array.splice(index + 1, 1);
  1008. }
  1009. });
  1010. this.set('configGroups', serviceGroups);
  1011. this.set('selectedConfigGroup', serviceGroups.findProperty('isDefault'));
  1012. }
  1013. }.observes('selectedService.configGroups.[]'),
  1014. /**
  1015. * load default groups for each service in case of initial load
  1016. * @param serviceConfigGroups
  1017. * @method restoreConfigGroups
  1018. */
  1019. restoreConfigGroups: function (serviceConfigGroups) {
  1020. var services = this.get('stepConfigs');
  1021. services.forEach(function (service) {
  1022. if (service.get('serviceName') === 'MISC') return;
  1023. var serviceRawGroups = serviceConfigGroups.filterProperty('service_name', service.serviceName);
  1024. if (serviceRawGroups.length) {
  1025. App.store.commit();
  1026. App.store.loadMany(App.ServiceConfigGroup, serviceRawGroups);
  1027. App.store.commit();
  1028. serviceRawGroups.forEach(function(item){
  1029. var modelGroup = App.ServiceConfigGroup.find(item.id);
  1030. modelGroup.set('properties', []);
  1031. item.properties.forEach(function (propertyData) {
  1032. var overriddenSCP, parentSCP = service.configs.filterProperty('filename', propertyData.filename).findProperty('name', propertyData.name);
  1033. if (parentSCP) {
  1034. App.config.createOverride(parentSCP, propertyData, modelGroup)
  1035. } else {
  1036. overriddenSCP = App.config.createCustomGroupConfig({
  1037. propertyName: propertyData.name,
  1038. filename: propertyData.filename,
  1039. value: propertyData.value,
  1040. savedValue: propertyData.value,
  1041. isEditable: false
  1042. }, modelGroup);
  1043. this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP);
  1044. }
  1045. }, this);
  1046. }, this);
  1047. service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
  1048. }
  1049. }, this);
  1050. },
  1051. /**
  1052. * Click-handler on config-group to make it selected
  1053. * @param {object} event
  1054. * @method selectConfigGroup
  1055. */
  1056. selectConfigGroup: function (event) {
  1057. this.set('selectedConfigGroup', event.context);
  1058. },
  1059. /**
  1060. * Rebuild list of configs switch of config group:
  1061. * on default - display all configs from default group and configs from non-default groups as disabled
  1062. * on non-default - display all from default group as disabled and configs from selected non-default group
  1063. * @method switchConfigGroupConfigs
  1064. */
  1065. switchConfigGroupConfigs: function () {
  1066. var serviceConfigs = this.get('selectedService.configs'),
  1067. selectedGroup = this.get('selectedConfigGroup'),
  1068. overrides = [];
  1069. if (!selectedGroup) return;
  1070. var displayedConfigGroups = this._getDisplayedConfigGroups();
  1071. displayedConfigGroups.forEach(function (group) {
  1072. overrides.pushObjects(group.get('properties'));
  1073. });
  1074. serviceConfigs.forEach(function (config) {
  1075. this._setEditableValue(config);
  1076. this._setOverrides(config, overrides);
  1077. }, this);
  1078. }.observes('selectedConfigGroup'),
  1079. /**
  1080. * Get list of config groups to display
  1081. * Returns empty array if no <code>selectedConfigGroup</code>
  1082. * @return {Array}
  1083. * @method _getDisplayedConfigGroups
  1084. */
  1085. _getDisplayedConfigGroups: function () {
  1086. var selectedGroup = this.get('selectedConfigGroup');
  1087. if (!selectedGroup) return [];
  1088. return selectedGroup.get('isDefault') ?
  1089. this.get('selectedService.configGroups').filterProperty('isDefault', false) :
  1090. [this.get('selectedConfigGroup')];
  1091. },
  1092. /**
  1093. * Set <code>isEditable</code> property to <code>config</code>
  1094. * @param {Ember.Object} config
  1095. * @return {Ember.Object} updated config-object
  1096. * @method _setEditableValue
  1097. */
  1098. _setEditableValue: function (config) {
  1099. var selectedGroup = this.get('selectedConfigGroup');
  1100. if (!selectedGroup) return config;
  1101. if (App.get('isKerberosEnabled') && config.get('isConfigIdentity')) {
  1102. config.set('isEditable', false);
  1103. } else {
  1104. var isEditable = config.get('isEditable'),
  1105. isServiceInstalled = this.get('installedServiceNames').contains(this.get('selectedService.serviceName'));
  1106. if (isServiceInstalled) {
  1107. isEditable = config.get('isReconfigurable') && selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
  1108. } else {
  1109. isEditable = selectedGroup.get('isDefault') && !config.get('disabledAsComponentAction');
  1110. }
  1111. if (config.get('group')) {
  1112. isEditable = config.get('group.name') === this.get('selectedConfigGroup.name');
  1113. }
  1114. config.set('isEditable', isEditable);
  1115. }
  1116. return config;
  1117. },
  1118. /**
  1119. * Set <code>overrides</code> property to <code>config</code>
  1120. * @param {Ember.Object} config
  1121. * @param {Ember.Enumerable} overrides
  1122. * @returns {Ember.Object}
  1123. * @method _setOverrides
  1124. */
  1125. _setOverrides: function (config, overrides) {
  1126. if (config.get('group')) return config;
  1127. var selectedGroup = this.get('selectedConfigGroup'),
  1128. overrideToAdd = this.get('overrideToAdd'),
  1129. configOverrides = overrides.filterProperty('id', config.get('id'));
  1130. if (!selectedGroup) return config;
  1131. if (overrideToAdd && overrideToAdd.get('id') === config.get('id')) {
  1132. var valueForOverride = (config.get('widget') || config.get('displayType') === 'checkbox') ? config.get('value') : '';
  1133. var group = this.get('selectedService.configGroups').findProperty('name', selectedGroup.get('name'));
  1134. var newSCP = App.config.createOverride(config, {value: valueForOverride, recommendedValue: valueForOverride}, group);
  1135. configOverrides.push(newSCP);
  1136. this.set('overrideToAdd', null);
  1137. }
  1138. configOverrides.setEach('isEditable', !selectedGroup.get('isDefault'));
  1139. configOverrides.setEach('parentSCP', config);
  1140. config.set('overrides', configOverrides);
  1141. return config;
  1142. },
  1143. /**
  1144. * @param serviceName
  1145. * @returns {boolean}
  1146. * @override
  1147. */
  1148. useInitialValue: function(serviceName) {
  1149. return !App.Service.find(serviceName).get('serviceName', serviceName);
  1150. },
  1151. /**
  1152. *
  1153. * @param parentProperties
  1154. * @param name
  1155. * @param fileName
  1156. * @returns {*}
  1157. * @override
  1158. */
  1159. allowUpdateProperty: function(parentProperties, name, fileName) {
  1160. if (name.contains('proxyuser')) return true;
  1161. if (['installerController'].contains(this.get('wizardController.name')) || !!(parentProperties && parentProperties.length)) {
  1162. return true;
  1163. } else if (['addServiceController'].contains(this.get('wizardController.name'))) {
  1164. var stackProperty = App.configsCollection.getConfigByName(name, fileName);
  1165. if (!stackProperty || !this.get('installedServices')[stackProperty.serviceName]) {
  1166. return true;
  1167. } else if (stackProperty.propertyDependsOn.length) {
  1168. return !!stackProperty.propertyDependsOn.filter(function (p) {
  1169. var service = App.config.get('serviceByConfigTypeMap')[p.type];
  1170. return service && !this.get('installedServices')[service.get('serviceName')];
  1171. }, this).length;
  1172. } else {
  1173. return false;
  1174. }
  1175. }
  1176. return true;
  1177. },
  1178. /**
  1179. * remove config based on recommendations
  1180. * @param config
  1181. * @param configsCollection
  1182. * @param parentProperties
  1183. * @protected
  1184. * @override
  1185. */
  1186. _removeConfigByRecommendation: function (config, configsCollection, parentProperties) {
  1187. this._super(config, configsCollection, parentProperties);
  1188. /**
  1189. * need to update wizard info when removing configs for installed services;
  1190. */
  1191. var installedServices = this.get('installedServices'), wizardController = this.get('wizardController'),
  1192. fileNamesToUpdate = wizardController ? wizardController.getDBProperty('fileNamesToUpdate') || [] : [],
  1193. fileName = Em.get(config, 'filename'), serviceName = Em.get(config, 'serviceName');
  1194. var modifiedFileNames = this.get('modifiedFileNames');
  1195. if (modifiedFileNames && !modifiedFileNames.contains(fileName)) {
  1196. modifiedFileNames.push(fileName);
  1197. } else if (wizardController && installedServices[serviceName]) {
  1198. if (!fileNamesToUpdate.contains(fileName)) {
  1199. fileNamesToUpdate.push(fileName);
  1200. }
  1201. }
  1202. if (wizardController) {
  1203. wizardController.setDBProperty('fileNamesToUpdate', fileNamesToUpdate.uniq());
  1204. }
  1205. },
  1206. /**
  1207. * @method manageConfigurationGroup
  1208. */
  1209. manageConfigurationGroup: function () {
  1210. App.router.get('manageConfigGroupsController').manageConfigurationGroups(this);
  1211. },
  1212. /**
  1213. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1214. * @return {$.ajax|null}
  1215. * @method checkMySQLHost
  1216. */
  1217. checkMySQLHost: function () {
  1218. // get ambari database type and hostname
  1219. return App.ajax.send({
  1220. name: 'ambari.service',
  1221. data: {
  1222. fields : "?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database_name,hostComponents/RootServiceHostComponents/properties/server.jdbc.url,hostComponents/RootServiceHostComponents/properties/server.jdbc.database"
  1223. },
  1224. sender: this,
  1225. success: 'getAmbariDatabaseSuccess'
  1226. });
  1227. },
  1228. /**
  1229. * Success callback for ambari database, get Ambari DB type and DB server hostname, then
  1230. * Check whether hive New MySQL database is on the same host as Ambari server MySQL server
  1231. * @param {object} data
  1232. * @method getAmbariDatabaseSuccess
  1233. */
  1234. getAmbariDatabaseSuccess: function (data) {
  1235. var ambariServerDBType = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.properties', {})['server.jdbc.database'],
  1236. ambariServerHostName = Em.getWithDefault(data.hostComponents, '0.RootServiceHostComponents.host_name', false),
  1237. hiveConnectionURL = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'javax.jdo.option.ConnectionURL', 'hive-site.xml') || {}, 'value', '');
  1238. if (ambariServerHostName) {
  1239. this.set('mySQLServerConflict', ambariServerDBType.contains('mysql') && hiveConnectionURL.contains(ambariServerHostName));
  1240. } else {
  1241. this.set('mySQLServerConflict', false);
  1242. }
  1243. },
  1244. /**
  1245. * Check if new MySql database was chosen for Hive service
  1246. * and it is not located on the same host as Ambari server
  1247. * that using MySql database too.
  1248. *
  1249. * @method resolveHiveMysqlDatabase
  1250. */
  1251. resolveHiveMysqlDatabase: function () {
  1252. var hiveService = this.get('content.services').findProperty('serviceName', 'HIVE');
  1253. if (!hiveService || !hiveService.get('isSelected') || hiveService.get('isInstalled')) {
  1254. return this.moveNext();
  1255. }
  1256. var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value;
  1257. if (hiveDBType === 'New MySQL Database') {
  1258. var self = this;
  1259. return this.checkMySQLHost().done(function () {
  1260. self.mySQLWarningHandler();
  1261. });
  1262. }
  1263. return this.moveNext();
  1264. },
  1265. /**
  1266. * Show warning popup about MySQL-DB issues (on post-submit)
  1267. *
  1268. * @returns {*}
  1269. * @method mySQLWarningHandler
  1270. */
  1271. mySQLWarningHandler: function () {
  1272. var self = this;
  1273. if (this.get('mySQLServerConflict')) {
  1274. // error popup before you can proceed
  1275. return App.ModalPopup.show({
  1276. header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
  1277. body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
  1278. secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
  1279. primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
  1280. encodeBody: false,
  1281. onPrimary: function () {
  1282. this._super();
  1283. self.set('submitButtonClicked', false);
  1284. },
  1285. onSecondary: function () {
  1286. var parent = this;
  1287. return App.ModalPopup.show({
  1288. header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
  1289. body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
  1290. onPrimary: function () {
  1291. this.hide();
  1292. parent.hide();
  1293. // go back to step 5: assign masters and disable default navigation warning
  1294. if ('installerController' === self.get('content.controllerName')) {
  1295. App.router.get('installerController').gotoStep(5, true);
  1296. }
  1297. else {
  1298. if ('addServiceController' === self.get('content.controllerName')) {
  1299. App.router.get('addServiceController').gotoStep(2, true);
  1300. }
  1301. }
  1302. },
  1303. onSecondary: function () {
  1304. this._super();
  1305. self.set('submitButtonClicked', false);
  1306. }
  1307. });
  1308. }
  1309. });
  1310. }
  1311. return this.moveNext();
  1312. },
  1313. checkDatabaseConnectionTest: function () {
  1314. var deferred = $.Deferred();
  1315. var configMap = [
  1316. {
  1317. serviceName: 'OOZIE',
  1318. ignored: [Em.I18n.t('installer.step7.oozie.database.new')]
  1319. },
  1320. {
  1321. serviceName: 'HIVE',
  1322. ignored: [Em.I18n.t('installer.step7.hive.database.new.mysql'), Em.I18n.t('installer.step7.hive.database.new.postgres')]
  1323. }
  1324. ];
  1325. configMap.forEach(function (config) {
  1326. var isConnectionNotTested = false;
  1327. var service = this.get('content.services').findProperty('serviceName', config.serviceName);
  1328. if (service && service.get('isSelected') && !service.get('isInstalled')) {
  1329. var serviceConfigs = this.get('stepConfigs').findProperty('serviceName', config.serviceName).configs;
  1330. var serviceDatabase = serviceConfigs.findProperty('name', config.serviceName.toLowerCase() + '_database').get('value');
  1331. if (!config.ignored.contains(serviceDatabase)) {
  1332. var filledProperties = App.db.get('tmp', config.serviceName + '_connection');
  1333. if (!filledProperties || App.isEmptyObject(filledProperties)) {
  1334. isConnectionNotTested = true;
  1335. } else {
  1336. for (var key in filledProperties) {
  1337. if (serviceConfigs.findProperty('name', key).get('value') !== filledProperties[key])
  1338. isConnectionNotTested = true;
  1339. }
  1340. }
  1341. }
  1342. }
  1343. config.isCheckIgnored = isConnectionNotTested;
  1344. }, this);
  1345. var ignoredServices = configMap.filterProperty('isCheckIgnored', true);
  1346. if (ignoredServices.length) {
  1347. var displayedServiceNames = ignoredServices.mapProperty('serviceName').map(function (serviceName) {
  1348. return this.get('content.services').findProperty('serviceName', serviceName).get('displayName');
  1349. }, this);
  1350. this.showDatabaseConnectionWarningPopup(displayedServiceNames, deferred);
  1351. }
  1352. else {
  1353. deferred.resolve();
  1354. }
  1355. return deferred;
  1356. },
  1357. showChangesWarningPopup: function(goToNextStep) {
  1358. return App.ModalPopup.show({
  1359. header: Em.I18n.t('common.warning'),
  1360. body: Em.I18n.t('services.service.config.exitChangesPopup.body'),
  1361. secondary: Em.I18n.t('common.cancel'),
  1362. primary: Em.I18n.t('yes'),
  1363. onPrimary: function () {
  1364. if (goToNextStep) {
  1365. goToNextStep();
  1366. this.hide();
  1367. }
  1368. },
  1369. onSecondary: function () {
  1370. this.hide();
  1371. }
  1372. });
  1373. },
  1374. showDatabaseConnectionWarningPopup: function (serviceNames, deferred) {
  1375. var self = this;
  1376. return App.ModalPopup.show({
  1377. header: Em.I18n.t('installer.step7.popup.database.connection.header'),
  1378. body: Em.I18n.t('installer.step7.popup.database.connection.body').format(serviceNames.join(', ')),
  1379. secondary: Em.I18n.t('common.cancel'),
  1380. primary: Em.I18n.t('common.proceedAnyway'),
  1381. onPrimary: function () {
  1382. deferred.resolve();
  1383. this._super();
  1384. },
  1385. onClose: function () {
  1386. this.onSecondary();
  1387. },
  1388. onSecondary: function () {
  1389. this._super();
  1390. self.set('submitButtonClicked', false);
  1391. App.set('router.nextBtnClickInProgress', false);
  1392. deferred.reject();
  1393. }
  1394. });
  1395. },
  1396. showOozieDerbyWarningPopup: function(callback) {
  1397. var self = this;
  1398. if (this.get('selectedServiceNames').contains('OOZIE')) {
  1399. var databaseType = Em.getWithDefault(App.config.findConfigProperty(this.get('stepConfigs'), 'oozie_database', 'oozie-env.xml') || {}, 'value', '');
  1400. if (databaseType === Em.I18n.t('installer.step7.oozie.database.new')) {
  1401. return App.ModalPopup.show({
  1402. header: Em.I18n.t('common.warning'),
  1403. body: Em.I18n.t('installer.step7.popup.oozie.derby.warning'),
  1404. secondary: Em.I18n.t('common.cancel'),
  1405. primary: Em.I18n.t('common.proceedAnyway'),
  1406. onPrimary: function() {
  1407. this.hide();
  1408. if (callback) {
  1409. callback();
  1410. }
  1411. },
  1412. onSecondary: function() {
  1413. App.set('router.nextBtnClickInProgress', false);
  1414. self.set('submitButtonClicked', false);
  1415. this.hide();
  1416. },
  1417. onClose: function() {
  1418. this.onSecondary();
  1419. }
  1420. });
  1421. }
  1422. }
  1423. if (callback) {
  1424. callback();
  1425. }
  1426. return false;
  1427. },
  1428. /**
  1429. * Proceed to the next step
  1430. **/
  1431. moveNext: function () {
  1432. App.set('router.nextBtnClickInProgress', false);
  1433. App.router.send('next');
  1434. this.set('submitButtonClicked', false);
  1435. },
  1436. /**
  1437. * Click-handler on Next button
  1438. * Disable "Submit"-button while server-side processes are running
  1439. * @method submit
  1440. */
  1441. submit: function () {
  1442. if (this.get('isSubmitDisabled') || App.get('router.nextBtnClickInProgress')) {
  1443. return false;
  1444. }
  1445. App.set('router.nextBtnClickInProgress', true);
  1446. if (this.get('supportsPreInstallChecks')) {
  1447. var preInstallChecksController = App.router.get('preInstallChecksController');
  1448. if (preInstallChecksController.get('preInstallChecksWhereRun')) {
  1449. return this.postSubmit();
  1450. }
  1451. return preInstallChecksController.notRunChecksWarnPopup(this.postSubmit.bind(this));
  1452. }
  1453. return this.postSubmit();
  1454. },
  1455. postSubmit: function () {
  1456. var self = this;
  1457. this.set('submitButtonClicked', true);
  1458. this.serverSideValidation().done(function() {
  1459. self.serverSideValidationCallback();
  1460. })
  1461. .fail(function (value) {
  1462. if ("invalid_configs" === value) {
  1463. self.set('submitButtonClicked', false);
  1464. App.set('router.nextBtnClickInProgress', false);
  1465. } else {
  1466. // Failed due to validation mechanism failure.
  1467. // Should proceed with other checks
  1468. self.serverSideValidationCallback();
  1469. }
  1470. });
  1471. },
  1472. /**
  1473. * @method serverSideValidationCallback
  1474. */
  1475. serverSideValidationCallback: function() {
  1476. var self = this;
  1477. this.showOozieDerbyWarningPopup(function() {
  1478. self.checkDatabaseConnectionTest().done(function () {
  1479. self.resolveHiveMysqlDatabase();
  1480. });
  1481. });
  1482. },
  1483. toggleIssuesFilter: function () {
  1484. var errorServices = [],
  1485. issueServices = [];
  1486. this.get('filterColumns').findProperty('attributeName', 'hasIssues').toggleProperty('selected');
  1487. // if currently selected service does not have issue, jump to the first service with issue.
  1488. if (this.get('selectedService.errorCount') === 0 )
  1489. {
  1490. this.get('stepConfigs').filterProperty('showConfig', true).forEach(function(service) {
  1491. if (service.get('errorCount') > 0) errorServices.push(service);
  1492. if (service.get('hasConfigIssues') === true) issueServices.push(service);
  1493. });
  1494. if (errorServices.length === 0 && issueServices.length === 0) return;
  1495. this.switchToService(errorServices.length > 0 ? errorServices[0] : issueServices[0]);
  1496. }
  1497. },
  1498. switchToService: function(service) {
  1499. this.set('selectedService', service);
  1500. $('a[href="#' + service.serviceName + '"]').tab('show');
  1501. },
  1502. issuesFilterSelected: function() {
  1503. return this.get('filterColumns').findProperty('attributeName', 'hasIssues').get('selected');
  1504. }.property('filterColumns.@each.selected'),
  1505. hasStepConfigIssues: function() {
  1506. return !this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('hasConfigIssues', false);
  1507. }.property('stepConfigs.@each.hasConfigIssues')
  1508. });