ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject git commit: AMBARI-6961. service config versioning needs to handle host config groups. (myroslav via mahadev)
Date Wed, 20 Aug 2014 22:29:27 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 48b61d0cc -> 5ed94d53a


AMBARI-6961. service config versioning needs to handle host config groups. (myroslav via mahadev)


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

Branch: refs/heads/trunk
Commit: 5ed94d53a3c7444ae1dc8143137f1bc528c6fd3d
Parents: 48b61d0
Author: Mahadev Konar <mahadev@apache.org>
Authored: Wed Aug 20 15:29:18 2014 -0700
Committer: Mahadev Konar <mahadev@apache.org>
Committed: Wed Aug 20 15:29:22 2014 -0700

----------------------------------------------------------------------
 .../ServiceConfigVersionResponse.java           |  30 ++++
 .../internal/ConfigGroupResourceProvider.java   |  15 ++
 .../ServiceConfigVersionResourceProvider.java   |  11 +-
 .../ambari/server/orm/dao/ClusterDAO.java       |  14 ++
 .../orm/entities/ServiceConfigEntity.java       |  28 ++++
 .../org/apache/ambari/server/state/Cluster.java |   5 +
 .../server/state/cluster/ClusterImpl.java       | 157 +++++++++++++++----
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |   4 +-
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |   4 +-
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |   5 +-
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  10 +-
 .../src/main/resources/properties.json          |   3 +
 12 files changed, 251 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
index f463a4b..49921bc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceConfigVersionResponse.java
@@ -30,9 +30,12 @@ public class ServiceConfigVersionResponse {
   private String serviceName;
   private Long version;
   private Long createTime;
+  private Long groupId;
+  private String groupName;
   private String userName;
   private String note;
   private List<ConfigurationResponse> configurations;
+  private List<String> hosts;
 
   @JsonProperty("service_name")
   public String getServiceName() {
@@ -100,5 +103,32 @@ public class ServiceConfigVersionResponse {
   public void setNote(String note) {
     this.note = note;
   }
+
+  public List<String> getHosts() {
+    return hosts;
+  }
+
+  @JsonProperty("hosts")
+  public void setHosts(List<String> hosts) {
+    this.hosts = hosts;
+  }
+
+  @JsonProperty("group_name")
+  public String getGroupName() {
+    return groupName;
+  }
+
+  public void setGroupName(String groupName) {
+    this.groupName = groupName;
+  }
+
+  @JsonProperty("group_id")
+  public Long getGroupId() {
+    return groupId;
+  }
+
+  public void setGroupId(Long groupId) {
+    this.groupId = groupId;
+  }
 }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/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 ab9646d..bb75832 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
@@ -456,6 +456,11 @@ public class ConfigGroupResourceProvider extends
         request.getTag(), request.getDescription(),
         request.getConfigs(), hosts);
 
+      String serviceName = null;
+      if (configGroup.getConfigurations() != null) {
+        serviceName = cluster.getServiceForConfigTypes(configGroup.getConfigurations().keySet());
+      }
+
       // Persist before add, since id is auto-generated
       configLogger.info("Persisting new Config group"
         + ", clusterName = " + cluster.getClusterName()
@@ -465,6 +470,9 @@ public class ConfigGroupResourceProvider extends
 
       configGroup.persist();
       cluster.addConfigGroup(configGroup);
+      if (serviceName != null) {
+        cluster.createServiceConfigVersion(serviceName, getManagementController().getAuthName(),
null, configGroup);
+      }
 
       ConfigGroupResponse response = new ConfigGroupResponse(configGroup
         .getId(), configGroup.getClusterName(), configGroup.getName(),
@@ -509,6 +517,10 @@ public class ConfigGroupResourceProvider extends
                                  + ", clusterName = " + request.getClusterName()
                                  + ", groupId = " + request.getId());
       }
+      String serviceName = null;
+      if (configGroup.getConfigurations() != null) {
+        serviceName = cluster.getServiceForConfigTypes(configGroup.getConfigurations().keySet());
+      }
 
       // Update hosts
       Map<String, Host> hosts = new HashMap<String, Host>();
@@ -541,6 +553,9 @@ public class ConfigGroupResourceProvider extends
         + ", user = " + getManagementController().getAuthName());
 
       configGroup.persist();
+      if (serviceName != null) {
+        cluster.createServiceConfigVersion(serviceName, getManagementController().getAuthName(),
null, configGroup);
+      }
     }
 
     getManagementController().getConfigHelper().invalidateStaleConfigsCache();

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
index 1713d01..3b7798e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceConfigVersionResourceProvider.java
@@ -38,6 +38,9 @@ public class ServiceConfigVersionResourceProvider extends
   public static final String SERVICE_CONFIG_VERSION_CREATE_TIME_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"createtime");
   public static final String SERVICE_CONFIG_VERSION_USER_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"user");
   public static final String SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"service_config_version_note");
+  public static final String SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"group_id");
+  public static final String SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"group_name");
+  public static final String SERVICE_CONFIG_VERSION_HOSTNAMES_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"hosts");
   public static final String SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID = PropertyHelper.getPropertyId(null,
"configurations");
 
   /**
@@ -101,6 +104,9 @@ public class ServiceConfigVersionResourceProvider extends
       resource.setProperty(SERVICE_CONFIG_VERSION_CONFIGURATIONS_PROPERTY_ID,
           convertToSubResources(response.getClusterName(), response.getConfigurations()));
       resource.setProperty(SERVICE_CONFIG_VERSION_NOTE_PROPERTY_ID, response.getNote());
+      resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_ID_PROPERTY_ID, response.getGroupId());
+      resource.setProperty(SERVICE_CONFIG_VERSION_GROUP_NAME_PROPERTY_ID, response.getGroupName());
+      resource.setProperty(SERVICE_CONFIG_VERSION_HOSTNAMES_PROPERTY_ID, response.getHosts());
 
       resources.add(resource);
     }
@@ -131,7 +137,10 @@ public class ServiceConfigVersionResourceProvider extends
       if (!propertyId.equals("cluster_name") && !propertyId.equals("serviceconfigversion")
&&
           !propertyId.equals("service_name") && !propertyId.equals("createtime")
&&
           !propertyId.equals("appliedtime") && !propertyId.equals("user") &&
-          !propertyId.equals("service_config_version_note")) {
+          !propertyId.equals("service_config_version_note") &&
+          !propertyId.equals("group_id") &&
+          !propertyId.equals("group_name") &&
+          !propertyId.equals("hosts")) {
 
         unsupportedProperties.add(propertyId);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
index 1be9e88..e52b8b2 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ClusterDAO.java
@@ -96,6 +96,20 @@ public class ClusterDAO {
     return daoUtils.selectOne(query);
   }
 
+  @RequiresSession
+  public ClusterConfigEntity findConfig(Long clusterId, String type, Long version) {
+    CriteriaBuilder cb = entityManagerProvider.get().getCriteriaBuilder();
+    CriteriaQuery<ClusterConfigEntity> cq = cb.createQuery(ClusterConfigEntity.class);
+    Root<ClusterConfigEntity> config = cq.from(ClusterConfigEntity.class);
+    cq.where(cb.and(
+        cb.equal(config.get("clusterId"), clusterId)),
+      cb.equal(config.get("type"), type),
+      cb.equal(config.get("version"), version)
+    );
+    TypedQuery<ClusterConfigEntity> query = entityManagerProvider.get().createQuery(cq);
+    return daoUtils.selectOne(query);
+  }
+
   /**
    * Create Cluster entity in Database
    * @param clusterEntity entity to create

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
index 86557ac..ec6bd9f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigEntity.java
@@ -20,7 +20,9 @@ package org.apache.ambari.server.orm.entities;
 
 import javax.persistence.Basic;
 import javax.persistence.CascadeType;
+import javax.persistence.CollectionTable;
 import javax.persistence.Column;
+import javax.persistence.ElementCollection;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.GenerationType;
@@ -32,6 +34,7 @@ import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import javax.persistence.TableGenerator;
+import java.util.Collection;
 import java.util.List;
 
 @Entity
@@ -57,6 +60,10 @@ public class ServiceConfigEntity {
   private String serviceName;
 
   @Basic
+  @Column(name = "group_id", nullable = true)
+  private Long groupId;
+
+  @Basic
   @Column(name = "version", nullable = false)
   private Long version;
 
@@ -72,6 +79,11 @@ public class ServiceConfigEntity {
   @Column(name = "note")
   private String note;
 
+  @ElementCollection()
+  @CollectionTable(name = "serviceconfighosts", joinColumns = {@JoinColumn(name = "service_config_id")})
+  @Column(name = "hostname")
+  private List<String> hostNames;
+
   @ManyToMany
   @JoinTable(
     name = "serviceconfigmapping",
@@ -155,4 +167,20 @@ public class ServiceConfigEntity {
   public void setNote(String note) {
     this.note = note;
   }
+
+  public Long getGroupId() {
+    return groupId;
+  }
+
+  public void setGroupId(Long groupId) {
+    this.groupId = groupId;
+  }
+
+  public List<String> getHostNames() {
+    return hostNames;
+  }
+
+  public void setHostNames(List<String> hostNames) {
+    this.hostNames = hostNames;
+  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
index d62b0cf..8970961 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
@@ -174,6 +174,11 @@ public interface Cluster {
    */
   ServiceConfigVersionResponse addDesiredConfig(String user, Config config, String serviceConfigVersionNote);
 
+  ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String user,
String note,
+                                                          ConfigGroup configGroup);
+
+  String getServiceForConfigTypes(Collection<String> configTypes);
+
   /**
    * Apply specified service config version (rollback)
    * @param serviceName service name

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 00316ce..c565060 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -85,7 +85,6 @@ import com.google.inject.Inject;
 import com.google.inject.Injector;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.persist.Transactional;
-import org.springframework.security.core.GrantedAuthority;
 
 public class ClusterImpl implements Cluster {
 
@@ -1412,6 +1411,82 @@ public class ClusterImpl implements Cluster {
     }
   }
 
+
+  @Override
+  public ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String
user, String note,
+                                                                 ConfigGroup configGroup)
{
+
+    //create next service config version
+    ServiceConfigEntity serviceConfigEntity = new ServiceConfigEntity();
+    serviceConfigEntity.setServiceName(serviceName);
+    serviceConfigEntity.setClusterEntity(clusterEntity);
+    serviceConfigEntity.setVersion(configVersionHelper.getNextVersion(serviceName));
+    serviceConfigEntity.setUser(user);
+    serviceConfigEntity.setNote(note);
+
+    if (configGroup != null) {
+      Collection<Config> configs = configGroup.getConfigurations().values();
+      List<ClusterConfigEntity> configEntities = new ArrayList<ClusterConfigEntity>(configs.size());
+      for (Config config : configs) {
+        configEntities.add(clusterDAO.findConfig(getClusterId(), config.getType(), config.getVersion()));
+      }
+      serviceConfigEntity.setClusterConfigEntities(configEntities);
+
+      serviceConfigEntity.setHostNames(new ArrayList<String>(configGroup.getHosts().keySet()));
+
+    } else {
+      List<ClusterConfigEntity> configEntities = getClusterConfigEntitiesByService(serviceName);
+      serviceConfigEntity.setClusterConfigEntities(configEntities);
+    }
+
+    serviceConfigDAO.create(serviceConfigEntity);
+
+    ServiceConfigVersionResponse response = new ServiceConfigVersionResponse();
+    response.setUserName(user);
+    response.setClusterName(getClusterName());
+    response.setVersion(serviceConfigEntity.getVersion());
+    response.setServiceName(serviceConfigEntity.getServiceName());
+    response.setCreateTime(serviceConfigEntity.getCreateTimestamp());
+    response.setUserName(serviceConfigEntity.getUser());
+    response.setNote(serviceConfigEntity.getNote());
+    response.setGroupId(serviceConfigEntity.getGroupId());
+    response.setHosts(serviceConfigEntity.getHostNames());
+    response.setGroupName(configGroup != null ? configGroup.getName() : null);
+
+    return response;
+  }
+
+  @Override
+  public String getServiceForConfigTypes(Collection<String> configTypes) {
+    String serviceName = null;
+    for (String configType : configTypes) {
+      for (Entry<String, String> entry : serviceConfigTypes.entries()) {
+        if (StringUtils.equals(entry.getValue(), configType)) {
+          if (serviceName != null) {
+            if (entry.getKey()!=null && !StringUtils.equals(serviceName, entry.getKey()))
{
+              throw new IllegalArgumentException("Config type {} belongs to {} service, "
+
+                "but config group qualified for {}");
+            }
+          } else {
+            serviceName = entry.getKey();
+          }
+        }
+      }
+    }
+    return serviceName;
+  }
+
+  public String getServiceByConfigType(String configType) {
+    for (Entry<String, String> entry : serviceConfigTypes.entries()) {
+      String serviceName = entry.getKey();
+      String type = entry.getValue();
+      if (StringUtils.equals(type, configType)) {
+        return serviceName;
+      }
+    }
+    return null;
+  }
+
   @Override
   public boolean setServiceConfigVersion(String serviceName, Long version, String user, String
note) throws AmbariException {
     if (null == user)
@@ -1470,6 +1545,7 @@ public class ClusterImpl implements Cluster {
           serviceConfigVersionResponse.setCreateTime(serviceConfigEntity.getCreateTimestamp());
           serviceConfigVersionResponse.setUserName(serviceConfigEntity.getUser());
           serviceConfigVersionResponse.setNote(serviceConfigEntity.getNote());
+          serviceConfigVersionResponse.setHosts(serviceConfigEntity.getHostNames());
           serviceConfigVersionResponse.setConfigurations(new ArrayList<ConfigurationResponse>());
 
           List<ClusterConfigEntity> clusterConfigEntities = serviceConfigEntity.getClusterConfigEntities();
@@ -1480,6 +1556,17 @@ public class ClusterImpl implements Cluster {
               config.getPropertiesAttributes()));
           }
 
+          Long groupId = serviceConfigEntity.getGroupId();
+          if (groupId != null) {
+            serviceConfigVersionResponse.setGroupId(groupId);
+            ConfigGroup configGroup = clusterConfigGroups.get(groupId);
+            if (configGroup != null) {
+              serviceConfigVersionResponse.setGroupName(configGroup.getName());
+            } else {
+              //TODO null or special name?
+            }
+          }
+
           serviceConfigVersionResponses.add(serviceConfigVersionResponse);
         }
 
@@ -1534,16 +1621,43 @@ public class ClusterImpl implements Cluster {
     }
 
     //disable all configs related to service
-    Collection<String> configTypes = serviceConfigTypes.get(serviceName);
-    for (ClusterConfigMappingEntity entity : clusterEntity.getConfigMappingEntities()) {
-      if (configTypes.contains(entity.getType()) && entity.isSelected() > 0) {
-        entity.setSelected(0);
+    if (serviceConfigEntity.getGroupId() == null) {
+      Collection<String> configTypes = serviceConfigTypes.get(serviceName);
+      for (ClusterConfigMappingEntity entity : clusterEntity.getConfigMappingEntities())
{
+        if (configTypes.contains(entity.getType()) && entity.isSelected() > 0)
{
+          entity.setSelected(0);
+        }
       }
-    }
-    clusterDAO.merge(clusterEntity);
+      clusterDAO.merge(clusterEntity);
 
-    for (ClusterConfigEntity configEntity : serviceConfigEntity.getClusterConfigEntities())
{
-      selectConfig(configEntity.getType(), configEntity.getTag(), user);
+      for (ClusterConfigEntity configEntity : serviceConfigEntity.getClusterConfigEntities())
{
+        selectConfig(configEntity.getType(), configEntity.getTag(), user);
+      }
+    } else {
+      Long configGroupId = serviceConfigEntity.getGroupId();
+      ConfigGroup configGroup = clusterConfigGroups.get(configGroupId);
+      if (configGroup != null) {
+        Map<String, Config> groupDesiredConfigs = new HashMap<String, Config>();
+        for (ClusterConfigEntity entity : serviceConfigEntity.getClusterConfigEntities())
{
+          Config config = allConfigs.get(entity.getType()).get(entity.getTag());
+          groupDesiredConfigs.put(config.getType(), config);
+        }
+        configGroup.setConfigurations(groupDesiredConfigs);
+
+        Map<String, Host> groupDesiredHosts = new HashMap<String, Host>();
+        for (String hostname : serviceConfigEntity.getHostNames()) {
+          Host host = clusters.getHost(hostname);
+          if (host != null) {
+            groupDesiredHosts.put(hostname, host);
+          } else {
+            LOG.warn("Host {} doesn't exist anymore, skipping", hostname);
+          }
+        }
+        configGroup.setHosts(groupDesiredHosts);
+        configGroup.persist();
+      } else {
+        throw new IllegalArgumentException("Config group {} doesn't exist");
+      }
     }
 
     ServiceConfigEntity serviceConfigEntityClone = new ServiceConfigEntity();
@@ -1553,6 +1667,8 @@ public class ClusterImpl implements Cluster {
     serviceConfigEntityClone.setClusterEntity(clusterEntity);
     serviceConfigEntityClone.setClusterConfigEntities(serviceConfigEntity.getClusterConfigEntities());
     serviceConfigEntityClone.setClusterId(serviceConfigEntity.getClusterId());
+    serviceConfigEntityClone.setHostNames(serviceConfigEntity.getHostNames());
+    serviceConfigEntityClone.setGroupId(serviceConfigEntity.getGroupId());
     serviceConfigEntityClone.setNote(serviceConfigVersionNote);
     serviceConfigEntityClone.setVersion(configVersionHelper.getNextVersion(serviceName));
 
@@ -1610,15 +1726,11 @@ public class ClusterImpl implements Cluster {
   private ServiceConfigVersionResponse createServiceConfigVersion(String serviceName, String
user,
                                                                   String serviceConfigVersionNote)
{
     //create next service config version
-    ServiceConfigEntity serviceConfigEntity = new ServiceConfigEntity();
-    serviceConfigEntity.setServiceName(serviceName);
-    serviceConfigEntity.setClusterEntity(clusterEntity);
-    serviceConfigEntity.setVersion(configVersionHelper.getNextVersion(serviceName));
-    serviceConfigEntity.setUser(user);
-    serviceConfigEntity.setNote(serviceConfigVersionNote);
+    return createServiceConfigVersion(serviceName, user, serviceConfigVersionNote, null);
+  }
 
+  private List<ClusterConfigEntity> getClusterConfigEntitiesByService(String serviceName)
{
     List<ClusterConfigEntity> configEntities = new ArrayList<ClusterConfigEntity>();
-    serviceConfigEntity.setClusterConfigEntities(configEntities);
 
     //add configs from this service
     Collection<String> configTypes = serviceConfigTypes.get(serviceName);
@@ -1634,18 +1746,7 @@ public class ClusterImpl implements Cluster {
         }
       }
     }
-
-    serviceConfigDAO.create(serviceConfigEntity);
-
-    ServiceConfigVersionResponse response = new ServiceConfigVersionResponse();
-    response.setUserName(user);
-    response.setClusterName(getClusterName());
-    response.setVersion(serviceConfigEntity.getVersion());
-    response.setServiceName(serviceConfigEntity.getServiceName());
-    response.setCreateTime(serviceConfigEntity.getCreateTimestamp());
-    response.setUserName(serviceConfigEntity.getUser());
-    response.setNote(serviceConfigEntity.getNote());
-    return response;
+    return configEntities;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index fe39612..dec0fcd 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -28,7 +28,8 @@ delimiter ;
 
 CREATE TABLE clusters (cluster_id BIGINT NOT NULL, resource_id BIGINT NOT NULL, cluster_info
VARCHAR(255) NOT NULL, cluster_name VARCHAR(100) NOT NULL UNIQUE, provisioning_state VARCHAR(255)
NOT NULL DEFAULT 'INIT', desired_cluster_state VARCHAR(255) NOT NULL, desired_stack_version
VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
 CREATE TABLE clusterconfig (config_id BIGINT NOT NULL, version_tag VARCHAR(255) NOT NULL,
version BIGINT NOT NULL, type_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL, config_data
LONGTEXT NOT NULL, config_attributes LONGTEXT, create_timestamp BIGINT NOT NULL, PRIMARY KEY
(config_id));
-CREATE TABLE serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', note LONGTEXT, PRIMARY KEY (service_config_id));
+CREATE TABLE serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', group_id BIGINT, note LONGTEXT, PRIMARY KEY
(service_config_id));
+CREATE TABLE serviceconfighosts (service_config_id BIGINT NOT NULL, hostname VARCHAR(255),
PRIMARY KEY(service_config_id, hostname));
 CREATE TABLE serviceconfigmapping (service_config_id BIGINT NOT NULL, config_id BIGINT NOT
NULL, PRIMARY KEY(service_config_id, config_id));
 CREATE TABLE clusterservices (service_name VARCHAR(255) NOT NULL, cluster_id BIGINT NOT NULL,
service_enabled INTEGER NOT NULL, PRIMARY KEY (service_name, cluster_id));
 CREATE TABLE clusterstate (cluster_id BIGINT NOT NULL, current_cluster_state VARCHAR(255)
NOT NULL, current_stack_version VARCHAR(255) NOT NULL, PRIMARY KEY (cluster_id));
@@ -119,6 +120,7 @@ ALTER TABLE hostconfigmapping ADD CONSTRAINT FK_hostconfmapping_cluster_id
FOREI
 ALTER TABLE hostconfigmapping ADD CONSTRAINT FK_hostconfmapping_host_name FOREIGN KEY (host_name)
REFERENCES hosts (host_name);
 ALTER TABLE serviceconfigmapping ADD CONSTRAINT FK_scvm_scv FOREIGN KEY (service_config_id)
REFERENCES serviceconfig(service_config_id);
 ALTER TABLE serviceconfigmapping ADD CONSTRAINT FK_scvm_config FOREIGN KEY (config_id) REFERENCES
clusterconfig(config_id);
+ALTER TABLE serviceconfighosts ADD CONSTRAINT  FK_scvhosts_scv FOREIGN KEY (service_config_id)
REFERENCES serviceconfig(service_config_id);
 ALTER TABLE configgroup ADD CONSTRAINT FK_configgroup_cluster_id FOREIGN KEY (cluster_id)
REFERENCES clusters (cluster_id);
 ALTER TABLE confgroupclusterconfigmapping ADD CONSTRAINT FK_confg FOREIGN KEY (cluster_id,
config_type, version_tag) REFERENCES clusterconfig (cluster_id, type_name, version_tag);
 ALTER TABLE confgroupclusterconfigmapping ADD CONSTRAINT FK_cgccm_gid FOREIGN KEY (config_group_id)
REFERENCES configgroup (group_id);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index e311646..0c35023 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -19,7 +19,8 @@
 ------create tables---------
 CREATE TABLE clusters (cluster_id NUMBER(19) NOT NULL, resource_id NUMBER(19) NOT NULL, cluster_info
VARCHAR2(255) NULL, cluster_name VARCHAR2(100) NOT NULL UNIQUE, provisioning_state VARCHAR2(255)
DEFAULT 'INIT' NOT NULL, desired_cluster_state VARCHAR2(255) NULL, desired_stack_version VARCHAR2(255)
NULL, PRIMARY KEY (cluster_id));
 CREATE TABLE clusterconfig (config_id NUMBER(19) NOT NULL, version_tag VARCHAR2(255) NOT
NULL, version NUMBER(19) NOT NULL, type_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19)
NOT NULL, config_data CLOB NOT NULL, config_attributes CLOB, create_timestamp NUMBER(19) NOT
NULL, PRIMARY KEY (config_id));
-CREATE TABLE serviceconfig (service_config_id NUMBER(19) NOT NULL, cluster_id NUMBER(19)
NOT NULL, service_name VARCHAR(255) NOT NULL, version NUMBER(19) NOT NULL, create_timestamp
NUMBER(19) NOT NULL, user_name VARCHAR(255) DEFAULT '_db' NOT NULL, note CLOB, PRIMARY KEY
(service_config_id));
+CREATE TABLE serviceconfig (service_config_id NUMBER(19) NOT NULL, cluster_id NUMBER(19)
NOT NULL, service_name VARCHAR(255) NOT NULL, version NUMBER(19) NOT NULL, create_timestamp
NUMBER(19) NOT NULL, user_name VARCHAR(255) DEFAULT '_db' NOT NULL, group_id NUMBER(19), note
CLOB, PRIMARY KEY (service_config_id));
+CREATE TABLE serviceconfighosts (service_config_id NUMBER(19) NOT NULL, hostname VARCHAR(255),
PRIMARY KEY(service_config_id, hostname));
 CREATE TABLE serviceconfigmapping (service_config_id NUMBER(19) NOT NULL, config_id NUMBER(19)
NOT NULL, PRIMARY KEY(service_config_id, config_id));
 CREATE TABLE clusterservices (service_name VARCHAR2(255) NOT NULL, cluster_id NUMBER(19)
NOT NULL, service_enabled NUMBER(10) NOT NULL, PRIMARY KEY (service_name, cluster_id));
 CREATE TABLE clusterstate (cluster_id NUMBER(19) NOT NULL, current_cluster_state VARCHAR2(255)
NULL, current_stack_version VARCHAR2(255) NULL, PRIMARY KEY (cluster_id));
@@ -86,6 +87,7 @@ ALTER TABLE adminpermission ADD CONSTRAINT UQ_perm_name_resource_type_id
UNIQUE
 ALTER TABLE members ADD CONSTRAINT FK_members_group_id FOREIGN KEY (group_id) REFERENCES
groups (group_id);
 ALTER TABLE members ADD CONSTRAINT FK_members_user_id FOREIGN KEY (user_id) REFERENCES users
(user_id);
 ALTER TABLE clusterconfig ADD CONSTRAINT FK_clusterconfig_cluster_id FOREIGN KEY (cluster_id)
REFERENCES clusters (cluster_id);
+ALTER TABLE serviceconfighosts ADD CONSTRAINT  FK_scvhosts_scv FOREIGN KEY (service_config_id)
REFERENCES serviceconfig(service_config_id);
 ALTER TABLE clusterservices ADD CONSTRAINT FK_clusterservices_cluster_id FOREIGN KEY (cluster_id)
REFERENCES clusters (cluster_id);
 ALTER TABLE clusterconfigmapping ADD CONSTRAINT clusterconfigmappingcluster_id FOREIGN KEY
(cluster_id) REFERENCES clusters (cluster_id);
 ALTER TABLE clusterstate ADD CONSTRAINT FK_clusterstate_cluster_id FOREIGN KEY (cluster_id)
REFERENCES clusters (cluster_id);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 25d973f..9b5e8bd 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -23,7 +23,9 @@ CREATE TABLE clusterconfig (config_id BIGINT NOT NULL, version_tag VARCHAR(255)
 
 CREATE TABLE clusterconfigmapping (cluster_id BIGINT NOT NULL, type_name VARCHAR(255) NOT
NULL, version_tag VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, selected INTEGER
NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id,
type_name, create_timestamp));
 
-CREATE TABLE serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', note TEXT, PRIMARY KEY (service_config_id));
+CREATE TABLE serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT NULL,
service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT NOT NULL,
user_name VARCHAR(255) NOT NULL DEFAULT '_db', group_id BIGINT, note TEXT, PRIMARY KEY (service_config_id));
+
+CREATE TABLE serviceconfighosts (service_config_id BIGINT NOT NULL, hostname VARCHAR(255),
PRIMARY KEY(service_config_id, hostname));
 
 CREATE TABLE serviceconfigmapping (service_config_id BIGINT NOT NULL, config_id BIGINT NOT
NULL, PRIMARY KEY(service_config_id, config_id));
 
@@ -171,6 +173,7 @@ ALTER TABLE users ADD CONSTRAINT FK_users_principal_id FOREIGN KEY (principal_id
 ALTER TABLE groups ADD CONSTRAINT FK_groups_principal_id FOREIGN KEY (principal_id) REFERENCES
adminprincipal(principal_id);
 ALTER TABLE serviceconfigmapping ADD CONSTRAINT FK_scvm_scv FOREIGN KEY (service_config_id)
REFERENCES serviceconfig(service_config_id);
 ALTER TABLE serviceconfigmapping ADD CONSTRAINT FK_scvm_config FOREIGN KEY (config_id) REFERENCES
clusterconfig(config_id);
+ALTER TABLE serviceconfighosts ADD CONSTRAINT  FK_scvhosts_scv FOREIGN KEY (service_config_id)
REFERENCES serviceconfig(service_config_id);
 ALTER TABLE clusters ADD CONSTRAINT FK_clusters_resource_id FOREIGN KEY (resource_id) REFERENCES
adminresource(resource_id);
 
 -- Alerting Framework

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index 2d5b267..b927672 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -37,9 +37,12 @@ GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfig TO :username;
 CREATE TABLE ambari.clusterconfigmapping (cluster_id BIGINT NOT NULL, type_name VARCHAR(255)
NOT NULL, version_tag VARCHAR(255) NOT NULL, create_timestamp BIGINT NOT NULL, selected INTEGER
NOT NULL DEFAULT 0, user_name VARCHAR(255) NOT NULL DEFAULT '_db', PRIMARY KEY (cluster_id,
type_name, create_timestamp));
 GRANT ALL PRIVILEGES ON TABLE ambari.clusterconfigmapping TO :username;
 
-CREATE TABLE ambari.serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT
NULL, service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT
NOT NULL, user_name VARCHAR(255) NOT NULL DEFAULT '_db', note TEXT, PRIMARY KEY (service_config_id));
+CREATE TABLE ambari.serviceconfig (service_config_id BIGINT NOT NULL, cluster_id BIGINT NOT
NULL, service_name VARCHAR(255) NOT NULL, version BIGINT NOT NULL, create_timestamp BIGINT
NOT NULL, user_name VARCHAR(255) NOT NULL DEFAULT '_db', group_id BIGINT, note TEXT, PRIMARY
KEY (service_config_id));
 GRANT ALL PRIVILEGES ON TABLE ambari.serviceconfig TO :username;
 
+CREATE TABLE ambari.serviceconfighosts (service_config_id BIGINT NOT NULL, hostname VARCHAR(255),
PRIMARY KEY(service_config_id, hostname));
+GRANT ALL PRIVILEGES ON TABLE ambari.serviceconfighosts TO :username;
+
 CREATE TABLE ambari.serviceconfigmapping (service_config_id BIGINT NOT NULL, config_id BIGINT
NOT NULL, PRIMARY KEY(service_config_id, config_id));
 GRANT ALL PRIVILEGES ON TABLE ambari.serviceconfigmapping TO :username;
 
@@ -181,8 +184,8 @@ ALTER TABLE ambari.serviceconfig ADD CONSTRAINT UQ_scv_service_version
UNIQUE (c
 ALTER TABLE ambari.adminpermission ADD CONSTRAINT UQ_perm_name_resource_type_id UNIQUE (permission_name,
resource_type_id);
 
 --------altering tables by creating foreign keys----------
-ALTER TABLE members ADD CONSTRAINT FK_members_group_id FOREIGN KEY (group_id) REFERENCES
groups (group_id);
-ALTER TABLE members ADD CONSTRAINT FK_members_user_id FOREIGN KEY (user_id) REFERENCES users
(user_id);
+ALTER TABLE ambari.members ADD CONSTRAINT FK_members_group_id FOREIGN KEY (group_id) REFERENCES
ambari.groups (group_id);
+ALTER TABLE ambari.members ADD CONSTRAINT FK_members_user_id FOREIGN KEY (user_id) REFERENCES
ambari.users (user_id);
 ALTER TABLE ambari.clusterconfig ADD CONSTRAINT FK_clusterconfig_cluster_id FOREIGN KEY (cluster_id)
REFERENCES ambari.clusters (cluster_id);
 ALTER TABLE ambari.clusterservices ADD CONSTRAINT FK_clusterservices_cluster_id FOREIGN KEY
(cluster_id) REFERENCES ambari.clusters (cluster_id);
 ALTER TABLE ambari.clusterconfigmapping ADD CONSTRAINT clusterconfigmappingcluster_id FOREIGN
KEY (cluster_id) REFERENCES ambari.clusters (cluster_id);
@@ -226,6 +229,7 @@ ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_confg
FOREIGN
 ALTER TABLE ambari.confgroupclusterconfigmapping ADD CONSTRAINT FK_cgccm_gid FOREIGN KEY
(config_group_id) REFERENCES ambari.configgroup (group_id);
 ALTER TABLE ambari.serviceconfigmapping ADD CONSTRAINT FK_scvm_scv FOREIGN KEY (service_config_id)
REFERENCES ambari.serviceconfig(service_config_id);
 ALTER TABLE ambari.serviceconfigmapping ADD CONSTRAINT FK_scvm_config FOREIGN KEY (config_id)
REFERENCES ambari.clusterconfig(config_id);
+ALTER TABLE ambari.serviceconfighosts ADD CONSTRAINT  FK_scvhosts_scv FOREIGN KEY (service_config_id)
REFERENCES ambari.serviceconfig(service_config_id);
 ALTER TABLE ambari.adminresource ADD CONSTRAINT FK_resource_resource_type_id FOREIGN KEY
(resource_type_id) REFERENCES ambari.adminresourcetype(resource_type_id);
 ALTER TABLE ambari.adminprincipal ADD CONSTRAINT FK_principal_principal_type_id FOREIGN KEY
(principal_type_id) REFERENCES ambari.adminprincipaltype(principal_type_id);
 ALTER TABLE ambari.adminpermission ADD CONSTRAINT FK_permission_resource_type_id FOREIGN
KEY (resource_type_id) REFERENCES ambari.adminresourcetype(resource_type_id);

http://git-wip-us.apache.org/repos/asf/ambari/blob/5ed94d53/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 6686f39..bc2ad22 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -88,6 +88,9 @@
     "ServiceConfigVersion":[
         "ServiceConfigVersion/cluster_name",
         "ServiceConfigVersion/service_name",
+        "ServiceConfigVersion/group_id",
+        "ServiceConfigVersion/group_name",
+        "ServiceConfigVersion/hosts",
         "ServiceConfigVersion/serviceconfigversion",
         "ServiceConfigVersion/createtime",
         "ServiceConfigVersion/user",


Mime
View raw message