You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/03/20 21:44:50 UTC

svn commit: r1459041 [6/18] - in /incubator/ambari/branches/branch-1.2: ./ ambari-agent/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/modules/hdp-ganglia/files/ ambari-agent/src/main/puppet/modules/hdp-ganglia/manifests/ ambari-agent/src/main/p...

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java Wed Mar 20 20:44:43 2013
@@ -18,17 +18,12 @@
 
 package org.apache.ambari.server.controller.internal;
 
-import org.apache.ambari.server.controller.spi.PropertyProvider;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.spi.Schema;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.Collections;
+
 
 /**
  * Simple schema implementation.
@@ -39,16 +34,6 @@ public class SchemaImpl implements Schem
    */
   private final ResourceProvider resourceProvider;
 
-  /**
-   * The list of associated property providers.
-   */
-  private final List<PropertyProvider> propertyProviders;
-
-  /**
-   * The map of categories and properties.
-   */
-  private final Map<String, Set<String>> categoryProperties;
-
 
   // ----- Constructors ------------------------------------------------------
 
@@ -56,13 +41,10 @@ public class SchemaImpl implements Schem
    * Create a new schema for the given providers.
    *
    * @param resourceProvider   the resource provider
-   * @param propertyProviders  the property providers
+   *
    */
-  public SchemaImpl(ResourceProvider resourceProvider,
-                    List<PropertyProvider> propertyProviders) {
+  public SchemaImpl(ResourceProvider resourceProvider) {
     this.resourceProvider   = resourceProvider;
-    this.propertyProviders  = propertyProviders;
-    this.categoryProperties = initCategoryProperties();
   }
 
 
@@ -72,37 +54,4 @@ public class SchemaImpl implements Schem
   public String getKeyPropertyId(Resource.Type type) {
     return resourceProvider.getKeyPropertyIds().get(type);
   }
-
-  @Override
-  public Map<String, Set<String>> getCategoryProperties() {
-    return categoryProperties;
-  }
-
-
-  // ----- helper methods ----------------------------------------------------
-
-  private Map<String, Set<String>> initCategoryProperties() {
-    Map<String, Set<String>> categories = new HashMap<String, Set<String>>();
-
-    for (String propertyId : getPropertyIds()) {
-      final String category = PropertyHelper.getPropertyCategory(propertyId);
-      Set<String> properties = categories.get(category);
-      if (properties == null) {
-        properties = new HashSet<String>();
-        categories.put(category, properties);
-      }
-      properties.add(PropertyHelper.getPropertyName(propertyId));
-    }
-    return categories;
-  }
-
-  private Set<String> getPropertyIds() {
-    Set<String> propertyIds = new HashSet<String>(resourceProvider.getPropertyIdsForSchema());
-    if (propertyProviders != null) {
-      for (PropertyProvider propertyProvider : propertyProviders) {
-        propertyIds.addAll(propertyProvider.getPropertyIds());
-      }
-    }
-    return propertyIds;
-  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ServiceResourceProvider.java Wed Mar 20 20:44:43 2013
@@ -34,7 +34,7 @@ import java.util.Set;
 /**
  * Resource provider for service resources.
  */
-class ServiceResourceProvider extends ResourceProviderImpl {
+class ServiceResourceProvider extends AbstractResourceProvider {
 
 
   // ----- Property ID constants ---------------------------------------------
@@ -101,14 +101,14 @@ class ServiceResourceProvider extends Re
       requests.add(getRequest(propertyMap));
     }
 
-    Set<ServiceResponse> responses    =  getResources(new Command<Set<ServiceResponse>>() {
+    Set<ServiceResponse> responses = getResources(new Command<Set<ServiceResponse>>() {
       @Override
       public Set<ServiceResponse> invoke() throws AmbariException {
         return getManagementController().getServices(requests);
       }
     });
 
-    Set<String>   requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
     Set<Resource> resources    = new HashSet<Resource>();
 
     for (ServiceResponse response : responses) {
@@ -179,9 +179,11 @@ class ServiceResourceProvider extends Re
     Set<String> unsupportedProperties = new HashSet<String>();
 
     for (String propertyId : propertyIds) {
-      String propertyCategory = PropertyHelper.getPropertyCategory(propertyId);
-      if (propertyCategory == null || !propertyCategory.equals("config")) {
-        unsupportedProperties.add(propertyId);
+      if (!propertyId.equals("config")) {
+        String propertyCategory = PropertyHelper.getPropertyCategory(propertyId);
+        if (propertyCategory == null || !propertyCategory.equals("config")) {
+          unsupportedProperties.add(propertyId);
+        }
       }
     }
     return unsupportedProperties;

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SimplifyingPredicateVisitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SimplifyingPredicateVisitor.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SimplifyingPredicateVisitor.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SimplifyingPredicateVisitor.java Wed Mar 20 20:44:43 2013
@@ -22,6 +22,7 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.predicate.AndPredicate;
 import org.apache.ambari.server.controller.predicate.ArrayPredicate;
 import org.apache.ambari.server.controller.predicate.BasePredicate;
+import org.apache.ambari.server.controller.predicate.CategoryPredicate;
 import org.apache.ambari.server.controller.predicate.ComparisonPredicate;
 import org.apache.ambari.server.controller.predicate.EqualsPredicate;
 import org.apache.ambari.server.controller.predicate.OrPredicate;
@@ -161,4 +162,9 @@ public class SimplifyingPredicateVisitor
     }
     return andPredicateList;
   }
+
+  @Override
+  public void acceptCategoryPredicate(CategoryPredicate predicate) {
+    lastVisited = predicate;
+  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java Wed Mar 20 20:44:43 2013
@@ -41,7 +41,7 @@ import java.util.Set;
 /**
  * Resource provider for task resources.
  */
-class TaskResourceProvider extends ResourceProviderImpl{
+class TaskResourceProvider extends AbstractResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 
@@ -91,7 +91,7 @@ class TaskResourceProvider extends Resou
   public Set<Resource> getResources(Request request, Predicate predicate)
       throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
 
-    Set<String> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+    Set<String> requestedIds = getRequestPropertyIds(request, predicate);
     final Map<String, Object> predicateProperties = PredicateHelper.getProperties(predicate);
 
     String clusterName = (String) predicateProperties.get(TASK_CLUSTER_NAME_PROPERTY_ID);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java Wed Mar 20 20:44:43 2013
@@ -33,7 +33,7 @@ import java.util.Set;
 /**
  * Resource provider for user resources.
  */
-class UserResourceProvider extends ResourceProviderImpl{
+class UserResourceProvider extends AbstractResourceProvider {
 
   // ----- Property ID constants ---------------------------------------------
 
@@ -106,7 +106,7 @@ class UserResourceProvider extends Resou
           + ", userResponseSize=" + responses.size());
     }
 
-    Set<String>   requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
     Set<Resource> resources    = new HashSet<Resource>();
 
     for (UserResponse userResponse : responses) {

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java Wed Mar 20 20:44:43 2013
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.controller.jdbc;
 
+import org.apache.ambari.server.controller.internal.BaseProvider;
 import org.apache.ambari.server.controller.internal.RequestStatusImpl;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.predicate.BasePredicate;
@@ -42,14 +43,13 @@ import java.util.Set;
 
 /**
  * Generic JDBC based resource provider.
+ * TODO : Not used. Move to Test for API integration testing.
  */
-public class JDBCResourceProvider implements ResourceProvider {
+public class JDBCResourceProvider extends BaseProvider implements ResourceProvider {
 
     private final Resource.Type type;
 
-    private final Set<String> propertyIds;
-
-    private final ConnectionFactory connectionFactory;
+  private final ConnectionFactory connectionFactory;
 
     /**
      * The schema for this provider's resource type.
@@ -68,10 +68,10 @@ public class JDBCResourceProvider implem
                                 Resource.Type type,
                                 Set<String> propertyIds,
                                 Map<Resource.Type, String> keyPropertyIds) {
-        this.connectionFactory = connectionFactory;
-        this.type = type;
-        this.propertyIds = propertyIds;
-        this.keyPropertyIds = keyPropertyIds;
+      super(propertyIds);
+      this.connectionFactory = connectionFactory;
+      this.type = type;
+      this.keyPropertyIds = keyPropertyIds;
     }
 
     @Override
@@ -79,7 +79,7 @@ public class JDBCResourceProvider implem
         throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
 
         Set<Resource> resources = new HashSet<Resource>();
-        Set<String> propertyIds = PropertyHelper.getRequestPropertyIds(this.propertyIds, request, predicate);
+        Set<String> propertyIds = getRequestPropertyIds(request, predicate);
 
         // Can't allow these properties with the old schema...
         propertyIds.remove(PropertyHelper.getPropertyId("Clusters", "cluster_id"));
@@ -398,25 +398,10 @@ public class JDBCResourceProvider implem
     }
 
     @Override
-    public Set<String> getPropertyIdsForSchema() {
-        return propertyIds;
-    }
-
-    @Override
     public Map<Resource.Type, String> getKeyPropertyIds() {
         return keyPropertyIds;
     }
 
-    @Override
-    public Set<String> checkPropertyIds(Set<String> propertyIds) {
-      if (!this.propertyIds.containsAll(propertyIds)) {
-        Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds);
-        unsupportedPropertyIds.removeAll(this.propertyIds);
-        return unsupportedPropertyIds;
-      }
-      return Collections.emptySet();
-    }
-
     /**
      * Lazily populate the imported key mappings for the given table.
      *

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLPredicateVisitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLPredicateVisitor.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLPredicateVisitor.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/SQLPredicateVisitor.java Wed Mar 20 20:44:43 2013
@@ -21,6 +21,7 @@ package org.apache.ambari.server.control
 import org.apache.ambari.server.controller.predicate.AlwaysPredicate;
 import org.apache.ambari.server.controller.predicate.ArrayPredicate;
 import org.apache.ambari.server.controller.predicate.BasePredicate;
+import org.apache.ambari.server.controller.predicate.CategoryPredicate;
 import org.apache.ambari.server.controller.predicate.ComparisonPredicate;
 import org.apache.ambari.server.controller.predicate.PredicateVisitor;
 import org.apache.ambari.server.controller.predicate.UnaryPredicate;
@@ -83,6 +84,11 @@ public class SQLPredicateVisitor impleme
     stringBuilder.append("TRUE");
   }
 
+  @Override
+  public void acceptCategoryPredicate(CategoryPredicate predicate) {
+    // Do nothing
+  }
+
 
   // ----- SQLPredicateVisitor -----------------------------------------------
 

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java Wed Mar 20 20:44:43 2013
@@ -19,8 +19,6 @@ package org.apache.ambari.server.control
 
 import org.apache.ambari.server.controller.spi.SystemException;
 
-import java.util.Map;
-
 /**
  * Provider of JMX host information.
  */
@@ -34,7 +32,21 @@ public interface JMXHostProvider {
    *
    * @return the JMX host name
    *
-   * @throws SystemException of unable to ge the JMX host name
+   * @throws SystemException if unable to get the JMX host name
+   */
+  public String getHostName(String clusterName, String componentName)
+      throws SystemException;
+
+  /**
+   * Get the port for the specified cluster name and component.
+   *
+   * @param clusterName    the cluster name
+   * @param componentName  the component name
+   *
+   * @return the port for the specified cluster name and component
+   *
+   * @throws SystemException if unable to get the JMX port
    */
-  public String getHostName(String clusterName, String componentName) throws SystemException;
+  public String getPort(String clusterName, String componentName)
+      throws SystemException;
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java Wed Mar 20 20:44:43 2013
@@ -18,10 +18,10 @@
 
 package org.apache.ambari.server.controller.jmx;
 
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.codehaus.jackson.map.DeserializationConfig;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.ObjectReader;
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -41,23 +40,16 @@ import java.util.Set;
 /**
  * Property provider implementation for JMX sources.
  */
-public class JMXPropertyProvider implements PropertyProvider {
+public class JMXPropertyProvider extends AbstractPropertyProvider {
 
   private static final String NAME_KEY = "name";
   private static final String PORT_KEY = "tag.port";
 
-  /**
-   * Set of property ids supported by this provider.
-   */
-  private final Set<String> propertyIds;
-
-  private final Map<String, Map<String, PropertyInfo>> componentMetrics;
-
   private final StreamProvider streamProvider;
 
   private final JMXHostProvider jmxHostProvider;
 
-  private static final Map<String, String> JMX_PORTS = new HashMap<String, String>();
+  private static final Map<String, String> DEFAULT_JMX_PORTS = new HashMap<String, String>();
 
   private final String clusterNamePropertyId;
 
@@ -69,11 +61,12 @@ public class JMXPropertyProvider impleme
 
 
   static {
-    JMX_PORTS.put("NAMENODE",     "50070");
-    JMX_PORTS.put("DATANODE",     "50075");
-    JMX_PORTS.put("JOBTRACKER",   "50030");
-    JMX_PORTS.put("TASKTRACKER",  "50060");
-    JMX_PORTS.put("HBASE_MASTER", "60010");
+    DEFAULT_JMX_PORTS.put("NAMENODE",           "50070");
+    DEFAULT_JMX_PORTS.put("DATANODE",           "50075");
+    DEFAULT_JMX_PORTS.put("JOBTRACKER",         "50030");
+    DEFAULT_JMX_PORTS.put("TASKTRACKER",        "50060");
+    DEFAULT_JMX_PORTS.put("HBASE_MASTER",       "60010");
+    DEFAULT_JMX_PORTS.put("HBASE_REGIONSERVER", "60030");
 
     ObjectMapper objectMapper = new ObjectMapper();
     objectMapper.configure(DeserializationConfig.Feature.USE_ANNOTATIONS, false);
@@ -102,17 +95,14 @@ public class JMXPropertyProvider impleme
                              String clusterNamePropertyId,
                              String hostNamePropertyId,
                              String componentNamePropertyId) {
-    this.componentMetrics         = componentMetrics;
+
+    super(componentMetrics);
+
     this.streamProvider           = streamProvider;
     this.jmxHostProvider          = jmxHostProvider;
     this.clusterNamePropertyId    = clusterNamePropertyId;
     this.hostNamePropertyId       = hostNamePropertyId;
     this.componentNamePropertyId  = componentNamePropertyId;
-
-    propertyIds = new HashSet<String>();
-    for (Map.Entry<String, Map<String, PropertyInfo>> entry : componentMetrics.entrySet()) {
-      propertyIds.addAll(entry.getValue().keySet());
-    }
   }
 
 
@@ -132,25 +122,22 @@ public class JMXPropertyProvider impleme
     return keepers;
   }
 
-  @Override
-  public Set<String> getPropertyIds() {
-    return propertyIds;
-  }
-
-  @Override
-  public Set<String> checkPropertyIds(Set<String> propertyIds) {
-    if (!this.propertyIds.containsAll(propertyIds)) {
-      Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds);
-      unsupportedPropertyIds.removeAll(this.propertyIds);
-      return unsupportedPropertyIds;
-    }
-    return Collections.emptySet();
-  }
-
 
   // ----- helper methods ----------------------------------------------------
 
   /**
+   * Get the spec to locate the JMX stream from the given host and port
+   *
+   * @param hostName  the host name
+   * @param port      the port
+   *
+   * @return the spec
+   */
+  protected String getSpec(String hostName, String port) {
+    return "http://" + hostName + ":" + port + "/jmx";
+  }
+
+  /**
    * Populate a resource by obtaining the requested JMX properties.
    *
    * @param resource  the resource to be populated
@@ -162,31 +149,36 @@ public class JMXPropertyProvider impleme
   private boolean populateResource(Resource resource, Request request, Predicate predicate)
       throws SystemException {
 
-    Set<String> ids = PropertyHelper.getRequestPropertyIds(propertyIds, request, predicate);
+    Set<String> ids = getRequestPropertyIds(request, predicate);
     if (ids.isEmpty()) {
       return true;
     }
 
-    String clusterName   = (String) resource.getPropertyValue(clusterNamePropertyId);
     String componentName = (String) resource.getPropertyValue(componentNamePropertyId);
-    String port          = JMX_PORTS.get(componentName);
 
-    String hostName;
-    if (hostNamePropertyId == null) {
-      hostName = jmxHostProvider.getHostName(clusterName, componentName);
-    }
-    else {
-      hostName = (String) resource.getPropertyValue(hostNamePropertyId);
+    if (getComponentMetrics().get(componentName) == null) {
+      // If there are no metrics defined for the given component then there is nothing to do.
+      return true;
     }
 
-    Map<String, PropertyInfo> metrics = componentMetrics.get(componentName);
+    String clusterName = (String) resource.getPropertyValue(clusterNamePropertyId);
 
-    if (metrics == null || hostName == null || port == null) {
-      return true;
+    String port = getPort(clusterName, componentName);
+    if (port == null) {
+      String error = "Unable to get JMX metrics.  No port value for " + componentName;
+      logError(error, null);
+      throw new SystemException(error, null);
+    }
+
+    String hostName = getHost(resource, clusterName, componentName);
+    if (hostName == null) {
+      String error = "Unable to get JMX metrics.  No host name for " + componentName;
+      logError(error, null);
+      throw new SystemException(error, null);
     }
 
-    String spec = getSpec(hostName + ":" + port);
-    InputStream in = null;
+    String      spec = getSpec(hostName, port);
+    InputStream in   = null;
     try {
       in = streamProvider.readFrom(spec);
       JMXMetricHolder metricHolder = objectReader.readValue(in);
@@ -201,66 +193,66 @@ public class JMXPropertyProvider impleme
       }
 
       for (String propertyId : ids) {
+        Map<String, PropertyInfo> propertyInfoMap = getPropertyInfoMap(componentName, propertyId);
 
-        PropertyInfo propertyInfo = metrics.get(propertyId);
+        for (Map.Entry<String, PropertyInfo> entry : propertyInfoMap.entrySet()) {
 
-        if (propertyInfo != null && propertyInfo.isPointInTime()) {
+          PropertyInfo propertyInfo = entry.getValue();
+          propertyId = entry.getKey();
 
-          String property = propertyInfo.getPropertyId();
-          String category = "";
+          if (propertyInfo.isPointInTime()) {
 
-          List<String> keyList = new LinkedList<String>();
-          int keyStartIndex = property.indexOf('[', 0);
-          int firstKeyIndex = keyStartIndex > -1 ? keyStartIndex : property.length();
-          while (keyStartIndex > -1) {
-            int keyEndIndex = property.indexOf(']', keyStartIndex);
-            if (keyEndIndex > -1 & keyEndIndex > keyStartIndex) {
-              keyList.add(property.substring(keyStartIndex + 1, keyEndIndex));
-              keyStartIndex = property.indexOf('[', keyEndIndex);
-            }
-            else {
-              keyStartIndex = -1;
+            String property = propertyInfo.getPropertyId();
+            String category = "";
+
+            List<String> keyList = new LinkedList<String>();
+            int keyStartIndex = property.indexOf('[', 0);
+            int firstKeyIndex = keyStartIndex > -1 ? keyStartIndex : property.length();
+            while (keyStartIndex > -1) {
+              int keyEndIndex = property.indexOf(']', keyStartIndex);
+              if (keyEndIndex > -1 & keyEndIndex > keyStartIndex) {
+                keyList.add(property.substring(keyStartIndex + 1, keyEndIndex));
+                keyStartIndex = property.indexOf('[', keyEndIndex);
+              }
+              else {
+                keyStartIndex = -1;
+              }
             }
-          }
-
 
-          int dotIndex = property.lastIndexOf('.', firstKeyIndex - 1);
-          if (dotIndex != -1){
-            category = property.substring(0, dotIndex);
-            property = property.substring(dotIndex + 1, firstKeyIndex);
-          }
+            int dotIndex = property.lastIndexOf('.', firstKeyIndex - 1);
+            if (dotIndex != -1){
+              category = property.substring(0, dotIndex);
+              property = property.substring(dotIndex + 1, firstKeyIndex);
+            }
 
-          Map<String, Object> properties = categories.get(category);
-          if (properties != null && properties.containsKey(property)) {
-            Object value = properties.get(property);
-            if (keyList.size() > 0 && value instanceof Map) {
-              Map map = (Map) value;
-              for (String key : keyList) {
-                value = map.get(key);
-                if (value instanceof Map) {
-                  map = (Map) value;
-                }
-                else {
-                  break;
+            Map<String, Object> properties = categories.get(category);
+            if (properties != null && properties.containsKey(property)) {
+              Object value = properties.get(property);
+              if (keyList.size() > 0 && value instanceof Map) {
+                Map map = (Map) value;
+                for (String key : keyList) {
+                  value = map.get(key);
+                  if (value instanceof Map) {
+                    map = (Map) value;
+                  }
+                  else {
+                    break;
+                  }
                 }
               }
+              resource.setProperty(propertyId, value);
             }
-            resource.setProperty(propertyId, value);
           }
         }
       }
     } catch (IOException e) {
-      if (LOG.isErrorEnabled()) {
-        LOG.error("Caught exception getting JMX metrics : spec=" + spec, e);
-      }
+      logError(spec, e);
     } finally {
       if (in != null) {
         try {
           in.close();
         } catch (IOException e) {
-          if (LOG.isWarnEnabled()) {
-            LOG.warn("Unable to close http input steam : spec=" + spec, e);
-          }
+            logError("Unable to close http input steam : spec=" + spec, e);
         }
       }
     }
@@ -268,6 +260,17 @@ public class JMXPropertyProvider impleme
     return true;
   }
 
+  private String getPort(String clusterName, String componentName) throws SystemException {
+    String port = jmxHostProvider.getPort(clusterName, componentName);
+    return port == null ? DEFAULT_JMX_PORTS.get(componentName) : port;
+  }
+
+  private String getHost(Resource resource, String clusterName, String componentName) throws SystemException {
+    return hostNamePropertyId == null ?
+        jmxHostProvider.getHostName(clusterName, componentName) :
+        (String) resource.getPropertyValue(hostNamePropertyId);
+  }
+
   private String getCategory(Map<String, Object> bean) {
     if (bean.containsKey(NAME_KEY)) {
       String name = (String) bean.get(NAME_KEY);
@@ -281,15 +284,13 @@ public class JMXPropertyProvider impleme
     return null;
   }
 
-  /**
-   * Get the spec to locate the JMX stream from the given source
-   *
-   * @param jmxSource  the source (host and port)
-   *
-   * @return the spec
-   */
-  protected String getSpec(String jmxSource) {
-//    return "http://" + jmxSource + "/jmx?qry=Hadoop:*";
-    return "http://" + jmxSource + "/jmx";
+  private static void logError(String error, IOException e) {
+    if (LOG.isErrorEnabled()) {
+      if (e == null) {
+        LOG.error("Caught exception getting JMX metrics : spec=" + error);
+      } else {
+        LOG.error("Caught exception getting JMX metrics : spec=" + error, e);
+      }
+    }
   }
 }

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicate.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicate.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryIsEmptyPredicate.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,49 @@
+/**
+ * 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.controller.predicate;
+
+import org.apache.ambari.server.controller.spi.Resource;
+
+import java.util.Map;
+
+/**
+ * Predicate that checks if the associated property category is empty.  If the associated
+ * property id references a Map property then treat the Map as a category.
+ */
+public class CategoryIsEmptyPredicate extends CategoryPredicate {
+
+  public CategoryIsEmptyPredicate(String propertyId) {
+    super(propertyId);
+  }
+
+  @Override
+  public boolean evaluate(Resource resource) {
+    String propertyId = getPropertyId();
+
+    // If the property exists as a Map then check isEmpty
+    Object value = resource.getPropertyValue(propertyId);
+    if (value instanceof Map) {
+      Map<?,?> mapValue = (Map) value;
+      return mapValue.isEmpty();
+    }
+    // Get the category
+    Map<String, Object> properties = resource.getPropertiesMap().get(propertyId);
+    return properties == null ? true : properties.isEmpty();
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryPredicate.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryPredicate.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/CategoryPredicate.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,33 @@
+/**
+ * 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.controller.predicate;
+
+/**
+ * Base class for predicates based on property categories.
+ */
+public abstract class CategoryPredicate extends PropertyPredicate implements BasePredicate {
+  public CategoryPredicate(String propertyId) {
+    super(propertyId);
+  }
+
+  @Override
+  public void accept(PredicateVisitor visitor) {
+    visitor.acceptCategoryPredicate(this);
+  }
+}

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitor.java Wed Mar 20 20:44:43 2013
@@ -29,4 +29,6 @@ public interface PredicateVisitor {
   public void acceptUnaryPredicate(UnaryPredicate predicate);
 
   public void acceptAlwaysPredicate(AlwaysPredicate predicate);
+
+  public void acceptCategoryPredicate(CategoryPredicate predicate);
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PredicateVisitorAcceptor.java Wed Mar 20 20:44:43 2013
@@ -22,5 +22,10 @@ package org.apache.ambari.server.control
  */
 public interface PredicateVisitorAcceptor {
 
+  /**
+   * Accept the given visitor.
+   *
+   * @param visitor  the visitor
+   */
   public void accept(PredicateVisitor visitor);
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/PropertyProvider.java Wed Mar 20 20:44:43 2013
@@ -17,8 +17,6 @@
  */
 package org.apache.ambari.server.controller.spi;
 
-import org.apache.ambari.server.AmbariException;
-
 import java.util.Set;
 
 /**
@@ -46,14 +44,6 @@ public interface PropertyProvider {
       throws SystemException;
 
   /**
-   * Get the set of property ids for the properties that this provider can provide.
-   *
-   * @return the set of property ids for the properties that this provider can provide
-   */
-  // TODO : remove this
-  public Set<String> getPropertyIds();
-
-  /**
    * Check whether the set of given property ids is supported by this resource
    * provider.
    *

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java Wed Mar 20 20:44:43 2013
@@ -37,7 +37,7 @@ public interface Request {
   public Set<String> getPropertyIds();
 
   /**
-   * Get the set of maps of properties being requested.  Used
+   * Get the property values of the request.  Used
    * for requests to update or create resources.  Each value
    * in the set is a map of properties for a resource being
    * created/updated.  Each map contains property values keyed

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java Wed Mar 20 20:44:43 2013
@@ -62,6 +62,13 @@ public interface Resource {
   public void setProperty(String id, Object value);
 
   /**
+   * Add an empty category to this resource.
+   *
+   * @param id    the category id
+   */
+  public void addCategory(String id);
+
+  /**
    * Get a property value for the given property id from this resource.
    *
    * @param id the property id

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java Wed Mar 20 20:44:43 2013
@@ -129,16 +129,13 @@ public interface ResourceProvider {
       NoSuchParentResourceException;
 
   /**
-   * Get the set of property ids for the properties that this provider can provide.
-   *
-   * @return the set of property ids for the properties that this provider can provide
-   */
-  // TODO : remove this
-  public Set<String> getPropertyIdsForSchema();
-
-  /**
    * Get the key property ids for the resource type associated with this resource
-   * providers.  The key properties are those that uniquely identify the resource.
+   * provider.  The key properties are those that uniquely identify the resource.
+   *</p>
+   * For example, the resource 'HostComponent' is uniquely identified by
+   * its associated 'Cluster', 'Host' and 'Component' resources.  The key property ids
+   * for a 'HostComponent' resource includes the property ids of the foreign key
+   * references from the 'HostComponent' to 'Cluster', 'Host' and 'Component' resources.
    *
    * @return a map of key property ids
    */

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Schema.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Schema.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Schema.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Schema.java Wed Mar 20 20:44:43 2013
@@ -17,8 +17,6 @@
  */
 package org.apache.ambari.server.controller.spi;
 
-import java.util.Map;
-import java.util.Set;
 
 /**
  * The schema is used to describe all of the properties that a resource type
@@ -32,22 +30,12 @@ public interface Schema {
    * </p>
    * For example, the resource 'HostComponent' is uniquely identified by
    * its associated 'Cluster', 'Host' and 'Component' resources.  Passing
-   * the 'Host' resource type to
-   * {@link Schema#getKeyPropertyId(org.apache.ambari.server.controller.spi.Resource.Type)}
-   * on a schema object of a 'HostComponent' resource will return the id of the
-   * property of the foreign key reference from the 'HostComponent' to the 'Host'.
+   * the 'Host' resource type to this method on a schema object of a 'HostComponent'
+   * resource will return the id of the property of the foreign key reference from
+   * the 'HostComponent' to the 'Host'.
    *
    * @param type the resource type
    * @return the key property id for the given resource type
    */
   public String getKeyPropertyId(Resource.Type type);
-
-  /**
-   * Get this schema's map of category and property names.  The map
-   * is keyed by category name and contains sets of property names
-   * for each category.
-   *
-   * @return the map of category and property names
-   */
-  public Map<String, Set<String>> getCategoryProperties();
-}
+  }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/PropertyHelper.java Wed Mar 20 20:44:43 2013
@@ -51,14 +51,37 @@ public class PropertyHelper {
   private static final Map<Resource.Type, Map<Resource.Type, String>> KEY_PROPERTY_IDS = readKeyPropertyIds(KEY_PROPERTIES_FILE);
 
   public static String getPropertyId(String category, String name) {
-    return category == null ? name : category + EXTERNAL_PATH_SEP + name;
+    String propertyId =  (category == null || category.isEmpty())? name :
+           (name == null || name.isEmpty()) ? category : category + EXTERNAL_PATH_SEP + name;
+
+    if (propertyId.endsWith("/")) {
+      propertyId = propertyId.substring(0, propertyId.length() - 1);
+    }
+    return propertyId;
   }
 
+
   public static Set<String> getPropertyIds(Resource.Type resourceType) {
     Set<String> propertyIds = PROPERTY_IDS.get(resourceType);
     return propertyIds == null ? Collections.<String>emptySet() : propertyIds;
   }
 
+  /**
+   * Extract the set of property ids from a component PropertyInfo map.
+   *
+   * @param componentPropertyInfoMap  the map
+   *
+   * @return the set of property ids
+   */
+  public static Set<String> getPropertyIds(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap ) {
+    Set<String> propertyIds = new HashSet<String>();
+
+    for (Map.Entry<String, Map<String, PropertyInfo>> entry : componentPropertyInfoMap.entrySet()) {
+      propertyIds.addAll(entry.getValue().keySet());
+    }
+    return propertyIds;
+  }
+
   public static Map<String, Map<String, PropertyInfo>> getGangliaPropertyIds(Resource.Type resourceType) {
     return GANGLIA_PROPERTY_IDS.get(resourceType);
   }
@@ -97,6 +120,25 @@ public class PropertyHelper {
   }
 
   /**
+   * Get the set of categories for the given property ids.
+   *
+   * @param propertyIds  the property ids
+   *
+   * @return the set of categories
+   */
+  public static Set<String> getCategories(Set<String> propertyIds) {
+    Set<String> categories = new HashSet<String>();
+    for (String property : propertyIds) {
+      String category = PropertyHelper.getPropertyCategory(property);
+      while (category != null) {
+        categories.add(category);
+        category = PropertyHelper.getPropertyCategory(category);
+      }
+    }
+    return categories;
+  }
+
+  /**
    * Get all of the property ids associated with the given request.
    *
    * @param request  the request
@@ -142,44 +184,6 @@ public class PropertyHelper {
   }
 
   /**
-   * Get the set of property ids required to satisfy the given request.
-   *
-   * @param providerPropertyIds  the provider property ids
-   * @param request              the request
-   * @param predicate            the predicate
-   *
-   * @return the set of property ids needed to satisfy the request
-   */
-  public static Set<String> getRequestPropertyIds(Set<String> providerPropertyIds,
-                                                      Request request,
-                                                      Predicate predicate) {
-    Set<String> propertyIds  = request.getPropertyIds();
-
-    // if no properties are specified, then return them all
-    if (propertyIds == null || propertyIds.isEmpty()) {
-      providerPropertyIds = new HashSet<String>(providerPropertyIds);
-
-//      // strip out the temporal properties, they must be asked for explicitly
-//      Iterator<String> iter = providerPropertyIds.iterator();
-//      while (iter.hasNext()) {
-//        String propertyId = iter.next();
-//        if (propertyId.isTemporal()) {
-//          iter.remove();
-//        }
-//      }
-      return providerPropertyIds;
-    }
-
-    propertyIds = new HashSet<String>(propertyIds);
-
-    if (predicate != null) {
-      propertyIds.addAll(PredicateHelper.getPropertyIds(predicate));
-    }
-    propertyIds.retainAll(providerPropertyIds);
-    return propertyIds;
-  }
-
-  /**
    * Factory method to create a create request from the given set of property maps.
    * Each map contains the properties to be used to create a resource.  Multiple maps in the
    * set should result in multiple creates.

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ComponentConfigMappingDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ComponentConfigMappingDAO.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ComponentConfigMappingDAO.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ComponentConfigMappingDAO.java Wed Mar 20 20:44:43 2013
@@ -49,6 +49,7 @@ public class ComponentConfigMappingDAO {
     return daoUtils.selectList(query, configTypes);
   }
 
+  @Transactional
   public List<ComponentConfigMappingEntity> findByComponentAndType(long clusterId, String serviceName, String componentName,
                                                                    Collection<String> configTypes) {
     if (configTypes.isEmpty()) {

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/DaoUtils.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/DaoUtils.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/DaoUtils.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/DaoUtils.java Wed Mar 20 20:44:43 2013
@@ -27,7 +27,7 @@ import java.util.Collections;
 import java.util.List;
 
 @Singleton
-public class DaoUtils {
+class DaoUtils {
 
   public <T> List<T> selectList(TypedQuery<T> query, Object... parameters) {
     setParameters(query, parameters);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/KeyValueDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/KeyValueDAO.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/KeyValueDAO.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/KeyValueDAO.java Wed Mar 20 20:44:43 2013
@@ -39,6 +39,7 @@ public class KeyValueDAO {
     return entityManagerProvider.get().find(KeyValueEntity.class, key);
   }
 
+  @Transactional
   public Collection<KeyValueEntity> findAll() {
     TypedQuery<KeyValueEntity> query =
         entityManagerProvider.get().createQuery("SELECT keyValue FROM KeyValueEntity keyValue", KeyValueEntity.class);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/StageDAO.java Wed Mar 20 20:44:43 2013
@@ -43,6 +43,7 @@ public class StageDAO {
     return entityManagerProvider.get().find(StageEntity.class, stageEntityPK);
   }
 
+  @Transactional
   public long getLastRequestId() {
     TypedQuery<Long> query = entityManagerProvider.get().createQuery("SELECT max(stage.requestId) FROM StageEntity stage", Long.class);
     Long result = daoUtils.selectSingle(query);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/ExecutionCommandEntity.java Wed Mar 20 20:44:43 2013
@@ -19,13 +19,14 @@
 package org.apache.ambari.server.orm.entities;
 
 import javax.persistence.*;
+import java.util.Arrays;
 
 @Table(name = "execution_command", schema = "ambari", catalog = "")
 @Entity
 public class ExecutionCommandEntity {
   private Long taskId;
 
-  @Column(name = "task_id", insertable = false, updatable = false, nullable = false)
+  @Column(name = "task_id")
   @Id
   public Long getTaskId() {
     return taskId;
@@ -55,7 +56,7 @@ public class ExecutionCommandEntity {
 
     ExecutionCommandEntity that = (ExecutionCommandEntity) o;
 
-    if (command != null ? !command.equals(that.command) : that.command != null) return false;
+    if (command != null ? !Arrays.equals(command, that.command) : that.command != null) return false;
     if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
 
     return true;
@@ -64,14 +65,14 @@ public class ExecutionCommandEntity {
   @Override
   public int hashCode() {
     int result = taskId != null ? taskId.hashCode() : 0;
-    result = 31 * result + (command != null ? command.hashCode() : 0);
+    result = 31 * result + (command != null ? Arrays.hashCode(command) : 0);
     return result;
   }
 
   private HostRoleCommandEntity hostRoleCommand;
 
   @OneToOne
-  @JoinColumn(name = "task_id", referencedColumnName = "task_id", nullable = false)
+  @JoinColumn(name = "task_id", referencedColumnName = "task_id", nullable = false, insertable = false, updatable = false)
   public HostRoleCommandEntity getHostRoleCommand() {
     return hostRoleCommand;
   }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/HostRoleCommandEntity.java Wed Mar 20 20:44:43 2013
@@ -23,6 +23,7 @@ import org.apache.ambari.server.RoleComm
 import org.apache.ambari.server.actionmanager.HostRoleStatus;
 
 import javax.persistence.*;
+import java.util.Arrays;
 
 @Table(name = "host_role_command", schema = "ambari", catalog = "")
 @Entity
@@ -218,8 +219,8 @@ public class HostRoleCommandEntity {
     if (stageId != null ? !stageId.equals(that.stageId) : that.stageId != null) return false;
     if (startTime != null ? !startTime.equals(that.startTime) : that.startTime != null) return false;
     if (status != null ? !status.equals(that.status) : that.status != null) return false;
-    if (stdError != null ? !stdError.equals(that.stdError) : that.stdError != null) return false;
-    if (stdOut != null ? !stdOut.equals(that.stdOut) : that.stdOut != null) return false;
+    if (stdError != null ? !Arrays.equals(stdError, that.stdError) : that.stdError != null) return false;
+    if (stdOut != null ? !Arrays.equals(stdOut, that.stdOut) : that.stdOut != null) return false;
     if (taskId != null ? !taskId.equals(that.taskId) : that.taskId != null) return false;
 
     return true;
@@ -235,8 +236,8 @@ public class HostRoleCommandEntity {
     result = 31 * result + (event != null ? event.hashCode() : 0);
     result = 31 * result + (exitcode != null ? exitcode.hashCode() : 0);
     result = 31 * result + (status != null ? status.hashCode() : 0);
-    result = 31 * result + (stdError != null ? stdError.hashCode() : 0);
-    result = 31 * result + (stdOut != null ? stdOut.hashCode() : 0);
+    result = 31 * result + (stdError != null ? Arrays.hashCode(stdError) : 0);
+    result = 31 * result + (stdOut != null ? Arrays.hashCode(stdOut) : 0);
     result = 31 * result + (startTime != null ? startTime.hashCode() : 0);
     result = 31 * result + (lastAttemptTime != null ? lastAttemptTime.hashCode() : 0);
     result = 31 * result + (attemptCount != null ? attemptCount.hashCode() : 0);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java Wed Mar 20 20:44:43 2013
@@ -84,4 +84,17 @@ public interface Service {
   public boolean isClientOnlyService();
 
   public void delete() throws AmbariException;
+
+  public enum Type {
+    HDFS,
+    MAPREDUCE,
+    HBASE,
+    HIVE,
+    OOZIE,
+    WEBHCAT,
+    SQOOP,
+    NAGIOS,
+    GANGLIA,
+    ZOOKEEPER
+  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java Wed Mar 20 20:44:43 2013
@@ -305,13 +305,6 @@ public class ServiceComponentImpl implem
   @Override
   public synchronized void updateDesiredConfigs(Map<String, Config> configs) {
 
-    Set<String> deletedTypes = new HashSet<String>();
-    for (String type : this.desiredConfigs.keySet()) {
-      if (!configs.containsKey(type)) {
-        deletedTypes.add(type);
-      }
-    }
-
     for (Entry<String,Config> entry : configs.entrySet()) {
       boolean contains = false;
 
@@ -343,33 +336,6 @@ public class ServiceComponentImpl implem
       this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
     }
 
-    if (!deletedTypes.isEmpty()) {
-      if (persisted) {
-        List<ComponentConfigMappingEntity> deleteEntities =
-            componentConfigMappingDAO.findByComponentAndType(
-                desiredStateEntity.getClusterId(), desiredStateEntity.getServiceName(),
-                desiredStateEntity.getComponentName(),
-                deletedTypes);
-        for (ComponentConfigMappingEntity deleteEntity : deleteEntities) {
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Deleting desired config from ServiceComponent"
-                + ", clusterId=" + desiredStateEntity.getClusterId()
-                + ", serviceName=" + desiredStateEntity.getServiceName()
-                + ", componentName=" + desiredStateEntity.getComponentName()
-                + ", configType=" + deleteEntity.getConfigType()
-                + ", configVersionTag=" + deleteEntity.getVersionTag());
-          }
-          desiredStateEntity.getComponentConfigMappingEntities().remove(
-              deleteEntity);
-          componentConfigMappingDAO.remove(deleteEntity);
-        }
-      } else {
-        for (String deletedType : deletedTypes) {
-          desiredConfigs.remove(deletedType);
-        }
-      }
-    }
-
     saveIfPersisted();
   }
 

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java Wed Mar 20 20:44:43 2013
@@ -257,13 +257,6 @@ public class ServiceImpl implements Serv
   @Override
   public synchronized void updateDesiredConfigs(Map<String, Config> configs) {
 
-    Set<String> deletedTypes = new HashSet<String>();
-    for (String type : this.desiredConfigs.keySet()) {
-      if (!configs.containsKey(type)) {
-        deletedTypes.add(type);
-      }
-    }
-
     for (Entry<String,Config> entry : configs.entrySet()) {
       boolean contains = false;
 
@@ -291,31 +284,6 @@ public class ServiceImpl implements Serv
       this.desiredConfigs.put(entry.getKey(), entry.getValue().getVersionTag());
     }
 
-    if (!deletedTypes.isEmpty()) {
-      if (persisted) {
-        List<ServiceConfigMappingEntity> deleteEntities =
-            serviceConfigMappingDAO.findByServiceAndType(
-                serviceEntity.getClusterId(), serviceEntity.getServiceName(),
-                deletedTypes);
-        for (ServiceConfigMappingEntity deleteEntity : deleteEntities) {
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Deleting desired config from ServiceComponent"
-                + ", clusterId=" + serviceEntity.getClusterId()
-                + ", serviceName=" + serviceEntity.getServiceName()
-                + ", configType=" + deleteEntity.getConfigType()
-                + ", configVersionTag=" + deleteEntity.getVersionTag());
-          }
-          serviceEntity.getServiceConfigMappings().remove(
-              deleteEntity);
-          serviceConfigMappingDAO.remove(deleteEntity);
-        }
-      } else {
-        for (String deletedType : deletedTypes) {
-          desiredConfigs.remove(deletedType);
-        }
-      }
-    }
-
     saveIfPersisted();
 
   }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceInfo.java Wed Mar 20 20:44:43 2013
@@ -105,11 +105,11 @@ public class ServiceInfo {
     sb.append("Service name:" + name + "\nversion:" + version +
         "\nuser:" + user + "\ncomment:" + comment);
 //    if(properties != null)
-//    for (PropertyInfo property : properties) {
+//    for (PropertyInfo property : getProperties()) {
 //      sb.append("\tProperty name=" + property.getName() +
     //"\nproperty value=" + property.getValue() + "\ndescription=" + property.getDescription());
 //    }
-    for(ComponentInfo component : components){
+    for(ComponentInfo component : getComponents()){
       sb.append("\n\n\nComponent:\n");
       sb.append("name="+ component.getName());
       sb.append("\tcategory="+ component.getCategory() );