You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2017/09/07 20:33:57 UTC

ambari git commit: AMBARI-21908. Server returns 500 error for create config group request. (swagle)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.6 55d0db4af -> f67dd616d


AMBARI-21908. Server returns 500 error for create config group request. (swagle)


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

Branch: refs/heads/branch-2.6
Commit: f67dd616d6d61ce9f7d761cdd06f22abfa65111f
Parents: 55d0db4
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Thu Sep 7 13:30:37 2017 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Thu Sep 7 13:30:37 2017 -0700

----------------------------------------------------------------------
 .../server/controller/ConfigGroupRequest.java    | 14 ++++++++++++--
 .../internal/ConfigGroupResourceProvider.java    | 19 +++++++++++--------
 .../ambari/server/topology/AmbariContext.java    |  4 ++--
 ambari-server/src/main/resources/properties.json |  1 +
 4 files changed, 26 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f67dd616/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
index efa1a7e..4ea6aa3 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigGroupRequest.java
@@ -28,18 +28,20 @@ public class ConfigGroupRequest {
   private String clusterName;
   private String groupName;
   private String tag;
+  private String serviceName;
   private String description;
   private String serviceConfigVersionNote;
   private Set<String> hosts;
   private Map<String, Config> configs;
 
   public ConfigGroupRequest(Long id, String clusterName, String groupName,
-                            String tag, String description, Set<String> hosts,
-                            Map<String, Config> configs) {
+                            String tag, String serviceName, String description,
+                            Set<String> hosts, Map<String, Config> configs) {
     this.id = id;
     this.clusterName = clusterName;
     this.groupName = groupName;
     this.tag = tag;
+    this.serviceName = serviceName;
     this.description = description;
     this.hosts = hosts;
     this.configs = configs;
@@ -69,6 +71,14 @@ public class ConfigGroupRequest {
     this.tag = tag;
   }
 
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
   public String getDescription() {
     return description;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/f67dd616/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
index 0ea54cb..9bd10f1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ConfigGroupResourceProvider.java
@@ -62,6 +62,7 @@ import org.apache.ambari.server.state.ConfigFactory;
 import org.apache.ambari.server.state.Host;
 import org.apache.ambari.server.state.configgroup.ConfigGroup;
 import org.apache.ambari.server.state.configgroup.ConfigGroupFactory;
+import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -84,6 +85,8 @@ public class ConfigGroupResourceProvider extends
     .getPropertyId("ConfigGroup", "group_name");
   protected static final String CONFIGGROUP_TAG_PROPERTY_ID = PropertyHelper
     .getPropertyId("ConfigGroup", "tag");
+  protected static final String CONFIGGROUP_SERVICENAME_PROPERTY_ID = PropertyHelper
+    .getPropertyId("ConfigGroup", "service_name");
   protected static final String CONFIGGROUP_DESC_PROPERTY_ID = PropertyHelper
     .getPropertyId("ConfigGroup", "description");
   protected static final String CONFIGGROUP_SCV_NOTE_ID = PropertyHelper
@@ -494,20 +497,18 @@ public class ConfigGroupResourceProvider extends
     }
   }
 
-  private synchronized Set<ConfigGroupResponse> createConfigGroups
-    (Set<ConfigGroupRequest> requests) throws AmbariException, AuthorizationException {
+  private synchronized Set<ConfigGroupResponse> createConfigGroups(Set<ConfigGroupRequest> requests)
+      throws AmbariException, AuthorizationException {
 
     if (requests.isEmpty()) {
       LOG.warn("Received an empty requests set");
       return null;
     }
 
-    Set<ConfigGroupResponse> configGroupResponses = new
-      HashSet<ConfigGroupResponse>();
+    Set<ConfigGroupResponse> configGroupResponses = new HashSet<ConfigGroupResponse>();
 
     Clusters clusters = getManagementController().getClusters();
-    ConfigGroupFactory configGroupFactory = getManagementController()
-      .getConfigGroupFactory();
+    ConfigGroupFactory configGroupFactory = getManagementController().getConfigGroupFactory();
 
     for (ConfigGroupRequest request : requests) {
 
@@ -550,8 +551,8 @@ public class ConfigGroupResourceProvider extends
 
       verifyHostList(cluster, hosts, request);
 
-      String serviceName = null;
-      if (request.getConfigs() != null && !request.getConfigs().isEmpty()) {
+      String serviceName = request.getServiceName();
+      if (serviceName == null && !MapUtils.isEmpty(request.getConfigs())) {
         try {
           serviceName = cluster.getServiceForConfigTypes(request.getConfigs().keySet());
         } catch (IllegalArgumentException e) {
@@ -704,6 +705,7 @@ public class ConfigGroupResourceProvider extends
       configGroup.setName(request.getGroupName());
       configGroup.setDescription(request.getDescription());
       configGroup.setTag(request.getTag());
+      configGroup.setServiceName(request.getServiceName());
 
       if (serviceName != null) {
         cluster.createServiceConfigVersion(serviceName, getManagementController().getAuthName(),
@@ -730,6 +732,7 @@ public class ConfigGroupResourceProvider extends
       (String) properties.get(CONFIGGROUP_CLUSTER_NAME_PROPERTY_ID),
       (String) properties.get(CONFIGGROUP_NAME_PROPERTY_ID),
       (String) properties.get(CONFIGGROUP_TAG_PROPERTY_ID),
+      (String) properties.get(CONFIGGROUP_SERVICENAME_PROPERTY_ID),
       (String) properties.get(CONFIGGROUP_DESC_PROPERTY_ID),
       null,
       null);

http://git-wip-us.apache.org/repos/asf/ambari/blob/f67dd616/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
index da517f3..6a2d58d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/topology/AmbariContext.java
@@ -769,8 +769,8 @@ public class AmbariContext {
         }
       });
 
-      ConfigGroupRequest request = new ConfigGroupRequest(
-          null, clusterName, absoluteGroupName, service, "Host Group Configuration",
+      ConfigGroupRequest request = new ConfigGroupRequest(null, clusterName,
+        absoluteGroupName, service, service, "Host Group Configuration",
         Sets.newHashSet(filteredGroupHosts), serviceConfigs);
 
       // get the config group provider and create config group resource

http://git-wip-us.apache.org/repos/asf/ambari/blob/f67dd616/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index 80a86b8..228318d 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -97,6 +97,7 @@
         "ConfigGroup/id",
         "ConfigGroup/cluster_name",
         "ConfigGroup/group_name",
+        "ConfigGroup/service_name",
         "ConfigGroup/tag",
         "ConfigGroup/description",
         "ConfigGroup/hosts",