You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2014/09/26 18:48:24 UTC
[09/44] git commit: AMBARI-7491 Error message appeared during adding
services. (ababiichuk)
AMBARI-7491 Error message appeared during adding services. (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cb3e2eef
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cb3e2eef
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cb3e2eef
Branch: refs/heads/branch-alerts-dev
Commit: cb3e2eef274a721ada7c65d17aff9c117c1c8654
Parents: c9a7a3c
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Thu Sep 25 18:44:42 2014 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Thu Sep 25 18:45:05 2014 +0300
----------------------------------------------------------------------
ambari-web/app/controllers/wizard.js | 30 +++++++++++++++++---
.../app/controllers/wizard/step7_controller.js | 6 ++--
.../app/controllers/wizard/step8_controller.js | 4 +--
ambari-web/app/models/config_group.js | 15 ++++++----
ambari-web/app/models/service_config.js | 14 +++++----
5 files changed, 48 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3e2eef/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index eeffdfd..7815b4e 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -886,11 +886,11 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
*/
saveServiceConfigGroups: function (stepController, isAddService) {
var serviceConfigGroups = [],
- isForUpdate = false,
+ isForInstalledService = false,
hosts = isAddService ? App.router.get('addServiceController').getDBProperty('hosts') : this.getDBProperty('hosts');
stepController.get('stepConfigs').forEach(function (service) {
// mark group of installed service
- if (service.get('selected') === false) isForUpdate = true;
+ if (service.get('selected') === false) isForInstalledService = true;
service.get('configGroups').forEach(function (configGroup) {
var properties = [];
configGroup.get('properties').forEach(function (property) {
@@ -903,14 +903,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
})
});
//configGroup copied into plain JS object to avoid Converting circular structure to JSON
+ var hostNames = configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;});
serviceConfigGroups.push({
id: configGroup.get('id'),
name: configGroup.get('name'),
description: configGroup.get('description'),
- hosts: configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;}),
+ hosts: hostNames,
properties: properties,
isDefault: configGroup.get('isDefault'),
- isForUpdate: isForUpdate,
+ isForInstalledService: isForInstalledService,
+ isForUpdate: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
service: {id: configGroup.get('service.id')}
});
}, this)
@@ -918,6 +920,26 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
this.set('content.configGroups', serviceConfigGroups);
},
+
+ /**
+ * generate string hash for config group
+ * @param {Object} configGroup
+ * @param {Array|undefined} hosts
+ * @returns {String|null}
+ * @method getConfigGroupHash
+ */
+ getConfigGroupHash: function(configGroup, hosts) {
+ if (!Em.get(configGroup, 'properties.length') && !Em.get(configGroup, 'hosts.length') && !hosts) {
+ return null;
+ }
+ var hash = {};
+ Em.get(configGroup, 'properties').forEach(function (config) {
+ hash[Em.get(config, 'name')] = {value: Em.get(config, 'value'), isFinal: Em.get(config, 'isFinal')};
+ });
+ hash['hosts'] = hosts || Em.get(configGroup, 'hosts');
+ return JSON.stringify(hash);
+ },
+
/**
* return slaveComponents bound to hosts
* @return {Array}
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3e2eef/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 22db35d..15e6d9f 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -17,8 +17,6 @@
*/
var App = require('app');
-var numberUtils = require('utils/number_utils');
-var stringUtils = require('utils/string_utils');
/**
* By Step 7, we have the following information stored in App.db and set on this
* controller by the router.
@@ -645,7 +643,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, {
serviceConfigProperty.validate();
}, this);
-
+ component.get('configGroups').filterProperty('isDefault', false).forEach(function(configGroup) {
+ configGroup.set('hash', this.get('wizardController').getConfigGroupHash(configGroup));
+ }, this);
var overrideToAdd = this.get('overrideToAdd');
if (overrideToAdd) {
overrideToAdd = componentConfig.get('configs').findProperty('name', overrideToAdd.name);
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3e2eef/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 1fd0b0a..f8021c4 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1523,11 +1523,11 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, {
});
groupData.desired_configs = serviceConfigController.buildGroupDesiredConfigs.call(serviceConfigController, groupConfigs, timeTag);
// check for group from installed service
- if (configGroup.isForUpdate === true) {
+ if (configGroup.isForInstalledService === true) {
// if group is a new one, create it
if (!configGroup.id) {
sendData.push({"ConfigGroup": groupData});
- } else {
+ } else if (configGroup.isForUpdate){
// update an existing group
groupData.id = configGroup.id;
updateData.push({"ConfigGroup": groupData});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3e2eef/ambari-web/app/models/config_group.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/config_group.js b/ambari-web/app/models/config_group.js
index 9618001..edb3d34 100644
--- a/ambari-web/app/models/config_group.js
+++ b/ambari-web/app/models/config_group.js
@@ -82,15 +82,16 @@ App.ConfigGroup = Ember.Object.extend({
hosts: [],
/**
- * In add service wizard we have installed services.
- * And on deploy step we need to update existing config groups
- * also mark it for be sure that config group data came from
- * installed service.
- *
+ * this flag is used for installed services' config groups
+ * if user make changes to them - mark this flag to true
*/
isForUpdate: false,
/**
+ * mark config groups for installed services
+ */
+ isForInstalledService: false,
+ /**
* Provides a display friendly name. This includes trimming
* names to a certain length.
*/
@@ -158,5 +159,7 @@ App.ConfigGroup = Ember.Object.extend({
result += item.name + " : " + item.value + '<br/>';
}, this);
return result;
- }.property('properties.length')
+ }.property('properties.length'),
+
+ hash: null
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3e2eef/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index 963ff16..6f3d32f 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -857,12 +857,14 @@ App.ServiceConfigProperty = Ember.Object.extend({
isError = true;
} else {
var overrides = parentSCP.get('overrides');
- overrides.forEach(function (override) {
- if (self != override && value === override.get('value') && supportsFinal && isFinal === parentSCP.get('isFinal')) {
- self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
- isError = true;
- }
- });
+ if (overrides) {
+ overrides.forEach(function (override) {
+ if (self != override && value === override.get('value') && supportsFinal && isFinal === parentSCP.get('isFinal')) {
+ self.set('errorMessage', 'Multiple configuration overrides cannot have same value');
+ isError = true;
+ }
+ });
+ }
}
}
}