step7_controller.js 57 KB

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