incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maha...@apache.org
Subject svn commit: r1401566 [1/2] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/ ambari-agent/src/main/python/ambari_agent/ ambari-server/src/main/java/org/apache/ambari/server/api/resources/ ambar...
Date Wed, 24 Oct 2012 06:24:21 GMT
Author: mahadev
Date: Wed Oct 24 06:24:20 2012
New Revision: 1401566

URL: http://svn.apache.org/viewvc?rev=1401566&view=rev
Log:
AMBARI-900. Add configuration mapping support. (Nate Cole via mahadev)

Added:
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntityPK.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntityPK.java
Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/init.pp
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/site.pp
    incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/test.json
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ConfigurationResourceDefinition.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/python/ambari-server.py
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/resources/META-INF/persistence.xml

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Wed Oct 24 06:24:20 2012
@@ -12,6 +12,8 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-900. Add configuration mapping support. (Nate Cole via mahadev)
+
   AMBARI-895. Need name consistency for metrics. (Tom Beerbower via mahadev)
 
   AMBARI-893. provide api support for temporal queries. (John Speidel via 

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/init.pp?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/init.pp (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/init.pp Wed Oct 24 06:24:20 2012
@@ -25,11 +25,12 @@ class hdp-templeton(
 {
 # Configs generation  
 
-  if has_key($configuration, 'hdp_templeton__templeton_site') {
-    configgenerator::configfile{'templeton_site_xml': 
+  if has_key($configuration, 'templeton_site') {
+    configgenerator::configfile{'templeton_site': 
+      modulespath => $hdp-templeton::params::conf_dir,
       filename => 'templeton-site.xml',
       module => 'hdp-templeton',
-      configuration => $configuration['hdp_templeton__templeton_site']
+      configuration => $configuration['templeton_site']
     }
   }
 
@@ -70,7 +71,7 @@ class hdp-templeton(
       force => true
     }
 
-    hdp-templeton::configfile { ['templeton-site.xml','templeton-env.sh']: }
+    hdp-templeton::configfile { ['templeton-env.sh']: }
 
     anchor { 'hdp-templeton::begin': } -> Hdp::Package['templeton'] -> Hdp::User[$templeton_user] -> Hdp::Directory[$templeton_config_dir] -> Hdp-templeton::Configfile<||> ->  anchor { 'hdp-templeton::end': }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/site.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/site.pp?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/site.pp (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/site.pp Wed Oct 24 06:24:20 2012
@@ -49,6 +49,9 @@ core_site=> {
 hive_site=> {
 "hive.exec.scratchdir" => "/tmp"
 },
+templeton_site=> {
+"templeton.override.enabled" => "true"
+},
 oozie_site=> {
 "oozie.service.ActionService.executor.ext.classes" => "org.apache.oozie.action.hadoop.HiveActionExecutor, org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.email.EmailActionExecutor,"
 },
@@ -63,11 +66,13 @@ $task_bin_exe = "ls"
 $hadoop_piddirprefix = "/tmp"
 $ganglia_server_host = "localhost"
 node /default/ {
- stage{1 :} -> stage{2 :} -> stage{3 :} -> stage{4 :} -> stage{5 :} -> stage{6 :}
+ stage{1 :} -> stage{2 :} -> stage{3 :} -> stage{4 :} -> stage{5 :} -> stage{6 :} -> stage{7 :} -> stage{8 :}
 class {'hdp-hadoop::namenode': stage => 1, service_state => installed_and_configured}
 class {'hdp-hadoop::datanode': stage => 2, service_state => installed_and_configured}
 class {'hdp-hbase::master': stage => 3, service_state => installed_and_configured}
 class {'hdp-hive::server': stage => 4, service_state => installed_and_configured}
 class {'hdp-hive::client': stage => 5, service_state => installed_and_configured}
 class {'hdp-oozie::server': stage => 6, service_state => installed_and_configured}
+class {'hdp-templeton::server': stage => 7, service_state => installed_and_configured}
+class {'hdp-templeton::client': stage => 8, service_state => installed_and_configured}
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/test.json
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/test.json?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/test.json (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-agent/src/main/python/ambari_agent/test.json Wed Oct 24 06:24:20 2012
@@ -19,7 +19,7 @@
 
 "xml_configurations_keys" : ["hdfs_site", "hdfs_site", "core_site", "mapred_queue_acls", 
                              "hadoop_policy", "mapred_site", "capacity_scheduler", "hbase_site",
-                             "hbase_policy", "hive_site", "oozie_site"],
+                             "hbase_policy", "hive_site", "oozie_site", "templeton_site"],
 
 "configurations" : {
 "hdfs_site" : { "dfs.block.size" : "256000000", "dfs.replication" : "1" } ,
@@ -40,7 +40,8 @@
 "hbase_policy" : {"security.client.protocol.acl" : "*"},
 "hadoop_metrics" : {"ganglia_server_host" : "localhost"},
 "hive_site" : {"hive.exec.scratchdir" : "/tmp"},
-"oozie_site" : {"oozie.service.ActionService.executor.ext.classes" : "org.apache.oozie.action.hadoop.HiveActionExecutor, org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.email.EmailActionExecutor,"}
+"oozie_site" : {"oozie.service.ActionService.executor.ext.classes" : "org.apache.oozie.action.hadoop.HiveActionExecutor, org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.email.EmailActionExecutor,"},
+"templeton_site" : {"templeton.override.enabled" : "true"}
 },
 "roleCommands": [
 {
@@ -72,6 +73,16 @@
   "role": "OOZIE_SERVER",
   "cmd": "INSTALL",
   "roleParams" : {}
+},
+{
+  "role": "TEMPLETON_SERVER",
+  "cmd": "INSTALL",
+  "roleParams" : {}
+},
+{
+  "role": "TEMPLETON_CLIENT",
+  "cmd": "INSTALL",
+  "roleParams" : {}
 }
 ]
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ConfigurationResourceDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ConfigurationResourceDefinition.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ConfigurationResourceDefinition.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ConfigurationResourceDefinition.java Wed Oct 24 06:24:20 2012
@@ -19,9 +19,15 @@
 package org.apache.ambari.server.api.resources;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import org.apache.ambari.server.api.resources.ResourceDefinition.PostProcessor;
+import org.apache.ambari.server.api.services.Request;
+import org.apache.ambari.server.api.util.TreeNode;
 import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.Schema;
+import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 /**
@@ -48,6 +54,14 @@ public class ConfigurationResourceDefini
     if (null != configTag)
       setProperty(PropertyHelper.getPropertyId("tag", "Config"), configTag);
   }
+  
+  @Override
+  public List<PostProcessor> getPostProcessors() {
+    List<PostProcessor> listProcessors = super.getPostProcessors();
+    listProcessors.add(new HrefProcessor());
+
+    return listProcessors;
+  }  
 
   @Override
   public String getPluralName() {
@@ -63,4 +77,25 @@ public class ConfigurationResourceDefini
   public Map<String, ResourceDefinition> getSubResources() {
     return new HashMap<String, ResourceDefinition>();
   }
+  
+  private class HrefProcessor extends BaseHrefPostProcessor {
+
+    @Override
+    public void process(Request request, TreeNode<Resource> resultNode, String href) {
+      if (resultNode.getObject().getType() == Resource.Type.Configuration) {
+
+        String clusterId = getResourceIds().get(Resource.Type.Cluster);
+        String type = (String) resultNode.getObject().getPropertyValue(PropertyHelper.getPropertyId("type"));
+        String tag = (String) resultNode.getObject().getPropertyValue(PropertyHelper.getPropertyId("tag"));
+        
+        href = href.substring(0, href.indexOf(clusterId) + clusterId.length() + 1) +
+            "configurations?type=" + type + "&tag=" + tag;
+        
+        resultNode.setProperty("href", href);
+      } else {
+        super.process(request, resultNode, href);
+      }
+      
+    }
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaInfo.java Wed Oct 24 06:24:20 2012
@@ -33,7 +33,6 @@ import javax.xml.parsers.DocumentBuilder
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.ParserConfigurationException;
 
-import org.apache.commons.collections.map.HashedMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -75,11 +74,8 @@ public class AmbariMetaInfo {
   private static final String PROPERTY_XML_PROPERTY_DESCRIPTION = "description";
 
 
-
-
-
   public Map<String, Map<String, String>> getSupportedConfigs(String stackName, String version, String serviceName) {
-    Map<String, Map<String, String>> propertiesResult =  new HashMap<String, Map<String, String> >();
+    Map<String, Map<String, String>> propertiesResult = new HashMap<String, Map<String, String>>();
 
     ServiceInfo service = getServiceInfo(stackName, version, serviceName);
     if (service != null)
@@ -87,14 +83,14 @@ public class AmbariMetaInfo {
         List<PropertyInfo> properties = service.getProperties();
         if (properties != null)
           for (PropertyInfo propertyInfo : properties) {
-            Map<String, String> fileProperties = propertiesResult.get( propertyInfo.getFilename() );
-            if(fileProperties == null){
+            Map<String, String> fileProperties = propertiesResult.get(propertyInfo.getFilename());
+            if (fileProperties == null) {
               fileProperties = new HashMap<String, String>();
-              fileProperties.put(propertyInfo.getName(), propertyInfo.getValue() );
-              propertiesResult.put(propertyInfo.getFilename(), fileProperties  );
+              fileProperties.put(propertyInfo.getName(), propertyInfo.getValue());
+              propertiesResult.put(propertyInfo.getFilename(), fileProperties);
 
-            }else{
-              fileProperties.put(propertyInfo.getName(), propertyInfo.getValue() );
+            } else {
+              fileProperties.put(propertyInfo.getName(), propertyInfo.getValue());
             }
 
           }
@@ -120,12 +116,12 @@ public class AmbariMetaInfo {
   }
 
   public List<ServiceInfo> getSupportedServices(String stackName, String version) {
-      List<ServiceInfo> servicesResulr = null;
-      StackInfo stack = getStackInfo(stackName , version);
-      if( stack!= null )
-        servicesResulr = stack.getServices();
-      return servicesResulr;
-    }
+    List<ServiceInfo> servicesResulr = null;
+    StackInfo stack = getStackInfo(stackName, version);
+    if (stack != null)
+      servicesResulr = stack.getServices();
+    return servicesResulr;
+  }
 
   private StackInfo getStackInfo(String stackName, String version) {
     StackInfo stackInfoResult = null;
@@ -205,52 +201,8 @@ public class AmbariMetaInfo {
           }
 
       }
-    }//stack root
-
-//////TODO delete before final commit. Show all objects structure for debug
-//    for (StackInfo elem : stacksResult) {
-//      log.info("###elem = \n" + elem);
-//      log.info("contain services= " + elem.getServices().size());
-//      System.out.println("###elem = \n" + elem);
-//      System.out.println("contain services= " + elem.getServices().size());
-//    }
-//    System.out.println(" \n\n\n ");
-
-
-  }
-
-
-  public static void main(String[] args) throws Exception {
-    AmbariMetaInfo metadata = new AmbariMetaInfo();
-
-//    //Get Stack
-//    StackInfo stack = metadata.getStackInfo("HDP","0.1");
-//    System.out.println("stack = " + stack);
-
-//    //Get services
-//    List<ServiceInfo>services = metadata.getSupportedServices("HDP","0.1");
-//    for(ServiceInfo service : services){
-//      System.out.println("service = " + service);
-//    }
-
-//    //Get ServiceInfo
-//    ServiceInfo si = metadata.getServiceInfo("HDP","0.1", "HDFS");
-//    System.out.println("si = " + si);
-
-    //Get supported Configs
-    Map<String,Map<String, String> > configsAll = metadata.getSupportedConfigs("HDP","0.1", "HDFS");
-    Set<String>filesKeys  = configsAll.keySet();
-    for(String file: filesKeys){
-      System.out.println("\t\t\t\t\t\t\t\t\t\t\t\t\file = " + file);
-      Map<String,String> configs = configsAll.get(file);
-      Set<String> propertyKeys = configs.keySet();
-      for(String property : propertyKeys ){
-        System.out.println("name = " + property+ "\t value=" + configs.get(property));
-      }
-
     }
 
-//    System.out.println( new Configuration().getMetadataPath() );
   }
 
 
@@ -333,7 +285,6 @@ public class AmbariMetaInfo {
       Document doc = dBuilder.parse(propertyFile);
       doc.getDocumentElement().normalize();
 
-
       NodeList propertyNodes = doc.getElementsByTagName(PROPERTY_XML_MAIN_BLOCK_NAME);
 
       for (int index = 0; index < propertyNodes.getLength(); index++) {
@@ -346,7 +297,7 @@ public class AmbariMetaInfo {
           propertyInfo.setName(getTagValue(PROPERTY_XML_PROPERTY_NAME, property));
           propertyInfo.setValue(getTagValue(PROPERTY_XML_PROPERTY_VALUE, property));
           propertyInfo.setDescription(getTagValue(PROPERTY_XML_PROPERTY_DESCRIPTION, property));
-          propertyInfo.setFilename( propertyFile.getName() );
+          propertyInfo.setFilename(propertyFile.getName());
 
           if (propertyInfo.getName() == null || propertyInfo.getValue() == null)
             continue;
@@ -370,9 +321,6 @@ public class AmbariMetaInfo {
       result = value.getNodeValue();
     } catch (NullPointerException e) {
       log.debug("There is no field like " + sTag + "in this DOM element.", e);
-    } catch (Exception e) {
-      log.error("Error while getting value from xml DOM element", e);
-      throw e;
     } finally {
       return result;
     }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/api/services/ConfigurationService.java Wed Oct 24 06:24:20 2012
@@ -20,8 +20,6 @@ package org.apache.ambari.server.api.ser
 
 import javax.ws.rs.GET;
 import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.HttpHeaders;
@@ -65,7 +63,19 @@ public class ConfigurationService extend
   }  
 
   /**
-   * Handles URL: /clusters/{clusterId}/configurations
+   * Handles URL: /clusters/{clusterId}/configurations.  The body should contain:
+   * <pre>
+   * {
+   *     "type":"type_string",
+   *     "tag":"version_tag",
+   *     "properties":
+   *     {
+   *         "key1":"value1",
+   *         // ...
+   *         "keyN":"valueN"
+   *     }
+   * }
+   * </pre>
    * Get all services for a cluster.
    *
    * @param headers http headers
@@ -80,65 +90,6 @@ public class ConfigurationService extend
         createResourceDefinition(null, null, m_clusterName));
   }    
   
-  /*
-   * Handles URL: /clusters/{clusterID}/configurations/{configType}
-   * Get a specific service.
-   *
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param configType service id
-   * @return service resource representation
-  
-  @GET
-  @Path("{configType}")
-  @Produces("text/plain")
-  public Response getService(@Context HttpHeaders headers, @Context UriInfo ui,
-                             @PathParam("configType") String configType) {
-
-    return handleRequest(headers, null, ui, Request.Type.GET,
-        createResourceDefinition(configType, null, m_clusterName));
-  }
-   */
-  
-  /*
-   * Handles URL: /clusters/{clusterId}/configurations/{configType}/{configTag}
-   *
-  @GET
-  @Path("{configType}/{configTag}")
-  @Produces("text/plain")
-  public Response getConfig(@Context HttpHeaders headers, @Context UriInfo ui,
-                             @PathParam("configType") String configType,
-                             @PathParam("configTag") String configTag) {
-    return handleRequest(headers, null, ui, Request.Type.GET,
-        createResourceDefinition(configType, configTag, m_clusterName));    
-  }
-   */
-
-
-
-  /*
-   * Handles: PUT /clusters/{clusterId}/configurations/{configType}
-   * Create a specific service.
-   *
-   * @param body        http body
-   * @param headers     http headers
-   * @param ui          uri info
-   * @param serviceName service id
-   * @return information regarding the created service
-   *
-  @PUT
-  @Path("{configType}")
-  @Produces("text/plain")
-  public Response createConfig(String body, @Context HttpHeaders headers, @Context UriInfo ui,
-                                @PathParam("configType") String configType) {
-
-    return handleRequest(headers, body, ui, Request.Type.PUT,
-        createResourceDefinition(configType, null, m_clusterName));
-  }
-  
-   */
-
-
   /**
    * Create a service resource definition.
    *

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Wed Oct 24 06:24:20 2012
@@ -19,6 +19,7 @@
 package org.apache.ambari.server.controller;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -1055,10 +1056,23 @@ public class AmbariManagementControllerI
       if (null != request.getType()) {
         Map<String, Config> configs = cluster.getDesiredConfigsByType(request.getType());
 
-        for (Entry<String, Config> entry : configs.entrySet()) {
+        if (null != configs) {
+          for (Entry<String, Config> entry : configs.entrySet()) {
+            ConfigurationResponse response = new ConfigurationResponse(
+                cluster.getClusterName(), request.getType(),
+                entry.getValue().getVersionTag(), new HashMap<String, String>());
+            responses.add(response);
+          }
+        }
+      } else {
+        // !!! all configuration
+        Collection<Config> all = cluster.getAllConfigs();
+        
+        for (Config config : all) {
           ConfigurationResponse response = new ConfigurationResponse(
-              cluster.getClusterName(), request.getType(),
-              entry.getValue().getVersionTag(), new HashMap<String, String>());
+             cluster.getClusterName(), config.getType(), config.getVersionTag(),
+             new HashMap<String, String>());
+          
           responses.add(response);
         }
       }
@@ -1333,11 +1347,24 @@ public class AmbariManagementControllerI
       Service s = cluster.getService(request.getServiceName());
 
       if (request.getConfigVersions() != null) {
+        Map<String, Config> updated = new HashMap<String, Config>();
+        
+        for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
+          Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
+          if (null != config) {
+            updated.put(config.getType(), config);
+          }
+          
+          if (0 != updated.size()) {
+            s.updateDesiredConfigs(updated);
+            s.persist();
+          }
+          
+        }
+        
         // TODO handle config updates
         // handle recursive updates to all components and hostcomponents
         // if different from old desired configs, trigger relevant actions
-        throw new AmbariException("Unsupported operation - config updates not"
-            + " allowed");
       }
 
       if (request.getDesiredState() == null
@@ -1557,11 +1584,23 @@ public class AmbariManagementControllerI
         request.getComponentName());
 
       if (request.getConfigVersions() != null) {
+        Map<String, Config> updated = new HashMap<String, Config>();
+        
+        for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
+          Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
+          if (null != config) {
+            updated.put(config.getType(), config);
+          }
+          
+          if (0 != updated.size()) {
+            sc.updateDesiredConfigs(updated);
+            sc.persist();
+          }
+        }
+        
         // TODO handle config updates
         // handle recursive updates to all components and hostcomponents
         // if different from old desired configs, trigger relevant actions
-        throw new AmbariException("Unsupported operation - config updates not"
-            + " allowed");
       }
 
       if (request.getDesiredState() == null
@@ -1802,11 +1841,23 @@ public class AmbariManagementControllerI
         request.getHostname());
 
       if (request.getConfigVersions() != null) {
+        Map<String, Config> updated = new HashMap<String, Config>();
+        
+        for (Entry<String,String> entry : request.getConfigVersions().entrySet()) {
+          Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
+          if (null != config) {
+            updated.put(config.getType(), config);
+          }
+          
+          if (0 != updated.size()) {
+            sch.updateDesiredConfigs(updated);
+            sch.persist();
+          }
+        }
+        
         // TODO handle config updates
         // handle recursive updates to all components and hostcomponents
         // if different from old desired configs, trigger relevant actions
-        throw new AmbariException("Unsupported operation - config updates not"
-            + " allowed");
       }
 
       if (request.getDesiredState() == null

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ResourceProviderImpl.java Wed Oct 24 06:24:20 2012
@@ -81,6 +81,7 @@ public abstract class ResourceProviderIm
   protected static final PropertyId SERVICE_CLUSTER_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("cluster_name", "ServiceInfo");
   protected static final PropertyId SERVICE_SERVICE_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("service_name", "ServiceInfo");
   protected static final PropertyId SERVICE_SERVICE_STATE_PROPERTY_ID = PropertyHelper.getPropertyId("state", "ServiceInfo");
+
   // Components
   protected static final PropertyId COMPONENT_CLUSTER_NAME_PROPERTY_ID   = PropertyHelper.getPropertyId("cluster_name", "ServiceComponentInfo");
   protected static final PropertyId COMPONENT_SERVICE_NAME_PROPERTY_ID   = PropertyHelper.getPropertyId("service_name", "ServiceComponentInfo");
@@ -426,7 +427,12 @@ public abstract class ResourceProviderIm
       for (ServiceResponse response : responses) {
         Resource resource = new ResourceImpl(Resource.Type.Service);
 //        setResourceProperty(resource, SERVICE_CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
-        setResourceProperty(resource, SERVICE_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+        
+        resource.setProperty(SERVICE_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
+//        resource.setProperty(SERVICE_SERVICE_NAME_PROPERTY_ID, response.getServiceName());
+        
+        
+//        setResourceProperty(resource, SERVICE_CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
         setResourceProperty(resource, SERVICE_SERVICE_NAME_PROPERTY_ID, response.getServiceName(), requestedIds);
 //        setResourceProperty(resource, SERVICE_VERSION_PROPERTY_ID, response.getCurrentStackVersion(), requestedIds);
         resources.add(resource);
@@ -438,7 +444,20 @@ public abstract class ResourceProviderIm
     public void updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
-        requests.add(getRequest(propertyMap));
+        
+        Map<String, String> configMappings = new HashMap<String, String>();
+        
+        for (PropertyId id : propertyMap.keySet()) {
+          if (id.getCategory().equals ("config")) {
+            configMappings.put(id.getName(), (String) propertyMap.get(id));
+          }
+        }
+        
+        ServiceRequest svcRequest = getRequest(propertyMap);
+        if (configMappings.size() > 0)
+          svcRequest.setConfigVersions(configMappings);
+        
+        requests.add(svcRequest);
       }
       getManagementController().updateServices(requests);
     }
@@ -535,7 +554,20 @@ public abstract class ResourceProviderIm
     public void updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceComponentRequest> requests = new HashSet<ServiceComponentRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
-        requests.add(getRequest(propertyMap));
+        ServiceComponentRequest compRequest = getRequest(propertyMap);
+        
+        Map<String, String> configMap = new HashMap<String,String>();
+        
+        for (Entry<PropertyId,Object> entry : propertyMap.entrySet()) {
+          if (entry.getKey().getCategory().equals("config")) {
+            configMap.put(entry.getKey().getName(), (String) entry.getValue());
+          }
+        }
+        
+        if (0 != configMap.size())
+          compRequest.setConfigVersions(configMap);
+        
+        requests.add(compRequest);
       }
       getManagementController().updateComponents(requests);
     }
@@ -733,7 +765,21 @@ public abstract class ResourceProviderIm
     public void updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceComponentHostRequest> requests = new HashSet<ServiceComponentHostRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
-        requests.add(getRequest(propertyMap));
+        
+        ServiceComponentHostRequest hostCompRequest = getRequest(propertyMap);
+        
+        Map<String, String> configMap = new HashMap<String,String>();
+        
+        for (Entry<PropertyId,Object> entry : propertyMap.entrySet()) {
+          if (entry.getKey().getCategory().equals("config")) {
+            configMap.put(entry.getKey().getName(), (String) entry.getValue());
+          }
+        }
+        
+        if (0 != configMap.size())
+          hostCompRequest.setConfigVersions(configMap);
+        
+        requests.add(hostCompRequest);        
       }
       getManagementController().updateHostComponents(requests);
     }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ClusterServiceEntity.java Wed Oct 24 06:24:20 2012
@@ -168,4 +168,17 @@ public class ClusterServiceEntity {
   public void setServiceComponentDesiredStateEntities(Collection<ServiceComponentDesiredStateEntity> serviceComponentDesiredStateEntities) {
     this.serviceComponentDesiredStateEntities = serviceComponentDesiredStateEntities;
   }
+  
+  private Collection<ServiceConfigMappingEntity> serviceConfigMappings;
+  @OneToMany(mappedBy = "serviceConfigEntity")
+  public Collection<ServiceConfigMappingEntity> getServiceConfigMappings() {
+    return serviceConfigMappings;
+  }
+  
+  public void setServiceConfigMappings(Collection<ServiceConfigMappingEntity> entities) {
+    serviceConfigMappings = entities;
+  }
+  
+  
+  
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntity.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntity.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,137 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@IdClass(ComponentConfigMappingEntityPK.class)
+@Entity
+@Table(name = "componentconfigmapping", schema = "ambari", catalog = "")
+public class ComponentConfigMappingEntity {
+  private Long clusterId;
+  private String serviceName;
+  private String componentName;
+  private String configType;
+  private String configTag;
+  private Long timestamp;
+  private ServiceComponentDesiredStateEntity componentEntity;
+  
+  @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
+  @Id
+  public Long getClusterId() {
+    return clusterId;
+  }
+  
+  public void setClusterId(Long id) {
+    clusterId = id;
+  }
+  
+  @Column(name = "service_name", insertable = false, updatable = false, nullable = false)
+  @Id
+  public String getServiceName() {
+    return serviceName;
+  }
+  
+  public void setServiceName(String name) {
+    serviceName = name;
+  }
+  
+  @Column(name = "component_name", insertable = false, updatable = false, nullable = false)
+  @Id
+  public String getComponentName() {
+    return componentName;
+  }
+  
+  public void setComponentName(String name) {
+    componentName = name;
+  }
+
+  @Column(name = "config_type", insertable = true, updatable = false, nullable = false)
+  public String getConfigType() {
+    return configType;
+  }
+  
+  public void setConfigType(String type) {
+    configType = type;
+  }
+  
+  @Column(name = "config_tag", nullable = false, insertable = true, updatable = true)
+  public String getVersionTag() {
+    return configTag;
+  }
+  
+  public void setVersionTag(String tag) {
+    configTag = tag;
+  }
+  
+  @Column(name="timestamp", nullable = false, insertable = true, updatable = true)
+  public Long getTimestamp() {
+    return timestamp;
+  }
+  
+  public void setTimestamp(Long stamp) {
+    timestamp = stamp;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ComponentConfigMappingEntity that = (ComponentConfigMappingEntity) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+    if (componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) return false;
+    if (configType != null ? !configType.equals(that.configType) : that.configType != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId !=null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
+    result = 31 * result + (configType != null ? configType.hashCode() : 0);
+    return result;
+  }  
+  
+  
+  @ManyToOne
+  @JoinColumns({
+    @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+    @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false),
+    @JoinColumn(name = "component_name", referencedColumnName = "component_name", nullable = false)
+  })
+  public ServiceComponentDesiredStateEntity getServiceComponentDesiredStateEntity() {
+    return componentEntity;
+  }
+  
+  public void setServiceComponentDesiredStateEntity(ServiceComponentDesiredStateEntity entity) {
+    componentEntity = entity;
+  }
+  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntityPK.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntityPK.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ComponentConfigMappingEntityPK.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+
+/**
+ * @author ncole
+ *
+ */
+public class ComponentConfigMappingEntityPK implements Serializable {
+  private Long clusterId;
+  private String serviceName;
+  private String componentName;
+  
+  @Id
+  @Column(name = "cluster_id", insertable = true, updatable = true, nullable = false, length = 10)
+  public Long getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
+  }
+
+  @Id
+  @Column(name = "service_name", insertable = true, updatable = true, nullable = false)
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+  
+  @Column(name = "component_name", insertable = true, updatable = true, nullable = false)
+  @Id
+  public String getComponentName() {
+    return componentName;
+  }
+  
+  public void setComponentName(String name) {
+    componentName = name;
+  }
+  
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ComponentConfigMappingEntityPK that = (ComponentConfigMappingEntityPK) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
+    return result;
+  }  
+  
+  
+  
+  
+  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntity.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntity.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,151 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@IdClass(HostComponentConfigMappingEntityPK.class)
+@Table(name = "hostcomponentconfigmapping", schema = "ambari", catalog = "")
+@Entity
+public class HostComponentConfigMappingEntity {
+  private Long clusterId;
+  private String serviceName;
+  private String componentName;
+  private String hostName;
+  private String configType;
+  private String configTag;
+  private Long timestamp;
+  private HostComponentDesiredStateEntity hostComponentEntity;
+  
+  @Column(name = "cluster_id", insertable = false, updatable = false, nullable = false)
+  @Id
+  public Long getClusterId() {
+    return clusterId;
+  }
+  
+  public void setClusterId(Long id) {
+    clusterId = id;
+  }
+  
+  @Column(name = "service_name", insertable = false, updatable = false, nullable = false)
+  @Id
+  public String getServiceName() {
+    return serviceName;
+  }
+  
+  public void setServiceName(String name) {
+    serviceName = name;
+  }
+  
+  @Column(name = "component_name", insertable = false, updatable = false, nullable = false)
+  @Id
+  public String getComponentName() {
+    return componentName;
+  }
+  
+  public void setComponentName(String name) {
+    componentName = name;
+  }
+  
+  @Column(name = "host_name", insertable = false, updatable = false, nullable = false)
+  @Id
+  public String getHostName() {
+    return hostName;
+  }
+  
+  public void setHostName(String name) {
+    hostName = name;
+  }
+
+  @Column(name = "config_type", insertable = true, updatable = false, nullable = false)
+  public String getConfigType() {
+    return configType;
+  }
+  
+  public void setConfigType(String type) {
+    configType = type;
+  }
+  
+  @Column(name = "config_tag", nullable = false, insertable = true, updatable = true)
+  public String getVersionTag() {
+    return configTag;
+  }
+  
+  public void setVersionTag(String tag) {
+    configTag = tag;
+  }
+  
+  @Column(name="timestamp", nullable = false, insertable = true, updatable = true)
+  public Long getTimestamp() {
+    return timestamp;
+  }
+  
+  public void setTimestamp(Long stamp) {
+    timestamp = stamp;
+  }
+  
+  @ManyToOne
+  @JoinColumns({
+    @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+    @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false),
+    @JoinColumn(name = "component_name", referencedColumnName = "component_name", nullable = false),
+    @JoinColumn(name = "host_name", referencedColumnName = "host_name", nullable = false) })
+  public HostComponentDesiredStateEntity getHostComponentDesiredStateEntity() {
+    return hostComponentEntity;
+  }
+  
+  public void setHostComponentDesiredStateEntity(HostComponentDesiredStateEntity entity) {
+    hostComponentEntity = entity;
+  }
+
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    HostComponentConfigMappingEntity that = (HostComponentConfigMappingEntity) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+    if (componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) return false;
+    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+    if (configType != null ? !configType.equals(that.configType) : that.configType != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId !=null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
+    result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
+    result = 31 * result + (configType != null ? configType.hashCode() : 0);
+    return result;
+  }  
+  
+  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntityPK.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntityPK.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentConfigMappingEntityPK.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.Table;
+
+public class HostComponentConfigMappingEntityPK {
+  private Long clusterId;
+  private String serviceName;
+  private String componentName;
+  private String hostName;
+  
+  @Id
+  @Column(name = "cluster_id", insertable = true, updatable = true, nullable = false, length = 10)
+  public Long getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
+  }
+
+  @Id
+  @Column(name = "service_name", insertable = true, updatable = true, nullable = false)
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+  
+  @Column(name = "component_name", insertable = true, updatable = true, nullable = false)
+  @Id
+  public String getComponentName() {
+    return componentName;
+  }
+  
+  public void setComponentName(String name) {
+    componentName = name;
+  }
+  
+  @Column(name = "host_name", insertable = true, updatable = true, nullable = false)
+  @Id
+  public String getHostName() {
+    return hostName;
+  }
+  
+  public void setHostName(String name) {
+    hostName = name;
+  }
+  
+  
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    HostComponentConfigMappingEntityPK that = (HostComponentConfigMappingEntityPK) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (componentName != null ? !componentName.equals(that.componentName) : that.componentName != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+    if (hostName != null ? !hostName.equals(that.hostName) : that.hostName != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 31 * result + (componentName != null ? componentName.hashCode() : 0);
+    result = 31 * result + (hostName != null ? hostName.hashCode() : 0);
+    return result;
+  }  
+  
+  
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostComponentDesiredStateEntity.java Wed Oct 24 06:24:20 2012
@@ -17,9 +17,17 @@
  */
 package org.apache.ambari.server.orm.entities;
 
-import org.apache.ambari.server.state.State;
+import java.util.Collection;
+
+import javax.persistence.Basic;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
 
-import javax.persistence.*;
+import org.apache.ambari.server.state.State;
 
 @javax.persistence.IdClass(HostComponentDesiredStateEntityPK.class)
 @javax.persistence.Table(name = "hostcomponentdesiredstate", schema = "ambari", catalog = "")
@@ -167,4 +175,15 @@ public class HostComponentDesiredStateEn
   public void setHostEntity(HostEntity hostEntity) {
     this.hostEntity = hostEntity;
   }
+  
+  private Collection<HostComponentConfigMappingEntity> configMappingEntities;
+  @OneToMany(mappedBy = "hostComponentDesiredStateEntity")
+  public Collection<HostComponentConfigMappingEntity> getHostComponentConfigMappingEntities() {
+    return configMappingEntities;
+  }
+  
+  public void setHostComponentConfigMappingEntities(Collection<HostComponentConfigMappingEntity> entities) {
+    configMappingEntities = entities;
+  }
+  
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceComponentDesiredStateEntity.java Wed Oct 24 06:24:20 2012
@@ -147,4 +147,14 @@ public class ServiceComponentDesiredStat
   public void setHostComponentDesiredStateEntities(Collection<HostComponentDesiredStateEntity> hostComponentDesiredStateEntities) {
     this.hostComponentDesiredStateEntities = hostComponentDesiredStateEntities;
   }
+
+  private Collection<ComponentConfigMappingEntity> configMappingEntities;
+  @OneToMany(mappedBy = "serviceComponentDesiredStateEntity")
+  public Collection<ComponentConfigMappingEntity> getComponentConfigMappingEntities() {
+    return configMappingEntities;
+  }
+  
+  public void setComponentConfigMappingEntities(Collection<ComponentConfigMappingEntity> entities) {
+    configMappingEntities = entities;
+  }
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntity.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,124 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+@IdClass(ServiceConfigMappingEntityPK.class)
+@Entity
+@Table(name="serviceconfigmapping", schema="ambari", catalog="")
+public class ServiceConfigMappingEntity {
+  private Long clusterId;
+  private String serviceName;
+  private String configType;
+  private String configVersion;
+  private Long timestamp;
+  private ClusterServiceEntity serviceEntity;
+  
+  @Column(name = "cluster_id", nullable = false, insertable = false, updatable = false)
+  @Id
+  public Long getClusterId() {
+    return clusterId;
+  }
+  
+  public void setClusterId(Long id) {
+    clusterId = id;
+  }
+  
+  @Column(name = "service_name", nullable = false, insertable = false, updatable = false)
+  @Id
+  public String getServiceName() {
+    return serviceName;
+  }
+  
+  public void setServiceName(String name) {
+    serviceName = name;
+  }
+  
+  @Column(name = "config_type", nullable = false, insertable = true, updatable = false)
+  public String getConfigType() {
+    return configType;
+  }
+  
+  public void setConfigType(String type) {
+    configType = type;
+  }
+  
+  @Column(name = "config_tag", nullable = false, insertable = true, updatable = true)
+  public String getVersionTag() {
+    return configVersion;
+  }
+  
+  public void setVersionTag(String tag) {
+    configVersion = tag;
+  }
+  
+  @Column(name = "timestamp", nullable = false, insertable = true, updatable = true)
+  public Long getTimestamp() {
+    return timestamp;
+  }
+  
+  public void setTimestamp(Long stamp) {
+    timestamp = stamp;
+  }
+
+  @ManyToOne
+  @JoinColumns({
+      @JoinColumn(name = "cluster_id", referencedColumnName = "cluster_id", nullable = false),
+      @JoinColumn(name = "service_name", referencedColumnName = "service_name", nullable = false) })  
+  public ClusterServiceEntity getServiceConfigEntity() {
+    return serviceEntity;
+  }
+  
+  public void setServiceConfigEntity(ClusterServiceEntity entity) {
+    serviceEntity = entity;
+  }
+  
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceConfigMappingEntity that = (ServiceConfigMappingEntity) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+    if (configType != null ? !configType.equals(that.configType) : that.configType != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId !=null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 31 * result + (configType != null ? configType.hashCode() : 0);
+    return result;
+  } 
+  
+
+  
+  
+}

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntityPK.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntityPK.java?rev=1401566&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntityPK.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ServiceConfigMappingEntityPK.java Wed Oct 24 06:24:20 2012
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.orm.entities;
+
+import javax.persistence.Column;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+public class ServiceConfigMappingEntityPK implements Serializable {
+  private Long clusterId;
+  private String serviceName;
+
+  @Id
+  @Column(name = "cluster_id", nullable = false, insertable = true, updatable = true, length = 10)
+  public Long getClusterId() {
+    return clusterId;
+  }
+
+  public void setClusterId(Long clusterId) {
+    this.clusterId = clusterId;
+  }
+
+  @Id
+  @Column(name = "service_name", nullable = false, insertable = true, updatable = true)
+  public String getServiceName() {
+    return serviceName;
+  }
+
+  public void setServiceName(String serviceName) {
+    this.serviceName = serviceName;
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceConfigMappingEntityPK that = (ServiceConfigMappingEntityPK) o;
+
+    if (clusterId != null ? !clusterId.equals(that.clusterId) : that.clusterId != null) return false;
+    if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId !=null ? clusterId.intValue() : 0;
+    result = 31 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    return result;
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java Wed Oct 24 06:24:20 2012
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.state;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -85,6 +86,8 @@ public interface Cluster {
 
   public void addDesiredConfig(Config config);
 
+  public Collection<Config> getAllConfigs();
+  
   public ClusterResponse convertToResponse() throws AmbariException;
 
   public void refresh();

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ConfigImpl.java Wed Oct 24 06:24:20 2012
@@ -80,7 +80,7 @@ public class ConfigImpl implements Confi
   public synchronized Map<String, String> getProperties() {
     if (null != entity && null == properties) {
       
-      properties = gson.fromJson(entity.getData(), Map.class);
+      properties = gson.<Map<String, String>>fromJson(entity.getData(), Map.class);
       
     }
     return Collections.unmodifiableMap(null == properties ? new HashMap<String, String>() : properties);

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java Wed Oct 24 06:24:20 2012
@@ -61,7 +61,8 @@ public class ServiceComponentImpl implem
   boolean persisted = false;
   private ServiceComponentDesiredStateEntity desiredStateEntity;
 
-  private Map<String, Config>  desiredConfigs;
+  // [ type -> versionTag ]
+  private Map<String, String>  desiredConfigs;
 
   private Map<String, ServiceComponentHost> hostComponents;
   private Injector injector;
@@ -83,7 +84,7 @@ public class ServiceComponentImpl implem
     desiredStateEntity.setComponentName(componentName);
     desiredStateEntity.setDesiredState(State.INIT);
 
-    this.desiredConfigs = new HashMap<String, Config>();
+    this.desiredConfigs = new HashMap<String, String>();
     setDesiredStackVersion(new StackVersion(""));
 
     this.hostComponents = new HashMap<String, ServiceComponentHost>();
@@ -106,7 +107,8 @@ public class ServiceComponentImpl implem
     // FIXME use meta data library to decide client or not
     this.isClientComponent = false;
 
-    this.desiredConfigs = new HashMap<String, Config>();
+    this.desiredConfigs = new HashMap<String, String>();
+
     this.hostComponents = new HashMap<String, ServiceComponentHost>();
     for (HostComponentStateEntity hostComponentStateEntity : desiredStateEntity.getHostComponentStateEntities()) {
       HostComponentDesiredStateEntityPK pk = new HostComponentDesiredStateEntityPK();
@@ -120,6 +122,10 @@ public class ServiceComponentImpl implem
       hostComponents.put(hostComponentStateEntity.getComponentName(),
           serviceComponentHostFactory.createExisting(this, hostComponentStateEntity, hostComponentDesiredStateEntity));
     }
+    
+    for (ComponentConfigMappingEntity entity : desiredStateEntity.getComponentConfigMappingEntities()) {
+      desiredConfigs.put(entity.getConfigType(), entity.getVersionTag());
+    }
 
     persisted = true;
   }
@@ -251,12 +257,41 @@ public class ServiceComponentImpl implem
 
   @Override
   public synchronized Map<String, Config> getDesiredConfigs() {
-    return Collections.unmodifiableMap(desiredConfigs);
+    Map<String, Config> map = new HashMap<String, Config>();
+    for (Entry<String, String> entry : desiredConfigs.entrySet()) {
+      Config config = service.getCluster().getDesiredConfig(entry.getKey(), entry.getValue());
+      if (null != config) {
+        map.put(entry.getKey(), config);
+      }
+    }
+    return Collections.unmodifiableMap(map);
   }
 
   @Override
   public synchronized void updateDesiredConfigs(Map<String, Config> configs) {
-    this.desiredConfigs.putAll(configs);
+    for (Entry<String,Config> entry : configs.entrySet()) {
+      ComponentConfigMappingEntity newEntity = new ComponentConfigMappingEntity();
+      newEntity.setClusterId(desiredStateEntity.getClusterId());
+      newEntity.setServiceName(desiredStateEntity.getServiceName());
+      newEntity.setComponentName(desiredStateEntity.getComponentName());
+      newEntity.setConfigType(entry.getKey());
+      newEntity.setVersionTag(entry.getValue().getVersionTag());
+      newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
+      
+      if (!desiredStateEntity.getComponentConfigMappingEntities().contains(newEntity)) {
+        newEntity.setServiceComponentDesiredStateEntity(desiredStateEntity);
+        desiredStateEntity.getComponentConfigMappingEntities().add(newEntity);
+      } else {
+        for (ComponentConfigMappingEntity entity : desiredStateEntity.getComponentConfigMappingEntities()) {
+          if (entity.equals(newEntity)) {
+            entity.setVersionTag(newEntity.getVersionTag());
+            entity.setTimestamp(newEntity.getTimestamp());
+          }
+        }
+      }
+        
+      this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
+    }
   }
 
   @Override
@@ -281,10 +316,11 @@ public class ServiceComponentImpl implem
 
   private synchronized Map<String, String> getConfigVersions() {
     Map<String, String> configVersions = new HashMap<String, String>();
-    for (Config c : desiredConfigs.values()) {
-      configVersions.put(c.getType(), c.getVersionTag());
-    }
-    return configVersions;
+//    for (Config c : desiredConfigs.values()) {
+//      configVersions.put(c.getType(), c.getVersionTag());
+//    }
+//    return configVersions;
+    return desiredConfigs;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java Wed Oct 24 06:24:20 2012
@@ -18,25 +18,34 @@
 
 package org.apache.ambari.server.state;
 
-import com.google.gson.Gson;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
-import org.apache.ambari.server.orm.dao.*;
-import org.apache.ambari.server.orm.entities.*;
-
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.controller.ServiceResponse;
+import org.apache.ambari.server.orm.dao.ClusterDAO;
+import org.apache.ambari.server.orm.dao.ClusterServiceDAO;
+import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
+import org.apache.ambari.server.orm.dao.ServiceDesiredStateDAO;
+import org.apache.ambari.server.orm.entities.ClusterEntity;
+import org.apache.ambari.server.orm.entities.ClusterServiceEntity;
+import org.apache.ambari.server.orm.entities.ClusterServiceEntityPK;
+import org.apache.ambari.server.orm.entities.ServiceComponentDesiredStateEntity;
+import org.apache.ambari.server.orm.entities.ServiceConfigMappingEntity;
+import org.apache.ambari.server.orm.entities.ServiceDesiredStateEntity;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.Gson;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
+
 
 public class ServiceImpl implements Service {
 
@@ -50,7 +59,8 @@ public class ServiceImpl implements Serv
   private boolean persisted = false;
   private final Cluster cluster;
   private Map<String, Config> configs;
-  private Map<String, Config> desiredConfigs;
+  // [ String type -> Config Tag ], no need to hold the direct reference to the config
+  private Map<String, String> desiredConfigs;
   private Map<String, ServiceComponent> components;
 
   @Inject
@@ -69,8 +79,7 @@ public class ServiceImpl implements Serv
   private ServiceComponentFactory serviceComponentFactory;
 
   private void init() {
-    // TODO
-    // initialize from DB
+
   }
 
   @AssistedInject
@@ -85,7 +94,8 @@ public class ServiceImpl implements Serv
     serviceEntity.setServiceDesiredStateEntity(serviceDesiredStateEntity);
 
     this.cluster = cluster;
-    this.desiredConfigs = new HashMap<String, Config>();
+    this.desiredConfigs = new HashMap<String, String>();
+
     this.components = new HashMap<String, ServiceComponent>();
     setDesiredStackVersion(new StackVersion(""));
     init();
@@ -101,9 +111,11 @@ public class ServiceImpl implements Serv
     //TODO check for null states?
     this.serviceDesiredStateEntity = serviceEntity.getServiceDesiredStateEntity();
 
-    this.desiredConfigs = new HashMap<String, Config>();
+    this.desiredConfigs = new HashMap<String, String>();
 
     this.components = new HashMap<String, ServiceComponent>();
+    
+    this.configs = new HashMap<String, Config>();
 
     if (!serviceEntity.getServiceComponentDesiredStateEntities().isEmpty()) {
       for (ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity : serviceEntity.getServiceComponentDesiredStateEntities()) {
@@ -111,6 +123,12 @@ public class ServiceImpl implements Serv
             serviceComponentFactory.createExisting(this, serviceComponentDesiredStateEntity));
       }
     }
+    
+    for (ServiceConfigMappingEntity mappingEntity : serviceEntity.getServiceConfigMappings()) {
+      desiredConfigs.put(mappingEntity.getConfigType(), mappingEntity.getVersionTag());
+    }
+    
+    
     persisted = true;
   }
 
@@ -212,12 +230,42 @@ public class ServiceImpl implements Serv
 
   @Override
   public synchronized Map<String, Config> getDesiredConfigs() {
-    return Collections.unmodifiableMap(desiredConfigs);
+    Map<String, Config> map = new HashMap<String, Config>();
+    for (Entry<String, String> entry : desiredConfigs.entrySet()) {
+      Config config = cluster.getDesiredConfig(entry.getKey(), entry.getValue());
+      if (null != config) {
+        map.put(entry.getKey(), config);
+      }
+    }
+    return Collections.unmodifiableMap(map);
   }
-
+  
   @Override
   public synchronized void updateDesiredConfigs(Map<String, Config> configs) {
-    this.desiredConfigs.putAll(configs);
+
+    for (Entry<String,Config> entry : configs.entrySet()) {
+      ServiceConfigMappingEntity newEntity = new ServiceConfigMappingEntity();
+      newEntity.setClusterId(serviceEntity.getClusterId());
+      newEntity.setConfigType(entry.getKey());
+      newEntity.setServiceName(getName());
+      newEntity.setVersionTag(entry.getValue().getVersionTag());
+      newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
+      
+      if (!serviceEntity.getServiceConfigMappings().contains(newEntity)) {
+        newEntity.setServiceConfigEntity(serviceEntity);
+        serviceEntity.getServiceConfigMappings().add(newEntity);
+      } else {
+        for (ServiceConfigMappingEntity entity : serviceEntity.getServiceConfigMappings()) {
+          if (entity.equals(newEntity)) {
+            entity.setVersionTag(newEntity.getVersionTag());
+            entity.setTimestamp(newEntity.getTimestamp());
+          }
+        }
+      }
+        
+      this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
+    }
+    
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java Wed Oct 24 06:24:20 2012
@@ -19,11 +19,13 @@
 package org.apache.ambari.server.state.cluster;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeMap;
 import java.util.concurrent.locks.Lock;
@@ -333,7 +335,7 @@ public class ClusterImpl implements Clus
   public synchronized Config getDesiredConfig(String configType, String versionTag) {
     if (!configs.containsKey(configType)
         || !configs.get(configType).containsKey(versionTag)) {
-      // TODO throw error
+      return null;
     }
     return configs.get(configType).get(versionTag);
   }
@@ -352,6 +354,16 @@ public class ClusterImpl implements Clus
 
     configs.get(config.getType()).put(config.getVersionTag(), config);
   }
+  
+  public synchronized Collection<Config> getAllConfigs() {
+    List<Config> list = new ArrayList<Config>();
+    for (Entry<String,Map<String,Config>> entry : configs.entrySet()) {
+      for (Config config : entry.getValue().values()) {
+        list.add(config);
+      }
+    }
+    return Collections.unmodifiableList(list);
+  }
 
   @Override
   public synchronized ClusterResponse convertToResponse()

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java?rev=1401566&r1=1401565&r2=1401566&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java Wed Oct 24 06:24:20 2012
@@ -18,33 +18,27 @@
 
 package org.apache.ambari.server.state.svccomphost;
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.locks.*;
 
-import com.google.gson.Gson;
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.ServiceComponentHostResponse;
 import org.apache.ambari.server.orm.dao.*;
 import org.apache.ambari.server.orm.entities.*;
 import org.apache.ambari.server.state.*;
-import org.apache.ambari.server.state.fsm.InvalidStateTransitionException;
-import org.apache.ambari.server.state.fsm.SingleArcTransition;
-import org.apache.ambari.server.state.fsm.StateMachine;
-import org.apache.ambari.server.state.fsm.StateMachineFactory;
+import org.apache.ambari.server.state.fsm.*;
 import org.apache.ambari.server.state.job.Job;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.gson.Gson;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
+
 public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   private static final Logger LOG =
@@ -76,7 +70,7 @@ public class ServiceComponentHostImpl im
   private HostComponentDesiredStateEntity desiredStateEntity;
 
   private Map<String, Config> configs;
-  private Map<String, Config> desiredConfigs;
+  private Map<String, String> desiredConfigs;
 
   private long lastOpStartTime;
   private long lastOpEndTime;
@@ -467,7 +461,7 @@ public class ServiceComponentHostImpl im
     }
 
     this.resetLastOpInfo();
-    this.desiredConfigs = new HashMap<String, Config>();
+    this.desiredConfigs = new HashMap<String, String>();
     this.configs = new HashMap<String, Config>();
   }
 
@@ -496,6 +490,13 @@ public class ServiceComponentHostImpl im
       LOG.error("Host '{}' was not found", stateEntity.getHostName());
       throw new RuntimeException(e);
     }
+    
+    desiredConfigs = new HashMap<String, String>();
+    
+    for (HostComponentConfigMappingEntity entity : desiredStateEntity.getHostComponentConfigMappingEntities()) {
+      desiredConfigs.put(entity.getConfigType(), entity.getVersionTag());
+    }
+    
 
     persisted = true;
   }
@@ -673,6 +674,7 @@ public class ServiceComponentHostImpl im
   public Map<String, Config> getConfigs() {
     try {
       readLock.lock();
+      
       return Collections.unmodifiableMap(configs);
     }
     finally {
@@ -682,8 +684,10 @@ public class ServiceComponentHostImpl im
 
   @Override
   public void updateConfigs(Map<String, Config> configs) {
+    
     try {
       writeLock.lock();
+
       this.configs.putAll(configs);
     }
     finally {
@@ -742,7 +746,20 @@ public class ServiceComponentHostImpl im
   public Map<String, Config> getDesiredConfigs() {
     try {
       readLock.lock();
-      return Collections.unmodifiableMap(desiredConfigs);
+      
+      Map<String, Config> map = new HashMap<String, Config>();
+      for (Entry<String, String> entry : desiredConfigs.entrySet()) {
+        Config config = clusters.getClusterById(getClusterId()).getDesiredConfig(
+            entry.getKey(), entry.getValue());
+        if (null != config) {
+          map.put(entry.getKey(), config);
+        }
+      }
+      return Collections.unmodifiableMap(map);
+    }
+    catch (AmbariException e) {
+      // TODO do something
+      return null;
     }
     finally {
       readLock.unlock();
@@ -753,7 +770,32 @@ public class ServiceComponentHostImpl im
   public void updateDesiredConfigs(Map<String, Config> configs) {
     try {
       writeLock.lock();
-      this.desiredConfigs.putAll(configs);
+      
+      for (Entry<String,Config> entry : configs.entrySet()) {
+        HostComponentConfigMappingEntity newEntity = new HostComponentConfigMappingEntity();
+        newEntity.setClusterId(desiredStateEntity.getClusterId());
+        newEntity.setServiceName(desiredStateEntity.getServiceName());
+        newEntity.setComponentName(desiredStateEntity.getComponentName());
+        newEntity.setHostName(desiredStateEntity.getHostName());
+        newEntity.setConfigType(entry.getKey());
+        newEntity.setVersionTag(entry.getValue().getVersionTag());
+        newEntity.setTimestamp(Long.valueOf(new java.util.Date().getTime()));
+        
+        if (!desiredStateEntity.getHostComponentConfigMappingEntities().contains(newEntity)) {
+          newEntity.setHostComponentDesiredStateEntity(desiredStateEntity);
+          desiredStateEntity.getHostComponentConfigMappingEntities().add(newEntity);
+        } else {
+          for (HostComponentConfigMappingEntity entity : desiredStateEntity.getHostComponentConfigMappingEntities()) {
+            if (entity.equals(newEntity)) {
+              entity.setVersionTag(newEntity.getVersionTag());
+              entity.setTimestamp(newEntity.getTimestamp());
+            }
+          }
+        }
+          
+        this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
+      }      
+      
     }
     finally {
       writeLock.unlock();



Mime
View raw message