|
@@ -17,21 +17,14 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
var App = require('app');
|
|
var App = require('app');
|
|
-var dataManipulationUtils = require('utils/data_manipulation');
|
|
|
|
var lazyLoading = require('utils/lazy_loading');
|
|
var lazyLoading = require('utils/lazy_loading');
|
|
|
|
|
|
/**
|
|
/**
|
|
- * this mixin has method to save configs (used in MainServiceInfoConfigsController)
|
|
|
|
- * all methods are divided into couple groups :
|
|
|
|
- * 0. HELPERS - some helper methods
|
|
|
|
- * 1. PRE SAVE CHECKS - warning popups and validations checks
|
|
|
|
- * 2. PREPARE CONFIGS TO SAVE - filtering and formatting changed configs
|
|
|
|
- * 2.1 PREPARE DATABASE CONFIGS - modify database properties
|
|
|
|
- * 2.2 ADD DYNAMIC CONFIGS - !!!NEED INVESTIGATION
|
|
|
|
- * 3. GENERATING JSON TO SAVE - generating json data
|
|
|
|
- * 4. AJAX REQUESTS - ajax request
|
|
|
|
- * 5. AFTER SAVE INFO - after save methods like to show popup with result
|
|
|
|
- * 6. ADDITIONAL
|
|
|
|
|
|
+ * Mixin for saving configs
|
|
|
|
+ * Contains methods for
|
|
|
|
+ * - generation JSON for saving configs and groups
|
|
|
|
+ * - format properties if needed
|
|
|
|
+ * - requests to save configs and groups
|
|
*/
|
|
*/
|
|
App.ConfigsSaverMixin = Em.Mixin.create({
|
|
App.ConfigsSaverMixin = Em.Mixin.create({
|
|
|
|
|
|
@@ -50,7 +43,10 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
* List of heapsize properties not to be parsed
|
|
* List of heapsize properties not to be parsed
|
|
* @type {string[]}
|
|
* @type {string[]}
|
|
*/
|
|
*/
|
|
- heapsizeException: ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize', 'apptimelineserver_heapsize', 'jobhistory_heapsize', 'nfsgateway_heapsize', 'accumulo_master_heapsize', 'accumulo_tserver_heapsize', 'accumulo_monitor_heapsize', 'accumulo_gc_heapsize', 'accumulo_other_heapsize', 'hbase_master_heapsize', 'hbase_regionserver_heapsize', 'metrics_collector_heapsize'],
|
|
|
|
|
|
+ heapsizeException: ['hadoop_heapsize', 'yarn_heapsize', 'nodemanager_heapsize', 'resourcemanager_heapsize',
|
|
|
|
+ 'apptimelineserver_heapsize', 'jobhistory_heapsize', 'nfsgateway_heapsize', 'accumulo_master_heapsize',
|
|
|
|
+ 'accumulo_tserver_heapsize', 'accumulo_monitor_heapsize', 'accumulo_gc_heapsize', 'accumulo_other_heapsize',
|
|
|
|
+ 'hbase_master_heapsize', 'hbase_regionserver_heapsize', 'metrics_collector_heapsize'],
|
|
|
|
|
|
/**
|
|
/**
|
|
* Regular expression for heapsize properties detection
|
|
* Regular expression for heapsize properties detection
|
|
@@ -58,6 +54,30 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
*/
|
|
*/
|
|
heapsizeRegExp: /_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/,
|
|
heapsizeRegExp: /_heapsize|_newsize|_maxnewsize|_permsize|_maxpermsize$/,
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * If some of services has such type core-site can be saved
|
|
|
|
+ *
|
|
|
|
+ * @type {string}
|
|
|
|
+ */
|
|
|
|
+ coreSiteServiceType: 'HCFS',
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Core site can be used by multiple services
|
|
|
|
+ * If some of services listed below is selected/installed than core site can be saved
|
|
|
|
+ *
|
|
|
|
+ * @type {string[]}
|
|
|
|
+ */
|
|
|
|
+ coreSiteServiceNames: ['HDFS', 'GLUSTERFS', 'RANGER_KMS'],
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * List of services which configs should be saved
|
|
|
|
+ *
|
|
|
|
+ * @type {App.StackService[]}
|
|
|
|
+ */
|
|
|
|
+ currentServices: function() {
|
|
|
|
+ return [App.StackService.find(this.get('content.serviceName'))];
|
|
|
|
+ }.property('content.serviceName'),
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* clear info to default
|
|
* clear info to default
|
|
* @method clearSaveInfo
|
|
* @method clearSaveInfo
|
|
@@ -353,11 +373,11 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
* generating common JSON object for desired configs
|
|
* generating common JSON object for desired configs
|
|
* @param configsToSave
|
|
* @param configsToSave
|
|
* @param fileNamesToSave
|
|
* @param fileNamesToSave
|
|
- * @param serviceConfigNote
|
|
|
|
- * @param {boolean} [isNotDefaultGroup=false]
|
|
|
|
|
|
+ * @param {string} [serviceConfigNote='']
|
|
|
|
+ * @param {boolean} [ignoreVersionNote=false]
|
|
* @returns {Array}
|
|
* @returns {Array}
|
|
*/
|
|
*/
|
|
- generateDesiredConfigsJSON: function(configsToSave, fileNamesToSave, serviceConfigNote, isNotDefaultGroup) {
|
|
|
|
|
|
+ generateDesiredConfigsJSON: function(configsToSave, fileNamesToSave, serviceConfigNote, ignoreVersionNote) {
|
|
var desired_config = [];
|
|
var desired_config = [];
|
|
if (Em.isArray(configsToSave) && Em.isArray(fileNamesToSave) && fileNamesToSave.length && configsToSave.length) {
|
|
if (Em.isArray(configsToSave) && Em.isArray(fileNamesToSave) && fileNamesToSave.length && configsToSave.length) {
|
|
serviceConfigNote = serviceConfigNote || "";
|
|
serviceConfigNote = serviceConfigNote || "";
|
|
@@ -367,7 +387,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
if (this.allowSaveSite(fName)) {
|
|
if (this.allowSaveSite(fName)) {
|
|
var properties = configsToSave.filterProperty('filename', fName);
|
|
var properties = configsToSave.filterProperty('filename', fName);
|
|
var type = App.config.getConfigTagFromFileName(fName);
|
|
var type = App.config.getConfigTagFromFileName(fName);
|
|
- desired_config.push(this.createDesiredConfig(type, tagVersion, properties, serviceConfigNote, isNotDefaultGroup));
|
|
|
|
|
|
+ desired_config.push(this.createDesiredConfig(type, tagVersion, properties, serviceConfigNote, ignoreVersionNote));
|
|
}
|
|
}
|
|
}, this);
|
|
}, this);
|
|
}
|
|
}
|
|
@@ -375,54 +395,65 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
- * for some file names we have a restriction
|
|
|
|
- * and can't save them, in this this method will return false
|
|
|
|
|
|
+ * For some file names we have a restriction
|
|
|
|
+ * and can't save them, in this case method will return false
|
|
|
|
+ *
|
|
* @param fName
|
|
* @param fName
|
|
* @returns {boolean}
|
|
* @returns {boolean}
|
|
*/
|
|
*/
|
|
allowSaveSite: function(fName) {
|
|
allowSaveSite: function(fName) {
|
|
- switch (fName) {
|
|
|
|
- case 'mapred-queue-acls.xml':
|
|
|
|
|
|
+ switch(App.config.getConfigTagFromFileName(fName)) {
|
|
|
|
+ case 'mapred-queue-acls':
|
|
return false;
|
|
return false;
|
|
- case 'core-site.xml':
|
|
|
|
- var serviceName = this.get('content.serviceName');
|
|
|
|
- var serviceType = App.StackService.find().findProperty('serviceName',serviceName).get('serviceType');
|
|
|
|
- return ['HDFS', 'GLUSTERFS', 'RANGER_KMS'].contains(this.get('content.serviceName')) || serviceType === 'HCFS';
|
|
|
|
- default :
|
|
|
|
|
|
+ case 'core-site':
|
|
|
|
+ return this.allowSaveCoreSite();
|
|
|
|
+ default:
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Defines conditions in which core-site can be saved
|
|
|
|
+ *
|
|
|
|
+ * @returns {boolean}
|
|
|
|
+ */
|
|
|
|
+ allowSaveCoreSite: function() {
|
|
|
|
+ return this.get('currentServices').some(function(service) {
|
|
|
|
+ return (this.get('coreSiteServiceNames').contains(service.get('serviceName'))
|
|
|
|
+ || this.get('coreSiteServiceType') === service.get('serviceType'));
|
|
|
|
+ }, this);
|
|
|
|
+ },
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* generating common JSON object for desired config
|
|
* generating common JSON object for desired config
|
|
* @param {string} type - file name without '.xml'
|
|
* @param {string} type - file name without '.xml'
|
|
* @param {string} tagVersion - version + timestamp
|
|
* @param {string} tagVersion - version + timestamp
|
|
* @param {App.ConfigProperty[]} properties - array of properties from model
|
|
* @param {App.ConfigProperty[]} properties - array of properties from model
|
|
- * @param {string} serviceConfigNote
|
|
|
|
- * @param {boolean} [isNotDefaultGroup=false]
|
|
|
|
|
|
+ * @param {string} [serviceConfigNote='']
|
|
|
|
+ * @param {boolean} [ignoreVersionNote=false]
|
|
* @returns {{type: string, tag: string, properties: {}, properties_attributes: {}|undefined, service_config_version_note: string|undefined}}
|
|
* @returns {{type: string, tag: string, properties: {}, properties_attributes: {}|undefined, service_config_version_note: string|undefined}}
|
|
*/
|
|
*/
|
|
- createDesiredConfig: function(type, tagVersion, properties, serviceConfigNote, isNotDefaultGroup) {
|
|
|
|
|
|
+ createDesiredConfig: function(type, tagVersion, properties, serviceConfigNote, ignoreVersionNote) {
|
|
Em.assert('type and tagVersion should be defined', type && tagVersion);
|
|
Em.assert('type and tagVersion should be defined', type && tagVersion);
|
|
var desired_config = {
|
|
var desired_config = {
|
|
"type": type,
|
|
"type": type,
|
|
"tag": tagVersion,
|
|
"tag": tagVersion,
|
|
"properties": {}
|
|
"properties": {}
|
|
};
|
|
};
|
|
- if (!isNotDefaultGroup) {
|
|
|
|
|
|
+ if (!ignoreVersionNote) {
|
|
desired_config.service_config_version_note = serviceConfigNote || "";
|
|
desired_config.service_config_version_note = serviceConfigNote || "";
|
|
}
|
|
}
|
|
var attributes = { final: {} };
|
|
var attributes = { final: {} };
|
|
if (Em.isArray(properties)) {
|
|
if (Em.isArray(properties)) {
|
|
properties.forEach(function(property) {
|
|
properties.forEach(function(property) {
|
|
|
|
|
|
- if (property.get('isRequiredByAgent')) {
|
|
|
|
- desired_config.properties[property.get('name')] = this.formatValueBeforeSave(property);
|
|
|
|
|
|
+ if (Em.get(property, 'isRequiredByAgent')) {
|
|
|
|
+ desired_config.properties[Em.get(property, 'name')] = this.formatValueBeforeSave(property);
|
|
/**
|
|
/**
|
|
* add is final value
|
|
* add is final value
|
|
*/
|
|
*/
|
|
- if (property.get('isFinal')) {
|
|
|
|
- attributes.final[property.get('name')] = "true";
|
|
|
|
|
|
+ if (Em.get(property, 'isFinal')) {
|
|
|
|
+ attributes.final[Em.get(property, 'name')] = "true";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}, this);
|
|
}, this);
|
|
@@ -441,20 +472,20 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
* @returns {string}
|
|
* @returns {string}
|
|
*/
|
|
*/
|
|
formatValueBeforeSave: function(property) {
|
|
formatValueBeforeSave: function(property) {
|
|
- var name = property.get('name');
|
|
|
|
- var value = property.get('value');
|
|
|
|
|
|
+ var name = Em.get(property, 'name');
|
|
|
|
+ var value = Em.get(property, 'value');
|
|
var kdcTypesMap = App.router.get('mainAdminKerberosController.kdcTypesValues');
|
|
var kdcTypesMap = App.router.get('mainAdminKerberosController.kdcTypesValues');
|
|
- //TODO check for core-site
|
|
|
|
- if (this.get('heapsizeRegExp').test(name) && !this.get('heapsizeException').contains(name) && !(value).endsWith("m")) {
|
|
|
|
|
|
+
|
|
|
|
+ if (this.addM(name, value)) {
|
|
return value += "m";
|
|
return value += "m";
|
|
}
|
|
}
|
|
- if (typeof property.get('value') === "boolean") {
|
|
|
|
- return property.get('value').toString();
|
|
|
|
|
|
+ if (typeof value === "boolean") {
|
|
|
|
+ return value.toString();
|
|
}
|
|
}
|
|
switch (name) {
|
|
switch (name) {
|
|
case 'kdc_type':
|
|
case 'kdc_type':
|
|
return Em.keys(kdcTypesMap).filter(function(key) {
|
|
return Em.keys(kdcTypesMap).filter(function(key) {
|
|
- return kdcTypesMap[key] === property.get('value');
|
|
|
|
|
|
+ return kdcTypesMap[key] === value;
|
|
})[0];
|
|
})[0];
|
|
case 'storm.zookeeper.servers':
|
|
case 'storm.zookeeper.servers':
|
|
case 'nimbus.seeds':
|
|
case 'nimbus.seeds':
|
|
@@ -465,10 +496,23 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
- return App.config.trimProperty(property, true);
|
|
|
|
|
|
+ return App.config.trimProperty(property);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Site object name follow the format *permsize/*heapsize and the value NOT ends with "m"
|
|
|
|
+ *
|
|
|
|
+ * @param name
|
|
|
|
+ * @param value
|
|
|
|
+ * @returns {*|boolean}
|
|
|
|
+ */
|
|
|
|
+ addM: function (name, value) {
|
|
|
|
+ return this.get('heapsizeRegExp').test(name)
|
|
|
|
+ && !this.get('heapsizeException').contains(name)
|
|
|
|
+ && !(value).endsWith("m");
|
|
|
|
+ },
|
|
|
|
+
|
|
/*********************************** 4. AJAX REQUESTS **************************************/
|
|
/*********************************** 4. AJAX REQUESTS **************************************/
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -863,94 +907,5 @@ App.ConfigsSaverMixin = Em.Mixin.create({
|
|
this.hide();
|
|
this.hide();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Save "final" attribute for properties
|
|
|
|
- * @param {Array} properties - array of properties
|
|
|
|
- * @returns {Object|null}
|
|
|
|
- * @method getConfigAttributes
|
|
|
|
- */
|
|
|
|
- getConfigAttributes: function(properties) {
|
|
|
|
- var attributes = {
|
|
|
|
- final: {}
|
|
|
|
- };
|
|
|
|
- var finalAttributes = attributes.final;
|
|
|
|
- var hasAttributes = false;
|
|
|
|
- properties.forEach(function (property) {
|
|
|
|
- if (property.isRequiredByAgent !== false && property.isFinal) {
|
|
|
|
- hasAttributes = true;
|
|
|
|
- finalAttributes[property.name] = "true";
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- if (hasAttributes) {
|
|
|
|
- return attributes;
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * create site object
|
|
|
|
- * @param {string} siteName
|
|
|
|
- * @param {string} tagName
|
|
|
|
- * @param {object[]} siteObj
|
|
|
|
- * @return {Object}
|
|
|
|
- * @method createSiteObj
|
|
|
|
- */
|
|
|
|
- createSiteObj: function (siteName, tagName, siteObj) {
|
|
|
|
- var heapsizeException = this.get('heapsizeException');
|
|
|
|
- var heapsizeRegExp = this.get('heapsizeRegExp');
|
|
|
|
- var siteProperties = {};
|
|
|
|
- siteObj.forEach(function (_siteObj) {
|
|
|
|
- var value = _siteObj.value;
|
|
|
|
- if (_siteObj.isRequiredByAgent == false) return;
|
|
|
|
- // site object name follow the format *permsize/*heapsize and the value NOT ends with "m"
|
|
|
|
- if (heapsizeRegExp.test(_siteObj.name) && !heapsizeException.contains(_siteObj.name) && !(_siteObj.value).endsWith("m")) {
|
|
|
|
- value += "m";
|
|
|
|
- }
|
|
|
|
- siteProperties[_siteObj.name] = value;
|
|
|
|
- switch (siteName) {
|
|
|
|
- case 'falcon-startup.properties':
|
|
|
|
- case 'falcon-runtime.properties':
|
|
|
|
- case 'pig-properties':
|
|
|
|
- siteProperties[_siteObj.name] = value;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- siteProperties[_siteObj.name] = this.setServerConfigValue(_siteObj.name, value);
|
|
|
|
- }
|
|
|
|
- }, this);
|
|
|
|
- var result = {"type": siteName, "tag": tagName, "properties": siteProperties};
|
|
|
|
- var attributes = this.getConfigAttributes(siteObj);
|
|
|
|
- if (attributes) {
|
|
|
|
- result['properties_attributes'] = attributes;
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * This method will be moved to config's decorators class.
|
|
|
|
- *
|
|
|
|
- * For now, provide handling for special properties that need
|
|
|
|
- * be specified in special format required for server.
|
|
|
|
- *
|
|
|
|
- * @param configName {String} - name of config property
|
|
|
|
- * @param value {*} - value of config property
|
|
|
|
- *
|
|
|
|
- * @return {String} - formatted value
|
|
|
|
- * @method setServerConfigValue
|
|
|
|
- */
|
|
|
|
- setServerConfigValue: function (configName, value) {
|
|
|
|
- switch (configName) {
|
|
|
|
- case 'storm.zookeeper.servers':
|
|
|
|
- case 'nimbus.seeds':
|
|
|
|
- if(Em.isArray(value)) {
|
|
|
|
- return JSON.stringify(value).replace(/"/g, "'");
|
|
|
|
- } else {
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- return value;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|