You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2012/11/07 09:13:24 UTC

svn commit: r1406489 [7/19] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-agent/ ambari-agent/conf/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/manifestloader/ ambari-agent/src/main/puppet/modules/configgenerator/manifests/ ambari-agen...

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=1406489&r1=1406488&r2=1406489&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 Nov  7 08:13:12 2012
@@ -28,6 +28,8 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.ActionRequest;
+import org.apache.ambari.server.controller.ActionResponse;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.ClusterRequest;
 import org.apache.ambari.server.controller.ClusterResponse;
@@ -35,19 +37,26 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.ConfigurationResponse;
 import org.apache.ambari.server.controller.HostRequest;
 import org.apache.ambari.server.controller.HostResponse;
+import org.apache.ambari.server.controller.RequestStatusRequest;
+import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ServiceComponentHostRequest;
 import org.apache.ambari.server.controller.ServiceComponentHostResponse;
 import org.apache.ambari.server.controller.ServiceComponentRequest;
 import org.apache.ambari.server.controller.ServiceComponentResponse;
 import org.apache.ambari.server.controller.ServiceRequest;
 import org.apache.ambari.server.controller.ServiceResponse;
+import org.apache.ambari.server.controller.TaskStatusRequest;
+import org.apache.ambari.server.controller.TaskStatusResponse;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Basic resource provider implementation that maps to a management controller.
@@ -105,10 +114,32 @@ public abstract class ResourceProviderIm
   protected static final PropertyId CONFIGURATION_CLUSTER_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("cluster_name","Config");
   protected static final PropertyId CONFIGURATION_CONFIG_TYPE_PROPERTY_ID     = PropertyHelper.getPropertyId("type");
   protected static final PropertyId CONFIGURATION_CONFIG_TAG_PROPERTY_ID      = PropertyHelper.getPropertyId("tag");
+  // Actions
+  protected static final PropertyId ACTION_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name", "Actions");
+  protected static final PropertyId ACTION_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("service_name", "Actions");
+  protected static final PropertyId ACTION_ACTION_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("action_name", "Actions");
+  // Requests
+  protected static final PropertyId REQUEST_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name","Requests");
+  protected static final PropertyId REQUEST_ID_PROPERTY_ID           = PropertyHelper.getPropertyId("id","Requests");
+  // Tasks
+  protected static final PropertyId TASK_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name","Tasks");
+  protected static final PropertyId TASK_REQUEST_ID_PROPERTY_ID   = PropertyHelper.getPropertyId("request_id","Tasks");
+  protected static final PropertyId TASK_ID_PROPERTY_ID           = PropertyHelper.getPropertyId("id","Tasks");
+  protected static final PropertyId TASK_STAGE_ID_PROPERTY_ID     = PropertyHelper.getPropertyId("stage_id","Tasks");
+  protected static final PropertyId TASK_HOST_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("host_name","Tasks");
+  protected static final PropertyId TASK_ROLE_PROPERTY_ID         = PropertyHelper.getPropertyId("role","Tasks");
+  protected static final PropertyId TASK_COMMAND_PROPERTY_ID      = PropertyHelper.getPropertyId("command","Tasks");
+  protected static final PropertyId TASK_STATUS_PROPERTY_ID       = PropertyHelper.getPropertyId("status","Tasks");
+  protected static final PropertyId TASK_EXIT_CODE_PROPERTY_ID    = PropertyHelper.getPropertyId("exit_code","Tasks");
+  protected static final PropertyId TASK_STDERR_PROPERTY_ID       = PropertyHelper.getPropertyId("stderr","Tasks");
+  protected static final PropertyId TASK_STOUT_PROPERTY_ID        = PropertyHelper.getPropertyId("stdout","Tasks");
+  protected static final PropertyId TASK_START_TIME_PROPERTY_ID   = PropertyHelper.getPropertyId("start_time","Tasks");
+  protected static final PropertyId TASK_ATTEMPT_CNT_PROPERTY_ID  = PropertyHelper.getPropertyId("attempt_cnt","Tasks");
 
+  private final static Logger LOG =
+      LoggerFactory.getLogger(ResourceProviderImpl.class);
 
-  // ----- Constructors ------------------------------------------------------
-
+    // ----- Constructors ------------------------------------------------------
   /**
    * Create a  new resource provider for the given management controller.
    *
@@ -181,6 +212,24 @@ public abstract class ResourceProviderIm
   }
 
   /**
+   * Get a request status
+   *
+   * @return the request status
+   */
+  protected RequestStatus getRequestStatus(RequestStatusResponse response) {
+
+    if (response != null){
+      Resource requestResource = new ResourceImpl(Resource.Type.Request);
+      requestResource.setProperty(PropertyHelper.getPropertyId("id", "Requests"), response.getRequestId());
+      // TODO : how do we tell what a request status is?
+      // for now make everything InProgress
+      requestResource.setProperty(PropertyHelper.getPropertyId("status", "Requests"), "InProgress");
+      return new RequestStatusImpl(requestResource);
+    }
+    return new RequestStatusImpl(null);
+  }
+
+  /**
    * Get a map of property values from a given predicate.
    *
    * @param predicate  the predicate
@@ -222,8 +271,22 @@ public abstract class ResourceProviderIm
    */
   private static void setResourceProperty(Resource resource, PropertyId propertyId, String value, Set<PropertyId> requestedIds) {
     if (requestedIds.contains(propertyId)) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Setting property for resource"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
       resource.setProperty(propertyId, value);
     }
+    else {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Skipping property for resource as not in requestedIds"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
+    }
   }
 
   /**
@@ -236,9 +299,27 @@ public abstract class ResourceProviderIm
    * @param requestedIds  the requested set of property ids
    */
   private static void setResourceProperty(Resource resource, PropertyId propertyId, Long value, Set<PropertyId> requestedIds) {
-    if (requestedIds.contains(propertyId)) {
+    // FIXME requestedIds does not seem to be populated properly for get
+    // requests where a full response was requested
+    if (requestedIds == null
+        || requestedIds.isEmpty()
+        || requestedIds.contains(propertyId)) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Setting property for resource"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
       resource.setProperty(propertyId, value);
     }
+    else {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Skipping property for resource as not in requestedIds"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
+    }
   }
 
   /**
@@ -252,8 +333,45 @@ public abstract class ResourceProviderIm
    */
   private static void setResourceProperty(Resource resource, PropertyId propertyId, Integer value, Set<PropertyId> requestedIds) {
     if (requestedIds.contains(propertyId)) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Setting property for resource"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
       resource.setProperty(propertyId, value);
     }
+    else {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Skipping property for resource as not in requestedIds"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
+    }
+  }
+
+  /**
+   * Set a short property value on the given resource for the given id and value.
+   * Make sure that the id is in the given set of requested ids.
+   *
+   * @param resource      the resource
+   * @param propertyId    the property id
+   * @param value         the value to set
+   * @param requestedIds  the requested set of property ids
+   */
+  private static void setResourceProperty(Resource resource, PropertyId propertyId, Short value, Set<PropertyId> requestedIds) {
+    if (requestedIds.contains(propertyId)) {
+      resource.setProperty(propertyId, value);
+    }
+    else {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Skipping property for resource as not in requestedIds"
+            + ", resourceType=" + resource.getType()
+            + ", propertyId=" + propertyId.getName()
+            + ", value=" + value);
+      }
+    }
   }
 
   /**
@@ -283,10 +401,15 @@ public abstract class ResourceProviderIm
         return new HostComponentResourceProvider(propertyIds, keyPropertyIds, managementController);
       case Configuration:
         return new ConfigurationResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Action:
+        return new ActionResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Request:
+        return new RequestResourceProvider(propertyIds, keyPropertyIds, managementController);
+      case Task:
+        return new TaskResourceProvider(propertyIds, keyPropertyIds, managementController);
       default:
         throw new IllegalArgumentException("Unknown type " + type);
     }
-    
   }
 
 
@@ -316,44 +439,52 @@ public abstract class ResourceProviderIm
 // ----- ResourceProvider ------------------------------------------------
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
 
       for (Map<PropertyId, Object> properties : request.getProperties()) {
         getManagementController().createCluster(getRequest(properties));
       }
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
-      Set<PropertyId> requestedIds   = request.getPropertyIds();
       ClusterRequest  clusterRequest = getRequest(getProperties(predicate));
+      Set<PropertyId> requestedIds   = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
 
-      Set<ClusterResponse> responses = getManagementController().getClusters(clusterRequest);
+      // TODO : handle multiple requests
+      Set<ClusterResponse> responses = getManagementController().getClusters(Collections.singleton(clusterRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (ClusterResponse response : responses) {
         Resource resource = new ResourceImpl(Resource.Type.Cluster);
         setResourceProperty(resource, CLUSTER_ID_PROPERTY_ID, response.getClusterId(), requestedIds);
         setResourceProperty(resource, CLUSTER_NAME_PROPERTY_ID, response.getClusterName(), requestedIds);
+        // FIXME requestedIds does not seem to be filled in properly for
+        // non-partial responses
+        resource.setProperty(CLUSTER_VERSION_PROPERTY_ID,
+            response.getDesiredStackVersion());
         resources.add(resource);
       }
       return resources;
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
         ClusterRequest clusterRequest = getRequest(propertyMap);
         getManagementController().updateCluster(clusterRequest);
       }
+      return getRequestStatus(null);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(null, predicate)) {
         ClusterRequest clusterRequest = getRequest(propertyMap);
         getManagementController().deleteCluster(clusterRequest);
       }
+      return getRequestStatus(null);
     }
 
     // ----- utility methods -------------------------------------------------
@@ -373,10 +504,12 @@ public abstract class ResourceProviderIm
     private ClusterRequest getRequest(Map<PropertyId, Object> properties) {
 
       Long id = (Long) properties.get(CLUSTER_ID_PROPERTY_ID);
+      String stackVersion = (String) properties.get(CLUSTER_VERSION_PROPERTY_ID);
+
       return new ClusterRequest(
           id == null ? null : id,
           (String) properties.get(CLUSTER_NAME_PROPERTY_ID),
-          (String) properties.get(CLUSTER_VERSION_PROPERTY_ID),
+          stackVersion == null ? "HDP-0.1" : stackVersion,    // TODO : looks like version is required
           /*properties.get(CLUSTER_HOSTS_PROPERTY_ID)*/ null);
     }
   }
@@ -408,30 +541,32 @@ public abstract class ResourceProviderIm
     // ----- ResourceProvider ------------------------------------------------
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
       Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
       for (Map<PropertyId, Object> propertyMap : request.getProperties()) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().createServices(requests);
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
-      Set<PropertyId> requestedIds   = request.getPropertyIds();
+      Set<PropertyId> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
       ServiceRequest  serviceRequest = getRequest(getProperties(predicate));
 
-      Set<ServiceResponse> responses = getManagementController().getServices(serviceRequest);
+      // TODO : handle multiple requests
+      Set<ServiceResponse> responses = getManagementController().getServices(Collections.singleton(serviceRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (ServiceResponse response : responses) {
         Resource resource = new ResourceImpl(Resource.Type.Service);
 //        setResourceProperty(resource, SERVICE_CLUSTER_ID_PROPERTY_ID, response.getClusterId(), 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);
@@ -441,34 +576,34 @@ public abstract class ResourceProviderIm
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
-        
+
         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);
+      return getRequestStatus(getManagementController().updateServices(requests));
     }
 
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       Set<ServiceRequest> requests = new HashSet<ServiceRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(null, predicate)) {
         requests.add(getRequest(propertyMap));
       }
-      getManagementController().deleteServices(requests);
+      return getRequestStatus(getManagementController().deleteServices(requests));
     }
 
     // ----- utility methods -------------------------------------------------
@@ -522,20 +657,22 @@ public abstract class ResourceProviderIm
     // ----- ResourceProvider ------------------------------------------------
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
       Set<ServiceComponentRequest> requests = new HashSet<ServiceComponentRequest>();
       for (Map<PropertyId, Object> propertyMap : request.getProperties()) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().createComponents(requests);
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
-      Set<PropertyId>          requestedIds            = request.getPropertyIds();
-      ServiceComponentRequest  serviceComponentRequest = getRequest(getProperties(predicate));
+      Set<PropertyId> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+      ServiceComponentRequest serviceComponentRequest = getRequest(getProperties(predicate));
 
-      Set<ServiceComponentResponse> responses = getManagementController().getComponents(serviceComponentRequest);
+      // TODO : handle multiple requests
+      Set<ServiceComponentResponse> responses = getManagementController().getComponents(Collections.singleton(serviceComponentRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (ServiceComponentResponse response : responses) {
@@ -551,34 +688,34 @@ public abstract class ResourceProviderIm
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceComponentRequest> requests = new HashSet<ServiceComponentRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
         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);
+      return getRequestStatus(getManagementController().updateComponents(requests));
     }
 
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       Set<ServiceComponentRequest> requests = new HashSet<ServiceComponentRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(null, predicate)) {
         requests.add(getRequest(propertyMap));
       }
-      getManagementController().deleteComponents(requests);
+      return getRequestStatus(getManagementController().deleteComponents(requests));
     }
 
     // ----- utility methods -------------------------------------------------
@@ -631,30 +768,40 @@ public abstract class ResourceProviderIm
     // ----- ResourceProvider ------------------------------------------------
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
       Set<HostRequest> requests = new HashSet<HostRequest>();
       for (Map<PropertyId, Object> propertyMap : request.getProperties()) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().createHosts(requests);
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
-      Set<PropertyId> requestedIds = request.getPropertyIds();
+      Set<PropertyId> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
       HostRequest     hostRequest  = getRequest(getProperties(predicate));
 
-      Set<HostResponse> responses = getManagementController().getHosts(hostRequest);
+      // TODO : handle multiple requests
+      Set<HostResponse> responses = getManagementController().getHosts(Collections.singleton(hostRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (HostResponse response : responses) {
         Resource resource = new ResourceImpl(Resource.Type.Host);
-        // TODO : more than one cluster
-//        setResourceProperty(resource, HOST_CLUSTER_NAME_PROPERTY_ID, response.getClusterNames(), requestedIds);
+
+        // TODO : properly handle more than one cluster
+        if (null != hostRequest.getClusterNames()) {
+          for (String clusterName : hostRequest.getClusterNames()) {
+            if (response.getClusterNames().contains(clusterName)) {
+              setResourceProperty(resource, HOST_CLUSTER_NAME_PROPERTY_ID, clusterName, requestedIds);
+            }
+          }
+        }
+
         setResourceProperty(resource, HOST_NAME_PROPERTY_ID, response.getHostname(), requestedIds);
         setResourceProperty(resource, HOST_IP_PROPERTY_ID, response.getIpv4(), requestedIds);
-        setResourceProperty(resource, HOST_TOTAL_MEM_PROPERTY_ID, response.getTotalMemBytes(), requestedIds);
-        setResourceProperty(resource, HOST_CPU_COUNT_PROPERTY_ID, response.getCpuCount(), requestedIds);
+        setResourceProperty(resource, HOST_TOTAL_MEM_PROPERTY_ID, Long.valueOf(response.getTotalMemBytes()), requestedIds);
+        setResourceProperty(resource, HOST_CPU_COUNT_PROPERTY_ID, Long.valueOf(response.getCpuCount()), requestedIds);
         setResourceProperty(resource, HOST_OS_ARCH_PROPERTY_ID, response.getOsArch(), requestedIds);
         setResourceProperty(resource, HOST_OS_TYPE_PROPERTY_ID, response.getOsType(), requestedIds);
         // TODO ...
@@ -664,21 +811,23 @@ public abstract class ResourceProviderIm
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<HostRequest> requests = new HashSet<HostRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().updateHosts(requests);
+      return getRequestStatus(null);
     }
 
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       Set<HostRequest> requests = new HashSet<HostRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(null, predicate)) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().deleteHosts(requests);
+      return getRequestStatus(null);
     }
 
     // ----- utility methods -------------------------------------------------
@@ -699,7 +848,9 @@ public abstract class ResourceProviderIm
       return new HostRequest(
           (String)  properties.get(HOST_NAME_PROPERTY_ID),
           // TODO : more than one cluster
-          Collections.singletonList((String)  properties.get(HOST_CLUSTER_NAME_PROPERTY_ID)),
+          properties.containsKey(HOST_CLUSTER_NAME_PROPERTY_ID) ?
+              Collections.singletonList((String)  properties.get(HOST_CLUSTER_NAME_PROPERTY_ID)) :
+                Collections.<String>emptyList(),
           null);
     }
   }
@@ -733,20 +884,22 @@ public abstract class ResourceProviderIm
     // ----- ResourceProvider ------------------------------------------------
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
       Set<ServiceComponentHostRequest> requests = new HashSet<ServiceComponentHostRequest>();
       for (Map<PropertyId, Object> propertyMap : request.getProperties()) {
         requests.add(getRequest(propertyMap));
       }
       getManagementController().createHostComponents(requests);
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
-      Set<PropertyId>             requestedIds         = request.getPropertyIds();
+      Set<PropertyId> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
       ServiceComponentHostRequest hostComponentRequest = getRequest(getProperties(predicate));
 
-      Set<ServiceComponentHostResponse> responses = getManagementController().getHostComponents(hostComponentRequest);
+      // TODO : handle multiple requests
+      Set<ServiceComponentHostResponse> responses = getManagementController().getHostComponents(Collections.singleton(hostComponentRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (ServiceComponentHostResponse response : responses) {
@@ -762,35 +915,35 @@ public abstract class ResourceProviderIm
     }
 
     @Override
-    public void updateResources(Request request, Predicate predicate) throws AmbariException {
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
       Set<ServiceComponentHostRequest> requests = new HashSet<ServiceComponentHostRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(request.getProperties().iterator().next(), predicate)) {
-        
+
         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);        
+
+        requests.add(hostCompRequest);
       }
-      getManagementController().updateHostComponents(requests);
+      return getRequestStatus(getManagementController().updateHostComponents(requests));
     }
 
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       Set<ServiceComponentHostRequest> requests = new HashSet<ServiceComponentHostRequest>();
       for (Map<PropertyId, Object> propertyMap : getPropertyMaps(null, predicate)) {
         requests.add(getRequest(propertyMap));
       }
-      getManagementController().deleteHostComponents(requests);
+      return getRequestStatus(getManagementController().deleteHostComponents(requests));
     }
 
     // ----- utility methods -------------------------------------------------
@@ -817,34 +970,34 @@ public abstract class ResourceProviderIm
           (String) properties.get(HOST_COMPONENT_STATE_PROPERTY_ID));
     }
   }
-  
+
   /**
    * Resource provider for configuration resources.
    */
   private static class ConfigurationResourceProvider extends ResourceProviderImpl {
-    
+
     private static Set<PropertyId> pkPropertyIds =
         new HashSet<PropertyId>(Arrays.asList(new PropertyId[]{
             CONFIGURATION_CLUSTER_NAME_PROPERTY_ID,
             CONFIGURATION_CONFIG_TYPE_PROPERTY_ID }));
-    
+
     private ConfigurationResourceProvider(Set<PropertyId> propertyIds,
         Map<Resource.Type, PropertyId> keyPropertyIds,
         AmbariManagementController managementController) {
-    
+
       super(propertyIds, keyPropertyIds, managementController);
-      
+
     }
 
     @Override
-    public void createResources(Request request) throws AmbariException {
+    public RequestStatus createResources(Request request) throws AmbariException {
       for (Map<PropertyId, Object> map : request.getProperties()) {
-        
+
         String cluster = (String) map.get(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID);
         String type = (String) map.get(PropertyHelper.getPropertyId("type", ""));
         String tag = (String) map.get(PropertyHelper.getPropertyId("tag", ""));
         Map<String, String> configMap = new HashMap<String, String>();
-        
+
         Iterator<Entry<PropertyId, Object>> it1 = map.entrySet().iterator();
         while (it1.hasNext()) {
           Entry<PropertyId, Object> entry = it1.next();
@@ -852,21 +1005,22 @@ public abstract class ResourceProviderIm
             configMap.put(entry.getKey().getName(), entry.getValue().toString());
           }
         }
-        
+
         ConfigurationRequest configRequest = new ConfigurationRequest(cluster, type, tag, configMap);
-        
+
         getManagementController().createConfiguration(configRequest);
       }
-      
+      return getRequestStatus(null);
     }
 
     @Override
     public Set<Resource> getResources(Request request, Predicate predicate)
         throws AmbariException {
-      
+
       ConfigurationRequest configRequest = getRequest(getProperties(predicate));
 
-      Set<ConfigurationResponse> responses = getManagementController().getConfigurations(configRequest);
+      // TODO : handle multiple requests
+      Set<ConfigurationResponse> responses = getManagementController().getConfigurations(Collections.singleton(configRequest));
 
       Set<Resource> resources = new HashSet<Resource>();
       for (ConfigurationResponse response : responses) {
@@ -876,24 +1030,23 @@ public abstract class ResourceProviderIm
         resource.setProperty(CONFIGURATION_CONFIG_TAG_PROPERTY_ID, response.getVersionTag());
         if (null != response.getConfigs() && response.getConfigs().size() > 0) {
           Map<String, String> configs = response.getConfigs();
-          
+
           for (Entry<String, String> entry : configs.entrySet()) {
             PropertyId id = PropertyHelper.getPropertyId(entry.getKey(), "properties");
             resource.setProperty(id, entry.getValue());
           }
-        }              
+        }
 
         resources.add(resource);
       }
       return resources;
-      
     }
 
     /**
      * Throws an exception, as Configurations cannot be updated.
      */
     @Override
-    public void updateResources(Request request, Predicate predicate)
+    public RequestStatus updateResources(Request request, Predicate predicate)
         throws AmbariException {
       throw new AmbariException ("Cannot update a Configuration resource.");
     }
@@ -902,7 +1055,7 @@ public abstract class ResourceProviderIm
      * Throws an exception, as Configurations cannot be deleted.
      */
     @Override
-    public void deleteResources(Predicate predicate) throws AmbariException {
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
       throw new AmbariException ("Cannot delete a Configuration resource.");
     }
 
@@ -910,15 +1063,264 @@ public abstract class ResourceProviderIm
     protected Set<PropertyId> getPKPropertyIds() {
       return pkPropertyIds;
     }
-    
+
     private ConfigurationRequest getRequest(Map<PropertyId, Object> properties) {
       String type = (String) properties.get(CONFIGURATION_CONFIG_TYPE_PROPERTY_ID);
-      
+
       String tag = (String) properties.get(CONFIGURATION_CONFIG_TAG_PROPERTY_ID);
-      
+
       return new ConfigurationRequest(
           (String) properties.get(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID),
           type, tag, new HashMap<String, String>());
     }
   }
+
+  private static class ActionResourceProvider extends ResourceProviderImpl {
+    private static Set<PropertyId> pkPropertyIds =
+        new HashSet<PropertyId>(Arrays.asList(new PropertyId[]{
+            ACTION_CLUSTER_NAME_PROPERTY_ID,
+            ACTION_SERVICE_NAME_PROPERTY_ID }));
+
+    private ActionResourceProvider(Set<PropertyId> propertyIds,
+        Map<Resource.Type, PropertyId> keyPropertyIds,
+        AmbariManagementController managementController) {
+
+      super(propertyIds, keyPropertyIds, managementController);
+    }
+
+    @Override
+    public RequestStatus createResources(Request request) throws AmbariException {
+      Set<ActionRequest> requests = new HashSet<ActionRequest>();
+      for (Map<PropertyId, Object> propertyMap : request.getProperties()) {
+        requests.add(getRequest(propertyMap));
+      }
+      return getRequestStatus(getManagementController().createActions(requests));
+    }
+
+    @Override
+    public Set<Resource> getResources(Request request, Predicate predicate)
+        throws AmbariException {
+      ActionRequest actionRequest = getRequest(getProperties(predicate));
+
+      // TODO : handle multiple requests
+      Set<ActionResponse> responses = getManagementController().getActions(
+          Collections.singleton(actionRequest));
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (ActionResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Action);
+        resource.setProperty(ACTION_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
+        resource.setProperty(ACTION_SERVICE_NAME_PROPERTY_ID, response.getServiceName());
+        resource.setProperty(ACTION_ACTION_NAME_PROPERTY_ID, response.getActionName());
+        resources.add(resource);
+      }
+      return resources;
+    }
+
+    @Override
+    public RequestStatus updateResources(Request request, Predicate predicate)
+        throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    protected Set<PropertyId> getPKPropertyIds() {
+      return pkPropertyIds;
+    }
+
+    private ActionRequest getRequest(Map<PropertyId, Object> properties) {
+      return new ActionRequest(
+          (String)  properties.get(ACTION_CLUSTER_NAME_PROPERTY_ID),
+          (String)  properties.get(ACTION_SERVICE_NAME_PROPERTY_ID),
+          (String)  properties.get(ACTION_ACTION_NAME_PROPERTY_ID),
+          null);
+    }
+  }
+
+  // ------ RequestResourceProvider inner class ------------------------------
+
+  private static class RequestResourceProvider extends ResourceProviderImpl{
+
+    private static Set<PropertyId> pkPropertyIds =
+        new HashSet<PropertyId>(Arrays.asList(new PropertyId[]{
+            REQUEST_ID_PROPERTY_ID}));
+
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param keyPropertyIds        the key property ids
+     * @param managementController  the management controller
+     */
+    private RequestResourceProvider(Set<PropertyId> propertyIds,
+                                          Map<Resource.Type, PropertyId> keyPropertyIds,
+                                          AmbariManagementController managementController) {
+      super(propertyIds, keyPropertyIds, managementController);
+    }
+
+    // ----- ResourceProvider ------------------------------------------------
+
+    @Override
+    public RequestStatus createResources(Request request) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId>         requestedIds         = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+      Map<PropertyId, Object> predicateProperties  = getProperties(predicate);
+      RequestStatusRequest    requestStatusRequest = getRequest(predicateProperties);
+
+      String clusterName = (String) predicateProperties.get(REQUEST_CLUSTER_NAME_PROPERTY_ID);
+
+      Set<RequestStatusResponse> responses = getManagementController()
+          .getRequestStatus(requestStatusRequest);
+      Set<Resource> resources = new HashSet<Resource>();
+      for (RequestStatusResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Request);
+        setResourceProperty(resource, REQUEST_CLUSTER_NAME_PROPERTY_ID, clusterName, requestedIds);
+        setResourceProperty(resource, REQUEST_ID_PROPERTY_ID, response.getRequestId(), requestedIds);
+        resources.add(resource);
+      }
+      return resources;
+    }
+
+    @Override
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    @Override
+    protected Set<PropertyId> getPKPropertyIds() {
+      return pkPropertyIds;
+    }
+
+    /**
+     * Get a component request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the component request object
+     */
+    private RequestStatusRequest getRequest(Map<PropertyId, Object> properties) {
+      Long requestId = null;
+      if (properties.get(REQUEST_ID_PROPERTY_ID) != null) {
+        requestId = Long.valueOf((String) properties
+            .get(REQUEST_ID_PROPERTY_ID));
+      }
+      return new RequestStatusRequest(requestId);
+    }
+  }
+
+  // ------ TaskResourceProvider inner class ------------------------
+
+  private static class TaskResourceProvider extends ResourceProviderImpl{
+
+    private static Set<PropertyId> pkPropertyIds =
+        new HashSet<PropertyId>(Arrays.asList(new PropertyId[]{
+            TASK_ID_PROPERTY_ID}));
+
+    // ----- Constructors ----------------------------------------------------
+
+    /**
+     * Create a  new resource provider for the given management controller.
+     *
+     * @param propertyIds           the property ids
+     * @param keyPropertyIds        the key property ids
+     * @param managementController  the management controller
+     */
+    private TaskResourceProvider(Set<PropertyId> propertyIds,
+                                          Map<Resource.Type, PropertyId> keyPropertyIds,
+                                          AmbariManagementController managementController) {
+      super(propertyIds, keyPropertyIds, managementController);
+    }
+
+    // ----- ResourceProvider ------------------------------------------------
+
+    @Override
+    public RequestStatus createResources(Request request) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    public Set<Resource> getResources(Request request, Predicate predicate) throws AmbariException {
+      Set<PropertyId> requestedIds = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
+      TaskStatusRequest taskStatusRequest = getRequest(getProperties(predicate));
+
+      // TODO : handle multiple requests
+      LOG.info("Request to management controller " + taskStatusRequest.getRequestId() +
+          " taskid " + taskStatusRequest.getTaskId());
+
+      Set<TaskStatusResponse> responses = getManagementController().getTaskStatus(Collections.singleton(taskStatusRequest));
+      LOG.info("Printing size of responses " + responses.size());
+      for (TaskStatusResponse response: responses) {
+        LOG.info("Printing response from management controller " + response.toString());
+      }
+
+      Set<Resource> resources = new HashSet<Resource>();
+      for (TaskStatusResponse response : responses) {
+        Resource resource = new ResourceImpl(Resource.Type.Task);
+        resource.setProperty(TASK_ID_PROPERTY_ID, response.getTaskId() + "");
+        resource.setProperty(TASK_STAGE_ID_PROPERTY_ID, response.getStageId() + "");
+        resource.setProperty(TASK_HOST_NAME_PROPERTY_ID, response.getHostName() + "");
+        resource.setProperty(TASK_ROLE_PROPERTY_ID, response.getRole() + "");
+        resource.setProperty(TASK_COMMAND_PROPERTY_ID, response.getCommand() + "");
+        resource.setProperty(TASK_STATUS_PROPERTY_ID, response.getStatus());
+        resource.setProperty(TASK_EXIT_CODE_PROPERTY_ID, response.getExitCode() + "");
+        resource.setProperty(TASK_STDERR_PROPERTY_ID, response.getStderr() + "");
+        resource.setProperty(TASK_STOUT_PROPERTY_ID, response.getStdout() + "");
+        resource.setProperty(TASK_START_TIME_PROPERTY_ID, response.getStartTime() + "");
+        resource.setProperty(TASK_ATTEMPT_CNT_PROPERTY_ID, response.getAttemptCount() + "");
+        LOG.info("Creating resource " + resource.toString());
+        resources.add(resource);
+      }
+      return resources;
+    }
+
+    @Override
+    public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    @Override
+    public RequestStatus deleteResources(Predicate predicate) throws AmbariException {
+      throw new UnsupportedOperationException("Not currently supported.");
+    }
+
+    // ----- utility methods -------------------------------------------------
+
+    @Override
+    protected Set<PropertyId> getPKPropertyIds() {
+      return pkPropertyIds;
+    }
+
+    /**
+     * Get a component request object from a map of property values.
+     *
+     * @param properties  the predicate
+     *
+     * @return the component request object
+     */
+    private TaskStatusRequest getRequest(Map<PropertyId, Object> properties) {
+      String taskId = (String) properties.get(TASK_ID_PROPERTY_ID);
+      Long task_id = (taskId == null? null: Long.valueOf(taskId));
+      return new TaskStatusRequest(
+          Long.valueOf((String) properties.get(TASK_REQUEST_ID_PROPERTY_ID)),
+          task_id);
+    }
+  }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/SchemaImpl.java Wed Nov  7 08:13:12 2012
@@ -88,8 +88,10 @@ public class SchemaImpl implements Schem
 
   private Set<PropertyId> getPropertyIds() {
     Set<PropertyId> propertyIds = new HashSet<PropertyId>(resourceProvider.getPropertyIds());
-    for (PropertyProvider propertyProvider : propertyProviders) {
-      propertyIds.addAll(propertyProvider.getPropertyIds());
+    if (propertyProviders != null) {
+      for (PropertyProvider propertyProvider : propertyProviders) {
+        propertyIds.addAll(propertyProvider.getPropertyIds());
+      }
     }
     return propertyIds;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCProviderModule.java Wed Nov  7 08:13:12 2012
@@ -20,6 +20,7 @@ package org.apache.ambari.server.control
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.ganglia.GangliaPropertyProvider;
+import org.apache.ambari.server.controller.internal.DefaultProviderModule;
 import org.apache.ambari.server.controller.internal.URLStreamProvider;
 import org.apache.ambari.server.controller.jmx.JMXPropertyProvider;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -46,31 +47,7 @@ import java.util.Set;
 /**
  * The default provider module implementation.
  */
-public class JDBCProviderModule implements ProviderModule {
-
-  private static final PropertyId HOST_ATTRIBUTES_PROPERTY_ID               = PropertyHelper.getPropertyId("attributes", "Hosts");
-  private static final PropertyId HOST_COMPONENT_HOST_NAME_PROPERTY_ID      = PropertyHelper.getPropertyId("host_name", "HostRoles");
-  private static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("component_name", "HostRoles");
-
-  /**
-   * The map of resource providers.
-   */
-  private final Map<Resource.Type, ResourceProvider> resourceProviders = new HashMap<Resource.Type, ResourceProvider>();
-
-  /**
-   * The map of lists of property providers.
-   */
-  private final Map<Resource.Type,List<PropertyProvider>> propertyProviders = new HashMap<Resource.Type, List<PropertyProvider>>();
-
-  /**
-   * The map of hosts.
-   */
-  private Map<String, String> hostMapping;
-
-  /**
-   * The host name of the Ganglia collector.
-   */
-  private String gangliaCollectorHostName;
+public class JDBCProviderModule extends DefaultProviderModule {
 
 
   // ----- Constructors ------------------------------------------------------
@@ -79,111 +56,15 @@ public class JDBCProviderModule implemen
    * Create a default provider module.
    */
   public JDBCProviderModule() {
-    // First create all of the resource providers...
-    for (Resource.Type type : Resource.Type.values()){
-      createResourceProvider(type);
-    }
-
-    // ... then create the things needed to create the property providers ...
-    try {
-      hostMapping              = getHostMap();
-      gangliaCollectorHostName = getGangliaCollectorHost();
-    } catch (AmbariException e) {
-      // TODO ...
-    }
-
-    // ... then create all of the property providers
-    for (Resource.Type type : Resource.Type.values()){
-      createPropertyProviders(type);
-    }
+    super();
   }
 
-
-  // ----- ProviderModule ----------------------------------------------------
-
-  @Override
-  public ResourceProvider getResourceProvider(Resource.Type type) {
-    return resourceProviders.get(type);
-  }
-
-  @Override
-  public List<PropertyProvider> getPropertyProviders(Resource.Type type) {
-    return propertyProviders.get(type);
-  }
-
-
   // ----- utility methods ---------------------------------------------------
 
-  private void createResourceProvider(Resource.Type type) {
-    resourceProviders.put( type, new JDBCResourceProvider(DBHelper.CONNECTION_FACTORY, type,
+  @Override
+  protected void createResourceProvider(Resource.Type type) {
+    putResourceProvider( type, new JDBCResourceProvider(DBHelper.CONNECTION_FACTORY, type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type)));
   }
-
-  private void createPropertyProviders(Resource.Type type) {
-    List<PropertyProvider> providers = new LinkedList<PropertyProvider>();
-
-
-    if (type == Resource.Type.Component) {
-      providers.add(new GangliaPropertyProvider(
-          PropertyHelper.getGangliaPropertyIds(type),
-          new URLStreamProvider(),
-          gangliaCollectorHostName,
-          null,
-          PropertyHelper.getPropertyId("component_name", "ServiceComponentInfo")));
-    }
-
-    if (type == Resource.Type.HostComponent) {
-      providers.add(new JMXPropertyProvider(
-          PropertyHelper.getJMXPropertyIds(type),
-          new URLStreamProvider(),
-          hostMapping));
-
-      providers.add(new GangliaPropertyProvider(
-          PropertyHelper.getGangliaPropertyIds(type),
-          new URLStreamProvider(),
-          gangliaCollectorHostName,
-          PropertyHelper.getPropertyId("host_name", "HostRoles"),
-          PropertyHelper.getPropertyId("component_name", "HostRoles")));
-    }
-    propertyProviders.put(type, providers);
-  }
-
-  public Map<String, String> getHostMap() throws AmbariException {
-    Map<String, String> hostMap      = new HashMap<String, String>();
-    ResourceProvider    hostProvider = getResourceProvider(Resource.Type.Host);
-    ObjectMapper mapper       = new ObjectMapper();
-    Request request      = PropertyHelper.getReadRequest(Collections.singleton(HOST_ATTRIBUTES_PROPERTY_ID));
-
-    Set<Resource> hosts = hostProvider.getResources(request, null);
-    for (Resource host : hosts) {
-      String attributes = (String) host.getPropertyValue(HOST_ATTRIBUTES_PROPERTY_ID);
-      if (attributes != null && !attributes.startsWith("[]")) {
-        try {
-          Map<String, String> attributeMap = mapper.readValue(attributes, new TypeReference<Map<String, String>>() {});
-          hostMap.put(attributeMap.get("privateFQDN"), attributeMap.get("publicFQDN"));
-        } catch (IOException e) {
-          throw new IllegalStateException("Can't read hosts " + attributes, e);
-        }
-      }
-    }
-    return hostMap;
-  }
-
-  public String getGangliaCollectorHost() throws AmbariException {
-    ResourceProvider provider = getResourceProvider(Resource.Type.HostComponent);
-    Request          request  = PropertyHelper.getReadRequest(Collections.singleton(HOST_COMPONENT_HOST_NAME_PROPERTY_ID));
-
-    Predicate predicate = new PredicateBuilder().property(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID).
-        equals("GANGLIA_MONITOR_SERVER").toPredicate();
-
-    Set<Resource> hostComponents = provider.getResources(request, predicate);
-    for (Resource hostComponent : hostComponents) {
-      String hostName = (String) hostComponent.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID);
-      return hostMapping.get(hostName);
-    }
-
-    return null;
-  }
-
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCResourceProvider.java Wed Nov  7 08:13:12 2012
@@ -19,12 +19,14 @@
 package org.apache.ambari.server.controller.jdbc;
 
 import org.apache.ambari.server.controller.internal.PropertyIdImpl;
+import org.apache.ambari.server.controller.internal.RequestStatusImpl;
 import org.apache.ambari.server.controller.internal.ResourceImpl;
 import org.apache.ambari.server.controller.predicate.BasePredicate;
 import org.apache.ambari.server.controller.predicate.PredicateVisitorAcceptor;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
@@ -36,6 +38,7 @@ import java.sql.ResultSet;
 import java.sql.ResultSetMetaData;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -77,6 +80,9 @@ public class JDBCResourceProvider implem
     Set<Resource> resources = new HashSet<Resource>();
     Set<PropertyId> propertyIds = PropertyHelper.getRequestPropertyIds(this.propertyIds, request, predicate);
 
+    // Can't allow cluster_id with the old schema...
+    propertyIds.remove(PropertyHelper.getPropertyId("cluster_id", "Clusters"));
+
     try {
       Connection connection = connectionFactory.getConnection();
 
@@ -105,19 +111,21 @@ public class JDBCResourceProvider implem
           resources.add(resource);
         }
 
+        statement.close();
       } finally {
         connection.close();
       }
 
     } catch (SQLException e) {
-      throw new IllegalStateException("DB error : ", e);
+//      throw new IllegalStateException("DB error : ", e);
+      return Collections.emptySet();
     }
 
     return resources;
   }
 
   @Override
-  public void createResources(Request request) {
+  public RequestStatus createResources(Request request) {
     try {
       Connection connection = connectionFactory.getConnection();
 
@@ -131,6 +139,8 @@ public class JDBCResourceProvider implem
           Statement statement = connection.createStatement();
 
           statement.execute(sql);
+
+          statement.close();
         }
       } finally {
         connection.close();
@@ -139,10 +149,12 @@ public class JDBCResourceProvider implem
     } catch (SQLException e) {
       throw new IllegalStateException("DB error : ", e);
     }
+
+    return getRequestStatus();
   }
 
   @Override
-  public void updateResources(Request request, Predicate predicate) {
+  public RequestStatus updateResources(Request request, Predicate predicate) {
 
     try {
       Connection connection = connectionFactory.getConnection();
@@ -156,6 +168,8 @@ public class JDBCResourceProvider implem
         Statement statement = connection.createStatement();
 
         statement.execute(sql);
+
+        statement.close();
       } finally {
         connection.close();
       }
@@ -163,10 +177,12 @@ public class JDBCResourceProvider implem
     } catch (SQLException e) {
       throw new IllegalStateException("DB error : ", e);
     }
+
+    return getRequestStatus();
   }
 
   @Override
-  public void deleteResources(Predicate predicate) {
+  public RequestStatus deleteResources(Predicate predicate) {
     try {
       Connection connection = connectionFactory.getConnection();
       try {
@@ -174,6 +190,7 @@ public class JDBCResourceProvider implem
 
         Statement statement = connection.createStatement();
         statement.execute(sql);
+        statement.close();
       } finally {
         connection.close();
       }
@@ -181,6 +198,8 @@ public class JDBCResourceProvider implem
     } catch (SQLException e) {
       throw new IllegalStateException("DB error : ", e);
     }
+
+    return getRequestStatus();
   }
 
 
@@ -379,6 +398,15 @@ public class JDBCResourceProvider implem
   }
 
   /**
+   * Get a request status
+   *
+   * @return the request status
+   */
+  private RequestStatus getRequestStatus() {
+    return new RequestStatusImpl(null);
+  }
+
+  /**
    * Get the set of tables associated with the given property ids.
    *
    * @param propertyIds  the property ids

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,28 @@
+/**
+ * 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.jmx;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public interface JMXHostProvider {
+  public Map<String, String> getHostMapping(String hostName);
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java Wed Nov  7 08:13:12 2012
@@ -39,6 +39,7 @@ import java.util.Set;
  */
 public class JMXPropertyProvider implements PropertyProvider {
 
+  protected static final PropertyId HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("cluster_name", "HostRoles");
   protected static final PropertyId HOST_COMPONENT_HOST_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("host_name", "HostRoles");
   protected static final PropertyId HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId("component_name", "HostRoles");
 
@@ -54,7 +55,7 @@ public class JMXPropertyProvider impleme
 
   private final StreamProvider streamProvider;
 
-  private final Map<String, String> hostMapping;
+  private final JMXHostProvider jmxHostProvider;
 
   private static final Map<String, String> JMX_PORTS = new HashMap<String, String>();
 
@@ -74,13 +75,13 @@ public class JMXPropertyProvider impleme
    *
    * @param componentMetrics the map of supported metrics
    * @param streamProvider   the stream provider
-   * @param hostMapping      the host mapping
+   * @param jmxHostProvider      the host mapping
    */
   public JMXPropertyProvider(Map<String, Map<PropertyId, String>> componentMetrics, StreamProvider streamProvider,
-                             Map<String, String> hostMapping) {
+                             JMXHostProvider jmxHostProvider) {
     this.componentMetrics = componentMetrics;
     this.streamProvider   = streamProvider;
-    this.hostMapping      = hostMapping;
+    this.jmxHostProvider  = jmxHostProvider;
 
     propertyIds = new HashSet<PropertyId>();
     for (Map.Entry<String, Map<PropertyId, String>> entry : componentMetrics.entrySet()) {
@@ -135,7 +136,15 @@ public class JMXPropertyProvider impleme
 
     Set<PropertyId> ids = PropertyHelper.getRequestPropertyIds(getPropertyIds(), request, predicate);
 
-    String hostName      = hostMapping.get(resource.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID));
+    String clusterName   = (String) resource.getPropertyValue(HOST_COMPONENT_CLUSTER_NAME_PROPERTY_ID);
+
+    // TODO : what should we do if the host mapping is null?
+    if (jmxHostProvider.getHostMapping(clusterName) == null) {
+      return true;
+    }
+
+
+    String hostName      = jmxHostProvider.getHostMapping(clusterName).get(resource.getPropertyValue(HOST_COMPONENT_HOST_NAME_PROPERTY_ID));
     String componentName = (String) resource.getPropertyValue(HOST_COMPONENT_COMPONENT_NAME_PROPERTY_ID);
     String port          = JMX_PORTS.get(componentName);
 
@@ -181,7 +190,8 @@ public class JMXPropertyProvider impleme
         }
       }
     } catch (IOException e) {
-      throw new AmbariException("Can't get metrics : " + spec, e);
+      // TODO : log this
+//      throw new AmbariException("Can't get metrics : " + spec, e);
     }
 
     return true;
@@ -202,6 +212,7 @@ public class JMXPropertyProvider impleme
    * @return the spec
    */
   protected String getSpec(String jmxSource) {
-    return "http://" + jmxSource + "/jmx?qry=Hadoop:*";
+//    return "http://" + jmxSource + "/jmx?qry=Hadoop:*";
+    return "http://" + jmxSource + "/jmx";
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/Comparables.java Wed Nov  7 08:13:12 2012
@@ -30,6 +30,32 @@ public class Comparables {
       public int compareTo(String s) {
         return value.compareTo(Integer.valueOf(s));
       }
+
+      @Override
+      public boolean equals(Object obj) {
+        if (obj == null) {
+          return false;
+        }
+        if (obj == value) {
+          return true;
+        }
+        if (obj instanceof String) {
+          try {
+            return value.equals(Integer.valueOf((String)obj));
+          } catch (NumberFormatException nfe) {
+            return false;
+          }
+        }
+        if (obj instanceof  Integer) {
+          return value.equals((Integer)obj);
+        }
+        return  false;
+      }
+
+      @Override
+      public int hashCode() {
+        return value.toString().hashCode();
+      }
     };
   }
 
@@ -40,6 +66,32 @@ public class Comparables {
       public int compareTo(String s) {
         return value.compareTo(Float.valueOf(s));
       }
+
+      @Override
+      public boolean equals(Object obj) {
+        if (obj == null) {
+          return false;
+        }
+        if (obj == value) {
+          return true;
+        }
+        if (obj instanceof String) {
+          try {
+            return value.equals(Float.valueOf((String)obj));
+          } catch (NumberFormatException nfe) {
+            return false;
+          }
+        }
+        if (obj instanceof  Float) {
+          return value.equals((Float)obj);
+        }
+        return  false;
+      }
+
+      @Override
+      public int hashCode() {
+        return value.toString().hashCode();
+      }
     };
   }
 
@@ -50,6 +102,33 @@ public class Comparables {
       public int compareTo(String s) {
         return value.compareTo(Double.valueOf(s));
       }
+
+      @Override
+      public boolean equals(Object obj) {
+        if (obj == null) {
+          return false;
+        }
+        if (obj == value) {
+          return true;
+        }
+        if (obj instanceof String) {
+          try {
+            return value.equals(Double.valueOf((String)obj));
+          } catch (NumberFormatException nfe) {
+            return false;
+          }
+        }
+        if (obj instanceof  Double) {
+          return value.equals((Double)obj);
+        }
+        return  false;
+      }
+
+      @Override
+      public int hashCode() {
+        return value.toString().hashCode();
+      }
+
     };
   }
 
@@ -60,6 +139,32 @@ public class Comparables {
       public int compareTo(String s) {
         return value.compareTo(Long.valueOf(s));
       }
+
+      @Override
+      public boolean equals(Object obj) {
+        if (obj == null) {
+          return false;
+        }
+        if (obj == value) {
+          return true;
+        }
+        if (obj instanceof String) {
+          try {
+            return value.equals(Long.valueOf((String)obj));
+          } catch (NumberFormatException nfe) {
+            return false;
+          }
+        }
+        if (obj instanceof  Long) {
+          return value.equals((Long)obj);
+        }
+        return  false;
+      }
+
+      @Override
+      public int hashCode() {
+        return value.toString().hashCode();
+      }
     };
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/ComparisonPredicate.java Wed Nov  7 08:13:12 2012
@@ -21,15 +21,33 @@ package org.apache.ambari.server.control
 import org.apache.ambari.server.controller.spi.PropertyId;
 import org.apache.ambari.server.controller.spi.Resource;
 
+import java.text.NumberFormat;
+import java.text.ParsePosition;
+
 /**
  * Predicate that compares a given value to a {@link Resource} property.
  */
 public abstract class ComparisonPredicate<T> extends PropertyPredicate implements BasePredicate {
   private final Comparable<T> value;
+  private final String stringValue;
+  private final Double doubleValue;
 
   public ComparisonPredicate(PropertyId propertyId, Comparable<T> value) {
     super(propertyId);
     this.value = value;
+
+    if (value instanceof Number) {
+      stringValue = null;
+      doubleValue = ((Number) value).doubleValue();
+    }
+    else if (value instanceof String) {
+      stringValue = (String) value;
+      doubleValue = stringToDouble(stringValue);
+    }
+    else {
+      stringValue = null;
+      doubleValue = null;
+    }
   }
 
   public Comparable<T> getValue() {
@@ -59,6 +77,33 @@ public abstract class ComparisonPredicat
     visitor.acceptComparisonPredicate(this);
   }
 
+  protected int compareValueTo(Object propertyValue) throws ClassCastException{
+
+    if (doubleValue != null) {
+      if (propertyValue instanceof Number ) {
+        return (int) (doubleValue - ((Number) propertyValue).doubleValue());
+      }
+      else if (propertyValue instanceof String) {
+        Double doubleFromString = stringToDouble((String) propertyValue);
+        if (doubleFromString != null) {
+          return (int) (doubleValue - doubleFromString);
+        }
+      }
+    }
+    if (stringValue != null) {
+      return stringValue.compareTo(propertyValue.toString());
+    }
+
+    return getValue().compareTo((T) propertyValue);
+  }
+
+  private Double stringToDouble(String stringValue) {
+    ParsePosition parsePosition = new ParsePosition(0);
+    NumberFormat  numberFormat  = NumberFormat.getInstance();
+    Number        parsedNumber  = numberFormat.parse((String) value, parsePosition);
+
+    return parsePosition.getIndex() == stringValue.length() ? parsedNumber.doubleValue() : null;
+  }
 
   public abstract String getOperator();
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/EqualsPredicate.java Wed Nov  7 08:13:12 2012
@@ -34,7 +34,7 @@ public class EqualsPredicate<T> extends 
   @Override
   public boolean evaluate(Resource resource) {
     Object propertyValue = resource.getPropertyValue(getPropertyId());
-    return propertyValue != null && getValue().compareTo(propertyValue) == 0;
+    return propertyValue != null && compareValueTo(propertyValue) == 0;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterEqualsPredicate.java Wed Nov  7 08:13:12 2012
@@ -33,7 +33,7 @@ public class GreaterEqualsPredicate<T> e
   @Override
   public boolean evaluate(Resource resource) {
     Object propertyValue = resource.getPropertyValue(getPropertyId());
-    return propertyValue != null && getValue().compareTo(propertyValue) <= 0;
+    return propertyValue != null && compareValueTo(propertyValue) <= 0;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/GreaterPredicate.java Wed Nov  7 08:13:12 2012
@@ -32,7 +32,7 @@ public class GreaterPredicate<T> extends
   @Override
   public boolean evaluate(Resource resource) {
     Object propertyValue = resource.getPropertyValue(getPropertyId());
-    return propertyValue != null && getValue().compareTo(propertyValue) < 0;
+    return propertyValue != null && compareValueTo(propertyValue) < 0;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessEqualsPredicate.java Wed Nov  7 08:13:12 2012
@@ -33,7 +33,7 @@ public class LessEqualsPredicate<T> exte
   @Override
   public boolean evaluate(Resource resource) {
     Object propertyValue = resource.getPropertyValue(getPropertyId());
-    return propertyValue != null && getValue().compareTo(propertyValue) >= 0;
+    return propertyValue != null && compareValueTo(propertyValue) >= 0;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/LessPredicate.java Wed Nov  7 08:13:12 2012
@@ -32,7 +32,7 @@ public class LessPredicate<T> extends Co
   @Override
   public boolean evaluate(Resource resource) {
     Object propertyValue = resource.getPropertyValue(getPropertyId());
-    return propertyValue != null && getValue().compareTo(propertyValue) > 0;
+    return propertyValue != null && compareValueTo(propertyValue) > 0;
   }
 
   @Override

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/predicate/PropertyPredicate.java Wed Nov  7 08:13:12 2012
@@ -29,6 +29,7 @@ public abstract class PropertyPredicate 
   private final PropertyId propertyId;
 
   public PropertyPredicate(PropertyId propertyId) {
+    assert (propertyId != null);
     this.propertyId = propertyId;
   }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ClusterController.java Wed Nov  7 08:13:12 2012
@@ -65,7 +65,7 @@ public interface ClusterController {
    *
    * @throws AmbariException thrown if the resources cannot be created
    */
-  public void createResources(Resource.Type type, Request request) throws AmbariException;
+  public RequestStatus createResources(Resource.Type type, Request request) throws AmbariException;
 
   /**
    * Update the resources selected by the given predicate with the properties
@@ -79,7 +79,7 @@ public interface ClusterController {
    *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public void updateResources(Resource.Type type, Request request,
+  public RequestStatus updateResources(Resource.Type type, Request request,
                               Predicate predicate) throws AmbariException;
 
   /**
@@ -91,6 +91,6 @@ public interface ClusterController {
    *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public void deleteResources(Resource.Type type,
+  public RequestStatus deleteResources(Resource.Type type,
                               Predicate predicate) throws AmbariException;
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Request.java Wed Nov  7 08:13:12 2012
@@ -56,5 +56,11 @@ public interface Request {
    */
   public TemporalInfo getTemporalInfo(PropertyId id);
 
+  /**
+   * Set the {@link TemporalInfo temporal information} for the given properties
+   * on this request.
+   *
+   * @param mapTemporalInfo  the temporal data to associate with this request
+   */
   public void setTemporalInfo(Map<PropertyId, TemporalInfo> mapTemporalInfo);
 }

Added: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/RequestStatus.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/RequestStatus.java?rev=1406489&view=auto
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/RequestStatus.java (added)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/RequestStatus.java Wed Nov  7 08:13:12 2012
@@ -0,0 +1,58 @@
+/**
+ * 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.spi;
+
+import java.util.Set;
+
+/**
+ * A RequestStatus represents the result of an asynchronous operation on resources. Methods are
+ * provided to check the status of the operation and to retrieve the set of resources involved
+ * in the operation.
+ */
+public interface RequestStatus {
+
+  /**
+   * Get the resources involved in the operation initiated by the request.
+   *
+   * @return the set of resources
+   */
+  public Set<Resource> getAssociatedResources();
+
+  /**
+   * Get the id of the request.
+   *
+   * @return the request id
+   */
+  public Resource getRequestResource();
+
+  /**
+   * Get the status of the operation initiated by the request.
+   *
+   * @return the status
+   */
+  public Status getStatus();
+
+  /**
+   * Request status.
+   */
+  public enum Status {
+    Accepted,
+    InProgress,
+    Complete
+  }
+}

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java Wed Nov  7 08:13:12 2012
@@ -15,8 +15,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.ambari.server.controller.spi;
 
+
 import org.apache.ambari.server.api.util.TreeNode;
 
 import java.util.Map;
@@ -76,6 +78,9 @@ public interface Resource {
     Host,
     Component,
     HostComponent,
-    Configuration
+    Configuration,
+    Action,
+    Request,
+    Task
   }
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/ResourceProvider.java Wed Nov  7 08:13:12 2012
@@ -35,12 +35,15 @@ public interface ResourceProvider {
   /**
    * Create the resources defined by the properties in the given request object.
    *
+   *
    * @param request  the request object which defines the set of properties
    *                 for the resources to be created
    *
+   * @return the request status
+   *
    * @throws AmbariException thrown if the resources cannot be created
    */
-  public void createResources(Request request) throws AmbariException;
+  public RequestStatus createResources(Request request) throws AmbariException;
 
   /**
    * Get a set of {@link Resource resources} based on the given request and predicate
@@ -71,24 +74,30 @@ public interface ResourceProvider {
    * Update the resources selected by the given predicate with the properties
    * from the given request object.
    *
+   *
    * @param request    the request object which defines the set of properties
    *                   for the resources to be updated
    * @param predicate  the predicate object which can be used to filter which
    *                   resources are updated
    *
+   * @return the request status
+   *
    * @throws AmbariException thrown if the resource cannot be updated
    */
-  public void updateResources(Request request, Predicate predicate) throws AmbariException;
+  public RequestStatus updateResources(Request request, Predicate predicate) throws AmbariException;
 
   /**
    * Delete the resources selected by the given predicate.
    *
+   *
    * @param predicate the predicate object which can be used to filter which
    *                  resources are deleted
    *
+   * @return the request status
+   *
    * @throws AmbariException thrown if the resource cannot be deleted
    */
-  public void deleteResources(Predicate predicate) throws AmbariException;
+  public RequestStatus deleteResources(Predicate predicate) throws AmbariException;
 
   /**
    * Get the set of property ids for the properties that this provider can provide.

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/ClusterControllerHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/ClusterControllerHelper.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/ClusterControllerHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/ClusterControllerHelper.java Wed Nov  7 08:13:12 2012
@@ -35,7 +35,7 @@ public class ClusterControllerHelper {
   public static synchronized ClusterController getClusterController() {
     if (controller == null) {
       try {
-        Class implClass = Class.forName(PROVIDER_MODULE_CLASS);
+        Class<?> implClass = Class.forName(PROVIDER_MODULE_CLASS);
         ProviderModule providerModule = (ProviderModule) implClass.newInstance();
         controller = new ClusterControllerImpl(providerModule);
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java?rev=1406489&r1=1406488&r2=1406489&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/utilities/DBHelper.java Wed Nov  7 08:13:12 2012
@@ -73,6 +73,7 @@ public class DBHelper {
           }
         }
 
+        statement.close();
       } finally {
         connection.close();
       }