step7_controller.js 57 KB

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