You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2013/10/29 15:58:35 UTC

[1/3] git commit: AMBARI-3583 - Requests API should rollup tasks information

Updated Branches:
  refs/heads/trunk d57d5f794 -> c7f1fed4b


AMBARI-3583 - Requests API should rollup tasks information


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

Branch: refs/heads/trunk
Commit: c7f1fed4b864e2fd9d5d385c848580df7f9199f3
Parents: 8b0fc1c
Author: tbeerbower <tb...@hortonworks.com>
Authored: Mon Oct 28 17:12:03 2013 -0400
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Tue Oct 29 10:58:08 2013 -0400

----------------------------------------------------------------------
 .../server/controller/internal/RequestResourceProvider.java      | 2 +-
 .../server/controller/internal/RequestResourceProviderTest.java  | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/c7f1fed4/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
index 7452b75..b6b03b4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RequestResourceProvider.java
@@ -248,7 +248,7 @@ class RequestResourceProvider extends AbstractControllerResourceProvider {
                                    completedTaskCount == taskCount ? HostRoleStatus.COMPLETED :
                                                                      HostRoleStatus.PENDING;
     double progressPercent =
-        (queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount / (double) taskCount) * 100.0;
+        ((queuedTaskCount * 0.09 + inProgressTaskCount * 0.35 + completedTaskCount)/(double) taskCount) * 100.0;
 
     setResourceProperty(resource, REQUEST_STATUS_PROPERTY_ID, requestStatus.toString(), requestedPropertyIds);
     setResourceProperty(resource, REQUEST_TASK_CNT_ID, taskCount, requestedPropertyIds);

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/c7f1fed4/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
index 80d34e7..a613a0e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
@@ -359,10 +359,10 @@ public class RequestResourceProviderTest {
 
       if (id == 100L) {
         Assert.assertEquals(1, resource.getPropertyValue(RequestResourceProvider.REQUEST_COMPLETED_TASK_CNT_ID));
-        Assert.assertEquals(85.0, resource.getPropertyValue(RequestResourceProvider.REQUEST_PROGRESS_PERCENT_ID));
+        Assert.assertEquals(67.5, resource.getPropertyValue(RequestResourceProvider.REQUEST_PROGRESS_PERCENT_ID));
       } else {
         Assert.assertEquals(0, resource.getPropertyValue(RequestResourceProvider.REQUEST_COMPLETED_TASK_CNT_ID));
-        Assert.assertEquals(43.99999999999999, resource.getPropertyValue(RequestResourceProvider.REQUEST_PROGRESS_PERCENT_ID));
+        Assert.assertEquals(21.999999999999996, resource.getPropertyValue(RequestResourceProvider.REQUEST_PROGRESS_PERCENT_ID));
       }
     }
 


[3/3] git commit: AMBARI-3604 - Components in API should have 'category' field

Posted by tb...@apache.org.
AMBARI-3604 - Components in API should have 'category' field


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

Branch: refs/heads/trunk
Commit: 8b0fc1cb6cc952f4e2a34410a6609b29c4328337
Parents: d57d5f7
Author: tbeerbower <tb...@hortonworks.com>
Authored: Mon Oct 28 13:31:05 2013 -0400
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Tue Oct 29 10:58:08 2013 -0400

----------------------------------------------------------------------
 .../server/api/services/ClusterService.java     |  12 +
 .../controller/AmbariManagementController.java  |  66 +-
 .../AmbariManagementControllerImpl.java         | 574 +---------------
 .../controller/ServiceComponentResponse.java    |  20 +
 .../internal/ComponentResourceProvider.java     | 663 ++++++++++++++++++-
 .../src/main/resources/properties.json          |   1 +
 .../AmbariManagementControllerImplTest.java     | 159 -----
 .../AmbariManagementControllerTest.java         |  77 +--
 .../internal/ComponentResourceProviderTest.java | 420 ++++++++++--
 .../internal/JMXHostProviderTest.java           |   2 +-
 10 files changed, 1098 insertions(+), 896 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
index 5567145..8451b85 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/ClusterService.java
@@ -172,6 +172,18 @@ public class ClusterService extends BaseService {
   }
 
   /**
+   * Get the component resource without specifying the parent service.
+   * Allows accessing component resources across services.
+   *
+   * @param clusterName the cluster name
+   * @return  the host component service with no parent set
+   */
+  @Path("{clusterName}/components")
+  public ComponentService getComponentHandler(@PathParam("clusterName") String clusterName) {
+    return new ComponentService(clusterName, null);
+  }
+
+  /**
    * Gets the workflows sub-resource.
    */
   @Path("{clusterName}/workflows")

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index d7a8467..32f25ea 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -25,6 +25,7 @@ import org.apache.ambari.server.state.Cluster;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.Service;
 import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentFactory;
 import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.ServiceFactory;
 import org.apache.ambari.server.state.State;
@@ -51,16 +52,6 @@ public interface AmbariManagementController {
   public void createCluster(ClusterRequest request) throws AmbariException;
 
   /**
-   * Create the component defined by the attributes in the given request object.
-   *
-   * @param requests  the request object which defines the component to be created
-   *
-   * @throws AmbariException thrown if the component cannot be created
-   */
-  public void createComponents(Set<ServiceComponentRequest> requests)
-      throws AmbariException;
-
-  /**
    * Create the host defined by the attributes in the given request object.
    *
    * @param requests  the request object which defines the host to be created
@@ -115,18 +106,6 @@ public interface AmbariManagementController {
       throws AmbariException;
 
   /**
-   * Get the components identified by the given request objects.
-   *
-   * @param requests  the request objects which identify the components to be returned
-   *
-   * @return a set of component responses
-   *
-   * @throws AmbariException thrown if the resource cannot be read
-   */
-  public Set<ServiceComponentResponse> getComponents(
-      Set<ServiceComponentRequest> requests) throws AmbariException;
-
-  /**
    * Get the hosts identified by the given request objects.
    *
    * @param requests  the request objects which identify the hosts to be returned
@@ -208,26 +187,6 @@ public interface AmbariManagementController {
       throws AmbariException;
 
   /**
-   * Update the component identified by the given request object with the
-   * values carried by the given request object.
-   *
-   *
-   *
-   * @param requests    the request object which defines which component to
-   *                   update and the values to set
-   *
-   * @param requestProperties  the request properties
-   * @param runSmokeTest       indicates whether or not to run a smoke test
-   *
-   * @return a track action response
-   *
-   * @throws AmbariException thrown if the resource cannot be updated
-   */
-  public RequestStatusResponse updateComponents(
-      Set<ServiceComponentRequest> requests, Map<String, String> requestProperties,
-      boolean runSmokeTest) throws AmbariException;
-
-  /**
    * Update the host identified by the given request object with the
    * values carried by the given request object.
    *
@@ -279,18 +238,6 @@ public interface AmbariManagementController {
   public void deleteCluster(ClusterRequest request) throws AmbariException;
 
   /**
-   * Delete the component identified by the given request object.
-   *
-   * @param requests  the request object which identifies which component to delete
-   *
-   * @return a track action response
-   *
-   * @throws AmbariException thrown if the resource cannot be deleted
-   */
-  public RequestStatusResponse deleteComponents(
-      Set<ServiceComponentRequest> requests) throws AmbariException;
-
-  /**
    * Delete the host identified by the given request object.
    *
    * @param requests  the request object which identifies which host to delete
@@ -501,10 +448,17 @@ public interface AmbariManagementController {
   public ServiceFactory getServiceFactory();
 
   /**
-   * Get the action manager for this management controller.
+   * Get the service component factory for this management controller.
    *
-   * @return the action manager
+   * @return the service component factory
    */
+  public ServiceComponentFactory getServiceComponentFactory();
+
+  /**
+    * Get the action manager for this management controller.
+    *
+    * @return the action manager
+    */
   public ActionManager getActionManager();
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 7cabd01..cd7e957 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -286,185 +286,6 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
-  public synchronized void createComponents(
-      Set<ServiceComponentRequest> requests) throws AmbariException {
-
-    if (requests.isEmpty()) {
-      LOG.warn("Received an empty requests set");
-      return;
-    }
-
-    // do all validation checks
-    Map<String, Map<String, Set<String>>> componentNames =
-        new HashMap<String, Map<String,Set<String>>>();
-    Set<String> duplicates = new HashSet<String>();
-
-    for (ServiceComponentRequest request : requests) {
-      if (request.getClusterName() == null
-          || request.getClusterName().isEmpty()
-          || request.getComponentName() == null
-          || request.getComponentName().isEmpty()) {
-        throw new IllegalArgumentException("Invalid arguments"
-            + ", clustername and componentname should be"
-            + " non-null and non-empty when trying to create a"
-            + " component");
-      }
-
-      Cluster cluster;
-      try {
-        cluster = clusters.getCluster(request.getClusterName());
-      } catch (ClusterNotFoundException e) {
-        throw new ParentObjectNotFoundException(
-            "Attempted to add a component to a cluster which doesn't exist:", e);
-      }
-
-      if (request.getServiceName() == null
-          || request.getServiceName().isEmpty()) {
-        StackId stackId = cluster.getDesiredStackVersion();
-        String serviceName =
-            ambariMetaInfo.getComponentToService(stackId.getStackName(),
-                stackId.getStackVersion(), request.getComponentName());
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Looking up service name for component"
-              + ", componentName=" + request.getComponentName()
-              + ", serviceName=" + serviceName);
-        }
-
-        if (serviceName == null
-            || serviceName.isEmpty()) {
-          throw new AmbariException("Could not find service for component"
-              + ", componentName=" + request.getComponentName()
-              + ", clusterName=" + cluster.getClusterName()
-              + ", stackInfo=" + stackId.getStackId());
-        }
-        request.setServiceName(serviceName);
-      }
-
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Received a createComponent request"
-            + ", clusterName=" + request.getClusterName()
-            + ", serviceName=" + request.getServiceName()
-            + ", componentName=" + request.getComponentName()
-            + ", request=" + request);
-      }
-
-      if (!componentNames.containsKey(request.getClusterName())) {
-        componentNames.put(request.getClusterName(),
-            new HashMap<String, Set<String>>());
-      }
-      if (!componentNames.get(request.getClusterName())
-          .containsKey(request.getServiceName())) {
-        componentNames.get(request.getClusterName()).put(
-            request.getServiceName(), new HashSet<String>());
-      }
-      if (componentNames.get(request.getClusterName())
-          .get(request.getServiceName()).contains(request.getComponentName())){
-        // throw error later for dup
-        duplicates.add("[clusterName=" + request.getClusterName() + ", serviceName=" + request.getServiceName() +
-            ", componentName=" + request.getComponentName() + "]");
-        continue;
-      }
-      componentNames.get(request.getClusterName())
-          .get(request.getServiceName()).add(request.getComponentName());
-
-      if (request.getDesiredState() != null
-          && !request.getDesiredState().isEmpty()) {
-        State state = State.valueOf(request.getDesiredState());
-        if (!state.isValidDesiredState()
-            || state != State.INIT) {
-          throw new IllegalArgumentException("Invalid desired state"
-              + " only INIT state allowed during creation"
-              + ", providedDesiredState=" + request.getDesiredState());
-        }
-      }
-
-      Service s;
-      try {
-        s = cluster.getService(request.getServiceName());
-      } catch (ServiceNotFoundException e) {
-        throw new ParentObjectNotFoundException(
-            "Attempted to add a component to a service which doesn't exist:", e);
-      }
-      try {
-        ServiceComponent sc = s.getServiceComponent(request.getComponentName());
-        if (sc != null) {
-          // throw error later for dup
-          duplicates.add("[clusterName=" + request.getClusterName() + ", serviceName=" + request.getServiceName() +
-              ", componentName=" + request.getComponentName() + "]");
-          continue;
-        }
-      } catch (AmbariException e) {
-        // Expected
-      }
-
-      StackId stackId = s.getDesiredStackVersion();
-      if (!ambariMetaInfo.isValidServiceComponent(stackId.getStackName(),
-          stackId.getStackVersion(), s.getName(), request.getComponentName())) {
-        throw new IllegalArgumentException("Unsupported or invalid component"
-            + " in stack"
-            + ", clusterName=" + request.getClusterName()
-            + ", serviceName=" + request.getServiceName()
-            + ", componentName=" + request.getComponentName()
-            + ", stackInfo=" + stackId.getStackId());
-      }
-    }
-
-    // ensure only a single cluster update
-    if (componentNames.size() != 1) {
-      throw new IllegalArgumentException("Invalid arguments, updates allowed"
-          + "on only one cluster at a time");
-    }
-
-    // Validate dups
-    if (!duplicates.isEmpty()) {
-      StringBuilder names = new StringBuilder();
-      boolean first = true;
-      for (String cName : duplicates) {
-        if (!first) {
-          names.append(",");
-        }
-        first = false;
-        names.append(cName);
-      }
-      String msg;
-      if (duplicates.size() == 1) {
-        msg = "Attempted to create a component which already exists: ";
-      } else {
-        msg = "Attempted to create components which already exist: ";
-      }
-      throw new DuplicateResourceException(msg + names.toString());
-    }
-
-
-    // now doing actual work
-    for (ServiceComponentRequest request : requests) {
-      Cluster cluster = clusters.getCluster(request.getClusterName());
-      Service s = cluster.getService(request.getServiceName());
-      ServiceComponent sc = serviceComponentFactory.createNew(s,
-          request.getComponentName());
-      sc.setDesiredStackVersion(s.getDesiredStackVersion());
-
-      if (request.getDesiredState() != null
-          && !request.getDesiredState().isEmpty()) {
-        State state = State.valueOf(request.getDesiredState());
-        sc.setDesiredState(state);
-      } else {
-        sc.setDesiredState(s.getDesiredState());
-      }
-
-      // FIXME fix config versions to configs conversion
-      Map<String, Config> configs = new HashMap<String, Config>();
-      if (request.getConfigVersions() != null) {
-      }
-
-      sc.updateDesiredConfigs(configs);
-      s.addServiceComponent(sc);
-      sc.persist();
-    }
-
-  }
-
-  @Override
   public synchronized void createHosts(Set<HostRequest> requests)
       throws AmbariException {
 
@@ -941,91 +762,6 @@ public class AmbariManagementControllerImpl implements
     return response;
   }
 
-  private synchronized Set<ServiceComponentResponse> getComponents(
-      ServiceComponentRequest request) throws AmbariException {
-    if (request.getClusterName() == null
-        || request.getClusterName().isEmpty()) {
-      throw new IllegalArgumentException("Invalid arguments, cluster name"
-          + " should be non-null");
-    }
-
-    final Cluster cluster;
-    try {
-      cluster = clusters.getCluster(request.getClusterName());
-    } catch (ObjectNotFoundException e) {
-      throw new ParentObjectNotFoundException("Parent Cluster resource doesn't exist", e);
-    }
-
-    Set<ServiceComponentResponse> response =
-        new HashSet<ServiceComponentResponse>();
-
-    if (request.getComponentName() != null) {
-      if (request.getServiceName() == null) {
-        StackId stackId = cluster.getDesiredStackVersion();
-        String serviceName =
-            ambariMetaInfo.getComponentToService(stackId.getStackName(),
-                stackId.getStackVersion(), request.getComponentName());
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Looking up service name for component"
-              + ", componentName=" + request.getComponentName()
-              + ", serviceName=" + serviceName);
-        }
-        if (serviceName == null
-            || serviceName.isEmpty()) {
-          throw new AmbariException("Could not find service for component"
-              + ", componentName=" + request.getComponentName()
-              + ", clusterName=" + cluster.getClusterName()
-              + ", stackInfo=" + stackId.getStackId());
-        }
-        request.setServiceName(serviceName);
-      }
-
-      final Service s;
-      try {
-        s = cluster.getService(request.getServiceName());
-      } catch (ObjectNotFoundException e) {
-        throw new ParentObjectNotFoundException("Parent Service resource doesn't exist", e);
-      }
-
-      ServiceComponent sc = s.getServiceComponent(request.getComponentName());
-      response.add(sc.convertToResponse());
-      return response;
-    }
-
-    boolean checkDesiredState = false;
-    State desiredStateToCheck = null;
-    if (request.getDesiredState() != null
-        && !request.getDesiredState().isEmpty()) {
-      desiredStateToCheck = State.valueOf(request.getDesiredState());
-      if (!desiredStateToCheck.isValidDesiredState()) {
-        throw new IllegalArgumentException("Invalid arguments, invalid desired"
-            + " state, desiredState=" + desiredStateToCheck);
-      }
-      checkDesiredState = true;
-    }
-
-    Set<Service> services = new HashSet<Service>();
-    if (request.getServiceName() != null
-        && !request.getServiceName().isEmpty()) {
-      services.add(cluster.getService(request.getServiceName()));
-    } else {
-      services.addAll(cluster.getServices().values());
-    }
-
-    for (Service s : services) {
-      // filter on request.getDesiredState()
-      for (ServiceComponent sc : s.getServiceComponents().values()) {
-        if (checkDesiredState
-            && (desiredStateToCheck != sc.getDesiredState())) {
-          // skip non matching state
-          continue;
-        }
-        response.add(sc.convertToResponse());
-      }
-    }
-    return response;
-  }
-
   private synchronized Set<HostResponse> getHosts(HostRequest request)
       throws AmbariException {
 
@@ -1939,286 +1675,6 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
-  public synchronized RequestStatusResponse updateComponents(Set<ServiceComponentRequest> requests,
-                                                             Map<String, String> requestProperties, boolean runSmokeTest)
-                                                             throws AmbariException {
-
-    if (requests.isEmpty()) {
-      LOG.warn("Received an empty requests set");
-      return null;
-    }
-
-    Map<State, List<ServiceComponent>> changedComps =
-        new HashMap<State, List<ServiceComponent>>();
-    Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts =
-        new HashMap<String, Map<State, List<ServiceComponentHost>>>();
-    Collection<ServiceComponentHost> ignoredScHosts =
-        new ArrayList<ServiceComponentHost>();
-
-    Set<String> clusterNames = new HashSet<String>();
-    Map<String, Map<String, Set<String>>> componentNames =
-        new HashMap<String, Map<String,Set<String>>>();
-    Set<State> seenNewStates = new HashSet<State>();
-
-    for (ServiceComponentRequest request : requests) {
-      if (request.getClusterName() == null
-          || request.getClusterName().isEmpty()
-          || request.getComponentName() == null
-          || request.getComponentName().isEmpty()) {
-        throw new IllegalArgumentException("Invalid arguments, cluster name"
-            + ", service name and component name should be provided to"
-            + " update components");
-      }
-
-      LOG.info("Received a updateComponent request"
-          + ", clusterName=" + request.getClusterName()
-          + ", serviceName=" + request.getServiceName()
-          + ", componentName=" + request.getComponentName()
-          + ", request=" + request.toString());
-
-      Cluster cluster = clusters.getCluster(request.getClusterName());
-
-      if (request.getServiceName() == null
-          || request.getServiceName().isEmpty()) {
-        StackId stackId = cluster.getDesiredStackVersion();
-        String serviceName =
-            ambariMetaInfo.getComponentToService(stackId.getStackName(),
-                stackId.getStackVersion(), request.getComponentName());
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Looking up service name for component"
-              + ", componentName=" + request.getComponentName()
-              + ", serviceName=" + serviceName);
-        }
-
-        if (serviceName == null
-            || serviceName.isEmpty()) {
-          throw new AmbariException("Could not find service for component"
-              + ", componentName=" + request.getComponentName()
-              + ", clusterName=" + cluster.getClusterName()
-              + ", stackInfo=" + stackId.getStackId());
-        }
-        request.setServiceName(serviceName);
-      }
-
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Received a updateComponent request"
-            + ", clusterName=" + request.getClusterName()
-            + ", serviceName=" + request.getServiceName()
-            + ", componentName=" + request.getComponentName()
-            + ", request=" + request);
-      }
-
-      clusterNames.add(request.getClusterName());
-
-      if (clusterNames.size() > 1) {
-        // FIXME throw correct error
-        throw new IllegalArgumentException("Updates to multiple clusters is not"
-            + " supported");
-      }
-
-      if (!componentNames.containsKey(request.getClusterName())) {
-        componentNames.put(request.getClusterName(),
-            new HashMap<String, Set<String>>());
-      }
-      if (!componentNames.get(request.getClusterName())
-          .containsKey(request.getServiceName())) {
-        componentNames.get(request.getClusterName()).put(
-            request.getServiceName(), new HashSet<String>());
-      }
-      if (componentNames.get(request.getClusterName())
-          .get(request.getServiceName()).contains(request.getComponentName())){
-        // throw error later for dup
-        throw new IllegalArgumentException("Invalid request contains duplicate"
-            + " service components");
-      }
-      componentNames.get(request.getClusterName())
-          .get(request.getServiceName()).add(request.getComponentName());
-
-      Service s = cluster.getService(request.getServiceName());
-      ServiceComponent sc = s.getServiceComponent(
-          request.getComponentName());
-      State newState = null;
-      if (request.getDesiredState() != null) {
-        newState = State.valueOf(request.getDesiredState());
-        if (!newState.isValidDesiredState()) {
-          throw new IllegalArgumentException("Invalid arguments, invalid"
-              + " desired state, desiredState=" + newState.toString());
-        }
-      }
-
-      if (request.getConfigVersions() != null) {
-        State.checkUpdateConfiguration(sc, newState);
-
-        for (Entry<String,String> entry :
-            request.getConfigVersions().entrySet()) {
-          Config config = cluster.getConfig(
-              entry.getKey(), entry.getValue());
-          if (null == config) {
-            // throw error for invalid config
-            throw new AmbariException("Trying to update servicecomponent with"
-                + " invalid configs"
-                + ", clusterName=" + cluster.getClusterName()
-                + ", clusterId=" + cluster.getClusterId()
-                + ", serviceName=" + s.getName()
-                + ", componentName=" + sc.getName()
-                + ", invalidConfigType=" + entry.getKey()
-                + ", invalidConfigTag=" + entry.getValue());
-          }
-        }
-      }
-
-      if (newState == null) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Nothing to do for new updateServiceComponent request"
-              + ", clusterName=" + request.getClusterName()
-              + ", serviceName=" + request.getServiceName()
-              + ", componentName=" + request.getComponentName()
-              + ", newDesiredState=null");
-        }
-        continue;
-      }
-
-      if (sc.isClientComponent() &&
-          !newState.isValidClientComponentState()) {
-        throw new AmbariException("Invalid desired state for a client"
-            + " component");
-      }
-
-      seenNewStates.add(newState);
-
-      State oldScState = sc.getDesiredState();
-      if (newState != oldScState) {
-        if (!State.isValidDesiredStateTransition(oldScState, newState)) {
-          // FIXME throw correct error
-          throw new AmbariException("Invalid transition for"
-              + " servicecomponent"
-              + ", clusterName=" + cluster.getClusterName()
-              + ", clusterId=" + cluster.getClusterId()
-              + ", serviceName=" + sc.getServiceName()
-              + ", componentName=" + sc.getName()
-              + ", currentDesiredState=" + oldScState
-              + ", newDesiredState=" + newState);
-        }
-        if (!changedComps.containsKey(newState)) {
-          changedComps.put(newState, new ArrayList<ServiceComponent>());
-        }
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Handling update to ServiceComponent"
-              + ", clusterName=" + request.getClusterName()
-              + ", serviceName=" + s.getName()
-              + ", componentName=" + sc.getName()
-              + ", currentDesiredState=" + oldScState
-              + ", newDesiredState=" + newState);
-        }
-        changedComps.get(newState).add(sc);
-      }
-
-      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
-        State oldSchState = sch.getState();
-        if (oldSchState == State.MAINTENANCE || oldSchState == State.UNKNOWN) {
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Ignoring ServiceComponentHost"
-                + ", clusterName=" + request.getClusterName()
-                + ", serviceName=" + s.getName()
-                + ", componentName=" + sc.getName()
-                + ", hostname=" + sch.getHostName()
-                + ", currentState=" + oldSchState
-                + ", newDesiredState=" + newState);
-          }
-          continue;
-        }
-
-        if (newState == oldSchState) {
-          ignoredScHosts.add(sch);
-          if (LOG.isDebugEnabled()) {
-            LOG.debug("Ignoring ServiceComponentHost"
-                + ", clusterName=" + request.getClusterName()
-                + ", serviceName=" + s.getName()
-                + ", componentName=" + sc.getName()
-                + ", hostname=" + sch.getHostName()
-                + ", currentState=" + oldSchState
-                + ", newDesiredState=" + newState);
-          }
-          continue;
-        }
-        if (!State.isValidStateTransition(oldSchState, newState)) {
-          // FIXME throw correct error
-          throw new AmbariException("Invalid transition for"
-              + " servicecomponenthost"
-              + ", clusterName=" + cluster.getClusterName()
-              + ", clusterId=" + cluster.getClusterId()
-              + ", serviceName=" + sch.getServiceName()
-              + ", componentName=" + sch.getServiceComponentName()
-              + ", hostname=" + sch.getHostName()
-              + ", currentState=" + oldSchState
-              + ", newDesiredState=" + newState);
-        }
-        if (!changedScHosts.containsKey(sc.getName())) {
-          changedScHosts.put(sc.getName(),
-              new HashMap<State, List<ServiceComponentHost>>());
-        }
-        if (!changedScHosts.get(sc.getName()).containsKey(newState)) {
-          changedScHosts.get(sc.getName()).put(newState,
-              new ArrayList<ServiceComponentHost>());
-        }
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Handling update to ServiceComponentHost"
-              + ", clusterName=" + request.getClusterName()
-              + ", serviceName=" + s.getName()
-              + ", componentName=" + sc.getName()
-              + ", hostname=" + sch.getHostName()
-              + ", currentState=" + oldSchState
-              + ", newDesiredState=" + newState);
-        }
-        changedScHosts.get(sc.getName()).get(newState).add(sch);
-      }
-    }
-
-    if (seenNewStates.size() > 1) {
-      // FIXME should we handle this scenario
-      throw new IllegalArgumentException("Cannot handle different desired"
-          + " state changes for a set of service components at the same time");
-    }
-
-    // TODO additional validation?
-
-    // TODO if all components reach a common state, should service state be
-    // modified?
-
-    for (ServiceComponentRequest request : requests) {
-      Cluster cluster = clusters.getCluster(request.getClusterName());
-      Service s = cluster.getService(request.getServiceName());
-      ServiceComponent sc = s.getServiceComponent(
-          request.getComponentName());
-      if (request.getConfigVersions() != null) {
-        Map<String, Config> updated = new HashMap<String, Config>();
-
-        for (Entry<String,String> entry :
-          request.getConfigVersions().entrySet()) {
-          Config config = cluster.getConfig(
-              entry.getKey(), entry.getValue());
-          updated.put(config.getType(), config);
-        }
-
-        if (!updated.isEmpty()) {
-          sc.updateDesiredConfigs(updated);
-          for (ServiceComponentHost sch :
-              sc.getServiceComponentHosts().values()) {
-            sch.deleteDesiredConfigs(updated.keySet());
-            sch.persist();
-          }
-          sc.persist();
-        }
-      }
-    }
-
-    Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
-
-    return createStages(cluster, requestProperties, null, null, changedComps, changedScHosts,
-        ignoredScHosts, runSmokeTest, false);
-  }
-
-  @Override
   public RequestStatusResponse createStages(Cluster cluster, Map<String, String> requestProperties,
                                             Map<String, String> requestParameters,
                                             Map<State, List<Service>> changedServices,
@@ -2801,12 +2257,6 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
-  public RequestStatusResponse deleteComponents(
-      Set<ServiceComponentRequest> request) throws AmbariException {
-    throw new AmbariException("Delete components not supported");
-  }
-
-  @Override
   public void deleteHosts(Set<HostRequest> requests)
       throws AmbariException {
 
@@ -3064,25 +2514,6 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
-  public Set<ServiceComponentResponse> getComponents(
-      Set<ServiceComponentRequest> requests) throws AmbariException {
-    Set<ServiceComponentResponse> response =
-        new HashSet<ServiceComponentResponse>();
-    for (ServiceComponentRequest request : requests) {
-      try {
-        response.addAll(getComponents(request));
-      } catch (ServiceComponentNotFoundException e) {
-        if (requests.size() == 1) {
-          // only throw exception if 1 request.
-          // there will be > 1 request in case of OR predicate
-          throw e;
-        }
-      }
-    }
-    return response;
-  }
-
-  @Override
   public Set<HostResponse> getHosts(Set<HostRequest> requests)
       throws AmbariException {
     Set<HostResponse> response = new HashSet<HostResponse>();
@@ -3912,6 +3343,11 @@ public class AmbariManagementControllerImpl implements
   }
 
   @Override
+  public ServiceComponentFactory getServiceComponentFactory() {
+    return serviceComponentFactory;
+  }
+
+  @Override
   public ActionManager getActionManager() {
     return actionManager;
   }

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
index f2c1f88..6365c40 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
@@ -37,6 +37,8 @@ public class ServiceComponentResponse {
 
   private String desiredState;
 
+  private String category;
+
   public ServiceComponentResponse(Long clusterId, String clusterName,
                                   String serviceName,
                                   String componentName,
@@ -151,6 +153,24 @@ public class ServiceComponentResponse {
     this.desiredStackVersion = desiredStackVersion;
   }
 
+  /**
+   * Get the component category.
+   *
+   * @return the category
+   */
+  public String getCategory() {
+    return category;
+  }
+
+  /**
+   * Set the component category.
+   *
+   * @param category  the category
+   */
+  public void setCategory(String category) {
+    this.category = category;
+  }
+
   @Override
   public boolean equals(Object o) {
     if (this == o) return true;

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index e88d8c3..521e054 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -18,16 +18,36 @@
 package org.apache.ambari.server.controller.internal;
 
 import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ClusterNotFoundException;
+import org.apache.ambari.server.DuplicateResourceException;
+import org.apache.ambari.server.ObjectNotFoundException;
+import org.apache.ambari.server.ParentObjectNotFoundException;
+import org.apache.ambari.server.ServiceComponentNotFoundException;
+import org.apache.ambari.server.ServiceNotFoundException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.AmbariManagementController;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ServiceComponentRequest;
 import org.apache.ambari.server.controller.ServiceComponentResponse;
 import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Config;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentFactory;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.State;
+
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -40,11 +60,12 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
   // ----- Property ID constants ---------------------------------------------
 
   // Components
-  protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("ServiceComponentInfo", "cluster_name");
-  protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID    = PropertyHelper.getPropertyId("ServiceComponentInfo", "service_name");
-  protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID  = PropertyHelper.getPropertyId("ServiceComponentInfo", "component_name");
-  protected static final String COMPONENT_STATE_PROPERTY_ID           = PropertyHelper.getPropertyId("ServiceComponentInfo", "state");
-  protected static final String COMPONENT_DESIRED_CONFIGS_PROPERTY_ID = PropertyHelper.getPropertyId("ServiceComponentInfo", "desired_configs");
+  protected static final String COMPONENT_CLUSTER_NAME_PROPERTY_ID    = "ServiceComponentInfo/cluster_name";
+  protected static final String COMPONENT_SERVICE_NAME_PROPERTY_ID    = "ServiceComponentInfo/service_name";
+  protected static final String COMPONENT_COMPONENT_NAME_PROPERTY_ID  = "ServiceComponentInfo/component_name";
+  protected static final String COMPONENT_STATE_PROPERTY_ID           = "ServiceComponentInfo/state";
+  protected static final String COMPONENT_DESIRED_CONFIGS_PROPERTY_ID = "ServiceComponentInfo/desired_configs";
+  protected static final String COMPONENT_CATEGORY_PROPERTY_ID        = "ServiceComponentInfo/category";
 
   //Parameters from the predicate
   private static final String QUERY_PARAMETERS_RUN_SMOKE_TEST_ID =
@@ -56,6 +77,7 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
           COMPONENT_SERVICE_NAME_PROPERTY_ID,
           COMPONENT_COMPONENT_NAME_PROPERTY_ID}));
 
+
   // ----- Constructors ----------------------------------------------------
 
   /**
@@ -71,6 +93,7 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
     super(propertyIds, keyPropertyIds, managementController);
   }
 
+
   // ----- ResourceProvider ------------------------------------------------
 
   @Override
@@ -88,7 +111,7 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
     createResources(new Command<Void>() {
       @Override
       public Void invoke() throws AmbariException {
-        getManagementController().createComponents(requests);
+        createComponents(requests);
         return null;
       }
     });
@@ -111,7 +134,7 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
     Set<ServiceComponentResponse> responses = getResources(new Command<Set<ServiceComponentResponse>>() {
       @Override
       public Set<ServiceComponentResponse> invoke() throws AmbariException {
-        return getManagementController().getComponents(requests);
+        return getComponents(requests);
       }
     });
 
@@ -127,6 +150,8 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
           response.getDesiredState(), requestedIds);
       setResourceProperty(resource, COMPONENT_DESIRED_CONFIGS_PROPERTY_ID,
           response.getConfigVersions(), requestedIds);
+      setResourceProperty(resource, COMPONENT_CATEGORY_PROPERTY_ID, response.getCategory(), requestedIds);
+
       resources.add(resource);
     }
     return resources;
@@ -154,13 +179,13 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
       requests.add(compRequest);
     }
 
-    final boolean runSmokeTest = "true".equals(getQueryParameterValue(
-        QUERY_PARAMETERS_RUN_SMOKE_TEST_ID, predicate)) ? true : false;
+    Object queryParameterValue = getQueryParameterValue(QUERY_PARAMETERS_RUN_SMOKE_TEST_ID, predicate);
+    final boolean runSmokeTest = queryParameterValue != null && queryParameterValue.equals("true");
 
     RequestStatusResponse response = modifyResources(new Command<RequestStatusResponse>() {
       @Override
       public RequestStatusResponse invoke() throws AmbariException {
-        return getManagementController().updateComponents(requests, request.getRequestInfoProperties(), runSmokeTest);
+        return updateComponents(requests, request.getRequestInfoProperties(), runSmokeTest);
       }
     });
 
@@ -173,15 +198,10 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
   public RequestStatus deleteResources(Predicate predicate)
       throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
 
-    final Set<ServiceComponentRequest> requests = new HashSet<ServiceComponentRequest>();
-    for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
-      requests.add(getRequest(propertyMap));
-    }
-
     RequestStatusResponse response = modifyResources(new Command<RequestStatusResponse>() {
       @Override
       public RequestStatusResponse invoke() throws AmbariException {
-        return getManagementController().deleteComponents(requests);
+        return deleteComponents();
       }
     });
 
@@ -189,13 +209,17 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
     return getRequestStatus(response);
   }
 
-  // ----- utility methods -------------------------------------------------
+
+  // ----- AbstractResourceProvider ------------------------------------------
 
   @Override
   protected Set<String> getPKPropertyIds() {
     return pkPropertyIds;
   }
 
+
+  // ----- utility methods ---------------------------------------------------
+
   /**
    * Get a component request object from a map of property values.
    *
@@ -211,4 +235,605 @@ class ComponentResourceProvider extends AbstractControllerResourceProvider {
         null,
         (String) properties.get(COMPONENT_STATE_PROPERTY_ID));
   }
-}
+
+  // Create the components for the given requests.
+  protected synchronized void createComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException {
+
+    if (requests.isEmpty()) {
+      LOG.warn("Received an empty requests set");
+      return;
+    }
+
+    Clusters clusters = getManagementController().getClusters();
+    AmbariMetaInfo ambariMetaInfo = getManagementController().getAmbariMetaInfo();
+    ServiceComponentFactory serviceComponentFactory = getManagementController().getServiceComponentFactory();
+
+    // do all validation checks
+    Map<String, Map<String, Set<String>>> componentNames =
+        new HashMap<String, Map<String, Set<String>>>();
+    Set<String> duplicates = new HashSet<String>();
+
+    for (ServiceComponentRequest request : requests) {
+      if (request.getClusterName() == null
+          || request.getClusterName().isEmpty()
+          || request.getComponentName() == null
+          || request.getComponentName().isEmpty()) {
+        throw new IllegalArgumentException("Invalid arguments"
+            + ", clustername and componentname should be"
+            + " non-null and non-empty when trying to create a"
+            + " component");
+      }
+
+      Cluster cluster;
+      try {
+        cluster = clusters.getCluster(request.getClusterName());
+      } catch (ClusterNotFoundException e) {
+        throw new ParentObjectNotFoundException(
+            "Attempted to add a component to a cluster which doesn't exist:", e);
+      }
+
+      if (request.getServiceName() == null
+          || request.getServiceName().isEmpty()) {
+        StackId stackId = cluster.getDesiredStackVersion();
+        String serviceName =
+            ambariMetaInfo.getComponentToService(stackId.getStackName(),
+                stackId.getStackVersion(), request.getComponentName());
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Looking up service name for component"
+              + ", componentName=" + request.getComponentName()
+              + ", serviceName=" + serviceName);
+        }
+
+        if (serviceName == null
+            || serviceName.isEmpty()) {
+          throw new AmbariException("Could not find service for component"
+              + ", componentName=" + request.getComponentName()
+              + ", clusterName=" + cluster.getClusterName()
+              + ", stackInfo=" + stackId.getStackId());
+        }
+        request.setServiceName(serviceName);
+      }
+
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Received a createComponent request"
+            + ", clusterName=" + request.getClusterName()
+            + ", serviceName=" + request.getServiceName()
+            + ", componentName=" + request.getComponentName()
+            + ", request=" + request);
+      }
+
+      if (!componentNames.containsKey(request.getClusterName())) {
+        componentNames.put(request.getClusterName(),
+            new HashMap<String, Set<String>>());
+      }
+      if (!componentNames.get(request.getClusterName())
+          .containsKey(request.getServiceName())) {
+        componentNames.get(request.getClusterName()).put(
+            request.getServiceName(), new HashSet<String>());
+      }
+      if (componentNames.get(request.getClusterName())
+          .get(request.getServiceName()).contains(request.getComponentName())) {
+        // throw error later for dup
+        duplicates.add("[clusterName=" + request.getClusterName() + ", serviceName=" + request.getServiceName() +
+            ", componentName=" + request.getComponentName() + "]");
+        continue;
+      }
+      componentNames.get(request.getClusterName())
+          .get(request.getServiceName()).add(request.getComponentName());
+
+      if (request.getDesiredState() != null
+          && !request.getDesiredState().isEmpty()) {
+        State state = State.valueOf(request.getDesiredState());
+        if (!state.isValidDesiredState()
+            || state != State.INIT) {
+          throw new IllegalArgumentException("Invalid desired state"
+              + " only INIT state allowed during creation"
+              + ", providedDesiredState=" + request.getDesiredState());
+        }
+      }
+
+      Service s;
+      try {
+        s = cluster.getService(request.getServiceName());
+      } catch (ServiceNotFoundException e) {
+        throw new ParentObjectNotFoundException(
+            "Attempted to add a component to a service which doesn't exist:", e);
+      }
+      try {
+        ServiceComponent sc = s.getServiceComponent(request.getComponentName());
+        if (sc != null) {
+          // throw error later for dup
+          duplicates.add("[clusterName=" + request.getClusterName() + ", serviceName=" + request.getServiceName() +
+              ", componentName=" + request.getComponentName() + "]");
+          continue;
+        }
+      } catch (AmbariException e) {
+        // Expected
+      }
+
+      StackId stackId = s.getDesiredStackVersion();
+      if (!ambariMetaInfo.isValidServiceComponent(stackId.getStackName(),
+          stackId.getStackVersion(), s.getName(), request.getComponentName())) {
+        throw new IllegalArgumentException("Unsupported or invalid component"
+            + " in stack"
+            + ", clusterName=" + request.getClusterName()
+            + ", serviceName=" + request.getServiceName()
+            + ", componentName=" + request.getComponentName()
+            + ", stackInfo=" + stackId.getStackId());
+      }
+    }
+
+    // ensure only a single cluster update
+    if (componentNames.size() != 1) {
+      throw new IllegalArgumentException("Invalid arguments, updates allowed"
+          + "on only one cluster at a time");
+    }
+
+    // Validate dups
+    if (!duplicates.isEmpty()) {
+      StringBuilder names = new StringBuilder();
+      boolean first = true;
+      for (String cName : duplicates) {
+        if (!first) {
+          names.append(",");
+        }
+        first = false;
+        names.append(cName);
+      }
+      String msg;
+      if (duplicates.size() == 1) {
+        msg = "Attempted to create a component which already exists: ";
+      } else {
+        msg = "Attempted to create components which already exist: ";
+      }
+      throw new DuplicateResourceException(msg + names.toString());
+    }
+
+    // now doing actual work
+    for (ServiceComponentRequest request : requests) {
+      Cluster cluster = clusters.getCluster(request.getClusterName());
+      Service s = cluster.getService(request.getServiceName());
+      ServiceComponent sc = serviceComponentFactory.createNew(s,
+          request.getComponentName());
+      sc.setDesiredStackVersion(s.getDesiredStackVersion());
+
+      if (request.getDesiredState() != null
+          && !request.getDesiredState().isEmpty()) {
+        State state = State.valueOf(request.getDesiredState());
+        sc.setDesiredState(state);
+      } else {
+        sc.setDesiredState(s.getDesiredState());
+      }
+
+      // FIXME fix config versions to configs conversion
+      Map<String, Config> configs = new HashMap<String, Config>();
+      if (request.getConfigVersions() != null) {
+      }
+
+      sc.updateDesiredConfigs(configs);
+      s.addServiceComponent(sc);
+      sc.persist();
+    }
+  }
+
+  // Get the components for the given requests.
+  protected Set<ServiceComponentResponse> getComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException {
+    Set<ServiceComponentResponse> response =
+        new HashSet<ServiceComponentResponse>();
+    for (ServiceComponentRequest request : requests) {
+      try {
+        response.addAll(getComponents(request));
+      } catch (ServiceComponentNotFoundException e) {
+        if (requests.size() == 1) {
+          // only throw exception if 1 request.
+          // there will be > 1 request in case of OR predicate
+          throw e;
+        }
+      }
+    }
+    return response;
+  }
+
+  // Get the components for the given request.
+  private synchronized Set<ServiceComponentResponse> getComponents(
+      ServiceComponentRequest request) throws AmbariException {
+    if (request.getClusterName() == null
+        || request.getClusterName().isEmpty()) {
+      throw new IllegalArgumentException("Invalid arguments, cluster name"
+          + " should be non-null");
+    }
+
+    Clusters clusters = getManagementController().getClusters();
+    AmbariMetaInfo ambariMetaInfo = getManagementController().getAmbariMetaInfo();
+
+    final Cluster cluster;
+    try {
+      cluster = clusters.getCluster(request.getClusterName());
+    } catch (ObjectNotFoundException e) {
+      throw new ParentObjectNotFoundException("Parent Cluster resource doesn't exist", e);
+    }
+
+    Set<ServiceComponentResponse> response =
+        new HashSet<ServiceComponentResponse>();
+    String category;
+
+    StackId stackId = cluster.getDesiredStackVersion();
+
+    if (request.getComponentName() != null) {
+      if (request.getServiceName() == null) {
+        String serviceName =
+            ambariMetaInfo.getComponentToService(stackId.getStackName(),
+                stackId.getStackVersion(), request.getComponentName());
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Looking up service name for component"
+              + ", componentName=" + request.getComponentName()
+              + ", serviceName=" + serviceName);
+        }
+        if (serviceName == null
+            || serviceName.isEmpty()) {
+          throw new AmbariException("Could not find service for component"
+              + ", componentName=" + request.getComponentName()
+              + ", clusterName=" + cluster.getClusterName()
+              + ", stackInfo=" + stackId.getStackId());
+        }
+        request.setServiceName(serviceName);
+      }
+
+      final Service s;
+      try {
+        s = cluster.getService(request.getServiceName());
+      } catch (ObjectNotFoundException e) {
+        throw new ParentObjectNotFoundException("Parent Service resource doesn't exist", e);
+      }
+
+      ServiceComponent sc = s.getServiceComponent(request.getComponentName());
+      ServiceComponentResponse serviceComponentResponse = sc.convertToResponse();
+
+
+      ComponentInfo componentInfo = ambariMetaInfo.getComponentCategory(stackId.getStackName(),
+          stackId.getStackVersion(), s.getName(), request.getComponentName());
+      if (componentInfo != null) {
+        category = componentInfo.getCategory();
+        if (category != null) {
+          serviceComponentResponse.setCategory(category);
+        }
+      }
+
+      response.add(serviceComponentResponse);
+      return response;
+    }
+
+    boolean checkDesiredState = false;
+    State desiredStateToCheck = null;
+    if (request.getDesiredState() != null
+        && !request.getDesiredState().isEmpty()) {
+      desiredStateToCheck = State.valueOf(request.getDesiredState());
+      if (!desiredStateToCheck.isValidDesiredState()) {
+        throw new IllegalArgumentException("Invalid arguments, invalid desired"
+            + " state, desiredState=" + desiredStateToCheck);
+      }
+      checkDesiredState = true;
+    }
+
+    Set<Service> services = new HashSet<Service>();
+    if (request.getServiceName() != null
+        && !request.getServiceName().isEmpty()) {
+      services.add(cluster.getService(request.getServiceName()));
+    } else {
+      services.addAll(cluster.getServices().values());
+    }
+
+    for (Service s : services) {
+      // filter on request.getDesiredState()
+      for (ServiceComponent sc : s.getServiceComponents().values()) {
+        if (checkDesiredState
+            && (desiredStateToCheck != sc.getDesiredState())) {
+          // skip non matching state
+          continue;
+        }
+
+        ComponentInfo componentInfo = ambariMetaInfo.getComponentCategory(stackId.getStackName(),
+            stackId.getStackVersion(), s.getName(), sc.getName());
+        ServiceComponentResponse serviceComponentResponse = sc.convertToResponse();
+        if (componentInfo != null) {
+          category = componentInfo.getCategory();
+          if (category != null) {
+            serviceComponentResponse.setCategory(category);
+          }
+        }
+        response.add(serviceComponentResponse);
+      }
+    }
+    return response;
+  }
+
+  // Update the components for the given requests.
+  protected synchronized RequestStatusResponse updateComponents(Set<ServiceComponentRequest> requests,
+                                                             Map<String, String> requestProperties, boolean runSmokeTest)
+      throws AmbariException {
+
+    if (requests.isEmpty()) {
+      LOG.warn("Received an empty requests set");
+      return null;
+    }
+
+    Clusters clusters = getManagementController().getClusters();
+    AmbariMetaInfo ambariMetaInfo = getManagementController().getAmbariMetaInfo();
+
+    Map<State, List<ServiceComponent>> changedComps =
+        new HashMap<State, List<ServiceComponent>>();
+    Map<String, Map<State, List<ServiceComponentHost>>> changedScHosts =
+        new HashMap<String, Map<State, List<ServiceComponentHost>>>();
+    Collection<ServiceComponentHost> ignoredScHosts =
+        new ArrayList<ServiceComponentHost>();
+
+    Set<String> clusterNames = new HashSet<String>();
+    Map<String, Map<String, Set<String>>> componentNames =
+        new HashMap<String, Map<String,Set<String>>>();
+    Set<State> seenNewStates = new HashSet<State>();
+
+    for (ServiceComponentRequest request : requests) {
+      if (request.getClusterName() == null
+          || request.getClusterName().isEmpty()
+          || request.getComponentName() == null
+          || request.getComponentName().isEmpty()) {
+        throw new IllegalArgumentException("Invalid arguments, cluster name"
+            + ", service name and component name should be provided to"
+            + " update components");
+      }
+
+      LOG.info("Received a updateComponent request"
+          + ", clusterName=" + request.getClusterName()
+          + ", serviceName=" + request.getServiceName()
+          + ", componentName=" + request.getComponentName()
+          + ", request=" + request.toString());
+
+      Cluster cluster = clusters.getCluster(request.getClusterName());
+
+      if (request.getServiceName() == null
+          || request.getServiceName().isEmpty()) {
+        StackId stackId = cluster.getDesiredStackVersion();
+        String serviceName =
+            ambariMetaInfo.getComponentToService(stackId.getStackName(),
+                stackId.getStackVersion(), request.getComponentName());
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Looking up service name for component"
+              + ", componentName=" + request.getComponentName()
+              + ", serviceName=" + serviceName);
+        }
+
+        if (serviceName == null
+            || serviceName.isEmpty()) {
+          throw new AmbariException("Could not find service for component"
+              + ", componentName=" + request.getComponentName()
+              + ", clusterName=" + cluster.getClusterName()
+              + ", stackInfo=" + stackId.getStackId());
+        }
+        request.setServiceName(serviceName);
+      }
+
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("Received a updateComponent request"
+            + ", clusterName=" + request.getClusterName()
+            + ", serviceName=" + request.getServiceName()
+            + ", componentName=" + request.getComponentName()
+            + ", request=" + request);
+      }
+
+      clusterNames.add(request.getClusterName());
+
+      if (clusterNames.size() > 1) {
+        // FIXME throw correct error
+        throw new IllegalArgumentException("Updates to multiple clusters is not"
+            + " supported");
+      }
+
+      if (!componentNames.containsKey(request.getClusterName())) {
+        componentNames.put(request.getClusterName(),
+            new HashMap<String, Set<String>>());
+      }
+      if (!componentNames.get(request.getClusterName())
+          .containsKey(request.getServiceName())) {
+        componentNames.get(request.getClusterName()).put(
+            request.getServiceName(), new HashSet<String>());
+      }
+      if (componentNames.get(request.getClusterName())
+          .get(request.getServiceName()).contains(request.getComponentName())){
+        // throw error later for dup
+        throw new IllegalArgumentException("Invalid request contains duplicate"
+            + " service components");
+      }
+      componentNames.get(request.getClusterName())
+          .get(request.getServiceName()).add(request.getComponentName());
+
+      Service s = cluster.getService(request.getServiceName());
+      ServiceComponent sc = s.getServiceComponent(
+          request.getComponentName());
+      State newState = null;
+      if (request.getDesiredState() != null) {
+        newState = State.valueOf(request.getDesiredState());
+        if (!newState.isValidDesiredState()) {
+          throw new IllegalArgumentException("Invalid arguments, invalid"
+              + " desired state, desiredState=" + newState.toString());
+        }
+      }
+
+      if (request.getConfigVersions() != null) {
+        State.checkUpdateConfiguration(sc, newState);
+
+        for (Map.Entry<String,String> entry :
+            request.getConfigVersions().entrySet()) {
+          Config config = cluster.getConfig(
+              entry.getKey(), entry.getValue());
+          if (null == config) {
+            // throw error for invalid config
+            throw new AmbariException("Trying to update servicecomponent with"
+                + " invalid configs"
+                + ", clusterName=" + cluster.getClusterName()
+                + ", clusterId=" + cluster.getClusterId()
+                + ", serviceName=" + s.getName()
+                + ", componentName=" + sc.getName()
+                + ", invalidConfigType=" + entry.getKey()
+                + ", invalidConfigTag=" + entry.getValue());
+          }
+        }
+      }
+
+      if (newState == null) {
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Nothing to do for new updateServiceComponent request"
+              + ", clusterName=" + request.getClusterName()
+              + ", serviceName=" + request.getServiceName()
+              + ", componentName=" + request.getComponentName()
+              + ", newDesiredState=null");
+        }
+        continue;
+      }
+
+      if (sc.isClientComponent() &&
+          !newState.isValidClientComponentState()) {
+        throw new AmbariException("Invalid desired state for a client"
+            + " component");
+      }
+
+      seenNewStates.add(newState);
+
+      State oldScState = sc.getDesiredState();
+      if (newState != oldScState) {
+        if (!State.isValidDesiredStateTransition(oldScState, newState)) {
+          // FIXME throw correct error
+          throw new AmbariException("Invalid transition for"
+              + " servicecomponent"
+              + ", clusterName=" + cluster.getClusterName()
+              + ", clusterId=" + cluster.getClusterId()
+              + ", serviceName=" + sc.getServiceName()
+              + ", componentName=" + sc.getName()
+              + ", currentDesiredState=" + oldScState
+              + ", newDesiredState=" + newState);
+        }
+        if (!changedComps.containsKey(newState)) {
+          changedComps.put(newState, new ArrayList<ServiceComponent>());
+        }
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Handling update to ServiceComponent"
+              + ", clusterName=" + request.getClusterName()
+              + ", serviceName=" + s.getName()
+              + ", componentName=" + sc.getName()
+              + ", currentDesiredState=" + oldScState
+              + ", newDesiredState=" + newState);
+        }
+        changedComps.get(newState).add(sc);
+      }
+
+      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+        State oldSchState = sch.getState();
+        if (oldSchState == State.MAINTENANCE || oldSchState == State.UNKNOWN) {
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Ignoring ServiceComponentHost"
+                + ", clusterName=" + request.getClusterName()
+                + ", serviceName=" + s.getName()
+                + ", componentName=" + sc.getName()
+                + ", hostname=" + sch.getHostName()
+                + ", currentState=" + oldSchState
+                + ", newDesiredState=" + newState);
+          }
+          continue;
+        }
+
+        if (newState == oldSchState) {
+          ignoredScHosts.add(sch);
+          if (LOG.isDebugEnabled()) {
+            LOG.debug("Ignoring ServiceComponentHost"
+                + ", clusterName=" + request.getClusterName()
+                + ", serviceName=" + s.getName()
+                + ", componentName=" + sc.getName()
+                + ", hostname=" + sch.getHostName()
+                + ", currentState=" + oldSchState
+                + ", newDesiredState=" + newState);
+          }
+          continue;
+        }
+        if (!State.isValidStateTransition(oldSchState, newState)) {
+          // FIXME throw correct error
+          throw new AmbariException("Invalid transition for"
+              + " servicecomponenthost"
+              + ", clusterName=" + cluster.getClusterName()
+              + ", clusterId=" + cluster.getClusterId()
+              + ", serviceName=" + sch.getServiceName()
+              + ", componentName=" + sch.getServiceComponentName()
+              + ", hostname=" + sch.getHostName()
+              + ", currentState=" + oldSchState
+              + ", newDesiredState=" + newState);
+        }
+        if (!changedScHosts.containsKey(sc.getName())) {
+          changedScHosts.put(sc.getName(),
+              new HashMap<State, List<ServiceComponentHost>>());
+        }
+        if (!changedScHosts.get(sc.getName()).containsKey(newState)) {
+          changedScHosts.get(sc.getName()).put(newState,
+              new ArrayList<ServiceComponentHost>());
+        }
+        if (LOG.isDebugEnabled()) {
+          LOG.debug("Handling update to ServiceComponentHost"
+              + ", clusterName=" + request.getClusterName()
+              + ", serviceName=" + s.getName()
+              + ", componentName=" + sc.getName()
+              + ", hostname=" + sch.getHostName()
+              + ", currentState=" + oldSchState
+              + ", newDesiredState=" + newState);
+        }
+        changedScHosts.get(sc.getName()).get(newState).add(sch);
+      }
+    }
+
+    if (seenNewStates.size() > 1) {
+      // FIXME should we handle this scenario
+      throw new IllegalArgumentException("Cannot handle different desired"
+          + " state changes for a set of service components at the same time");
+    }
+
+    // TODO additional validation?
+
+    // TODO if all components reach a common state, should service state be
+    // modified?
+
+    for (ServiceComponentRequest request : requests) {
+      Cluster cluster = clusters.getCluster(request.getClusterName());
+      Service s = cluster.getService(request.getServiceName());
+      ServiceComponent sc = s.getServiceComponent(
+          request.getComponentName());
+      if (request.getConfigVersions() != null) {
+        Map<String, Config> updated = new HashMap<String, Config>();
+
+        for (Map.Entry<String,String> entry :
+            request.getConfigVersions().entrySet()) {
+          Config config = cluster.getConfig(
+              entry.getKey(), entry.getValue());
+          updated.put(config.getType(), config);
+        }
+
+        if (!updated.isEmpty()) {
+          sc.updateDesiredConfigs(updated);
+          for (ServiceComponentHost sch :
+              sc.getServiceComponentHosts().values()) {
+            sch.deleteDesiredConfigs(updated.keySet());
+            sch.persist();
+          }
+          sc.persist();
+        }
+      }
+    }
+
+    Cluster cluster = clusters.getCluster(clusterNames.iterator().next());
+
+    return getManagementController().createStages(cluster, requestProperties, null, null, changedComps, changedScHosts,
+        ignoredScHosts, runSmokeTest, false);
+  }
+
+  // Delete the components for the given request.
+  protected RequestStatusResponse deleteComponents() throws AmbariException {
+    throw new AmbariException("Delete components not supported");
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/main/resources/properties.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/properties.json b/ambari-server/src/main/resources/properties.json
index c14031b..00abfac 100644
--- a/ambari-server/src/main/resources/properties.json
+++ b/ambari-server/src/main/resources/properties.json
@@ -49,6 +49,7 @@
         "ServiceComponents/display_name",
         "ServiceComponents/description",
         "ServiceComponentInfo/desired_configs",
+        "ServiceComponentInfo/category",
         "params/run_smoke_test",
         "_"
     ],

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
index 9dbcfcd..95143ee 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java
@@ -264,165 +264,6 @@ public class AmbariManagementControllerImplTest {
   }
 
   @Test
-  public void testGetComponents() throws Exception {
-    // member state mocks
-    Injector injector = createStrictMock(Injector.class);
-    Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
-    Clusters clusters = createNiceMock(Clusters.class);
-
-    Cluster cluster = createNiceMock(Cluster.class);
-    Service service = createNiceMock(Service.class);
-    ServiceComponent component = createNiceMock(ServiceComponent.class);
-    ServiceComponentResponse response = createNiceMock(ServiceComponentResponse.class);
-
-    // requests
-    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
-        Collections.<String, String>emptyMap(), null);
-
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
-    setRequests.add(request1);
-
-    // expectations
-    // constructor init
-    injector.injectMembers(capture(controllerCapture));
-    expect(injector.getInstance(Gson.class)).andReturn(null);
-
-    // getComponents
-    expect(clusters.getCluster("cluster1")).andReturn(cluster);
-    expect(cluster.getService("service1")).andReturn(service);
-    expect(service.getServiceComponent("component1")).andReturn(component);
-
-    expect(component.convertToResponse()).andReturn(response);
-    // replay mocks
-    replay(injector, clusters, cluster, service, component, response);
-
-    //test
-    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
-    Set<ServiceComponentResponse> setResponses = controller.getComponents(setRequests);
-
-    // assert and verify
-    assertSame(controller, controllerCapture.getValue());
-    assertEquals(1, setResponses.size());
-    assertTrue(setResponses.contains(response));
-
-    verify(injector, clusters, cluster, service, component, response);
-  }
-
-  /**
-   * Ensure that ServiceComponentNotFoundException is propagated in case where there is a single request.
-   */
-  @Test
-  public void testGetComponents___ServiceComponentNotFoundException() throws Exception {
-    // member state mocks
-    Injector injector = createStrictMock(Injector.class);
-    Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
-    Clusters clusters = createNiceMock(Clusters.class);
-
-    Cluster cluster = createNiceMock(Cluster.class);
-    Service service = createNiceMock(Service.class);
-
-    // requests
-    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
-        Collections.<String, String>emptyMap(), null);
-
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
-    setRequests.add(request1);
-
-    // expectations
-    // constructor init
-    injector.injectMembers(capture(controllerCapture));
-    expect(injector.getInstance(Gson.class)).andReturn(null);
-
-    // getComponents
-    expect(clusters.getCluster("cluster1")).andReturn(cluster);
-    expect(cluster.getService("service1")).andReturn(service);
-    expect(service.getServiceComponent("component1")).andThrow(
-        new ServiceComponentNotFoundException("cluster1", "service1", "component1"));
-    // replay mocks
-    replay(injector, clusters, cluster, service);
-
-    //test
-    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
-
-    // assert that exception is thrown in case where there is a single request
-    try {
-      controller.getComponents(setRequests);
-      fail("expected ServiceComponentNotFoundException");
-    } catch (ServiceComponentNotFoundException e) {
-      // expected
-    }
-
-    assertSame(controller, controllerCapture.getValue());
-    verify(injector, clusters, cluster, service);
-  }
-
-  /**
-   * Ensure that ServiceComponentNotFoundException is handled where there are multiple requests as would be the
-   * case when an OR predicate is provided in the query.
-   */
-  @Test
-  public void testGetComponents___OR_Predicate_ServiceComponentNotFoundException() throws Exception {
-    // member state mocks
-    Injector injector = createStrictMock(Injector.class);
-    Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
-    Clusters clusters = createNiceMock(Clusters.class);
-
-    Cluster cluster = createNiceMock(Cluster.class);
-    Service service = createNiceMock(Service.class);
-    ServiceComponent component1 = createNiceMock(ServiceComponent.class);
-    ServiceComponent component2 = createNiceMock(ServiceComponent.class);
-    ServiceComponentResponse response1 = createNiceMock(ServiceComponentResponse.class);
-    ServiceComponentResponse response2 = createNiceMock(ServiceComponentResponse.class);
-
-    // requests
-    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
-        Collections.<String, String>emptyMap(), null);
-    ServiceComponentRequest request2 = new ServiceComponentRequest("cluster1", "service1", "component2",
-        Collections.<String, String>emptyMap(), null);
-    ServiceComponentRequest request3 = new ServiceComponentRequest("cluster1", "service1", "component3",
-        Collections.<String, String>emptyMap(), null);
-    ServiceComponentRequest request4 = new ServiceComponentRequest("cluster1", "service1", "component4",
-        Collections.<String, String>emptyMap(), null);
-
-    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
-    setRequests.add(request1);
-    setRequests.add(request2);
-    setRequests.add(request3);
-    setRequests.add(request4);
-
-    // expectations
-    // constructor init
-    injector.injectMembers(capture(controllerCapture));
-    expect(injector.getInstance(Gson.class)).andReturn(null);
-
-    // getComponents
-    expect(clusters.getCluster("cluster1")).andReturn(cluster).times(4);
-    expect(cluster.getService("service1")).andReturn(service).times(4);
-
-    expect(service.getServiceComponent("component1")).andThrow(new ServiceComponentNotFoundException("cluster1", "service1", "component1"));
-    expect(service.getServiceComponent("component2")).andThrow(new ServiceComponentNotFoundException("cluster1", "service1", "component2"));
-    expect(service.getServiceComponent("component3")).andReturn(component1);
-    expect(service.getServiceComponent("component4")).andReturn(component2);
-
-    expect(component1.convertToResponse()).andReturn(response1);
-    expect(component2.convertToResponse()).andReturn(response2);
-    // replay mocks
-    replay(injector, clusters, cluster, service, component1,  component2, response1, response2);
-
-    //test
-    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
-    Set<ServiceComponentResponse> setResponses = controller.getComponents(setRequests);
-
-    // assert and verify
-    assertSame(controller, controllerCapture.getValue());
-    assertEquals(2, setResponses.size());
-    assertTrue(setResponses.contains(response1));
-    assertTrue(setResponses.contains(response2));
-
-    verify(injector, clusters, cluster, service, component1,  component2, response1, response2);
-  }
-
-  @Test
   public void testGetHosts() throws Exception {
     // member state mocks
     Injector injector = createStrictMock(Injector.class);


[2/3] AMBARI-3604 - Components in API should have 'category' field

Posted by tb...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 6874abb..2206062 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -43,6 +43,7 @@ import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ExecutionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.controller.internal.ComponentResourceProviderTest;
 import org.apache.ambari.server.controller.internal.ServiceResourceProviderTest;
 import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
@@ -219,7 +220,7 @@ public class AmbariManagementControllerTest {
     Set<ServiceComponentRequest> requests =
         new HashSet<ServiceComponentRequest>();
     requests.add(r);
-    controller.createComponents(requests);
+    ComponentResourceProviderTest.createComponents(controller, requests);
   }
 
   private void createServiceComponentHost(String clusterName,
@@ -685,7 +686,7 @@ public class AmbariManagementControllerTest {
 
     ServiceComponentRequest r =
         new ServiceComponentRequest(clusterName, serviceName, null, null, null);
-    Set<ServiceComponentResponse> response = controller.getComponents(Collections.singleton(r));
+    Set<ServiceComponentResponse> response = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(1, response.size());
 
     ServiceComponentResponse sc = response.iterator().next();
@@ -712,7 +713,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest(null, null, null, null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for invalid requests");
     } catch (Exception e) {
       // Expected
@@ -723,7 +724,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest("c1", null, null, null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for invalid requests");
     } catch (Exception e) {
       // Expected
@@ -734,7 +735,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest("c1", "s1", null, null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for invalid requests");
     } catch (Exception e) {
       // Expected
@@ -745,7 +746,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest("c1", "s1", "sc1", null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for invalid cluster");
     } catch (ParentObjectNotFoundException e) {
       // Expected
@@ -760,7 +761,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest("c1", "HDFS", "NAMENODE", null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for invalid service");
     } catch (ParentObjectNotFoundException e) {
       // Expected
@@ -786,7 +787,7 @@ public class AmbariManagementControllerTest {
     set1.add(valid1);
     set1.add(valid2);
     set1.add(valid3);
-    controller.createComponents(set1);
+    ComponentResourceProviderTest.createComponents(controller, set1);
 
     try {
       set1.clear();
@@ -796,7 +797,7 @@ public class AmbariManagementControllerTest {
           new ServiceComponentRequest("c1", "HDFS", "HDFS_CLIENT", null, null);
       set1.add(rInvalid1);
       set1.add(rInvalid2);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for dups in requests");
     } catch (Exception e) {
       // Expected
@@ -810,7 +811,7 @@ public class AmbariManagementControllerTest {
           new ServiceComponentRequest("c2", "HDFS", "HDFS_CLIENT", null, null);
       set1.add(rInvalid1);
       set1.add(rInvalid2);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for multiple clusters");
     } catch (Exception e) {
       // Expected
@@ -821,7 +822,7 @@ public class AmbariManagementControllerTest {
       ServiceComponentRequest rInvalid =
           new ServiceComponentRequest("c1", "HDFS", "NAMENODE", null, null);
       set1.add(rInvalid);
-      controller.createComponents(set1);
+      ComponentResourceProviderTest.createComponents(controller, set1);
       fail("Expected failure for already existing component");
     } catch (Exception e) {
       // Expected
@@ -867,7 +868,7 @@ public class AmbariManagementControllerTest {
     set1.add(valid1);
     set1.add(valid2);
     set1.add(valid3);
-    controller.createComponents(set1);
+    ComponentResourceProviderTest.createComponents(controller, set1);
 
     Assert.assertEquals(1, c1.getService("HDFS").getServiceComponents().size());
     Assert.assertEquals(2, c1.getService("MAPREDUCE").getServiceComponents().size());
@@ -1879,7 +1880,7 @@ public class AmbariManagementControllerTest {
     ServiceComponentRequest r = new ServiceComponentRequest("c1",
        s1.getName(), sc1.getName(), null, null);
 
-    Set<ServiceComponentResponse> resps = controller.getComponents(Collections.singleton(r));
+    Set<ServiceComponentResponse> resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(1, resps.size());
 
     ServiceComponentResponse resp = resps.iterator().next();
@@ -1968,7 +1969,7 @@ public class AmbariManagementControllerTest {
         null, null, null);
 
     try {
-      controller.getComponents(Collections.singleton(r));
+      ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
       fail("Expected failure for invalid cluster");
     } catch (Exception e) {
       // Expected
@@ -1977,25 +1978,25 @@ public class AmbariManagementControllerTest {
     // all comps per cluster
     r = new ServiceComponentRequest(c1.getClusterName(),
         null, null, null, null);
-    Set<ServiceComponentResponse> resps = controller.getComponents(Collections.singleton(r));
+    Set<ServiceComponentResponse> resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(3, resps.size());
 
     // all comps per cluster filter on state
     r = new ServiceComponentRequest(c2.getClusterName(),
         null, null, null, State.UNINSTALLED.toString());
-    resps = controller.getComponents(Collections.singleton(r));
+    resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(4, resps.size());
 
     // all comps for given service
     r = new ServiceComponentRequest(c2.getClusterName(),
         s5.getName(), null, null, null);
-    resps = controller.getComponents(Collections.singleton(r));
+    resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(2, resps.size());
 
     // all comps for given service filter by state
     r = new ServiceComponentRequest(c2.getClusterName(),
         s4.getName(), null, null, State.INIT.toString());
-    resps = controller.getComponents(Collections.singleton(r));
+    resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(1, resps.size());
     Assert.assertEquals(sc4.getName(),
         resps.iterator().next().getComponentName());
@@ -2003,7 +2004,7 @@ public class AmbariManagementControllerTest {
     // get single given comp
     r = new ServiceComponentRequest(c2.getClusterName(),
         null, sc5.getName(), null, State.INIT.toString());
-    resps = controller.getComponents(Collections.singleton(r));
+    resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(1, resps.size());
     Assert.assertEquals(sc5.getName(),
         resps.iterator().next().getComponentName());
@@ -2011,7 +2012,7 @@ public class AmbariManagementControllerTest {
     // get single given comp and given svc
     r = new ServiceComponentRequest(c2.getClusterName(),
         s4.getName(), sc5.getName(), null, State.INIT.toString());
-    resps = controller.getComponents(Collections.singleton(r));
+    resps = ComponentResourceProviderTest.getComponents(controller, Collections.singleton(r));
     Assert.assertEquals(1, resps.size());
     Assert.assertEquals(sc5.getName(),
         resps.iterator().next().getComponentName());
@@ -2026,7 +2027,7 @@ public class AmbariManagementControllerTest {
     r3 = new ServiceComponentRequest(c1.getClusterName(),
         null, null, null, State.INIT.toString());
     reqs.addAll(Arrays.asList(r1, r2, r3));
-    resps = controller.getComponents(reqs);
+    resps = ComponentResourceProviderTest.getComponents(controller, reqs);
     Assert.assertEquals(7, resps.size());
   }
 
@@ -2796,13 +2797,13 @@ public class AmbariManagementControllerTest {
     req1 = new ServiceComponentRequest(clusterName, serviceName1,
         sc3.getName(), null, State.INSTALLED.toString());
     reqs.add(req1);
-    controller.updateComponents(reqs, Collections.<String, String>emptyMap(), true);
+    ComponentResourceProviderTest.updateComponents(controller, reqs, Collections.<String, String>emptyMap(), true);
     try {
       reqs.clear();
       req1 = new ServiceComponentRequest(clusterName, serviceName1,
           sc1.getName(), null, State.INIT.toString());
       reqs.add(req1);
-      controller.updateComponents(reqs, Collections.<String, String>emptyMap(), true);
+      ComponentResourceProviderTest.updateComponents(controller, reqs, Collections.<String, String>emptyMap(), true);
       fail("Expected failure for invalid state update");
     } catch (Exception e) {
       // Expected
@@ -2828,7 +2829,7 @@ public class AmbariManagementControllerTest {
       req1 = new ServiceComponentRequest(clusterName, serviceName1,
           sc1.getName(), null, State.STARTED.toString());
       reqs.add(req1);
-      controller.updateComponents(reqs, Collections.<String, String>emptyMap(), true);
+      ComponentResourceProviderTest.updateComponents(controller, reqs, Collections.<String, String>emptyMap(), true);
       fail("Expected failure for invalid state update");
     } catch (Exception e) {
       // Expected
@@ -2859,7 +2860,7 @@ public class AmbariManagementControllerTest {
     reqs.add(req1);
     reqs.add(req2);
     reqs.add(req3);
-    RequestStatusResponse trackAction = controller.updateComponents(reqs, Collections.<String, String>emptyMap(), true);
+    RequestStatusResponse trackAction = ComponentResourceProviderTest.updateComponents(controller, reqs, Collections.<String, String>emptyMap(), true);
 
     Assert.assertEquals(State.INSTALLED, s1.getDesiredState());
     Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
@@ -2903,7 +2904,7 @@ public class AmbariManagementControllerTest {
         sc2.getName(), null, State.INSTALLED.toString());
     reqs.add(req1);
     reqs.add(req2);
-    trackAction = controller.updateComponents(reqs, Collections.<String, String>emptyMap(), true);
+    trackAction = ComponentResourceProviderTest.updateComponents(controller, reqs, Collections.<String, String>emptyMap(), true);
     Assert.assertNull(trackAction);
   }
 
@@ -3891,7 +3892,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
             componentName2, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     Assert.assertEquals(0, s.getDesiredConfigs().size());
     Assert.assertEquals(0, sc1.getDesiredConfigs().size());
@@ -3976,7 +3977,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
             componentName1, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     Assert.assertEquals(3, s.getDesiredConfigs().size());
     Assert.assertEquals(4, sc1.getDesiredConfigs().size());
@@ -4126,7 +4127,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
         componentName2, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     Assert.assertEquals(0, s.getDesiredConfigs().size());
     Assert.assertEquals(0, sc1.getDesiredConfigs().size());
@@ -4211,7 +4212,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
         componentName1, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     Assert.assertEquals(3, s.getDesiredConfigs().size());
     Assert.assertEquals(4, sc1.getDesiredConfigs().size());
@@ -4366,11 +4367,11 @@ public class AmbariManagementControllerTest {
     configVersions.put("hdfs-site", "version1");
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
       componentName2, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
       componentName1, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
     Assert.assertEquals(2, sc1.getDesiredConfigs().size());
     Assert.assertEquals(2, sc2.getDesiredConfigs().size());
 
@@ -4381,7 +4382,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
       componentName2, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     Assert.assertEquals(2, sc2.getDesiredConfigs().size());
     Assert.assertEquals("version122", sc2.getDesiredConfigs().get
@@ -4389,7 +4390,7 @@ public class AmbariManagementControllerTest {
     scReqs.clear();
     scReqs.add(new ServiceComponentRequest(clusterName, serviceName,
       componentName1, configVersions, null));
-    Assert.assertNull(controller.updateComponents(scReqs, Collections.<String, String>emptyMap(), true));
+    Assert.assertNull(ComponentResourceProviderTest.updateComponents(controller, scReqs, Collections.<String, String>emptyMap(), true));
 
     entityManager.clear();
 
@@ -7472,7 +7473,7 @@ public class AmbariManagementControllerTest {
       serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "YARN", "NODEMANAGER", null, null));
       serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "HDFS", "HDFS_CLIENT", null, null));
 
-      amc.createComponents(serviceComponentRequests);
+      ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
 
       Set<ServiceComponentHostRequest> componentHostRequests = new HashSet<ServiceComponentHostRequest>();
       componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "DATANODE", HOST1, null, null));
@@ -7586,7 +7587,7 @@ public class AmbariManagementControllerTest {
       serviceComponentRequests.add(new ServiceComponentRequest("c1", "HDFS", "DATANODE", null, null));
       serviceComponentRequests.add(new ServiceComponentRequest("c1", "HDFS", "HDFS_CLIENT", null, null));
 
-      amc.createComponents(serviceComponentRequests);
+      ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
 
       Set<HostRequest> hostRequests = new HashSet<HostRequest>();
       hostRequests.add(new HostRequest("host1", "c1", null));
@@ -7779,7 +7780,7 @@ public class AmbariManagementControllerTest {
       serviceComponentRequests.add(new ServiceComponentRequest("c1", "HDFS", "SECONDARY_NAMENODE", null, null));
       serviceComponentRequests.add(new ServiceComponentRequest("c1", "HDFS", "DATANODE", null, null));
       serviceComponentRequests.add(new ServiceComponentRequest("c1", "HDFS", "HDFS_CLIENT", null, null));
-      amc.createComponents(serviceComponentRequests);
+      ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
 
       //Create ServiceComponentHosts
       componentHostRequests = new HashSet<ServiceComponentHostRequest>();
@@ -7861,7 +7862,7 @@ public class AmbariManagementControllerTest {
       serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "YARN", "RESOURCEMANAGER", null, null));
       serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "YARN", "NODEMANAGER", null, null));
 
-      amc.createComponents(serviceComponentRequests);
+      ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);
 
       Set<HostRequest> hostRequests = new HashSet<HostRequest>();
       hostRequests.add(new HostRequest(HOST1, CLUSTER_NAME, null));

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
index a42f89e..1db614d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
@@ -18,7 +18,13 @@
 
 package org.apache.ambari.server.controller.internal;
 
+import com.google.gson.Gson;
+import com.google.inject.Injector;
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.ServiceComponentNotFoundException;
+import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.AmbariManagementControllerImpl;
 import org.apache.ambari.server.controller.RequestStatusResponse;
 import org.apache.ambari.server.controller.ServiceComponentRequest;
 import org.apache.ambari.server.controller.ServiceComponentResponse;
@@ -28,18 +34,42 @@ import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
-import org.easymock.*;
+import org.apache.ambari.server.state.Cluster;
+import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ComponentInfo;
+import org.apache.ambari.server.state.Service;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentFactory;
+import org.apache.ambari.server.state.ServiceComponentHost;
+import org.apache.ambari.server.state.StackId;
+import org.apache.ambari.server.state.State;
+import org.easymock.Capture;
 import org.junit.Assert;
 import org.junit.Test;
 
-import java.util.*;
-
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.anyBoolean;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
 import static org.easymock.EasyMock.createMock;
 import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.createStrictMock;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.replay;
 import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 /**
  * Tests for the component resource provider.
@@ -50,14 +80,35 @@ public class ComponentResourceProviderTest {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    Clusters clusters = createNiceMock(Clusters.class);
+    Cluster cluster = createNiceMock(Cluster.class);
+    Service service = createNiceMock(Service.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
+    ServiceComponentFactory serviceComponentFactory = createNiceMock(ServiceComponentFactory.class);
+    ServiceComponent serviceComponent = createNiceMock(ServiceComponent.class);
+    StackId stackId = createNiceMock(StackId.class);
+
+    expect(managementController.getClusters()).andReturn(clusters);
+    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
+    expect(managementController.getServiceComponentFactory()).andReturn(serviceComponentFactory);
+
+    expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
+    expect(cluster.getService("Service100")).andReturn(service).anyTimes();
+
+    expect(service.getDesiredStackVersion()).andReturn(stackId).anyTimes();
+    expect(service.getName()).andReturn("Service100").anyTimes();
+
+    expect(stackId.getStackName()).andReturn("HDP").anyTimes();
+    expect(stackId.getStackVersion()).andReturn("99").anyTimes();
 
-    managementController.createComponents(
-        AbstractResourceProviderTest.Matcher.getComponentRequestSet(
-            "Cluster100", "Service100", "Component100", null, null));
+    expect(ambariMetaInfo.isValidServiceComponent("HDP", "99", "Service100", "Component100")).andReturn(true).anyTimes();
+
+    expect(serviceComponentFactory.createNew(service, "Component100")).andReturn(serviceComponent);
 
     // replay
-    replay(managementController, response);
+    replay(managementController, response, clusters, cluster, service, stackId, ambariMetaInfo,
+        serviceComponentFactory, serviceComponent);
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
@@ -84,7 +135,8 @@ public class ComponentResourceProviderTest {
     provider.createResources(request);
 
     // verify
-    verify(managementController, response);
+    verify(managementController, response, clusters, cluster, service, stackId, ambariMetaInfo,
+        serviceComponentFactory, serviceComponent);
   }
 
   @Test
@@ -92,19 +144,45 @@ public class ComponentResourceProviderTest {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
-
-    Set<ServiceComponentResponse> allResponse = new HashSet<ServiceComponentResponse>();
-    allResponse.add(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, null, ""));
-    allResponse.add(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, null, ""));
-    allResponse.add(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, null, ""));
+    Clusters clusters = createNiceMock(Clusters.class);
+    Cluster cluster = createNiceMock(Cluster.class);
+    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
+    Service service = createNiceMock(Service.class);
+    ServiceComponent serviceComponent1 = createNiceMock(ServiceComponent.class);
+    ServiceComponent serviceComponent2 = createNiceMock(ServiceComponent.class);
+    ServiceComponent serviceComponent3 = createNiceMock(ServiceComponent.class);
+    StackId stackId = createNiceMock(StackId.class);
+    ComponentInfo componentInfo = createNiceMock(ComponentInfo.class);
+
+
+    Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
+    serviceComponentMap.put("Component101", serviceComponent1);
+    serviceComponentMap.put("Component102", serviceComponent2);
+    serviceComponentMap.put("Component103", serviceComponent3);
 
     // set expectations
-    expect(managementController.getComponents(
-        AbstractResourceProviderTest.Matcher.getComponentRequestSet(
-            "Cluster100", null, null, null, null))).andReturn(allResponse).once();
+    expect(managementController.getClusters()).andReturn(clusters);
+    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo);
+    expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
+    expect(cluster.getDesiredStackVersion()).andReturn(stackId);
+
+    expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
+
+    expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
+
+    expect(serviceComponent1.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component100", null, null, ""));
+    expect(serviceComponent2.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, null, ""));
+    expect(serviceComponent3.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, null, ""));
+
+
+    expect(ambariMetaInfo.getComponentCategory((String) anyObject(), (String) anyObject(),
+        (String) anyObject(), (String) anyObject())).andReturn(componentInfo).anyTimes();
+
+    expect(componentInfo.getCategory()).andReturn("MASTER").anyTimes();
 
     // replay
-    replay(managementController);
+    replay(managementController, clusters, cluster, ambariMetaInfo, service,
+        serviceComponent1, serviceComponent2, serviceComponent3, stackId, componentInfo);
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
@@ -116,6 +194,7 @@ public class ComponentResourceProviderTest {
 
     propertyIds.add(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID);
     propertyIds.add(ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID);
+    propertyIds.add(ComponentResourceProvider.COMPONENT_CATEGORY_PROPERTY_ID);
 
     Predicate predicate = new PredicateBuilder().property(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID).
         equals("Cluster100").toPredicate();
@@ -123,20 +202,17 @@ public class ComponentResourceProviderTest {
     Set<Resource> resources = provider.getResources(request, predicate);
 
     Assert.assertEquals(3, resources.size());
-    Set<String> names = new HashSet<String>();
     for (Resource resource : resources) {
       String clusterName = (String) resource.getPropertyValue(
           ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID);
       Assert.assertEquals("Cluster100", clusterName);
-      names.add((String) resource.getPropertyValue(ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID));
-    }
-    // Make sure that all of the response objects got moved into resources
-    for (ServiceComponentResponse response : allResponse ) {
-      Assert.assertTrue(names.contains(response.getComponentName()));
+      Assert.assertEquals("MASTER", resource.getPropertyValue(
+          ComponentResourceProvider.COMPONENT_CATEGORY_PROPERTY_ID));
     }
 
     // verify
-    verify(managementController);
+    verify(managementController, clusters, cluster, ambariMetaInfo, service,
+        serviceComponent1, serviceComponent2, serviceComponent3, stackId, componentInfo);
   }
 
   @Test
@@ -144,23 +220,75 @@ public class ComponentResourceProviderTest {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
-    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
+    Clusters clusters = createNiceMock(Clusters.class);
+    Cluster cluster = createNiceMock(Cluster.class);
+    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
+    Service service = createNiceMock(Service.class);
+    ServiceComponent serviceComponent1 = createNiceMock(ServiceComponent.class);
+    ServiceComponent serviceComponent2 = createNiceMock(ServiceComponent.class);
+    ServiceComponent serviceComponent3 = createNiceMock(ServiceComponent.class);
+    ServiceComponentHost serviceComponentHost = createNiceMock(ServiceComponentHost.class);
+    RequestStatusResponse requestStatusResponse = createNiceMock(RequestStatusResponse.class);
+    StackId stackId = createNiceMock(StackId.class);
+
+    Map<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>();
+    serviceComponentMap.put("Component101", serviceComponent1);
+    serviceComponentMap.put("Component102", serviceComponent2);
+    serviceComponentMap.put("Component103", serviceComponent3);
+
+    // set expectations
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
+    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
+    expect(clusters.getCluster("Cluster100")).andReturn(cluster).anyTimes();
+    expect(cluster.getDesiredStackVersion()).andReturn(stackId);
+
+    expect(cluster.getService("Service100")).andReturn(service).anyTimes();
+    expect(service.getServiceComponent("Component101")).andReturn(serviceComponent1).anyTimes();
+    expect(service.getServiceComponent("Component102")).andReturn(serviceComponent1).anyTimes();
+    expect(service.getServiceComponent("Component103")).andReturn(serviceComponent2).anyTimes();
+
+
+    expect(cluster.getServices()).andReturn(Collections.singletonMap("Service100", service)).anyTimes();
+
+    expect(service.getServiceComponents()).andReturn(serviceComponentMap).anyTimes();
+
+    expect(serviceComponent1.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component101", null, null, ""));
+    expect(serviceComponent2.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component102", null, null, ""));
+    expect(serviceComponent3.convertToResponse()).andReturn(new ServiceComponentResponse(100L, "Cluster100", "Service100", "Component103", null, null, ""));
+    expect(serviceComponent1.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
+    expect(serviceComponent2.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
+    expect(serviceComponent3.getDesiredState()).andReturn(State.INSTALLED).anyTimes();
+
+    expect(serviceComponentHost.getState()).andReturn(State.INSTALLED).anyTimes();
+
+    Map<String, ServiceComponentHost> serviceComponentHosts = Collections.singletonMap("Host100", serviceComponentHost);
+
+    expect(serviceComponent1.getServiceComponentHosts()).andReturn(serviceComponentHosts).anyTimes();
+    expect(serviceComponent2.getServiceComponentHosts()).andReturn(serviceComponentHosts).anyTimes();
+    expect(serviceComponent3.getServiceComponentHosts()).andReturn(serviceComponentHosts).anyTimes();
+
+
+    Capture<Map<String, String>> requestPropertiesCapture = new Capture<Map<String, String>>();
+    Capture<Map<State, List<Service>>> changedServicesCapture = new Capture<Map<State, List<Service>>>();
+    Capture<Map<State, List<ServiceComponent>>> changedCompsCapture = new Capture<Map<State, List<ServiceComponent>>>();
+    Capture<Map<String, Map<State, List<ServiceComponentHost>>>> changedScHostsCapture = new Capture<Map<String, Map<State, List<ServiceComponentHost>>>>();
+    Capture<Map<String, String>> requestParametersCapture = new Capture<Map<String, String>>();
+    Capture<Collection<ServiceComponentHost>> ignoredScHostsCapture = new Capture<Collection<ServiceComponentHost>>();
+    Capture<Cluster> clusterCapture = new Capture<Cluster>();
+
+    expect(managementController.createStages(capture(clusterCapture), capture(requestPropertiesCapture), capture(requestParametersCapture), capture(changedServicesCapture), capture(changedCompsCapture), capture(changedScHostsCapture), capture(ignoredScHostsCapture), anyBoolean(), anyBoolean()
+    )).andReturn(requestStatusResponse);
+
+
 
     Map<String, String> mapRequestProps = new HashMap<String, String>();
     mapRequestProps.put("context", "Called from a test");
 
-    Set<ServiceComponentResponse> nameResponse = new HashSet<ServiceComponentResponse>();
-    nameResponse.add(new ServiceComponentResponse(102L, "Cluster102", "Service", "Component", null, "1", "STARTED"));
-
-    // set expectations
-    expect(managementController.getComponents(EasyMock.<Set<ServiceComponentRequest>>anyObject())).
-        andReturn(nameResponse).once();
-    expect(managementController.updateComponents(
-        AbstractResourceProviderTest.Matcher.getComponentRequestSet(
-            "Cluster102", "Service", "Component", null, "STARTED"), eq(mapRequestProps), eq(false))).andReturn(response).once();
 
     // replay
-    replay(managementController, response);
+    replay(managementController, clusters, cluster, ambariMetaInfo, service,
+        serviceComponent1, serviceComponent2, serviceComponent3, serviceComponentHost,
+        requestStatusResponse, stackId);
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
@@ -171,17 +299,20 @@ public class ComponentResourceProviderTest {
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
 
     properties.put(ComponentResourceProvider.COMPONENT_STATE_PROPERTY_ID, "STARTED");
+    properties.put(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID, "Cluster100");
 
     // create the request
     Request request = PropertyHelper.getUpdateRequest(properties, mapRequestProps);
 
     // update the cluster named Cluster102
-    Predicate predicate = new PredicateBuilder().property(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID).
-        equals("Cluster102").toPredicate();
+    Predicate predicate = new PredicateBuilder().property(ComponentResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID).
+        equals("Cluster100").toPredicate();
     provider.updateResources(request, predicate);
 
     // verify
-    verify(managementController, response);
+    verify(managementController, clusters, cluster, ambariMetaInfo, service,
+        serviceComponent1, serviceComponent2, serviceComponent3, serviceComponentHost,
+        requestStatusResponse, stackId);
   }
 
   @Test
@@ -189,14 +320,9 @@ public class ComponentResourceProviderTest {
     Resource.Type type = Resource.Type.Component;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
-    RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
-
-    // set expectations
-    expect(managementController.deleteComponents(AbstractResourceProviderTest.Matcher.
-        getComponentRequestSet(null, null, "Component100", null, null))).andReturn(response);
 
     // replay
-    replay(managementController, response);
+    replay(managementController);
 
     ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
@@ -210,17 +336,203 @@ public class ComponentResourceProviderTest {
 
     Predicate  predicate = new PredicateBuilder().property(
         ComponentResourceProvider.COMPONENT_COMPONENT_NAME_PROPERTY_ID).equals("Component100").toPredicate();
-    provider.deleteResources(predicate);
+    try {
+      provider.deleteResources(predicate);
+      Assert.fail("Expected exception.");
+    } catch (Exception e) {
+      // expected
+    }
+
+    // verify
+    verify(managementController);
+  }
 
+  @Test
+  public void testGetComponents() throws Exception {
+    // member state mocks
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    Clusters clusters = createNiceMock(Clusters.class);
+    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
+    StackId stackId = createNiceMock(StackId.class);
+
+    Cluster cluster = createNiceMock(Cluster.class);
+    Service service = createNiceMock(Service.class);
+    ServiceComponent component = createNiceMock(ServiceComponent.class);
+    ServiceComponentResponse response = createNiceMock(ServiceComponentResponse.class);
+
+    // requests
+    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
+        Collections.<String, String>emptyMap(), null);
+
+    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    setRequests.add(request1);
+
+    // expectations
+    // constructor init
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
+    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
+
+    // getComponents
+    expect(clusters.getCluster("cluster1")).andReturn(cluster);
+    expect(cluster.getService("service1")).andReturn(service);
+    expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes();
+    expect(service.getServiceComponent("component1")).andReturn(component);
+
+    expect(component.convertToResponse()).andReturn(response);
+    // replay mocks
+    replay(clusters, cluster, service, component, response, ambariMetaInfo, stackId, managementController);
+
+    //test
+//    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
+    Set<ServiceComponentResponse> setResponses = getComponentResourceProvider(managementController).getComponents(setRequests);
+
+    // assert and verify
+    assertEquals(1, setResponses.size());
+    assertTrue(setResponses.contains(response));
+
+    verify(clusters, cluster, service, component, response, ambariMetaInfo, stackId, managementController);
+  }
 
-    ResourceProviderEvent lastEvent = observer.getLastEvent();
-    Assert.assertNotNull(lastEvent);
-    Assert.assertEquals(Resource.Type.Component, lastEvent.getResourceType());
-    Assert.assertEquals(ResourceProviderEvent.Type.Delete, lastEvent.getType());
-    Assert.assertEquals(predicate, lastEvent.getPredicate());
-    Assert.assertNull(lastEvent.getRequest());
+  /**
+   * Ensure that ServiceComponentNotFoundException is handled where there are multiple requests as would be the
+   * case when an OR predicate is provided in the query.
+   */
+  @Test
+  public void testGetComponents___OR_Predicate_ServiceComponentNotFoundException() throws Exception {
+    // member state mocks
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+    Clusters clusters = createNiceMock(Clusters.class);
+    AmbariMetaInfo ambariMetaInfo = createNiceMock(AmbariMetaInfo.class);
+    StackId stackId = createNiceMock(StackId.class);
+
+    Cluster cluster = createNiceMock(Cluster.class);
+    Service service = createNiceMock(Service.class);
+    ServiceComponent component1 = createNiceMock(ServiceComponent.class);
+    ServiceComponent component2 = createNiceMock(ServiceComponent.class);
+    ServiceComponentResponse response1 = createNiceMock(ServiceComponentResponse.class);
+    ServiceComponentResponse response2 = createNiceMock(ServiceComponentResponse.class);
+
+    // requests
+    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
+        Collections.<String, String>emptyMap(), null);
+    ServiceComponentRequest request2 = new ServiceComponentRequest("cluster1", "service1", "component2",
+        Collections.<String, String>emptyMap(), null);
+    ServiceComponentRequest request3 = new ServiceComponentRequest("cluster1", "service1", "component3",
+        Collections.<String, String>emptyMap(), null);
+    ServiceComponentRequest request4 = new ServiceComponentRequest("cluster1", "service1", "component4",
+        Collections.<String, String>emptyMap(), null);
+
+    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    setRequests.add(request1);
+    setRequests.add(request2);
+    setRequests.add(request3);
+    setRequests.add(request4);
+
+    // expectations
+    // constructor init
+    expect(managementController.getClusters()).andReturn(clusters).anyTimes();
+    expect(managementController.getAmbariMetaInfo()).andReturn(ambariMetaInfo).anyTimes();
+
+    // getComponents
+    expect(clusters.getCluster("cluster1")).andReturn(cluster).times(4);
+    expect(cluster.getDesiredStackVersion()).andReturn(stackId).anyTimes();
+    expect(cluster.getService("service1")).andReturn(service).times(4);
+
+    expect(service.getServiceComponent("component1")).andThrow(new ServiceComponentNotFoundException("cluster1", "service1", "component1"));
+    expect(service.getServiceComponent("component2")).andThrow(new ServiceComponentNotFoundException("cluster1", "service1", "component2"));
+    expect(service.getServiceComponent("component3")).andReturn(component1);
+    expect(service.getServiceComponent("component4")).andReturn(component2);
+
+    expect(component1.convertToResponse()).andReturn(response1);
+    expect(component2.convertToResponse()).andReturn(response2);
+    // replay mocks
+    replay(clusters, cluster, service, component1,  component2, response1, response2, ambariMetaInfo, stackId, managementController);
+
+    //test
+    Set<ServiceComponentResponse> setResponses = getComponentResourceProvider(managementController).getComponents(setRequests);
+
+    // assert and verify
+    assertEquals(2, setResponses.size());
+    assertTrue(setResponses.contains(response1));
+    assertTrue(setResponses.contains(response2));
+
+    verify(clusters, cluster, service, component1,  component2, response1, response2, ambariMetaInfo, stackId, managementController);
+  }
 
-    // verify
-    verify(managementController, response);
+  public static ComponentResourceProvider getComponentResourceProvider(AmbariManagementController managementController) {
+    Resource.Type type = Resource.Type.Component;
+
+    return (ComponentResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
+        type,
+        PropertyHelper.getPropertyIds(type),
+        PropertyHelper.getKeyPropertyIds(type),
+        managementController);
+  }
+
+  /**
+   * Ensure that ServiceComponentNotFoundException is propagated in case where there is a single request.
+   */
+  @Test
+  public void testGetComponents___ServiceComponentNotFoundException() throws Exception {
+    // member state mocks
+    Injector injector = createStrictMock(Injector.class);
+    Capture<AmbariManagementController> controllerCapture = new Capture<AmbariManagementController>();
+    Clusters clusters = createNiceMock(Clusters.class);
+
+    Cluster cluster = createNiceMock(Cluster.class);
+    Service service = createNiceMock(Service.class);
+
+    // requests
+    ServiceComponentRequest request1 = new ServiceComponentRequest("cluster1", "service1", "component1",
+        Collections.<String, String>emptyMap(), null);
+
+    Set<ServiceComponentRequest> setRequests = new HashSet<ServiceComponentRequest>();
+    setRequests.add(request1);
+
+    // expectations
+    // constructor init
+    injector.injectMembers(capture(controllerCapture));
+    expect(injector.getInstance(Gson.class)).andReturn(null);
+
+    // getComponents
+    expect(clusters.getCluster("cluster1")).andReturn(cluster);
+    expect(cluster.getService("service1")).andReturn(service);
+    expect(service.getServiceComponent("component1")).andThrow(
+        new ServiceComponentNotFoundException("cluster1", "service1", "component1"));
+    // replay mocks
+    replay(injector, clusters, cluster, service);
+
+    //test
+    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
+
+    // assert that exception is thrown in case where there is a single request
+    try {
+      getComponentResourceProvider(controller).getComponents(setRequests);
+      fail("expected ServiceComponentNotFoundException");
+    } catch (ServiceComponentNotFoundException e) {
+      // expected
+    }
+
+    assertSame(controller, controllerCapture.getValue());
+    verify(injector, clusters, cluster, service);
+  }
+
+  public static void createComponents(AmbariManagementController controller, Set<ServiceComponentRequest> requests) throws AmbariException {
+    ComponentResourceProvider provider = getComponentResourceProvider(controller);
+    provider.createComponents(requests);
+  }
+
+  public static Set<ServiceComponentResponse> getComponents(AmbariManagementController controller,
+                                                 Set<ServiceComponentRequest> requests) throws AmbariException {
+    ComponentResourceProvider provider = getComponentResourceProvider(controller);
+    return provider.getComponents(requests);
+  }
+
+  public static RequestStatusResponse updateComponents(AmbariManagementController controller,
+                                                     Set<ServiceComponentRequest> requests,
+                                                     Map<String, String> requestProperties, boolean runSmokeTest) throws AmbariException
+  {
+    ComponentResourceProvider provider = getComponentResourceProvider(controller);
+    return provider.updateComponents(requests, requestProperties, runSmokeTest);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/8b0fc1cb/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
index b19d4ce..b15a203 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/JMXHostProviderTest.java
@@ -89,7 +89,7 @@ public class JMXHostProviderTest {
     Set<ServiceComponentRequest> requests =
       new HashSet<ServiceComponentRequest>();
     requests.add(r);
-    controller.createComponents(requests);
+    ComponentResourceProviderTest.createComponents(controller, requests);
   }
 
   private void createServiceComponentHost(String clusterName,