ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-4008. Config group names should be unique in a service, not global. (akovalenko)
Date Fri, 06 Dec 2013 17:57:27 GMT
Updated Branches:
  refs/heads/trunk b92082252 -> 0a94a0f43


AMBARI-4008. Config group names should be unique in a service, not global. (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0a94a0f4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0a94a0f4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0a94a0f4

Branch: refs/heads/trunk
Commit: 0a94a0f439c31bc15ee3797658fff6e06171fdad
Parents: b920822
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Fri Dec 6 19:54:40 2013 +0200
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Fri Dec 6 19:54:40 2013 +0200

----------------------------------------------------------------------
 .../app/controllers/main/host/add_controller.js | 12 +--
 .../controllers/main/service/info/configs.js    | 10 +--
 .../service/manage_config_groups_controller.js  | 88 +++++++++-----------
 .../app/controllers/wizard/step7_controller.js  | 12 +--
 ambari-web/app/models/config_group.js           |  8 --
 ambari-web/app/utils/ajax.js                    |  2 +-
 ambari-web/app/utils/config.js                  |  4 +-
 .../app/views/common/configs/services_config.js |  2 +-
 .../main/service/manage_config_groups_view.js   |  2 +-
 9 files changed, 57 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 2cc93c7..aa41b2e 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -316,7 +316,7 @@ App.AddHostController = App.WizardController.extend({
   applyConfigGroup: function () {
     var serviceConfigGroups = this.get('content.serviceConfigGroups');
     serviceConfigGroups.forEach(function (group){
-      if(group.selectedConfigGroup != "Default") {
+      if (group.configGroups.someProperty('ConfigGroup.group_name', group.selectedConfigGroup))
{
         var configGroup = group.configGroups.findProperty('ConfigGroup.group_name', group.selectedConfigGroup);
         group.hosts.forEach(function(host){
           configGroup.ConfigGroup.hosts.push({
@@ -367,14 +367,15 @@ App.AddHostController = App.WizardController.extend({
           var service = componentServiceMap[slave.componentName];
           var configGroups = this.get('content.configGroups').filterProperty('ConfigGroup.tag',
service);
           var configGroupsNames = configGroups.mapProperty('ConfigGroup.group_name');
-          configGroupsNames.unshift('Default');
+          var defaultGroupName = App.Service.DisplayNames[service] + ' Default';
+          configGroupsNames.unshift(defaultGroupName);
           selectedServices.push({
             serviceId: service,
             displayName: App.Service.DisplayNames[service],
             hosts: slave.hosts.mapProperty('hostName'),
             configGroupsNames: configGroupsNames,
             configGroups: configGroups,
-            selectedConfigGroup: "Default"
+            selectedConfigGroup: defaultGroupName
           });
         }
       }
@@ -390,14 +391,15 @@ App.AddHostController = App.WizardController.extend({
         } else {
           var configGroups = this.get('content.configGroups').filterProperty('ConfigGroup.tag',
service);
           var configGroupsNames = configGroups.mapProperty('ConfigGroup.group_name').sort();
-          configGroupsNames.unshift('Default');
+          var defaultGroupName = App.Service.DisplayNames[service] + ' Default';
+          configGroupsNames.unshift(defaultGroupName);
           selectedServices.push({
             serviceId: service,
             displayName: App.Service.DisplayNames[service],
             hosts: selectedClientHosts,
             configGroupsNames: configGroupsNames,
             configGroups: configGroups,
-            selectedConfigGroup: "Default"
+            selectedConfigGroup: defaultGroupName
           });
         }
       }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 1c11baa..7010ea6 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -35,7 +35,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
   isApplyingChanges: false,
   // contain Service Config Property, when user proceed from Select Config Group dialog
   overrideToAdd: null,
-  usedConfigGroupNames: [],
   serviceConfigs: function () {
     return App.config.get('preDefinedServiceConfigs');
   }.property('App.config.preDefinedServiceConfigs'),
@@ -290,7 +289,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     // Create default configuration group
     var defaultConfigGroupHosts = App.Host.find().mapProperty('hostName');
     var selectedConfigGroup;
-    var usedConfigGroupNames = ['Default'];
     var siteToTagMap = {};
     for (var site in data.Clusters.desired_configs) {
       if (serviceConfigsDef.sites.indexOf(site) > -1) {
@@ -330,16 +328,13 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
               selectedConfigGroup = newConfigGroup;
             }
             configGroups.push(newConfigGroup);
-          } else {
-            usedConfigGroupNames.push(item.group_name);
           }
         }, this);
-        this.set('usedConfigGroupNames', usedConfigGroupNames);
       }
       this.set('configGroups', configGroups);
     }
     var defaultConfigGroup = App.ConfigGroup.create({
-      name: "Default",
+      name: App.Service.DisplayNames[serviceName] + " Default",
       description: "Default cluster level " + serviceName + " configuration",
       isDefault: true,
       hosts: defaultConfigGroupHosts,
@@ -1923,7 +1918,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       bodyClass: App.MainServiceManageConfigGroupView.extend({
         serviceName: serviceName,
         displayName: displayName,
-        usedConfigGroupNames: (controller && controller.get('usedConfigGroupNames')),
         controllerBinding: (!!controller) ? 'App.router.installerManageConfigGroupsController'
: 'App.router.manageConfigGroupsController'
       }),
       classNames: ['sixty-percent-width-modal', 'manage-configuration-group-popup'],
@@ -2055,4 +2049,4 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       }
     });
   }
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index d6ee058..04a052b 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -36,8 +36,6 @@ App.ManageConfigGroupsController = Em.Controller.extend({
 
   loadedHostsToGroupMap: {},
 
-  usedConfigGroupNames: [],
-
   resortConfigGroup: function() {
     var configGroups = Ember.copy(this.get('configGroups'));
     if(configGroups.length < 2){
@@ -59,6 +57,9 @@ App.ManageConfigGroupsController = Em.Controller.extend({
     this.set('serviceName', serviceName);
     App.ajax.send({
       name: 'service.load_config_groups',
+      data: {
+        serviceName: serviceName
+      },
       sender: this,
       success: 'onLoadConfigGroupsSuccess',
       error: 'onLoadConfigGroupsError'
@@ -69,55 +70,49 @@ App.ManageConfigGroupsController = Em.Controller.extend({
     var loadedHostsToGroupMap = this.get('loadedHostsToGroupMap');
     var usedHosts = [];
     var unusedHosts = [];
+    var serviceName = this.get('serviceName');
     var defaultConfigGroup = App.ConfigGroup.create({
-      name: "Default",
+      name: App.Service.DisplayNames[serviceName] + " Default",
       description: "Default cluster level " + this.get('serviceName') + " configuration",
       isDefault: true,
       parentConfigGroup: null,
       service: this.get('content'),
       configSiteTags: [],
-      serviceName: this.get('serviceName')
+      serviceName: serviceName
     });
     if (data && data.items) {
       var groupToTypeToTagMap = {};
       var configGroups = [];
-      var serviceName = this.get('serviceName');
-      var usedConfigGroupNames = [];
       data.items.forEach(function (configGroup) {
         configGroup = configGroup.ConfigGroup;
-        if (configGroup.tag === serviceName) {
-          var hostNames = configGroup.hosts.mapProperty('host_name');
-          loadedHostsToGroupMap[configGroup.group_name] = hostNames.slice();
-          var newConfigGroup = App.ConfigGroup.create({
-            id: configGroup.id,
-            name: configGroup.group_name,
-            description: configGroup.description,
-            isDefault: false,
-            parentConfigGroup: defaultConfigGroup,
-            service: App.Service.find().findProperty('serviceName', configGroup.tag),
-            hosts: hostNames,
-            configSiteTags: [],
-            properties: [],
-            apiResponse: configGroup
-          });
-          usedHosts = usedHosts.concat(newConfigGroup.get('hosts'));
-          configGroups.push(newConfigGroup);
-          var newConfigGroupSiteTags = newConfigGroup.get('configSiteTags');
-          configGroup.desired_configs.forEach(function (config) {
-            newConfigGroupSiteTags.push(App.ConfigSiteTag.create({
-              site: config.type,
-              tag: config.tag
-            }));
-            if (!groupToTypeToTagMap[configGroup.group_name]) {
-              groupToTypeToTagMap[configGroup.group_name] = {}
-            }
-            groupToTypeToTagMap[configGroup.group_name][config.type] = config.tag;
-          });
-        } else {
-          usedConfigGroupNames.push(configGroup.group_name);
-        }
+        var hostNames = configGroup.hosts.mapProperty('host_name');
+        loadedHostsToGroupMap[configGroup.group_name] = hostNames.slice();
+        var newConfigGroup = App.ConfigGroup.create({
+          id: configGroup.id,
+          name: configGroup.group_name,
+          description: configGroup.description,
+          isDefault: false,
+          parentConfigGroup: defaultConfigGroup,
+          service: App.Service.find().findProperty('serviceName', configGroup.tag),
+          hosts: hostNames,
+          configSiteTags: [],
+          properties: [],
+          apiResponse: configGroup
+        });
+        usedHosts = usedHosts.concat(newConfigGroup.get('hosts'));
+        configGroups.push(newConfigGroup);
+        var newConfigGroupSiteTags = newConfigGroup.get('configSiteTags');
+        configGroup.desired_configs.forEach(function (config) {
+          newConfigGroupSiteTags.push(App.ConfigSiteTag.create({
+            site: config.type,
+            tag: config.tag
+          }));
+          if (!groupToTypeToTagMap[configGroup.group_name]) {
+            groupToTypeToTagMap[configGroup.group_name] = {}
+          }
+          groupToTypeToTagMap[configGroup.group_name][config.type] = config.tag;
+        });
       }, this);
-      this.set('usedConfigGroupNames', usedConfigGroupNames);
       unusedHosts = App.Host.find().mapProperty('hostName');
       usedHosts.uniq().forEach(function (host) {
         unusedHosts = unusedHosts.without(host);
@@ -287,7 +282,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({
    * rename new config group
    */
   renameConfigGroup: function () {
-    if(this.get('selectedConfigGroup.name') == "Default") {
+    if(this.get('selectedConfigGroup.isDefault')) {
       return;
     }
     var content = this;
@@ -303,7 +298,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({
       content: content,
       validate: function () {
         var warningMessage = '';
-        if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName')))
{
+        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName')))
{
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
         }
         this.set('warningMessage', warningMessage);
@@ -364,7 +359,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({
       warningMessage: '',
       validate: function () {
         var warningMessage = '';
-        if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName').trim()))
{
+        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName').trim()))
{
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
         }
         this.set('warningMessage', warningMessage);
@@ -480,7 +475,7 @@ App.ManageConfigGroupsController = Em.Controller.extend({
    * duplicate config group
    */
   duplicateConfigGroup: function() {
-    if(this.get('selectedConfigGroup.name') == "Default") {
+    if(this.get('selectedConfigGroup.isDefault')) {
       return;
     }
     this.addConfigGroup(true);
@@ -520,9 +515,8 @@ App.ManageConfigGroupsController = Em.Controller.extend({
 App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.extend({
   name: 'installerManageConfigGroupsController',
 
-  loadConfigGroups: function (serviceName, usedConfigGroupNames) {
+  loadConfigGroups: function (serviceName) {
     this.set('serviceName', serviceName);
-    this.set('usedConfigGroupNames', usedConfigGroupNames);
     var loadedHostsToGroupMap = this.get('loadedHostsToGroupMap');
     var configGroups = this.copyConfigGroups(App.router.get('wizardStep7Controller.selectedService.configGroups'));
     configGroups.forEach(function (configGroup) {
@@ -571,7 +565,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
    * rename new config group
    */
   renameConfigGroup: function () {
-    if(this.get('selectedConfigGroup.name') == "Default") {
+    if(this.get('selectedConfigGroup.isDefault')) {
       return;
     }
     var self = this;
@@ -587,7 +581,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
       warningMessage: '',
       validate: function () {
         var warningMessage = '';
-        if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName')))
{
+        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName')))
{
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
         }
         this.set('warningMessage', warningMessage);
@@ -625,7 +619,7 @@ App.InstallerManageConfigGroupsController = App.ManageConfigGroupsController.ext
       warningMessage: '',
       validate: function () {
         var warningMessage = '';
-        if (self.get('usedConfigGroupNames').concat(self.get('configGroups').mapProperty('name')).contains(this.get('configGroupName')))
{
+        if (self.get('configGroups').mapProperty('name').contains(this.get('configGroupName')))
{
           warningMessage = Em.I18n.t("config.group.selection.dialog.err.name.exists");
         }
         this.set('warningMessage', warningMessage);

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/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 2c2848f..9709409 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -51,16 +51,8 @@ App.WizardStep7Controller = Em.Controller.extend({
   isInstaller: true,
 
   configGroups: [],
+
   selectedConfigGroup: null,
-  usedConfigGroupNames: function () {
-    var names = [];
-    var selectedServiceName = this.get('selectedService.serviceName');
-    this.get('stepConfigs').forEach(function (service) {
-      if (selectedServiceName != service.get('serviceName')) {
-      names.pushObjects(service.get('configGroups').mapProperty('name'));}
-    }, this);
-    return names;
-  }.property('selectedService.configGroups.@each.name'),
 
   isSubmitDisabled: function () {
     return (!this.stepConfigs.filterProperty('showConfig', true).everyProperty('errorCount',
0) || this.get("miscModalVisible"));
@@ -167,7 +159,7 @@ App.WizardStep7Controller = Em.Controller.extend({
       if (!serviceRawGroups.length) {
         service.set('configGroups', [
           App.ConfigGroup.create({
-            name: "Default",
+            name: App.Service.DisplayNames[service.serviceName] + " Default",
             description: "Default cluster level " + service.serviceName + " configuration",
             isDefault: true,
             hosts: Em.copy(hosts),

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/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 d99d143..1bfc348 100644
--- a/ambari-web/app/models/config_group.js
+++ b/ambari-web/app/models/config_group.js
@@ -83,14 +83,6 @@ App.ConfigGroup = Ember.Object.extend({
    */
   displayName: function () {
     var name = this.get('name');
-    if (name && name == "Default") {
-      if (this.get('serviceName')) {
-        name = App.Service.DisplayNames[this.get('serviceName').toUpperCase()] + " Default";
-      }
-      if (this.get('service')) {
-        name = App.Service.DisplayNames[this.get('service.id')] + " Default";
-      }
-    }
     if (name && name.length>App.config.CONFIG_GROUP_NAME_MAX_LENGTH) {
       var middle = Math.floor(App.config.CONFIG_GROUP_NAME_MAX_LENGTH / 2);
       name = name.substring(0, middle) + "..." + name.substring(name.length-middle);

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 4f299f2..9a2f1fa 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -91,7 +91,7 @@ var urls = {
     }
   },
   'service.load_config_groups': {
-    'real': '/clusters/{clusterName}/config_groups?fields=*',
+    'real': '/clusters/{clusterName}/config_groups?ConfigGroup/tag={serviceName}&fields=*',
     'mock': ''
   },
   'reassign.stop_services': {

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index a446125..a418c2a 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1015,7 +1015,7 @@ App.config = Em.Object.create({
     }
   },
 
-  launchConfigGroupSelectionCreationDialog : function(serviceId, configGroups, usedConfigGroupNames,
configProperty, callback, isInstaller) {
+  launchConfigGroupSelectionCreationDialog : function(serviceId, configGroups, configProperty,
callback, isInstaller) {
     var self = this;
     var availableConfigGroups = configGroups.slice();
     // delete Config Groups, that already have selected property overridden
@@ -1085,7 +1085,7 @@ App.config = Em.Object.create({
         var optionSelect = this.get('optionSelectConfigGroup');
         if (!optionSelect) {
           var nn = this.get('newConfigGroupName');
-          if (nn && usedConfigGroupNames.concat(configGroups.mapProperty('name')).contains(nn))
{
+          if (nn && configGroups.mapProperty('name').contains(nn)) {
             msg = Em.I18n.t("config.group.selection.dialog.err.name.exists");
           }
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/views/common/configs/services_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/services_config.js b/ambari-web/app/views/common/configs/services_config.js
index 99f0ae9..fc88342 100644
--- a/ambari-web/app/views/common/configs/services_config.js
+++ b/ambari-web/app/views/common/configs/services_config.js
@@ -553,7 +553,7 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({
     if (selectedConfigGroup.get('isDefault')) {
       // Launch dialog to pick/create Config-group
       App.config.launchConfigGroupSelectionCreationDialog(this.get('service.serviceName'),
-        configGroups, serviceConfigController.get('usedConfigGroupNames'), serviceConfigProperty,
function (selectedGroupInPopup) {
+        configGroups, serviceConfigProperty, function (selectedGroupInPopup) {
           console.log("launchConfigGroupSelectionCreationDialog(): Selected/Created:", selectedGroupInPopup);
           if (selectedGroupInPopup) {
             serviceConfigController.set('overrideToAdd', serviceConfigProperty);

http://git-wip-us.apache.org/repos/asf/ambari/blob/0a94a0f4/ambari-web/app/views/main/service/manage_config_groups_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/manage_config_groups_view.js b/ambari-web/app/views/main/service/manage_config_groups_view.js
index ae7b747..be13b85 100644
--- a/ambari-web/app/views/main/service/manage_config_groups_view.js
+++ b/ambari-web/app/views/main/service/manage_config_groups_view.js
@@ -63,7 +63,7 @@ App.MainServiceManageConfigGroupView = Em.View.extend({
   }.observes('controller.isLoaded', 'controller.configGroups'),
 
   didInsertElement: function () {
-    this.get('controller').loadConfigGroups(this.get('serviceName'), this.get('usedConfigGroupNames'));
+    this.get('controller').loadConfigGroups(this.get('serviceName'));
     App.tooltip($('.properties-link'));
     App.tooltip($("[rel='button-info']"));
     App.tooltip($("[rel='button-info-dropdown']"), {placement: 'left'});


Mime
View raw message