configs.js 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417
  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. require('controllers/wizard/slave_component_groups_controller');
  20. var batchUtils = require('utils/batch_scheduled_requests');
  21. App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.PreloadRequestsChainMixin, App.ThemesMappingMixin, App.VersionsMappingMixin, App.ConfigsSaverMixin, {
  22. name: 'mainServiceInfoConfigsController',
  23. isHostsConfigsPage: false,
  24. forceTransition: false,
  25. isRecommendedLoaded: true,
  26. dataIsLoaded: false,
  27. stepConfigs: [], //contains all field properties that are viewed in this service
  28. selectedService: null,
  29. serviceConfigTags: null,
  30. selectedConfigGroup: null,
  31. requestInProgress: null,
  32. selectedServiceConfigTypes: [],
  33. selectedServiceSupportsFinal: [],
  34. /**
  35. * config groups for current service
  36. * @type {App.ConfigGroup[]}
  37. */
  38. configGroups: [],
  39. allConfigs: [],
  40. uiConfigs: [],
  41. /**
  42. * Determines if save configs is in progress
  43. * @type {boolean}
  44. */
  45. saveInProgress: false,
  46. isCompareMode: false,
  47. compareServiceVersion: null,
  48. preSelectedConfigVersion: null,
  49. /**
  50. * contain Service Config Property, when user proceed from Select Config Group dialog
  51. */
  52. overrideToAdd: null,
  53. /**
  54. * version of default config group, configs of which currently applied
  55. */
  56. currentDefaultVersion: null,
  57. /**
  58. * version selected to view
  59. */
  60. selectedVersion: null,
  61. /**
  62. * note passed on configs save
  63. * @type {string}
  64. */
  65. serviceConfigVersionNote: '',
  66. versionLoaded: false,
  67. /**
  68. * current cluster-env version
  69. * @type {string}
  70. */
  71. clusterEnvTagVersion: '',
  72. /**
  73. * defines which service configs need to be loaded to stepConfigs
  74. * @type {string[]}
  75. */
  76. servicesToLoad: function() {
  77. return this.get('dependentServiceNames').concat([this.get('content.serviceName')]).uniq();
  78. }.property('content.serviceName', 'dependentServiceNames'),
  79. /**
  80. * defines which config groups need to be loaded
  81. * @type {object[]}
  82. */
  83. configGroupsToLoad: function() {
  84. return this.get('configGroups').concat(this.get('dependentConfigGroups')).uniq();
  85. }.property('content.serviceName', 'dependentServiceNames'),
  86. /**
  87. * configs from stack for dependent services
  88. * @type {App.StackConfigProperty[]}
  89. */
  90. advancedConfigs: function() {
  91. return App.StackConfigProperty.find().filter(function(scp) {
  92. return this.get('servicesToLoad').contains(scp.get('serviceName'));
  93. }, this);
  94. }.property('content.serviceName'),
  95. /**
  96. * @type {boolean}
  97. */
  98. isCurrentSelected: function () {
  99. return App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + this.get('selectedVersion')).get('isCurrent');
  100. }.property('selectedVersion', 'content.serviceName', 'dataIsLoaded'),
  101. /**
  102. * @type {boolean}
  103. */
  104. canEdit: function () {
  105. return this.get('isCurrentSelected') && !this.get('isCompareMode');
  106. }.property('isCurrentSelected', 'isCompareMode'),
  107. serviceConfigs: function () {
  108. return App.config.get('preDefinedServiceConfigs');
  109. }.property('App.config.preDefinedServiceConfigs'),
  110. configMapping: function () {
  111. return App.config.get('configMapping');
  112. }.property('App.config.configMapping'),
  113. configs: function () {
  114. return App.config.get('preDefinedSiteProperties');
  115. }.property('App.config.preDefinedSiteProperties'),
  116. secureConfigs: require('data/HDP2/secure_mapping'),
  117. showConfigHistoryFeature: true,
  118. /**
  119. * Map, which contains relation between group and site
  120. * to upload overridden properties
  121. * @type {object}
  122. */
  123. loadedGroupToOverrideSiteToTagMap: {},
  124. /**
  125. * During page load time the cluster level site to tag
  126. * mapping is stored here.
  127. *
  128. * Example:
  129. * {
  130. * 'hdfs-site': 'version1',
  131. * 'core-site': 'version1'
  132. * }
  133. */
  134. loadedClusterSiteToTagMap: {},
  135. /**
  136. * Number of errors in the configs in the selected service (only for AdvancedTab if App supports Enhanced Configs)
  137. * @type {number}
  138. */
  139. errorsCount: function () {
  140. return this.get('selectedService.configs').filter(function (config) {
  141. return Em.isNone(config.get('widget'));
  142. }).filter(function(config) {
  143. return !config.get('isValid') || (config.get('overrides') || []).someProperty('isValid', false);
  144. }).filterProperty('isVisible').length;
  145. }.property('selectedService.configs.@each.isValid', 'selectedService.configs.@each.overrideErrorTrigger'),
  146. /**
  147. * Determines if Save-button should be disabled
  148. * Disabled if some configs have invalid values or save-process currently in progress
  149. * @type {boolean}
  150. */
  151. isSubmitDisabled: function () {
  152. return (!(this.get('stepConfigs').everyProperty('errorCount', 0)) || this.get('saveInProgress'));
  153. }.property('stepConfigs.@each.errorCount', 'saveInProgress'),
  154. /**
  155. * Determines if some config value is changed
  156. * @type {boolean}
  157. */
  158. isPropertiesChanged: function(){
  159. return this.get('stepConfigs').someProperty('isPropertiesChanged', true);
  160. }.property('stepConfigs.@each.isPropertiesChanged'),
  161. slaveComponentGroups: null,
  162. /**
  163. * Filter text will be located here
  164. * @type {string}
  165. */
  166. filter: '',
  167. /**
  168. * List of filters for config properties to populate filter combobox
  169. * @type {{attributeName: string, attributeValue: boolean, caption: string}[]}
  170. */
  171. propertyFilters: [
  172. {
  173. attributeName: 'isOverridden',
  174. attributeValue: true,
  175. caption: 'common.combobox.dropdown.overridden'
  176. },
  177. {
  178. attributeName: 'isFinal',
  179. attributeValue: true,
  180. caption: 'common.combobox.dropdown.final'
  181. },
  182. {
  183. attributeName: 'hasCompareDiffs',
  184. attributeValue: true,
  185. caption: 'common.combobox.dropdown.changed',
  186. dependentOn: 'isCompareMode'
  187. },
  188. {
  189. attributeName: 'hasIssues',
  190. attributeValue: true,
  191. caption: 'common.combobox.dropdown.issues'
  192. }
  193. ],
  194. /**
  195. * Dropdown menu items in filter combobox
  196. * @type {{attributeName: string, attributeValue: string, name: string, selected: boolean}[]}
  197. */
  198. filterColumns: function () {
  199. var filterColumns = [];
  200. this.get('propertyFilters').forEach(function(filter) {
  201. if (Em.isNone(filter.dependentOn) || this.get(filter.dependentOn)) {
  202. filterColumns.push(Ember.Object.create({
  203. attributeName: filter.attributeName,
  204. attributeValue: filter.attributeValue,
  205. name: this.t(filter.caption),
  206. selected: filter.dependentOn ? this.get(filter.dependentOn) : false
  207. }));
  208. }
  209. }, this);
  210. return filterColumns;
  211. }.property('propertyFilters', 'isCompareMode'),
  212. /**
  213. * indicate whether service config version belongs to default config group
  214. * @param {object} version
  215. * @return {Boolean}
  216. * @private
  217. * @method isVersionDefault
  218. */
  219. isVersionDefault: function(version) {
  220. return (App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + version).get('groupId') == -1);
  221. },
  222. /**
  223. * register request to view to track his progress
  224. * @param {$.ajax} request
  225. * @method trackRequest
  226. */
  227. trackRequest: function (request) {
  228. this.set('requestInProgress', request);
  229. },
  230. /**
  231. * clear and set properties to default value
  232. * @method clearStep
  233. */
  234. clearStep: function () {
  235. if (this.get('requestInProgress') && this.get('requestInProgress').readyState !== 4) {
  236. this.get('requestInProgress').abort();
  237. this.set('requestInProgress', null);
  238. }
  239. this.clearSaveInfo();
  240. this.setProperties({
  241. saveInProgress: false,
  242. isInit: true,
  243. hash: null,
  244. forceTransition: false,
  245. dataIsLoaded: false,
  246. versionLoaded: false,
  247. filter: '',
  248. loadedGroupToOverrideSiteToTagMap: {},
  249. serviceConfigVersionNote: ''
  250. });
  251. this.get('filterColumns').setEach('selected', false);
  252. this.get('stepConfigs').clear();
  253. this.get('allConfigs').clear();
  254. this.get('uiConfigs').clear();
  255. if (this.get('serviceConfigTags')) {
  256. this.set('serviceConfigTags', null);
  257. }
  258. },
  259. /**
  260. * @type {object[]}
  261. */
  262. serviceConfigProperties: function () {
  263. return App.db.getServiceConfigProperties();
  264. }.property('content'),
  265. /**
  266. * "Finger-print" of the <code>stepConfigs</code>. Filled after first configGroup selecting
  267. * Used to determine if some changes were made (when user navigates away from this page)
  268. * @type {String|null}
  269. */
  270. hash: null,
  271. /**
  272. * Is this initial config group changing
  273. * @type {Boolean}
  274. */
  275. isInit: true,
  276. /**
  277. * On load function
  278. * @method loadStep
  279. */
  280. loadStep: function () {
  281. console.log("TRACE: Loading configure for service");
  282. var serviceName = this.get('content.serviceName');
  283. this.clearStep();
  284. if (App.get('isClusterSupportsEnhancedConfigs')) {
  285. this.setDependentServices(serviceName);
  286. this.loadConfigTheme(serviceName).always(function() {
  287. App.themesMapper.generateAdvancedTabs([serviceName]);
  288. });
  289. }
  290. this.loadClusterEnvSite();
  291. },
  292. /**
  293. * Generate "finger-print" for current <code>stepConfigs[0]</code>
  294. * Used to determine, if user has some unsaved changes (comparing with <code>hash</code>)
  295. * @returns {string|null}
  296. * @method getHash
  297. */
  298. getHash: function () {
  299. if (!this.get('stepConfigs')[0]) {
  300. return null;
  301. }
  302. var hash = {};
  303. this.get('stepConfigs')[0].configs.forEach(function (config) {
  304. hash[config.get('name')] = {value: config.get('value'), overrides: [], isFinal: config.get('isFinal')};
  305. if (!config.get('overrides')) return;
  306. if (!config.get('overrides.length')) return;
  307. config.get('overrides').forEach(function (override) {
  308. hash[config.get('name')].overrides.push(override.get('value'));
  309. });
  310. });
  311. return JSON.stringify(hash);
  312. },
  313. /**
  314. * Update configs on the page after <code>selectedConfigGroup</code> is changed
  315. * @method onConfigGroupChange
  316. */
  317. onConfigGroupChange: function () {
  318. console.time('!!!!!!!!!');
  319. var self = this;
  320. this.get('stepConfigs').clear();
  321. var selectedConfigGroup = this.get('selectedConfigGroup');
  322. var serviceName = this.get('content.serviceName');
  323. //STEP 1: handle tags from JSON data for host overrides
  324. var configGroupsWithOverrides = selectedConfigGroup.get('isDefault') && !this.get('isHostsConfigsPage') ? this.get('configGroupsToLoad') : [selectedConfigGroup].concat(this.get('dependentConfigGroups'));
  325. configGroupsWithOverrides.forEach(function (item) {
  326. var groupName = item.get('name');
  327. if (Em.isNone(this.loadedGroupToOverrideSiteToTagMap[groupName])) {
  328. this.loadedGroupToOverrideSiteToTagMap[groupName] = {};
  329. item.get('configSiteTags').forEach(function (siteTag) {
  330. var site = siteTag.get('site');
  331. this.loadedGroupToOverrideSiteToTagMap[groupName][site] = siteTag.get('tag');
  332. }, this);
  333. }
  334. }, this);
  335. //STEP 2: Create an array of objects defining tag names to be polled and new tag names to be set after submit
  336. this.setServiceConfigTags(this.loadedClusterSiteToTagMap);
  337. //STEP 4: Load on-site config by service from server
  338. App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function(configGroups){
  339. //Merge on-site configs with pre-defined
  340. var configSet = App.config.mergePreDefinedWithLoaded(configGroups, self.get('advancedConfigs'), self.get('serviceConfigTags'), serviceName);
  341. configSet = App.config.syncOrderWithPredefined(configSet);
  342. var configs = configSet.configs;
  343. /**
  344. * if property defined in stack but somehow it missed from cluster properties (can be after stack upgrade)
  345. * ui should add this properties to step configs
  346. */
  347. configs = self.mergeWithStackProperties(configs);
  348. //put properties from capacity-scheduler.xml into one config with textarea view
  349. if (self.get('content.serviceName') === 'YARN') {
  350. var configsToSkip = self.get('advancedConfigs').filterProperty('filename', 'capacity-scheduler.xml').filterProperty('subSection');
  351. configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml', configsToSkip);
  352. }
  353. self.set('allConfigs', configs);
  354. //add configs as names of host components
  355. self.addHostNamesToConfig();
  356. //load configs of version being compared against
  357. self.loadCompareVersionConfigs(self.get('allConfigs')).done(function (isComparison) {
  358. //Load and add overridden configs of group
  359. if (!isComparison && (!self.get('selectedConfigGroup').get('isDefault') || self.get('isCurrentSelected'))) {
  360. App.config.loadServiceConfigGroupOverrides(self.get('allConfigs'), self.get('loadedGroupToOverrideSiteToTagMap'), self.get('configGroupsToLoad'), self.onLoadOverrides, self);
  361. } else {
  362. self.onLoadOverrides(self.get('allConfigs'));
  363. }
  364. console.timeEnd('!!!!!!!!!');
  365. });
  366. });
  367. }.observes('selectedConfigGroup'),
  368. /**
  369. * adds properties form stack that doesn't belong to cluster
  370. * to step configs
  371. * also set recommended value if isn't exists
  372. *
  373. * @return {App.ServiceConfigProperty[]}
  374. * @method mergeWithStackProperties
  375. */
  376. mergeWithStackProperties: function(configs) {
  377. this.get('advancedConfigs').forEach(function(advanced) {
  378. var c = configs.findProperty('name', advanced.get('name'));
  379. if (c) {
  380. if (!c.get('recommendedValue')) {
  381. c.set('recommendedValue', advanced.get('value'));
  382. }
  383. } else if (advanced.get('widget')) {
  384. configs.pushObject(App.ServiceConfigProperty.create({
  385. name: advanced.get('name'),
  386. displayName: advanced.get('displayName'),
  387. value: advanced.get('value'),
  388. savedValue: null,
  389. filename: advanced.get('fileName'),
  390. isUserProperty: false,
  391. isNotSaved: true,
  392. recommendedValue: advanced.get('value'),
  393. isFinal: advanced.get('isFinal'),
  394. recommendedIsFinal: advanced.get('recommendedIsFinal'),
  395. serviceName: advanced.get('serviceName'),
  396. supportsFinal: advanced.get('supportsFinal'),
  397. category: 'Advanced ' + App.config.getConfigTagFromFileName(advanced.get('fileName')),
  398. widget: advanced.get('widget')
  399. }));
  400. }
  401. });
  402. return configs;
  403. },
  404. /**
  405. * load version configs for comparison
  406. * @param allConfigs
  407. * @return {object}
  408. * @private
  409. * @method loadCompareVersionConfigs
  410. */
  411. loadCompareVersionConfigs: function (allConfigs) {
  412. var dfd = $.Deferred();
  413. var self = this;
  414. var compareServiceVersions = [];
  415. if (this.get('compareServiceVersion')) {
  416. if (!this.isVersionDefault(this.get('compareServiceVersion').get('version'))) {
  417. compareServiceVersions = [this.get('compareServiceVersion').get('version'), this.get('selectedVersion')];
  418. } else {
  419. compareServiceVersions = [this.get('compareServiceVersion').get('version')];
  420. }
  421. this.getCompareVersionConfigs(compareServiceVersions).done(function (json) {
  422. self.initCompareConfig(allConfigs, json);
  423. self.set('compareServiceVersion', null);
  424. self.set('isCompareMode', true);
  425. dfd.resolve(true);
  426. }).fail(function () {
  427. self.set('compareServiceVersion', null);
  428. dfd.resolve(true);
  429. });
  430. } else {
  431. self.set('isCompareMode', false);
  432. allConfigs.setEach('isComparison', false);
  433. dfd.resolve(false);
  434. }
  435. return dfd.promise();
  436. },
  437. /**
  438. * attach analogical config to each property for comparison
  439. * @param allConfigs
  440. * @param json
  441. * @private
  442. * @method initCompareConfig
  443. */
  444. initCompareConfig: function(allConfigs, json) {
  445. var serviceVersionMap = {};
  446. var configNamesMap = {};
  447. var serviceName = this.get('content.serviceName');
  448. var compareVersionNumber = this.get('compareServiceVersion').get('version');
  449. //indicate whether compared versions are from non-default group
  450. var compareNonDefaultVersions = (json.items.length > 1);
  451. serviceVersionMap[compareVersionNumber] = {};
  452. if (compareNonDefaultVersions) {
  453. serviceVersionMap[this.get('selectedVersion')] = {};
  454. }
  455. allConfigs.mapProperty('name').forEach(function(name) {
  456. configNamesMap[name] = true;
  457. });
  458. json.items.forEach(function (item) {
  459. item.configurations.forEach(function (configuration) {
  460. if (serviceName == 'YARN' && configuration.type == 'capacity-scheduler') {
  461. // put all properties in a single textarea for capacity-scheduler
  462. var value = '';
  463. for (var prop in configuration.properties) {
  464. value += prop + '=' + configuration.properties[prop] + '\n';
  465. }
  466. serviceVersionMap[item.service_config_version][configuration.type + '-' + configuration.type] = {
  467. name: configuration.type,
  468. value: value,
  469. type: configuration.type,
  470. tag: configuration.tag,
  471. version: configuration.version,
  472. service_config_version: item.service_config_version
  473. };
  474. } else {
  475. for (var prop in configuration.properties) {
  476. serviceVersionMap[item.service_config_version][prop + '-' + configuration.type] = {
  477. name: prop,
  478. value: configuration.properties[prop],
  479. type: configuration.type,
  480. tag: configuration.tag,
  481. version: configuration.version,
  482. service_config_version: item.service_config_version
  483. };
  484. if (Em.isNone(configNamesMap[prop])) {
  485. allConfigs.push(this.getMockConfig(prop, serviceName, App.config.getOriginalFileName(configuration.type)));
  486. }
  487. }
  488. }
  489. if (configuration.properties_attributes && configuration.properties_attributes.final) {
  490. for (var final in configuration.properties_attributes.final) {
  491. serviceVersionMap[item.service_config_version][final + '-' + configuration.type].isFinal = (configuration.properties_attributes.final[final] === 'true');
  492. }
  493. }
  494. }, this);
  495. }, this);
  496. if (compareNonDefaultVersions) {
  497. allConfigs.forEach(function (serviceConfig) {
  498. this.setCompareConfigs(serviceConfig, serviceVersionMap, compareVersionNumber, this.get('selectedVersion'));
  499. }, this);
  500. } else {
  501. allConfigs.forEach(function (serviceConfig) {
  502. var serviceCfgVersionMap = serviceVersionMap[this.get('compareServiceVersion').get('version')];
  503. var compareConfig = serviceCfgVersionMap[serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)]
  504. this.setCompareDefaultGroupConfig(serviceConfig, compareConfig);
  505. }, this);
  506. }
  507. },
  508. /**
  509. * set compare properties to service config of non-default group
  510. * @param serviceConfig
  511. * @param serviceVersionMap
  512. * @param compareVersion
  513. * @param selectedVersion
  514. * @private
  515. * @method setCompareConfigs
  516. */
  517. setCompareConfigs: function (serviceConfig, serviceVersionMap, compareVersion, selectedVersion) {
  518. var compareConfig = serviceVersionMap[compareVersion][serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)];
  519. var selectedConfig = serviceVersionMap[selectedVersion][serviceConfig.name + '-' + App.config.getConfigTagFromFileName(serviceConfig.filename)];
  520. serviceConfig.compareConfigs = [];
  521. serviceConfig.isComparison = true;
  522. if (compareConfig && selectedConfig) {
  523. serviceConfig.compareConfigs.push(this.getComparisonConfig(serviceConfig, compareConfig));
  524. serviceConfig.compareConfigs.push(this.getComparisonConfig(serviceConfig, selectedConfig));
  525. serviceConfig.hasCompareDiffs = this.hasCompareDiffs(serviceConfig.compareConfigs[0], serviceConfig.compareConfigs[1]);
  526. } else if (compareConfig && !selectedConfig) {
  527. serviceConfig.compareConfigs.push(this.getComparisonConfig(serviceConfig, compareConfig));
  528. serviceConfig.compareConfigs.push(this.getMockComparisonConfig(selectedConfig, selectedVersion));
  529. serviceConfig.hasCompareDiffs = true;
  530. } else if (!compareConfig && selectedConfig) {
  531. serviceConfig.compareConfigs.push(this.getMockComparisonConfig(selectedConfig, compareVersion));
  532. serviceConfig.compareConfigs.push(this.getComparisonConfig(serviceConfig, selectedConfig));
  533. serviceConfig.hasCompareDiffs = true;
  534. }
  535. },
  536. /**
  537. * init attributes and wrap mock compare config into App.ServiceConfigProperty
  538. * @param serviceConfig
  539. * @param compareServiceVersion
  540. * @return {object}
  541. * @private
  542. * @method getMockComparisonConfig
  543. */
  544. getMockComparisonConfig: function (serviceConfig, compareServiceVersion) {
  545. var compareObject = $.extend(true, {isComparison: false}, serviceConfig);
  546. compareObject.isEditable = false;
  547. compareObject.serviceVersion = App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + compareServiceVersion);
  548. compareObject.isMock = true;
  549. compareObject.displayType = 'label';
  550. compareObject = App.ServiceConfigProperty.create(compareObject);
  551. compareObject.set('value', Em.I18n.t('common.property.undefined'));
  552. return compareObject;
  553. },
  554. /**
  555. * init attributes and wrap compare config into App.ServiceConfigProperty
  556. * @param serviceConfig
  557. * @param compareConfig
  558. * @return {object}
  559. * @private
  560. * @method getComparisonConfig
  561. */
  562. getComparisonConfig: function (serviceConfig, compareConfig) {
  563. var compareObject = $.extend(true, {isComparison: false, isOriginalSCP: false}, serviceConfig);
  564. compareObject.isEditable = false;
  565. if (compareConfig) {
  566. if (serviceConfig.isMock) {
  567. compareObject.displayType = 'string';
  568. compareObject.isMock = false;
  569. }
  570. compareObject.serviceVersion = App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + compareConfig.service_config_version);
  571. compareObject = App.ServiceConfigProperty.create(compareObject);
  572. compareObject.set('isFinal', compareConfig.isFinal);
  573. compareObject.set('value', App.config.formatOverrideValue(serviceConfig, compareConfig.value));
  574. compareObject.set('compareConfigs', null);
  575. }
  576. return compareObject;
  577. },
  578. /**
  579. * set compare properties to service config of default group
  580. * @param serviceConfig
  581. * @param compareConfig
  582. * @private
  583. * @method setCompareDefaultGroupConfig
  584. */
  585. setCompareDefaultGroupConfig: function (serviceConfig, compareConfig) {
  586. var compareObject = {};
  587. serviceConfig.compareConfigs = [];
  588. serviceConfig.isComparison = true;
  589. //if config isn't reconfigurable then it can't have changed value to compare
  590. if (compareConfig && (serviceConfig.isReconfigurable || serviceConfig.isUserProperty)) {
  591. compareObject = this.getComparisonConfig(serviceConfig, compareConfig);
  592. serviceConfig.hasCompareDiffs = serviceConfig.isMock || this.hasCompareDiffs(serviceConfig, compareObject);
  593. serviceConfig.compareConfigs.push(compareObject);
  594. } else if (serviceConfig.isUserProperty) {
  595. serviceConfig.compareConfigs.push(this.getMockComparisonConfig(serviceConfig, this.get('compareServiceVersion.version')));
  596. serviceConfig.hasCompareDiffs = true;
  597. }
  598. return serviceConfig;
  599. },
  600. /**
  601. * check value and final attribute of original and compare config for differencies
  602. * @param originalConfig
  603. * @param compareConfig
  604. * @return {Boolean}
  605. * @private
  606. * @method hasCompareDiffs
  607. */
  608. hasCompareDiffs: function (originalConfig, compareConfig) {
  609. return (originalConfig.value !== compareConfig.value) || (!!originalConfig.isFinal !== (compareConfig.isFinal == true));
  610. },
  611. /**
  612. * generate mock config object
  613. * @param name
  614. * @param serviceName
  615. * @param filename
  616. * @return {Object}
  617. * @private
  618. * @method getMockConfig
  619. */
  620. getMockConfig: function (name, serviceName, filename) {
  621. var undefinedConfig = {
  622. description: name,
  623. displayName: name,
  624. id: "site property",
  625. isOverridable: false,
  626. isReconfigurable: false,
  627. isRequired: false,
  628. isRequiredByAgent: false,
  629. isSecureConfig: false,
  630. isUserProperty: true,
  631. isVisible: true,
  632. name: name,
  633. filename: filename,
  634. serviceName: serviceName,
  635. value: Em.I18n.t('common.property.undefined'),
  636. isMock: true,
  637. displayType: 'label'
  638. };
  639. var category = App.config.identifyCategory(undefinedConfig);
  640. undefinedConfig.category = category && category.name;
  641. return undefinedConfig;
  642. },
  643. /**
  644. * get configs of chosen version from server to compare
  645. * @param compareServiceVersions
  646. * @return {$.ajax}
  647. * @private
  648. * @method getCompareVersionConfigs
  649. */
  650. getCompareVersionConfigs: function (compareServiceVersions) {
  651. this.set('versionLoaded', false);
  652. return App.ajax.send({
  653. name: 'service.serviceConfigVersions.get.multiple',
  654. sender: this,
  655. data: {
  656. serviceName: this.get('content.serviceName'),
  657. serviceConfigVersions: compareServiceVersions
  658. }
  659. });
  660. },
  661. /**
  662. * @param serviceConfig
  663. * @private
  664. * @method checkDatabaseProperties
  665. */
  666. checkDatabaseProperties: function (serviceConfig) {
  667. this.hideHiveDatabaseProperties(serviceConfig.configs);
  668. this.hideOozieDatabaseProperties(serviceConfig.configs);
  669. },
  670. /**
  671. * @param configs
  672. * @private
  673. * @method hideHiveDatabaseProperties
  674. */
  675. hideHiveDatabaseProperties: function (configs) {
  676. if (!['HIVE'].contains(this.get('content.serviceName'))) return;
  677. var property = configs.findProperty('name', 'hive_hostname');
  678. if (property) property.set('isVisible', false);
  679. if (configs.someProperty('name', 'hive_database')) {
  680. var hiveDb = configs.findProperty('name', 'hive_database');
  681. if (hiveDb.value === 'Existing MSSQL Server database with integrated authentication') {
  682. configs.findProperty('name', 'javax.jdo.option.ConnectionUserName').setProperties({
  683. isVisible: false,
  684. isRequired: false
  685. });
  686. configs.findProperty('name', 'javax.jdo.option.ConnectionPassword').setProperties({
  687. isVisible: false,
  688. isRequired: false
  689. });
  690. }
  691. }
  692. },
  693. /**
  694. * @param configs
  695. * @private
  696. * @method hideOozieDatabaseProperties
  697. */
  698. hideOozieDatabaseProperties: function (configs) {
  699. if (!['OOZIE'].contains(this.get('content.serviceName'))) return;
  700. var property = configs.findProperty('name', 'oozie_hostname');
  701. if (property) property.set('isVisible', false);
  702. if (configs.someProperty('name', 'oozie_database')) {
  703. var oozieDb = configs.findProperty('name', 'oozie_database');
  704. if (oozieDb.value === 'Existing MSSQL Server database with integrated authentication') {
  705. configs.findProperty('name', 'oozie.service.JPAService.jdbc.username').setProperties({
  706. isVisible: false,
  707. isRequired: false
  708. });
  709. configs.findProperty('name', 'oozie.service.JPAService.jdbc.password').setProperties({
  710. isVisible: false,
  711. isRequired: false
  712. });
  713. }
  714. }
  715. },
  716. /**
  717. * @param allConfigs
  718. * @private
  719. * @method onLoadOverrides
  720. */
  721. onLoadOverrides: function (allConfigs) {
  722. var self = this;
  723. var serviceNames = this.get('servicesToLoad');
  724. serviceNames.forEach(function(serviceName) {
  725. var serviceConfig = App.config.createServiceConfig(serviceName);
  726. //Make SecondaryNameNode invisible on enabling namenode HA
  727. if (serviceConfig.get('serviceName') === 'HDFS') {
  728. App.config.OnNnHAHideSnn(serviceConfig);
  729. }
  730. var configsByService = this.get('allConfigs').filterProperty('serviceName', serviceName);
  731. this.loadConfigs(configsByService, serviceConfig);
  732. this.get('stepConfigs').pushObject(serviceConfig);
  733. }, this);
  734. var selectedService = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName'));
  735. this.set('selectedService', selectedService);
  736. this.setVisibilityForRangerProperties(selectedService);
  737. this.checkOverrideProperty(selectedService);
  738. this.checkDatabaseProperties(selectedService);
  739. this.checkForSecureConfig(this.get('selectedService'));
  740. this.getRecommendationsForDependencies(null, true, function() {
  741. self.setProperties({
  742. dataIsLoaded: true,
  743. versionLoaded: true,
  744. hash: self.getHash(),
  745. isInit: false
  746. });
  747. });
  748. },
  749. /**
  750. * Changes format from Object to Array
  751. *
  752. * {
  753. * 'core-site': 'version1',
  754. * 'hdfs-site': 'version1',
  755. * ...
  756. * }
  757. *
  758. * to
  759. *
  760. * [
  761. * {
  762. * siteName: 'core-site',
  763. * tagName: 'version1',
  764. * newTageName: null
  765. * },
  766. * ...
  767. * ]
  768. *
  769. * set tagnames for configuration of the *-site.xml
  770. * @private
  771. * @method setServiceConfigTags
  772. */
  773. setServiceConfigTags: function (desiredConfigsSiteTags) {
  774. console.debug("setServiceConfigTags(): Trying to set ", desiredConfigsSiteTags);
  775. var newServiceConfigTags = [];
  776. for (var index in desiredConfigsSiteTags) {
  777. newServiceConfigTags.pushObject({
  778. siteName: index,
  779. tagName: desiredConfigsSiteTags[index],
  780. newTagName: null
  781. }, this);
  782. }
  783. console.debug("setServiceConfigTags(): Setting 'serviceConfigTags' to ", newServiceConfigTags);
  784. this.set('serviceConfigTags', newServiceConfigTags);
  785. },
  786. /**
  787. * check whether the config property is a security related knob
  788. * @param serviceConfig
  789. * @private
  790. * @method checkForSecureConfig
  791. */
  792. checkForSecureConfig: function (serviceConfig) {
  793. serviceConfig.get('configs').forEach(function (_config) {
  794. this.get('secureConfigs').forEach(function (_secureConfig) {
  795. if (_config.get('name') === _secureConfig.name) {
  796. _config.set('isSecureConfig', true);
  797. }
  798. }, this)
  799. }, this)
  800. },
  801. /**
  802. * Load child components to service config object
  803. * @param {Array} configs - array of configs
  804. * @param {Object} componentConfig - component config object
  805. * @method loadConfigs
  806. */
  807. loadConfigs: function (configs, componentConfig) {
  808. var defaultGroupSelected = this.get('selectedConfigGroup.isDefault');
  809. configs.forEach(function (_serviceConfigProperty) {
  810. var serviceConfigProperty = this.createConfigProperty(_serviceConfigProperty, defaultGroupSelected);
  811. componentConfig.get('configs').pushObject(serviceConfigProperty);
  812. serviceConfigProperty.validate();
  813. }, this);
  814. componentConfig.set('initConfigsLength', componentConfig.get('configs.length'));
  815. },
  816. /**
  817. * create {Em.Object} service_cfg_property based on {Object}_serviceConfigProperty and additional info
  818. * @param {Object} _serviceConfigProperty - config object
  819. * @param {Boolean} defaultGroupSelected - true if selected cfg group is default
  820. * @returns {Ember.Object|null}
  821. * @private
  822. * @method createConfigProperty
  823. */
  824. createConfigProperty: function (_serviceConfigProperty, defaultGroupSelected) {
  825. if (!_serviceConfigProperty) return null;
  826. var overrides = Em.get(_serviceConfigProperty, 'overrides');
  827. // we will populate the override properties below
  828. Em.set(_serviceConfigProperty, 'overrides', null);
  829. Em.set(_serviceConfigProperty, 'isOverridable', Em.isNone(Em.get(_serviceConfigProperty, 'isOverridable')) ? true : Em.get(_serviceConfigProperty, 'isOverridable'));
  830. var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
  831. this.setValuesForOverrides(overrides, _serviceConfigProperty, serviceConfigProperty, defaultGroupSelected);
  832. this.setEditability(serviceConfigProperty, defaultGroupSelected);
  833. return serviceConfigProperty;
  834. },
  835. /**
  836. * hide properties from Advanced ranger category that match pattern
  837. * if property with dependentConfigPattern is false otherwise don't hide
  838. * @param serviceConfig
  839. * @private
  840. * @method setVisibilityForRangerProperties
  841. */
  842. setVisibilityForRangerProperties: function(serviceConfig) {
  843. var category = "Advanced ranger-{0}-plugin-properties".format(this.get('content.serviceName').toLowerCase());
  844. if (serviceConfig.configCategories.findProperty('name', category)) {
  845. var patternConfig = serviceConfig.configs.findProperty('dependentConfigPattern');
  846. if (patternConfig) {
  847. var value = patternConfig.get('value') === true || ["yes", "true"].contains(patternConfig.get('value').toLowerCase());
  848. serviceConfig.configs.filter(function(c) {
  849. if (c.get('category') === category && c.get('name').match(patternConfig.get('dependentConfigPattern')) && c.get('name') != patternConfig.get('name'))
  850. c.set('isVisible', value);
  851. });
  852. }
  853. }
  854. },
  855. /**
  856. * trigger addOverrideProperty
  857. * @param {Object} componentConfig
  858. * @private
  859. * @method checkOverrideProperty
  860. */
  861. checkOverrideProperty: function (componentConfig) {
  862. var overrideToAdd = this.get('overrideToAdd');
  863. var value = Em.get(overrideToAdd, 'value');
  864. var isEnhanced = !!this.get('overrideToAdd.widget');
  865. if (overrideToAdd) {
  866. overrideToAdd = componentConfig.configs.filter(function(c){
  867. return c.name == overrideToAdd.name && c.filename == overrideToAdd.filename;
  868. });
  869. if (overrideToAdd[0]) {
  870. this.addOverrideProperty(overrideToAdd[0], this.get('selectedConfigGroup'), isEnhanced ? value : null);
  871. this.set('overrideToAdd', null);
  872. }
  873. }
  874. },
  875. /**
  876. * set isEditable property of config for admin
  877. * if default cfg group and not on the host config page
  878. * @param {Ember.Object} serviceConfigProperty
  879. * @param {Boolean} defaultGroupSelected
  880. * @private
  881. * @method setEditability
  882. */
  883. setEditability: function (serviceConfigProperty, defaultGroupSelected) {
  884. serviceConfigProperty.set('isEditable', false);
  885. if (serviceConfigProperty.get('isComparison')) return;
  886. if (App.isAccessible('ADMIN') && defaultGroupSelected && !this.get('isHostsConfigsPage') && !serviceConfigProperty.get('group')) {
  887. serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
  888. } else if (serviceConfigProperty.get('group') && this.get('selectedConfigGroup.name') === serviceConfigProperty.get('group.name')) {
  889. serviceConfigProperty.set('isEditable', true);
  890. }
  891. },
  892. /**
  893. * set override values
  894. * @param overrides
  895. * @param _serviceConfigProperty
  896. * @param serviceConfigProperty
  897. * @param defaultGroupSelected
  898. * @private
  899. * @method setValuesForOverrides
  900. */
  901. setValuesForOverrides: function (overrides, _serviceConfigProperty, serviceConfigProperty, defaultGroupSelected) {
  902. if (Em.isNone(overrides)) return;
  903. overrides.forEach(function (override) {
  904. if (defaultGroupSelected || (Em.get(override, 'group') && this.get('selectedConfigGroup.name') === Em.get(override, 'group.name'))
  905. || serviceConfigProperty.get('serviceName') !== this.get('content.serviceName')) {
  906. var newSCP = this.createNewSCP(override, _serviceConfigProperty, serviceConfigProperty, defaultGroupSelected);
  907. var parentOverridesArray = serviceConfigProperty.get('overrides');
  908. if (parentOverridesArray == null) {
  909. parentOverridesArray = Em.A([]);
  910. serviceConfigProperty.set('overrides', parentOverridesArray);
  911. }
  912. parentOverridesArray.pushObject(newSCP);
  913. serviceConfigProperty.set('overrideValues', parentOverridesArray.mapProperty('value'));
  914. serviceConfigProperty.set('overrideIsFinalValues', parentOverridesArray.mapProperty('isFinal'));
  915. console.debug("createOverrideProperty(): Added override to main-property:", serviceConfigProperty.get('name'));
  916. }
  917. }, this);
  918. },
  919. /**
  920. * create new overridden property and set appropriate fields
  921. * @param override
  922. * @param _serviceConfigProperty
  923. * @param serviceConfigProperty
  924. * @param defaultGroupSelected
  925. * @returns {*}
  926. * @private
  927. * @method createNewSCP
  928. */
  929. createNewSCP: function (override, _serviceConfigProperty, serviceConfigProperty, defaultGroupSelected) {
  930. var newSCP = App.ServiceConfigProperty.create(_serviceConfigProperty, {
  931. value: Em.get(override, 'value'),
  932. savedValue: Em.get(override, 'value'),
  933. recommendedValue: serviceConfigProperty.get('recommendedValue'),
  934. isFinal: Em.get(override, 'isFinal'),
  935. savedIsFinal: Em.get(override, 'isFinal'),
  936. recommendedIsFinal: serviceConfigProperty.get('recommendedIsFinal'),
  937. group: Em.get(override, 'group'),
  938. supportsFinal: serviceConfigProperty.get('supportsFinal'),
  939. isOriginalSCP: false,
  940. parentSCP: serviceConfigProperty,
  941. overrides: null
  942. });
  943. if (defaultGroupSelected) {
  944. newSCP.set('isEditable', false);
  945. }
  946. newSCP.validate();
  947. return newSCP;
  948. },
  949. /**
  950. * Array of Objects
  951. * {
  952. * hostProperty - hostName property name for current component
  953. * componentName - master componentName
  954. * serviceName - serviceName of component
  955. * serviceUseThis - services that use hostname property of component(componentName)
  956. * m(multiple) - true if can be more than one components installed on cluster
  957. * }
  958. */
  959. hostComponentsMapping: [
  960. {
  961. hostProperty: 'snamenode_host',
  962. componentName: 'SECONDARY_NAMENODE',
  963. serviceName: 'HDFS',
  964. serviceUseThis: []
  965. },
  966. {
  967. hostProperty: 'jobtracker_host',
  968. componentName: 'JOBTRACKER',
  969. serviceName: 'MAPREDUCE2',
  970. serviceUseThis: []
  971. },
  972. {
  973. hostProperty: 'hs_host',
  974. componentName: 'HISTORYSERVER',
  975. serviceName: 'MAPREDUCE2',
  976. serviceUseThis: ['YARN']
  977. },
  978. {
  979. hostProperty: 'ats_host',
  980. componentName: 'APP_TIMELINE_SERVER',
  981. serviceName: 'YARN',
  982. serviceUseThis: []
  983. },
  984. {
  985. hostProperty: 'rm_host',
  986. componentName: 'RESOURCEMANAGER',
  987. serviceName: 'YARN',
  988. serviceUseThis: []
  989. },
  990. {
  991. hostProperty: 'hivemetastore_host',
  992. componentName: 'HIVE_METASTORE',
  993. serviceName: 'HIVE',
  994. serviceUseThis: ['HIVE'],
  995. m: true
  996. },
  997. {
  998. hostProperty: 'hive_ambari_host',
  999. componentName: 'HIVE_SERVER',
  1000. serviceName: 'HIVE',
  1001. serviceUseThis: []
  1002. },
  1003. {
  1004. hostProperty: 'oozieserver_host',
  1005. componentName: 'OOZIE_SERVER',
  1006. serviceName: 'OOZIE',
  1007. serviceUseThis: [],
  1008. m: true
  1009. },
  1010. {
  1011. hostProperty: 'oozie_ambari_host',
  1012. componentName: 'OOZIE_SERVER',
  1013. serviceName: 'OOZIE',
  1014. serviceUseThis: []
  1015. },
  1016. {
  1017. hostProperty: 'hbasemaster_host',
  1018. componentName: 'HBASE_MASTER',
  1019. serviceName: 'HBASE',
  1020. serviceUseThis: [],
  1021. m: true
  1022. },
  1023. {
  1024. hostProperty: 'webhcatserver_host',
  1025. componentName: 'WEBHCAT_SERVER',
  1026. serviceName: 'HIVE',
  1027. serviceUseThis: [],
  1028. m: true
  1029. },
  1030. {
  1031. hostProperty: 'zookeeperserver_hosts',
  1032. componentName: 'ZOOKEEPER_SERVER',
  1033. serviceName: 'ZOOKEEPER',
  1034. serviceUseThis: ['HBASE', 'HIVE'],
  1035. m: true
  1036. },
  1037. {
  1038. hostProperty: 'stormuiserver_host',
  1039. componentName: 'STORM_UI_SERVER',
  1040. serviceName: 'STORM',
  1041. serviceUseThis: []
  1042. },
  1043. {
  1044. hostProperty: 'drpcserver_host',
  1045. componentName: 'DRPC_SERVER',
  1046. serviceName: 'STORM',
  1047. serviceUseThis: []
  1048. },
  1049. {
  1050. hostProperty: 'storm_rest_api_host',
  1051. componentName: 'STORM_REST_API',
  1052. serviceName: 'STORM',
  1053. serviceUseThis: []
  1054. },
  1055. {
  1056. hostProperty: 'supervisor_hosts',
  1057. componentName: 'SUPERVISOR',
  1058. serviceName: 'STORM',
  1059. serviceUseThis: [],
  1060. m: true
  1061. }
  1062. ],
  1063. /**
  1064. * Adds host name of master component to config
  1065. * @private
  1066. * @method addHostNamesToGlobalConfig
  1067. */
  1068. addHostNamesToConfig: function () {
  1069. var serviceName = this.get('content.serviceName');
  1070. var configs = this.get('allConfigs');
  1071. //namenode_host is required to derive "fs.default.name" a property of core-site
  1072. try {
  1073. this.setHostForService('HDFS', 'NAMENODE', 'namenode_host', true);
  1074. } catch (err) {
  1075. console.log("No NameNode Host available. This is expected if you're using GLUSTERFS rather than HDFS.");
  1076. }
  1077. var hostProperties = this.get('hostComponentsMapping').filter(function (h) {
  1078. return h.serviceUseThis.contains(serviceName) || h.serviceName == serviceName;
  1079. });
  1080. hostProperties.forEach(function (h) {
  1081. this.setHostForService(h.serviceName, h.componentName, h.hostProperty, h.m);
  1082. }, this);
  1083. if (serviceName === 'HIVE') {
  1084. var hiveDb = configs.findProperty('name', 'hive_database').value;
  1085. if (['Existing MySQL Database', 'Existing Oracle Database', 'Existing PostgreSQL Database', 'Existing MSSQL Server database with SQL authentication', 'Existing MSSQL Server database with integrated authentication'].contains(hiveDb)) {
  1086. configs.findProperty('name', 'hive_hostname').isVisible = true;
  1087. }
  1088. }
  1089. if (serviceName === 'OOZIE') {
  1090. var oozieDb = configs.findProperty('name', 'oozie_database').value;
  1091. if (['Existing MySQL Database', 'Existing Oracle Database', 'Existing PostgreSQL Database', 'Existing MSSQL Server database with SQL authentication', 'Existing MSSQL Server database with integrated authentication'].contains(oozieDb)) {
  1092. configs.findProperty('name', 'oozie_hostname').isVisible = true;
  1093. }
  1094. }
  1095. },
  1096. /**
  1097. * set host name(s) property for component
  1098. * @param {String} serviceName - service name of component
  1099. * @param {String} componentName - component name which host we want to know
  1100. * @param {String} hostProperty - name of host property for current component
  1101. * @param {Boolean} multiple - true if can be more than one component
  1102. * @private
  1103. * @method setHostForService
  1104. */
  1105. setHostForService: function (serviceName, componentName, hostProperty, multiple) {
  1106. var configs = this.get('allConfigs');
  1107. var serviceConfigs = this.get('serviceConfigs').findProperty('serviceName', serviceName).get('configs');
  1108. var hostConfig = serviceConfigs.findProperty('name', hostProperty);
  1109. if (hostConfig) {
  1110. hostConfig.recommendedValue = this.getMasterComponentHostValue(componentName, multiple);
  1111. configs.push(hostConfig);
  1112. }
  1113. },
  1114. /**
  1115. * get hostName of component
  1116. * @param {String} componentName
  1117. * @param {Boolean} multiple - true if can be more than one component installed on cluster
  1118. * @return {String|Array|Boolean} hostName|hostNames|false if missing component
  1119. * @private
  1120. * @method getMasterComponentHostValue
  1121. */
  1122. getMasterComponentHostValue: function (componentName, multiple) {
  1123. var components = this.get('content.hostComponents').filterProperty('componentName', componentName);
  1124. if (components.length > 0) {
  1125. return multiple ? components.mapProperty('hostName') : components[0].get('hostName');
  1126. }
  1127. return false;
  1128. },
  1129. /**
  1130. * Trigger loadStep
  1131. * @method loadStep
  1132. */
  1133. doCancel: function () {
  1134. this.set('preSelectedConfigVersion', null);
  1135. this.clearDependentConfigs();
  1136. Em.run.once(this, 'onConfigGroupChange');
  1137. },
  1138. /**
  1139. * trigger restartAllServiceHostComponents(batchUtils) if confirmed in popup
  1140. * @method restartAllStaleConfigComponents
  1141. * @return App.showConfirmationFeedBackPopup
  1142. */
  1143. restartAllStaleConfigComponents: function () {
  1144. var self = this;
  1145. var serviceDisplayName = this.get('content.displayName');
  1146. var bodyMessage = Em.Object.create({
  1147. confirmMsg: Em.I18n.t('services.service.restartAll.confirmMsg').format(serviceDisplayName),
  1148. confirmButton: Em.I18n.t('services.service.restartAll.confirmButton'),
  1149. additionalWarningMsg: this.get('content.passiveState') === 'OFF' ? Em.I18n.t('services.service.restartAll.warningMsg.turnOnMM').format(serviceDisplayName) : null
  1150. });
  1151. return App.showConfirmationFeedBackPopup(function (query) {
  1152. var selectedService = self.get('content.id');
  1153. batchUtils.restartAllServiceHostComponents(selectedService, true, query);
  1154. }, bodyMessage);
  1155. },
  1156. /**
  1157. * trigger launchHostComponentRollingRestart(batchUtils)
  1158. * @method rollingRestartStaleConfigSlaveComponents
  1159. */
  1160. rollingRestartStaleConfigSlaveComponents: function (componentName) {
  1161. batchUtils.launchHostComponentRollingRestart(componentName.context, this.get('content.displayName'), this.get('content.passiveState') === "ON", true);
  1162. },
  1163. /**
  1164. * trigger showItemsShouldBeRestarted popup with hosts that requires restart
  1165. * @param {{context: object}} event
  1166. * @method showHostsShouldBeRestarted
  1167. */
  1168. showHostsShouldBeRestarted: function (event) {
  1169. var restartRequiredHostsAndComponents = event.context.restartRequiredHostsAndComponents;
  1170. var hosts = [];
  1171. for (var hostName in restartRequiredHostsAndComponents) {
  1172. hosts.push(hostName);
  1173. }
  1174. var hostsText = hosts.length == 1 ? Em.I18n.t('common.host') : Em.I18n.t('common.hosts');
  1175. hosts = hosts.join(', ');
  1176. this.showItemsShouldBeRestarted(hosts, Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(hostsText));
  1177. },
  1178. /**
  1179. * trigger showItemsShouldBeRestarted popup with components that requires restart
  1180. * @param {{context: object}} event
  1181. * @method showComponentsShouldBeRestarted
  1182. */
  1183. showComponentsShouldBeRestarted: function (event) {
  1184. var restartRequiredHostsAndComponents = event.context.restartRequiredHostsAndComponents;
  1185. var hostsComponets = [];
  1186. var componentsObject = {};
  1187. for (var hostName in restartRequiredHostsAndComponents) {
  1188. restartRequiredHostsAndComponents[hostName].forEach(function (hostComponent) {
  1189. hostsComponets.push(hostComponent);
  1190. if (componentsObject[hostComponent] != undefined) {
  1191. componentsObject[hostComponent]++;
  1192. } else {
  1193. componentsObject[hostComponent] = 1;
  1194. }
  1195. })
  1196. }
  1197. var componentsList = [];
  1198. for (var obj in componentsObject) {
  1199. var componentDisplayName = (componentsObject[obj] > 1) ? obj + 's' : obj;
  1200. componentsList.push(componentsObject[obj] + ' ' + componentDisplayName);
  1201. }
  1202. var componentsText = componentsList.length == 1 ? Em.I18n.t('common.component') : Em.I18n.t('common.components');
  1203. hostsComponets = componentsList.join(', ');
  1204. this.showItemsShouldBeRestarted(hostsComponets, Em.I18n.t('service.service.config.restartService.shouldBeRestarted').format(componentsText));
  1205. },
  1206. /**
  1207. * Show popup with selectable (@see App.SelectablePopupBodyView) list of items
  1208. * @param {string} content string with comma-separated list of hostNames or componentNames
  1209. * @param {string} header popup header
  1210. * @returns {App.ModalPopup}
  1211. * @method showItemsShouldBeRestarted
  1212. */
  1213. showItemsShouldBeRestarted: function (content, header) {
  1214. return App.ModalPopup.show({
  1215. content: content,
  1216. header: header,
  1217. bodyClass: App.SelectablePopupBodyView,
  1218. secondary: null
  1219. });
  1220. },
  1221. /**
  1222. * add new overridden property to config property object
  1223. * @param {object} serviceConfigProperty - config property object
  1224. * @param {App.ConfigGroup} group - config group for new property
  1225. * @param {String} value
  1226. * @param {boolean} isNotSaved TODO
  1227. * @method addOverrideProperty
  1228. */
  1229. addOverrideProperty: function (serviceConfigProperty, group, value, isNotSaved) {
  1230. if (serviceConfigProperty.get('isOriginalSCP')) {
  1231. var overrides = serviceConfigProperty.get('overrides');
  1232. if (!overrides) {
  1233. overrides = [];
  1234. serviceConfigProperty.set('overrides', overrides);
  1235. }
  1236. // create new override with new value
  1237. var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty, {
  1238. value: value || '',
  1239. recommendedValue: serviceConfigProperty.get('recommendedValue'),
  1240. recommendedIsFinal: serviceConfigProperty.get('recommendedIsFinal'),
  1241. isOriginalSCP: false,
  1242. parentSCP: serviceConfigProperty,
  1243. isEditable: true,
  1244. group: group,
  1245. overrides: null,
  1246. isNotSaved: isNotSaved
  1247. });
  1248. console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty);
  1249. newSCP.validate();
  1250. overrides.pushObject(newSCP);
  1251. }
  1252. },
  1253. /**
  1254. * trigger manageConfigurationGroups
  1255. * @method manageConfigurationGroup
  1256. */
  1257. manageConfigurationGroup: function () {
  1258. App.router.get('manageConfigGroupsController').manageConfigurationGroups(null, this.get('content'));
  1259. },
  1260. /**
  1261. * If user changes cfg group if some configs was changed popup with propose to save changes must be shown
  1262. * @param {object} event - triggered event for selecting another config-group
  1263. * @method selectConfigGroup
  1264. */
  1265. selectConfigGroup: function (event) {
  1266. var self = this;
  1267. function callback() {
  1268. self.doSelectConfigGroup(event);
  1269. }
  1270. if (!this.get('isInit')) {
  1271. if (this.hasUnsavedChanges()) {
  1272. this.showSavePopup(null, callback);
  1273. return;
  1274. }
  1275. }
  1276. callback();
  1277. },
  1278. /**
  1279. * switch view to selected group
  1280. * @param event
  1281. * @method selectConfigGroup
  1282. */
  1283. doSelectConfigGroup: function (event) {
  1284. //clean when switch config group
  1285. this.loadedGroupToOverrideSiteToTagMap = {};
  1286. var configGroupVersions = App.ServiceConfigVersion.find().filterProperty('groupId', event.context.get('id'));
  1287. //check whether config group has config versions
  1288. if (configGroupVersions.length > 0) {
  1289. this.loadSelectedVersion(configGroupVersions.findProperty('isCurrent').get('version'), event.context);
  1290. } else {
  1291. this.loadSelectedVersion(null, event.context);
  1292. }
  1293. }
  1294. });