step7_controller.js 59 KB

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