1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- require('controllers/wizard/slave_component_groups_controller');
- App.MainServiceInfoConfigsController = Em.Controller.extend({
- name: 'mainServiceInfoConfigsController',
- dataIsLoaded: false,
- stepConfigs: [], //contains all field properties that are viewed in this service
- selectedService: null,
- serviceConfigTags: null,
- globalConfigs: [],
- uiConfigs: [],
- customConfig: [],
- isApplyingChanges: false,
- serviceConfigs: require('data/service_configs'),
- configs: require('data/config_properties').configProperties,
- configMapping: require('data/config_mapping'),
- customConfigs: require('data/custom_configs'),
-
- /**
- * During page load time, we get the host overrides from the server.
- * The current host -> site:tag map is stored below. This will be
- * useful during save, so that removals can also be determined.
- *
- * Example:
- * {
- * 'hostname1':{
- * 'global': 'version1',
- * 'core-site': 'version1',
- * 'hdfs-site', 'tag3187261938'
- * }
- * }
- *
- * @see savedHostToOverrideSiteToTagMap
- */
- loadedHostToOverrideSiteToTagMap: {},
- /**
- * During page load time the cluster level site to tag
- * mapping is stored here.
- *
- * Example:
- * {
- * 'global': 'version1',
- * 'hdfs-site': 'version1',
- * 'core-site': 'version1'
- * }
- */
- loadedClusterSiteToTagMap: {},
- /**
- * During page save time, we set the host overrides to the server.
- * The new host -> site:tag map is stored below. This will be
- * useful during save, to update the host's host components. Also,
- * it will be useful in deletion of overrides.
- *
- * Example:
- * {
- * 'hostname1': {
- * 'global': {
- * 'tagName': 'tag3187261938_hostname1',
- * 'map': {
- * 'hadoop_heapsize': '2048m'
- * }
- * }
- * }
- * }
- *
- * @see loadedHostToOverrideSiteToTagMap
- */
- savedHostToOverrideSiteToTagMap: {},
- /**
- * Holds the actual base service-config server data uploaded.
- * This is used by the host-override mechanism to update host
- * specific values.
- */
- savedSiteNameToServerServiceConfigDataMap: {},
-
- isSubmitDisabled: function () {
- return (!(this.stepConfigs.everyProperty('errorCount', 0)) || this.get('isApplyingChanges'));
- }.property('stepConfigs.@each.errorCount', 'isApplyingChanges'),
- slaveComponentGroups: null,
- /**
- * Filter text will be located here
- */
- filter: '',
- /**
- * Dropdown menu items in filter compbobox
- */
- filterColumns: function(){
- var result = [];
- for(var i = 1; i<4; i++){
- result.push(Ember.Object.create({
- name: this.t('common.combobox.dropdown.' + i),
- selected: false
- }));
- }
- return result;
- }.property(),
- /**
- * clear and set properties to default value
- */
- clearStep: function () {
- this.set('dataIsLoaded', false);
- this.set('filter', '');
- this.get('filterColumns').setEach('selected', false);
- this.get('stepConfigs').clear();
- this.get('globalConfigs').clear();
- this.get('uiConfigs').clear();
- this.get('customConfig').clear();
- this.set('loadedHostToOverrideSiteToTagMap', {});
- this.set('savedHostToOverrideSiteToTagMap', {});
- this.set('savedSiteNameToServerServiceConfigDataMap', {});
- if (this.get('serviceConfigTags')) {
- this.set('serviceConfigTags', null);
- }
- },
- serviceConfigProperties: function () {
- return App.db.getServiceConfigProperties();
- }.property('content'),
- /**
- * On load function
- */
- loadStep: function () {
- console.log("TRACE: Loading configure for service");
- this.clearStep();
- this.loadServiceConfigs();
- },
- /**
- * Loads the actual configuration of all host components.
- * This helps in determining which services need a restart, and also
- * in showing which properties are actually applied or not.
- * This method also compares the actual_configs with the desired_configs
- * and builds a diff structure.
- *
- * Internall it calculates an array of host-components which need restart.
- * Example:
- * [
- * {
- * componentName: 'DATANODE',
- * serviceName: 'HDFS',
- * host: 'host.name',
- * type: 'core-site',
- * desiredConfigTags: {tag:'version1'},
- * actualConfigTags: {tag:'version4'. host_override:'version2'}
- * },
- * ...
- * ]
- *
- * From there it return the following restart-data for this service.
- * It represents the hosts, whose components need restart, and the
- * properties which require restart.
- *
- * {
- * hostAndHostComponents: {
- * 'hostname1': {
- * 'DATANODE': {
- * 'property1': 'value1',
- * 'property2': 'value2'
- * },
- * 'TASKTRACKER': {
- * 'prop1': 'val1'
- * }
- * },
- * 'hostname6': {
- * 'ZOOKEEPER': {
- * 'property1': 'value3'
- * }
- * }
- * },
- * propertyToHostAndComponent: {
- * 'property1': {
- * 'hostname1': ['DATANODE'],
- * 'hostname6': ['ZOOKEEPER']
- * },
- * 'property2': {
- * 'hostname1': ['DATANODE']
- * },
- * 'prop1': {
- * 'hostname1': ['TASKTRACKER']
- * }
- * }
- * }
- */
- loadActualConfigsAndCalculateRestarts: function () {
- var currentService = this.get('content.serviceName');
- var restartData = {
- hostAndHostComponents: {},
- propertyToHostAndComponent: {}
- };
- var self = this;
- var actualConfigsUrl = this.getUrl('/data/services/host_component_actual_configs.json', '/services?fields=components/host_components/HostRoles/actual_configs');
- $.ajax({
- type: 'GET',
- url: actualConfigsUrl,
- async: false,
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- var diffHostComponents = [];
- console.debug("loadActualConfigs(" + actualConfigsUrl + "): Data=", data);
- var configsToDownload = [];
- data.items.forEach(function (service) {
- // For current service, do any of the host_components differ in
- // configuration?
- if (currentService === service.ServiceInfo.service_name) {
- service.components.forEach(function (serviceComponent) {
- serviceComponent.host_components.forEach(function (hostComponent) {
- if (hostComponent.HostRoles.actual_configs) {
- for ( var site in hostComponent.HostRoles.actual_configs) {
- var actualConfigsTags = hostComponent.HostRoles.actual_configs[site];
- var desiredConfigTags = self.getDesiredConfigTag(site, hostComponent.HostRoles.host_name);
- if (desiredConfigTags.tag !== actualConfigsTags.tag ||
- (desiredConfigTags.host_override != null &&
- actualConfigsTags.host_override != null &&
- desiredConfigTags.host_override !== actualConfigsTags.host_override)) {
- // Restart may be necessary for this host-component
- diffHostComponents.push({
- componentName: hostComponent.HostRoles.component_name,
- serviceName: serviceComponent.ServiceComponentInfo.service_name,
- host: hostComponent.HostRoles.host_name,
- type: site,
- desiredConfigTags: desiredConfigTags,
- actualConfigTags: actualConfigsTags
- });
- self.addConfigDownloadParam(site, actualConfigsTags.tag, configsToDownload);
- self.addConfigDownloadParam(site, actualConfigsTags.host_override, configsToDownload);
- self.addConfigDownloadParam(site, desiredConfigTags.tag, configsToDownload);
- self.addConfigDownloadParam(site, desiredConfigTags.host_override, configsToDownload);
- }
- }
- }
- });
- });
- }
- });
- if (configsToDownload.length > 0) {
- var url = self.getUrl('/data/configurations/cluster_level_actual_configs.json?' + configsToDownload.join('|'), '/configurations?' + configsToDownload.join('|'));
- $.ajax({
- type: 'GET',
- url: url,
- async: false,
- timeout: 10000,
- dataType: 'json',
- success: function (data) {
- console.log("configsToDownload(): In success for ", url);
- if (data.items) {
- data.items.forEach(function (item) {
- App.config.loadedConfigurationsCache[item.type + "_" + item.tag] = item.properties;
- });
- }
- },
- error: function (request, ajaxOptions, error) {
- console.log("TRACE: In error function for the configsToDownload call");
- console.log("TRACE: value of the url is: " + url);
- console.log("TRACE: error code status is: " + request.status);
- },
- statusCode: require('data/statusCodes')
- });
- }
- // Now all the configurations are loaded.
- // Find the diff in properties
- if (diffHostComponents.length > 0) {
- diffHostComponents.forEach(function (diffHostComponent) {
- var actualConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.actualConfigTags.tag];
- var desiredConfigs = App.config.loadedConfigurationsCache[diffHostComponent.type + "_" + diffHostComponent.desiredConfigTags.tag];
- var diffs = self.getConfigDifferences(actualConfigs, desiredConfigs);
- if (!jQuery.isEmptyObject(diffs)) {
- var skip = false;
- if (diffHostComponent.type == 'global') {
- if(!App.config.isServiceEffectedByGlobalChange(
- diffHostComponent.serviceName,
- diffHostComponent.desiredConfigTags.tag,
- diffHostComponent.actualConfigTags.tag)){
- skip = true;
- }
- }
- if(!skip){
- // Populate restartData.hostAndHostComponents
- if (!(diffHostComponent.host in restartData.hostAndHostComponents)) {
- restartData.hostAndHostComponents[diffHostComponent.host] = {};
- }
- if (!(diffHostComponent.componentName in restartData.hostAndHostComponents[diffHostComponent.host])) {
- restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName] = {};
- }
- jQuery.extend(restartData.hostAndHostComponents[diffHostComponent.host][diffHostComponent.componentName], diffs);
- // Populate restartData.propertyToHostAndComponent
- for ( var diff in diffs) {
- if (!(diff in restartData.propertyToHostAndComponent)) {
- restartData.propertyToHostAndComponent[diff] = {};
- }
- if (!(diffHostComponent.host in restartData.propertyToHostAndComponent[diff])) {
- restartData.propertyToHostAndComponent[diff][diffHostComponent.host] = [];
- }
- if (!(restartData.propertyToHostAndComponent[diff][diffHostComponent.host].contains(diffHostComponent.componentName))) {
- restartData.propertyToHostAndComponent[diff][diffHostComponent.host].push(diffHostComponent.componentName);
- }
- }
- }
- }
- });
- }
- console.log("loadActualConfigs(): Finished loading. Restart host components = ", diffHostComponents);
- },
- error: function (request, ajaxOptions, error) {
- console.log("loadActualConfigs(): URL:" + actualConfigsUrl + ". Status:", request.status, ", Error:", error);
- },
- statusCode: require('data/statusCodes')
- });
- console.log("loadActualConfigsAndCalculateRestarts(): Restart data = ", restartData);
- return restartData;
- },
-
- /**
- * Determines the differences between desired and actual configs and returns
- * them as an object. The key is the property, and value is actual_config.
- */
- getConfigDifferences: function (actualConfigs, desiredConfigs) {
- var differences = {};
- if (actualConfigs != null && desiredConfigs != null) {
- for(var desiredProp in desiredConfigs){
- if(desiredConfigs[desiredProp] !== actualConfigs[desiredProp]){
- differences[desiredProp] = actualConfigs[desiredProp];
- }
- }
- }
- return differences;
- },
-
- addConfigDownloadParam: function(site, tag, configsToDownload){
- if(tag!=null && !(site+"_"+tag in App.config.loadedConfigurationsCache)){
- var configParam = "(type="+site+"&tag="+tag+")";
- if(!configsToDownload.contains(configParam)){
- configsToDownload.push(configParam);
- }
- }
- },
-
- getDesiredConfigTag: function(site, hostName){
- var tag = {tag: this.loadedClusterSiteToTagMap[site], host_override: null};
- if(hostName in this.loadedHostToOverrideSiteToTagMap){
- var map = this.loadedHostToOverrideSiteToTagMap[hostName];
- if(site in map){
- tag.host_overrides = map[site];
- }
- }
- return tag;
- },
- /**
- * Loads service configurations
- */
- loadServiceConfigs: function () {
- App.ajax.send({
- name: 'config.tags',
- sender: this,
- data: {
- serviceName: this.get('content.serviceName'),
- serviceConfigsDef: this.get('serviceConfigs').findProperty('serviceName', this.get('content.serviceName'))
- },
- success: 'loadServiceTagsSuccess'
- });
- },
- loadServiceTagsSuccess: function(data, opt, params){
- var serviceConfigsDef = params.serviceConfigsDef;
- var serviceName = this.get('content.serviceName');
- console.debug("loadServiceConfigs(): data=", data);
- this.loadedClusterSiteToTagMap = {};
- //STEP 1: handle tags from JSON data
- for ( var site in data.Clusters.desired_configs) {
- if (serviceConfigsDef.sites.indexOf(site) > -1) {
- this.loadedClusterSiteToTagMap[site] = data.Clusters.desired_configs[site]['tag'];
- var overrides = data.Clusters.desired_configs[site].host_overrides;
- if (overrides) {
- overrides.forEach(function (override) {
- var hostname = override.host_name;
- var tag = override.tag;
- if(!this.loadedHostToOverrideSiteToTagMap[hostname]){
- this.loadedHostToOverrideSiteToTagMap[hostname] = {};
- }
- this.loadedHostToOverrideSiteToTagMap[hostname][site] = tag;
- }, this);
- }
- }
- }
- //STEP 2: Create an array of objects defining tag names to be polled and new tag names to be set after submit
- this.setServiceConfigTags(this.loadedClusterSiteToTagMap);
- //STEP 3: Load advanced configs from server
- var advancedConfigs = App.config.loadAdvancedConfig(serviceName) || [];
- //STEP 4: Load on-site config by service from server
- var configGroups = App.config.loadConfigsByTags(this.get('serviceConfigTags'));
- //STEP 5: Merge global and on-site configs with pre-defined
- var configSet = App.config.mergePreDefinedWithLoaded(configGroups, advancedConfigs, this.get('serviceConfigTags'), serviceName);
- //var serviceConfigs = this.getSitesConfigProperties(advancedConfigs);
- var configs = configSet.configs;
- //put global configs into globalConfigs to save them separately
- this.set('globalConfigs', configSet.globalConfigs);
- //STEP 6: add advanced configs
- App.config.addAdvancedConfigs(configs, advancedConfigs, serviceName);
- //STEP 7: add custom configs
- App.config.addCustomConfigs(configs);
- //STEP 8: add configs as names of host components
- this.addHostNamesToGlobalConfig();
- var allConfigs = this.get('globalConfigs').concat(configs);
- //this.loadServiceConfigHostsOverrides(serviceConfigs, this.loadedHostToOverrideSiteToTagMap);
- //STEP 9: Load and add host override configs
- App.config.loadServiceConfigHostsOverrides(allConfigs, this.loadedHostToOverrideSiteToTagMap);
- var restartData = this.loadActualConfigsAndCalculateRestarts();
- //STEP 10: creation of serviceConfig object which contains configs for current service
- var serviceConfig = App.config.createServiceConfig(serviceName);
- this.checkForRestart(serviceConfig, restartData);
- if (serviceName || serviceConfig.serviceName === 'MISC') {
- //STEP 11: render configs and wrap each in ServiceConfigProperty object
- this.loadComponentConfigs(allConfigs, serviceConfig, restartData);
- this.get('stepConfigs').pushObject(serviceConfig);
- }
- this.set('selectedService', this.get('stepConfigs').objectAt(0));
- this.set('dataIsLoaded', true);
- },
- /**
- * Changes format from Object to Array
- *
- * {
- * 'core-site': 'version1',
- * 'hdfs-site': 'version1',
- * 'global': 'version2',
- * ...
- * }
- *
- * to
- *
- * [
- * {
- * siteName: 'core-site',
- * tagName: 'version1',
- * newTageName: null
- * },
- * ...
- * ]
- *
- * set tagnames for configuration of the *-site.xml
- */
- setServiceConfigTags: function (desiredConfigsSiteTags) {
- console.debug("setServiceConfigTags(): Trying to set ", desiredConfigsSiteTags);
- var newServiceConfigTags = [];
- for (var index in desiredConfigsSiteTags) {
- newServiceConfigTags.pushObject({
- siteName: index,
- tagName: desiredConfigsSiteTags[index],
- newTagName: null
- }, this);
- }
- console.debug("setServiceConfigTags(): Setting 'serviceConfigTags' to ", newServiceConfigTags);
- this.set('serviceConfigTags', newServiceConfigTags);
- },
- /**
- * check whether host component must be restarted
- * @param serviceConfig
- * @param restartData
- */
- checkForRestart: function(serviceConfig, restartData){
- var hostsCount = 0;
- var hostComponentCount = 0;
- var restartHosts = Ember.A([]);
- if(restartData != null && restartData.hostAndHostComponents != null && !jQuery.isEmptyObject(restartData.hostAndHostComponents)){
- serviceConfig.set('restartRequired', true);
- for(var host in restartData.hostAndHostComponents){
- hostsCount++;
- var componentsArray = Ember.A([]);
- for(var component in restartData.hostAndHostComponents[host]){
- componentsArray.push(Ember.Object.create({name: App.format.role(component)}));
- hostComponentCount++;
- }
- var hostObj = App.Host.find(host);
- restartHosts.push(Ember.Object.create({hostData: hostObj, components: componentsArray}))
- }
- serviceConfig.set('restartRequiredHostsAndComponents', restartHosts);
- serviceConfig.set('restartRequiredMessage', 'Service needs '+hostComponentCount+' components on ' + hostsCount +' hosts to be restarted.')
- }
- },
- /**
- * Load child components to service config object
- * @param configs
- * @param componentConfig
- * @param restartData
- */
- loadComponentConfigs: function (configs, componentConfig, restartData) {
- configs.forEach(function (_serviceConfigProperty) {
- console.log("config", _serviceConfigProperty);
- if (!_serviceConfigProperty) return;
- var overrides = _serviceConfigProperty.overrides;
- // we will populate the override properties below
- _serviceConfigProperty.overrides = null;
- if (_serviceConfigProperty.isOverridable === undefined) {
- _serviceConfigProperty.isOverridable = true;
- }
- var serviceConfigProperty = App.ServiceConfigProperty.create(_serviceConfigProperty);
- var propertyName = serviceConfigProperty.get('name');
- if (restartData != null && propertyName in restartData.propertyToHostAndComponent) {
- serviceConfigProperty.set('isRestartRequired', true);
- var message = '<ul>';
- for(var host in restartData.propertyToHostAndComponent[propertyName]){
- var appHost = App.Host.find(host);
- message += "<li>"+appHost.get('publicHostName');
- message += "<ul>";
- restartData.propertyToHostAndComponent[propertyName][host].forEach(function(comp){
- message += "<li>"+App.format.role(comp)+"</li>"
- });
- message += "</ul></li>";
- }
- message += "</ul>";
- serviceConfigProperty.set('restartRequiredMessage', message);
- }
- if (serviceConfigProperty.get('serviceName') === this.get('content.serviceName')) {
- // serviceConfigProperty.serviceConfig = componentConfig;
- if (App.get('isAdmin')) {
- serviceConfigProperty.set('isEditable', serviceConfigProperty.get('isReconfigurable'));
- } else {
- serviceConfigProperty.set('isEditable', false);
- }
- console.log("config result", serviceConfigProperty);
- } else {
- serviceConfigProperty.set('isVisible', false);
- }
- if (overrides != null) {
- for(var overridenValue in overrides){
- var hostsArray = overrides[overridenValue];
- var newSCP = App.ServiceConfigProperty.create(_serviceConfigProperty);
- newSCP.set('value', overridenValue);
- newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
- newSCP.set('parentSCP', serviceConfigProperty);
- newSCP.set('selectedHostOptions', Ember.A(hostsArray));
- var parentOverridesArray = serviceConfigProperty.get('overrides');
- if(parentOverridesArray == null){
- parentOverridesArray = Ember.A([]);
- serviceConfigProperty.set('overrides', parentOverridesArray);
- }
- parentOverridesArray.pushObject(newSCP);
- console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty)
- }
- }
- componentConfig.configs.pushObject(serviceConfigProperty);
- serviceConfigProperty.validate();
- }, this);
- },
- /**
- * open popup with appropriate message
- */
- restartServicePopup: function (event) {
- if(this.get("isSubmitDisabled")){
- return;
- }
- var header;
- var message;
- var value;
- var flag = false;
- if (App.supports.hostOverrides ||
- (this.get('content.serviceName') !== 'HDFS' && this.get('content.isStopped') === true) ||
- ((this.get('content.serviceName') === 'HDFS') && this.get('content.isStopped') === true && (!App.Service.find().someProperty('id', 'MAPREDUCE') || App.Service.find('MAPREDUCE').get('isStopped')))) {
- var result = this.saveServiceConfigProperties();
- App.router.get('clusterController').updateClusterData();
- flag = result.flag;
- if (result.flag === true) {
- header = App.supports.hostOverrides ? Em.I18n.t('services.service.config.restartService') : Em.I18n.t('services.service.config.startService');
- message = Em.I18n.t('services.service.config.saveConfig');
- } else {
- header = Em.I18n.t('common.failure');
- message = result.message;
- value = result.value;
- }
- } else {
- if (this.get('content.serviceName') !== 'HDFS' || (this.get('content.serviceName') === 'HDFS' && !App.Service.find().someProperty('id', 'MAPREDUCE'))) {
- header = Em.I18n.t('services.service.config.stopService');
- message = Em.I18n.t('services.service.config.msgServiceStop');
- } else {
- header = Em.I18n.t('services.service.config.stopService');
- message = Em.I18n.t('services.service.config.msgHDFSMapRServiceStop');
- }
- }
-
- var self = this;
- App.ModalPopup.show({
- header: header,
- primary: Em.I18n.t('ok'),
- secondary: null,
- onPrimary: function () {
- this.hide();
- if (App.supports.hostOverrides) {
- self.loadStep();
- }
- },
- bodyClass: Ember.View.extend({
- flag: flag,
- message: message,
- siteProperties: value,
- getDisplayMessage: function () {
- var displayMsg = [];
- var siteProperties = this.get('siteProperties');
- if (siteProperties) {
- siteProperties.forEach(function (_siteProperty) {
- var displayProperty = _siteProperty.siteProperty;
- var displayNames = _siteProperty.displayNames;
- /////////
- if (displayNames && displayNames.length) {
- if (displayNames.length === 1) {
- displayMsg.push(displayProperty + Em.I18n.t('as') + displayNames[0]);
- } else {
- var name;
- displayNames.forEach(function (_name, index) {
- if (index === 0) {
- name = _name;
- } else if (index === siteProperties.length - 1) {
- name = name + Em.I18n.t('and') + _name;
- } else {
- name = name + ', ' + _name;
- }
- }, this);
- displayMsg.push(displayProperty + Em.I18n.t('as') + name);
- }
- } else {
- displayMsg.push(displayProperty);
- }
- }, this);
- }
- return displayMsg;
- }.property('siteProperties'),
- template: Ember.Handlebars.compile([
- '<h5>{{view.message}}</h5>',
- '{{#unless view.flag}}',
- '<br/>',
- '<div class="pre-scrollable" style="max-height: 250px;">',
- '<ul>',
- '{{#each val in view.getDisplayMessage}}',
- '<li>',
- '{{val}}',
- '</li>',
- '{{/each}}',
- '</ul>',
- '</div>',
- '{{/unless}}'
- ].join('\n'))
- })
- });
- },
- /**
- * Save config properties
- */
- saveServiceConfigProperties: function () {
- var result = {
- flag: false,
- message: null,
- value: null
- };
- this.savedHostToOverrideSiteToTagMap = {};
- var configs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).get('configs');
- this.saveGlobalConfigs(configs);
- this.saveSiteConfigs(configs);
- /**
- * First we put cluster configurations, which automatically creates /configurations
- * resources. Next we update host level overrides.
- */
- result.flag = this.doPUTClusterConfigurations();
- if (!result.flag) {
- result.message = Em.I18n.t('services.service.config.failSaveConfig');
- }else{
- result.flag = result.flag && this.doPUTHostOverridesConfigurationSites();
- if (!result.flag) {
- result.message = Em.I18n.t('services.service.config.failSaveConfigHostExceptions');
- }
- }
- console.log("The result from applyCreatdConfToService is: " + result);
- return result;
- },
- /**
- * save new or change exist configs in global configs
- * @param configs
- */
- saveGlobalConfigs: function (configs) {
- var globalConfigs = this.get('globalConfigs');
- configs.filterProperty('id', 'puppet var').forEach(function (uiConfigProperty) {
- if (globalConfigs.someProperty('name', uiConfigProperty.name)) {
- var modelGlobalConfig = globalConfigs.findProperty('name', uiConfigProperty.name);
- modelGlobalConfig.value = uiConfigProperty.value;
- var uiOverrides = uiConfigProperty.get('overrides');
- if(uiOverrides!=null && uiOverrides.get('length')>0){
- modelGlobalConfig.overrides = {};
- uiOverrides.forEach(function(uiOverride){
- var value = uiOverride.get('value');
- modelGlobalConfig.overrides[value] = [];
- uiOverride.get('selectedHostOptions').forEach(function(host){
- modelGlobalConfig.overrides[value].push(host);
- });
- });
- }
- } else {
- globalConfigs.pushObject({
- name: uiConfigProperty.name,
- value: uiConfigProperty.value
- });
- }
- }, this);
- this.setHiveHostName(globalConfigs);
- this.setOozieHostName(globalConfigs);
- this.set('globalConfigs', globalConfigs);
- },
- /**
- * set hive hostnames in global configs
- * @param globals
- */
- setHiveHostName: function (globals) {
- if (globals.someProperty('name', 'hive_database')) {
- var hiveDb = globals.findProperty('name', 'hive_database');
- if (hiveDb.value === 'New MySQL Database') {
- if (globals.someProperty('name', 'hive_ambari_host')) {
- globals.findProperty('name', 'hive_ambari_host').name = 'hive_hostname';
- }
- globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
- } else if (hiveDb.value === 'Existing MySQL Database'){
- globals.findProperty('name', 'hive_existing_mysql_host').name = 'hive_hostname';
- globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_host'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_oracle_database'));
- } else{ //existing oracle database
- globals.findProperty('name', 'hive_existing_oracle_host').name = 'hive_hostname';
- globals = globals.without(globals.findProperty('name', 'hive_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'hive_ambari_database'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_host'));
- globals = globals.without(globals.findProperty('name', 'hive_existing_mysql_database'));
- }
- }
- },
- /**
- * set hive hostnames in global configs
- * @param globals
- */
- setOozieHostName: function (globals) {
- if (globals.someProperty('name', 'oozie_database')) {
- var oozieDb = globals.findProperty('name', 'oozie_database');
- if (oozieDb.value === 'New Derby Database'){
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
- } else if (oozieDb.value === 'New MySQL Database') {
- if (globals.someProperty('name', 'oozie_ambari_host')) {
- globals.findProperty('name', 'oozie_ambari_host').name = 'oozie_hostname';
- }
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
- } else if (oozieDb.value === 'Existing MySQL Database'){
- globals.findProperty('name', 'oozie_existing_mysql_host').name = 'oozie_hostname';
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_oracle_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
- } else{ //existing oracle database
- globals.findProperty('name', 'oozie_existing_oracle_host').name = 'oozie_hostname';
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_ambari_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_host'));
- globals = globals.without(globals.findProperty('name', 'oozie_existing_mysql_database'));
- globals = globals.without(globals.findProperty('name', 'oozie_derby_database'));
- }
- }
- },
- /**
- * save site configs
- * @param configs
- */
- saveSiteConfigs: function (configs) {
- //storedConfigs contains custom configs as well
- var serviceConfigProperties = configs.filterProperty('id', 'site property');
- serviceConfigProperties.forEach(function(_config){
- if(typeof _config.get('value') === "boolean") _config.set('value', _config.value.toString());
- });
- var storedConfigs = serviceConfigProperties.filterProperty('value');
- var allUiConfigs = this.loadUiSideConfigs(this.get('configMapping').all());
- this.set('uiConfigs', storedConfigs.concat(allUiConfigs));
- },
- /**
- * return configs from the UI side
- * @param configMapping array with configs
- * @return {Array}
- */
- loadUiSideConfigs: function (configMapping) {
- var uiConfig = [];
- var configs = configMapping.filterProperty('foreignKey', null);
- configs.forEach(function (_config) {
- var valueWithOverrides = this.getGlobConfigValueWithOverrides(_config.templateName, _config.value, _config.name);
- if (valueWithOverrides !== null) {
- uiConfig.pushObject({
- "id": "site property",
- "name": _config.name,
- "value": valueWithOverrides.value,
- "filename": _config.filename,
- "overrides": valueWithOverrides.overrides
- });
- }
- }, this);
- return uiConfig;
- },
- /**
- * return global config value
- * @param templateName
- * @param expression
- * @param name
- * @return {
- * value: '...',
- * overrides: {
- * 'value1': [h1, h2],
- * 'value2': [h3]
- * }
- * }
- */
- getGlobConfigValueWithOverrides: function (templateName, expression, name) {
- var express = expression.match(/<(.*?)>/g);
- var value = expression;
- if (express == null) {
- return { value : expression, overrides: []}; // if site property do not map any global property then return the value
- }
- var overrideHostToValue = {};
- express.forEach(function (_express) {
- //console.log("The value of template is: " + _express);
- var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
- if (this.get('globalConfigs').someProperty('name', templateName[index])) {
- //console.log("The name of the variable is: " + this.get('content.serviceConfigProperties').findProperty('name', templateName[index]).name);
- var globalObj = this.get('globalConfigs').findProperty('name', templateName[index]);
- var globValue = globalObj.value;
- // Hack for templeton.zookeeper.hosts
- var preReplaceValue = null;
- if (value !== null) { // if the property depends on more than one template name like <templateName[0]>/<templateName[1]> then don't proceed to the next if the prior is null or not found in the global configs
- preReplaceValue = value;
- value = this._replaceConfigValues(name, _express, value, globValue);
- }
- if(globalObj.overrides!=null){
- for(ov in globalObj.overrides){
- var hostsArray = globalObj.overrides[ov];
- hostsArray.forEach(function(host){
- if(!(host in overrideHostToValue)){
- overrideHostToValue[host] = this._replaceConfigValues(name, _express, preReplaceValue, ov);
- }else{
- overrideHostToValue[host] = this._replaceConfigValues(name, _express, overrideHostToValue[host], ov);
- }
- }, this);
- }
- }
- } else {
- /*
- console.log("ERROR: The variable name is: " + templateName[index]);
- console.log("ERROR: mapped config from configMapping file has no corresponding variable in " +
- "content.serviceConfigProperties. Two possible reasons for the error could be: 1) The service is not selected. " +
- "and/OR 2) The service_config metadata file has no corresponding global var for the site property variable");
- */
- value = null;
- }
- }, this);
- var valueWithOverrides = {
- value: value,
- overrides: {}
- };
- if(!jQuery.isEmptyObject(overrideHostToValue)){
- for(var host in overrideHostToValue){
- var hostVal = overrideHostToValue[host];
- if(!(hostVal in valueWithOverrides.overrides)){
- valueWithOverrides.overrides[hostVal] = [];
- }
- valueWithOverrides.overrides[hostVal].push(host);
- }
- }
- return valueWithOverrides;
- },
-
- _replaceConfigValues: function (name, express, value, globValue) {
- if (name === "templeton.zookeeper.hosts" || name === 'hbase.zookeeper.quorum') {
- var zooKeeperPort = '2181';
- if (typeof globValue === 'string') {
- var temp = [];
- temp.push(globValue);
- globValue = temp;
- }
- if (name === "templeton.zookeeper.hosts") {
- var temp = [];
- globValue.forEach(function (_host, index) {
- temp.push(globValue[index] + ':' + zooKeeperPort);
- }, this);
- globValue = temp;
- }
- value = value.replace(express, globValue.toString());
- } else {
- value = value.replace(express, globValue);
- }
- return value;
- },
- /**
- * Saves cluster level configurations for all necessary sites.
- * PUT calls are made to /api/v1/clusters/clusterName for each site.
- *
- * @return {Boolean}
- */
- doPUTClusterConfigurations: function () {
- var result = true;
- var serviceConfigTags = this.get('serviceConfigTags');
- this.setNewTagNames(serviceConfigTags);
- var siteNameToServerDataMap = {};
-
- serviceConfigTags.forEach(function (_serviceTags) {
- if (_serviceTags.siteName === 'global') {
- console.log("TRACE: Inside global");
- var serverGlobalConfigs = this.createGlobalSiteObj(_serviceTags.newTagName);
- siteNameToServerDataMap['global'] = serverGlobalConfigs;
- if(this.isConfigChanged(App.config.loadedConfigurationsCache['global_'+this.loadedClusterSiteToTagMap['global']], serverGlobalConfigs.properties)){
- result = result && this.doPUTClusterConfigurationSite(serverGlobalConfigs);
- }
- } else if (_serviceTags.siteName === 'core-site') {
- console.log("TRACE: Inside core-site");
- if (this.get('content.serviceName') === 'HDFS') {
- var coreSiteConfigs = this.createCoreSiteObj(_serviceTags.newTagName);
- siteNameToServerDataMap['core-site'] = coreSiteConfigs;
- if(this.isConfigChanged(App.config.loadedConfigurationsCache['core-site_'+this.loadedClusterSiteToTagMap['core-site']], coreSiteConfigs.properties)){
- result = result && this.doPUTClusterConfigurationSite(coreSiteConfigs);
- }
- }
- } else {
- var serverConfigs = this.createSiteObj(_serviceTags.siteName, _serviceTags.newTagName);
- siteNameToServerDataMap[_serviceTags.siteName] = serverConfigs;
- if(this.isConfigChanged(App.config.loadedConfigurationsCache[_serviceTags.siteName+'_'+this.loadedClusterSiteToTagMap[_serviceTags.siteName]], serverConfigs.properties)){
- result = result && this.doPUTClusterConfigurationSite(serverConfigs);
- }
- }
- }, this);
- this.savedSiteNameToServerServiceConfigDataMap = siteNameToServerDataMap;
- return result;
- },
-
- /**
- * Compares the loaded config values with the saving config values.
- */
- isConfigChanged: function (loadedConfig, savingConfig) {
- var changed = false;
- if (loadedConfig != null && savingConfig != null) {
- var seenLoadKeys = [];
- for ( var loadKey in loadedConfig) {
- seenLoadKeys.push(loadKey);
- var loadValue = loadedConfig[loadKey];
- var saveValue = savingConfig[loadKey];
- if("boolean" == typeof(saveValue)){
- saveValue = saveValue.toString();
- }
- if(saveValue==null){
- saveValue = "null";
- }
- if (loadValue !== saveValue) {
- changed = true;
- break;
- }
- }
- for ( var saveKey in savingConfig) {
- if (seenLoadKeys.indexOf(saveKey) < 0) {
- changed = true;
- break;
- }
- }
- }
- return changed;
- },
-
- /**
- * Saves configuration of a particular site. The provided data
- * contains the site name and tag to be used.
- */
- doPUTClusterConfigurationSite: function (data) {
- var result;
- var url = this.getUrl('', '');
- var clusterData = {
- Clusters: {
- desired_config: data
- }
- };
- console.log("applyClusterConfigurationToSite(): PUTting data:", clusterData);
- $.ajax({
- type: 'PUT',
- url: url,
- async: false,
- dataType: 'text',
- data: JSON.stringify(clusterData),
- timeout: 5000,
- success: function (data) {
- console.log("applyClusterConfigurationToSite(): In success for data:", data);
- result = true;
- },
- error: function (request, ajaxOptions, error) {
- console.log('applyClusterConfigurationToSite(): ERROR:', request.responseText, ", error=", error);
- result = false;
- },
- statusCode: require('data/statusCodes')
- });
- console.log("applyClusterConfigurationToSite(): Exiting with result=" + result);
- return result;
- },
- /**
- * Creates host level overrides for service configuration.
- *
- */
- doPUTHostOverridesConfigurationSites: function(){
- var singlePUTHostData = [];
- var savedHostSiteArray = [];
- for ( var host in this.savedHostToOverrideSiteToTagMap) {
- for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
- var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
- var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
- savedHostSiteArray.push(host+"///"+siteName);
- singlePUTHostData.push({
- RequestInfo: {
- query: 'Hosts/host_name='+host
- },
- Body: {
- Hosts: {
- desired_config: {
- type: siteName,
- tag: tagName,
- properties: map
- }
- }
- }
- });
- }
- }
- // Now cleanup removed overrides
- for ( var loadedHost in this.loadedHostToOverrideSiteToTagMap) {
- for ( var loadedSiteName in this.loadedHostToOverrideSiteToTagMap[loadedHost]) {
- if (!(savedHostSiteArray.contains(loadedHost + "///" + loadedSiteName))) {
- // This host-site combination was loaded, but not saved.
- // Meaning it is not needed anymore. Hence send a DELETE command.
- singlePUTHostData.push({
- RequestInfo: {
- query: 'Hosts/host_name='+loadedHost
- },
- Body: {
- Hosts: {
- desired_config: {
- type: loadedSiteName,
- tag: this.loadedHostToOverrideSiteToTagMap[loadedHost][loadedSiteName],
- selected: false
- }
- }
- }
- });
- }
- }
- }
- console.debug("createHostOverrideConfigSites(): PUTting host-overrides. Data=",singlePUTHostData);
- if(singlePUTHostData.length>0){
- var url = this.getUrl('', '/hosts');
- var hostOverrideResult = true;
- $.ajax({
- type: 'PUT',
- url: url,
- data: JSON.stringify(singlePUTHostData),
- async: false,
- dataType: 'text',
- timeout: 5000,
- success: function (data) {
- var jsonData = jQuery.parseJSON(data);
- hostOverrideResult = true;
- console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
- },
- error: function (request, ajaxOptions, error) {
- hostOverrideResult = false;
- console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
- },
- statusCode: require('data/statusCodes')
- });
- return hostOverrideResult;
- }
- return true;
- },
-
- /**
- * add newTagName property to each config in serviceConfigs
- * @param serviceConfigs
- */
- setNewTagNames: function (serviceConfigs) {
- var time = (new Date).getTime();
- serviceConfigs.forEach(function (_serviceConfigs) {
- _serviceConfigs.newTagName = 'version' + time;
- }, this);
- },
- /**
- * create global site object
- * @param tagName
- * @return {Object}
- */
- createGlobalSiteObj: function (tagName) {
- var globalSiteProperties = {};
- this.get('globalConfigs').forEach(function (_globalSiteObj) {
- // do not pass any globalConfigs whose name ends with _host or _hosts
- if (!/_hosts?$/.test(_globalSiteObj.name)) {
- // append "m" to JVM memory options except for hadoop_heapsize
- if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && _globalSiteObj.name !== 'hadoop_heapsize') {
- _globalSiteObj.value += "m";
- }
- globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
- this.recordHostOverride(_globalSiteObj, 'global', tagName, this);
- //console.log("TRACE: name of the global property is: " + _globalSiteObj.name);
- //console.log("TRACE: value of the global property is: " + _globalSiteObj.value);
- }
- }, this);
- return {"type": "global", "tag": tagName, "properties": globalSiteProperties};
- },
-
- recordHostOverride: function(serviceConfigObj, siteName, tagName, self){
- if('get' in serviceConfigObj){
- return this._recordHostOverrideFromEmberObj(serviceConfigObj, siteName, tagName, self);
- }else{
- return this._recordHostOverrideFromObj(serviceConfigObj, siteName, tagName, self);
- }
- },
-
- /**
- * Records all the host overrides per site/tag
- */
- _recordHostOverrideFromObj: function(serviceConfigObj, siteName, tagName, self){
- var overrides = serviceConfigObj.overrides;
- if(overrides){
- for(var value in overrides){
- overrides[value].forEach(function(host){
- if(!(host in self.savedHostToOverrideSiteToTagMap)){
- self.savedHostToOverrideSiteToTagMap[host] = {};
- }
- if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
- self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
- self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
- }
- var finalTag = tagName + '_' + host;
- console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+value+")");
- self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
- self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = value;
- });
- }
- }
- },
- /**
- * Records all the host overrides per site/tag
- */
- _recordHostOverrideFromEmberObj: function(serviceConfigObj, siteName, tagName, self){
- var overrides = serviceConfigObj.get('overrides');
- if(overrides){
- overrides.forEach(function(override){
- override.get('selectedHostOptions').forEach(function(host){
- if(!(host in self.savedHostToOverrideSiteToTagMap)){
- self.savedHostToOverrideSiteToTagMap[host] = {};
- }
- if(!(siteName in self.savedHostToOverrideSiteToTagMap[host])){
- self.savedHostToOverrideSiteToTagMap[host][siteName] = {};
- self.savedHostToOverrideSiteToTagMap[host][siteName].map = {};
- }
- var finalTag = tagName + '_' + host;
- console.log("recordHostOverride(): Saving host override for host="+host+", site="+siteName+", tag="+finalTag+", (key,value)=("+serviceConfigObj.name+","+override.get('value')+")");
- self.savedHostToOverrideSiteToTagMap[host][siteName].tagName = finalTag;
- self.savedHostToOverrideSiteToTagMap[host][siteName].map[serviceConfigObj.name] = override.get('value');
- });
- });
- }
- },
- /**
- * create core site object
- * @param tagName
- * @return {Object}
- */
- createCoreSiteObj: function (tagName) {
- var coreSiteObj = this.get('uiConfigs').filterProperty('filename', 'core-site.xml');
- var coreSiteProperties = {};
- // hadoop.proxyuser.oozie.hosts needs to be skipped if oozie is not selected
- var isOozieSelected = App.Service.find().someProperty('serviceName', 'OOZIE');
- var oozieUser = this.get('globalConfigs').someProperty('name', 'oozie_user') ? this.get('globalConfigs').findProperty('name', 'oozie_user').value : null;
- var isHiveSelected = App.Service.find().someProperty('serviceName', 'HIVE');
- var hiveUser = this.get('globalConfigs').someProperty('name', 'hive_user') ? this.get('globalConfigs').findProperty('name', 'hive_user').value : null;
- var isHcatSelected = App.Service.find().someProperty('serviceName', 'WEBHCAT');
- var hcatUser = this.get('globalConfigs').someProperty('name', 'hcat_user') ? this.get('globalConfigs').findProperty('name', 'hcat_user').value : null;
- coreSiteObj.forEach(function (_coreSiteObj) {
- if ((isOozieSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + oozieUser + '.groups')) && (isHiveSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hiveUser + '.groups')) && (isHcatSelected || (_coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.hosts' && _coreSiteObj.name != 'hadoop.proxyuser.' + hcatUser + '.groups'))) {
- coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
- this.recordHostOverride(_coreSiteObj, 'core-site', tagName, this);
- }
- }, this);
- return {"type": "core-site", "tag": tagName, "properties": coreSiteProperties};
- },
- /**
- * create site object
- * @param siteName
- * @param tagName
- * @return {Object}
- */
- createSiteObj: function (siteName, tagName) {
- var siteObj = this.get('uiConfigs').filterProperty('filename', siteName + '.xml');
- var siteProperties = {};
- siteObj.forEach(function (_siteObj) {
- siteProperties[_siteObj.name] = _siteObj.value;
- this.recordHostOverride(_siteObj, siteName, tagName, this);
- }, this);
- return {"type": siteName, "tag": tagName, "properties": siteProperties};
- },
- /**
- * Set display names of the property tfrom he puppet/global names
- * @param: displayNames: a field to be set with displayNames
- * @param names: array of property puppet/global names
- */
- setPropertyDisplayNames: function (displayNames, names) {
- var stepConfigs = this.get('stepConfigs').findProperty('serviceName', this.get('content.serviceName')).configs;
- names.forEach(function (_name, index) {
- if (stepConfigs.someProperty('name', _name)) {
- displayNames.push(stepConfigs.findProperty('name', _name).displayName);
- }
- }, this);
- },
- /**
- * Set property of the site variable
- */
- setSiteProperty: function (key, value, filename) {
- if (filename === 'core-site.xml' && this.get('uiConfigs').filterProperty('filename', 'core-site.xml').someProperty('name', key)) {
- this.get('uiConfigs').filterProperty('filename', 'core-site.xml').findProperty('name', key).value = value;
- return;
- }
- this.get('uiConfigs').pushObject({
- "id": "site property",
- "name": key,
- "value": value,
- "filename": filename
- });
- },
- /**
- * return either specific url for request if testMode is false or testUrl
- * @param testUrl
- * @param url
- * @return {*}
- */
- getUrl: function (testUrl, url) {
- return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' + App.router.getClusterName() + url;
- },
- /**
- * Adds host name of master component to global config;
- */
- addHostNamesToGlobalConfig: function () {
- var serviceName = this.get('content.serviceName');
- var globalConfigs = this.get('globalConfigs');
- var serviceConfigs = this.get('serviceConfigs').findProperty('serviceName', serviceName).configs;
- //namenode_host is required to derive "fs.default.name" a property of core-site
- var nameNodeHost = this.get('serviceConfigs').findProperty('serviceName', 'HDFS').configs.findProperty('name', 'namenode_host');
- nameNodeHost.defaultValue = App.Service.find('HDFS').get('hostComponents').findProperty('componentName', 'NAMENODE').get('host.hostName');
- globalConfigs.push(nameNodeHost);
- //zooKeeperserver_host
- var zooKeperHost = this.get('serviceConfigs').findProperty('serviceName', 'ZOOKEEPER').configs.findProperty('name', 'zookeeperserver_hosts');
- if (serviceName === 'ZOOKEEPER' || serviceName === 'HBASE' || serviceName === 'WEBHCAT') {
- zooKeperHost.defaultValue = App.Service.find('ZOOKEEPER').get('hostComponents').filterProperty('componentName', 'ZOOKEEPER_SERVER').mapProperty('host.hostName');
- globalConfigs.push(zooKeperHost);
- }
- switch (serviceName) {
- case 'HDFS':
- var sNameNodeHost = serviceConfigs.findProperty('name', 'snamenode_host');
- sNameNodeHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'SECONDARY_NAMENODE').get('host.hostName');
- globalConfigs.push(sNameNodeHost);
- break;
- case 'MAPREDUCE':
- var jobTrackerHost = serviceConfigs.findProperty('name', 'jobtracker_host');
- jobTrackerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'JOBTRACKER').get('host.hostName');
- globalConfigs.push(jobTrackerHost);
- break;
- case 'HIVE':
- var hiveMetastoreHost = serviceConfigs.findProperty('name', 'hivemetastore_host');
- hiveMetastoreHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'HIVE_SERVER').get('host.hostName');
- globalConfigs.push(hiveMetastoreHost);
- break;
- case 'OOZIE':
- var oozieServerHost = serviceConfigs.findProperty('name', 'oozieserver_host');
- oozieServerHost.defaultValue = this.get('content.hostComponents').findProperty('componentName', 'OOZIE_SERVER').get('host.hostName');
- globalConfigs.push(oozieServerHost);
- break;
- case 'HBASE':
- var hbaseMasterHost = serviceConfigs.findProperty('name', 'hbasemaster_host');
- hbaseMasterHost.defaultValue = this.get('content.hostComponents').filterProperty('componentName', 'HBASE_MASTER').mapProperty('host.hostName');
- globalConfigs.push(hbaseMasterHost);
- break;
- }
- },
-
- /**
- * Provides service component name and display-name information for
- * the current selected service.
- */
- getCurrentServiceComponents: function () {
- var service = this.get('content');
- var components = service.get('hostComponents');
- var validComponents = Ember.A([]);
- var seenComponents = {};
- components.forEach(function(component){
- var cn = component.get('componentName');
- var cdn = component.get('displayName');
- if(!seenComponents[cn]){
- validComponents.push(Ember.Object.create({
- componentName: cn,
- displayName: cdn,
- selected: false
- }));
- seenComponents[cn] = cn;
- }
- });
- return validComponents;
- }.property('content'),
-
- getAllHosts: function () {
- return App.router.get('mainHostController.content');
- }.property('App.router.mainHostController.content'),
-
- doCancel: function () {
- location.reload();
- }
- });
|