You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by lp...@apache.org on 2017/09/12 10:04:39 UTC

[22/57] [abbrv] ambari git commit: AMBARI-21908. Server returns 500 error for create config group request. (swagle)

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/5b1a63b7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5b1a63b7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5b1a63b7

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: 5b1a63b7168296aab5a56744edd14dc1cc199425
Parents: 5e242c9
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Thu Sep 7 13:50:43 2017 -0700
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Thu Sep 7 13:50:43 2017 -0700

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


http://git-wip-us.apache.org/repos/asf/ambari/blob/5b1a63b7/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 cb20328..babdf10 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
@@ -27,18 +27,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;
@@ -68,6 +70,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/5b1a63b7/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 2a45f02..737bfa4 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
@@ -562,8 +565,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) {
@@ -751,6 +754,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/5b1a63b7/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 f81ff99..1556b0d 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/5b1a63b7/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 5f3acdd..e42864f 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -63,6 +63,7 @@
         "ConfigGroup/id",
         "ConfigGroup/cluster_name",
         "ConfigGroup/group_name",
+        "ConfigGroup/service_name",
         "ConfigGroup/tag",
         "ConfigGroup/description",
         "ConfigGroup/hosts",