step7_controller.js 58 KB

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