You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2017/05/17 20:51:51 UTC
[17/25] ambari git commit: AMBARI-21037 When adding services,
new versions of configs get added for the config types associated
with config groups. (atkach)
AMBARI-21037 When adding services, new versions of configs get added for the config types associated with config groups. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/735c4137
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/735c4137
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/735c4137
Branch: refs/heads/branch-feature-AMBARI-14714
Commit: 735c4137cb2cbb95c6da44809a447c148c7c6f9d
Parents: 4427a33
Author: Andrii Tkach <at...@apache.org>
Authored: Wed May 17 13:57:49 2017 +0300
Committer: Andrii Tkach <at...@apache.org>
Committed: Wed May 17 18:15:20 2017 +0300
----------------------------------------------------------------------
ambari-web/app/controllers/wizard.js | 6 ++--
.../app/controllers/wizard/step7_controller.js | 1 +
.../app/mixins/common/configs/configs_saver.js | 32 ++++++++++++++------
.../mixins/common/configs/configs_saver_test.js | 13 ++++++++
4 files changed, 39 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/735c4137/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index c3a54cf..a8a0249 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -1031,16 +1031,16 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
})
});
//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;});
+ var hostIds = 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: hostNames.slice(),
+ hosts: hostIds.slice(),
properties: properties.slice(),
is_default: configGroup.get('isDefault'),
is_for_installed_service: isForInstalledService,
- is_for_update: configGroup.isForUpdate || configGroup.get('hash') != this.getConfigGroupHash(configGroup, hostNames),
+ is_for_update: configGroup.get('isForUpdate') || configGroup.get('hash') !== this.getConfigGroupHash(configGroup, configGroup.get('hosts')),
service_name: configGroup.get('serviceName'),
service_id: configGroup.get('serviceName'),
desired_configs: configGroup.get('desiredConfigs'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/735c4137/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 8e14b70..6685c01 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -1186,6 +1186,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
this.get('stepConfigs').findProperty('serviceName', service.serviceName).get('configs').pushObject(overriddenSCP);
}
}, this);
+ modelGroup.set('hash', this.get('wizardController').getConfigGroupHash(modelGroup));
}, this);
service.set('configGroups', App.ServiceConfigGroup.find().filterProperty('serviceName', service.get('serviceName')));
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/735c4137/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 7d8721d..4a4163e 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -368,10 +368,10 @@ App.ConfigsSaverMixin = Em.Mixin.create({
/*********************************** 3. GENERATING JSON TO SAVE *****************************/
/**
- * Map that contains last used timestamp per filename.
+ * Map that contains last used timestamp.
* There is a case when two config groups can update same filename almost simultaneously
- * so they have equal timestamp only and this causes collision. So to prevent this we need to check
- * if specific filename with specific timestamp is not saved yet
+ * so they have equal timestamp and this causes collision. So to prevent this we need to check
+ * if specific filename with specific timestamp is not saved yet.
*
* @type {Object}
*/
@@ -389,14 +389,9 @@ App.ConfigsSaverMixin = Em.Mixin.create({
var desired_config = [];
if (Em.isArray(configsToSave) && Em.isArray(fileNamesToSave) && fileNamesToSave.length && configsToSave.length) {
serviceConfigNote = serviceConfigNote || "";
- var tagVersion = "version" + (new Date).getTime();
- fileNamesToSave.forEach(function(fName) {
- /** @see <code>_timeStamps<code> **/
- if (this.get('_timeStamps')[fName] === tagVersion) {
- tagVersion = "version" + ((new Date).getTime() + 1);
- }
- this.get('_timeStamps')[fName] = tagVersion;
+ fileNamesToSave.forEach(function(fName) {
+ var tagVersion = this.getUniqueTag();
if (this.allowSaveSite(fName)) {
var properties = configsToSave.filterProperty('filename', fName);
@@ -409,6 +404,23 @@ App.ConfigsSaverMixin = Em.Mixin.create({
},
/**
+ * generate unique tag
+ * @returns {string}
+ */
+ getUniqueTag: function() {
+ var timestamp = (new Date).getTime();
+ var tagVersion = "version" + timestamp;
+
+ while(this.get('_timeStamps')[tagVersion]) {
+ timestamp++;
+ tagVersion = "version" + timestamp;
+ }
+ /** @see <code>_timeStamps<code> **/
+ this.get('_timeStamps')[tagVersion] = true;
+ return tagVersion;
+ },
+
+ /**
* For some file names we have a restriction
* and can't save them, in this case method will return false
*
http://git-wip-us.apache.org/repos/asf/ambari/blob/735c4137/ambari-web/test/mixins/common/configs/configs_saver_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index 6e65cf9..7815938 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -259,6 +259,19 @@ describe('App.ConfigsSaverMixin', function() {
})
});
+ describe('#getUniqueTag', function() {
+
+ it('should generate unique tags', function() {
+ var tags = [];
+ for (var i = 0; i < 3; i++) {
+ tags.push(mixin.getUniqueTag());
+ }
+ expect(tags[1]).to.not.be.equal(tags[0]);
+ expect(tags[2]).to.not.be.equal(tags[1]);
+ expect(tags[0]).to.not.be.equal(tags[2]);
+ });
+ });
+
describe('#getModifiedConfigs', function () {
var configs = [
Em.Object.create({