You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by hi...@apache.org on 2012/10/25 02:34:32 UTC

svn commit: r1401933 - in /incubator/ambari/branches/AMBARI-666: ./ ambari-server/src/main/java/org/apache/ambari/server/controller/ ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/ ambari-server/src/test/java/org/apache/ambari/ser...

Author: hitesh
Date: Thu Oct 25 00:34:31 2012
New Revision: 1401933

URL: http://svn.apache.org/viewvc?rev=1401933&view=rev
Log:
AMBARI-907. Add support for getting multiple objects in controller. (Contributed by hitesh)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCManagementController.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Thu Oct 25 00:34:31 2012
@@ -12,6 +12,9 @@ AMBARI-666 branch (unreleased changes)
 
   NEW FEATURES
 
+  AMBARI-907. Add support for getting multiple objects in controller.
+  (hitesh)
+
   AMBARI-906. Util to extract hosts for various components. (jitendra)
 
   AMBARI-903. Various fixes for config handling integration. (Hitesh Shah via 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java Thu Oct 25 00:34:31 2012
@@ -103,6 +103,8 @@ public interface AmbariManagementControl
    */
   public Set<ClusterResponse> getClusters(ClusterRequest request)
       throws AmbariException;
+  public Set<ClusterResponse> getClusters(Set<ClusterRequest> requests)
+      throws AmbariException;
 
   /**
    * Get the services identified by the given request object.
@@ -116,6 +118,8 @@ public interface AmbariManagementControl
    */
   public Set<ServiceResponse> getServices(ServiceRequest request)
       throws AmbariException;
+  public Set<ServiceResponse> getServices(Set<ServiceRequest> requests)
+      throws AmbariException;
 
   /**
    * Get the components identified by the given request object.
@@ -128,6 +132,8 @@ public interface AmbariManagementControl
    */
   public Set<ServiceComponentResponse> getComponents(
       ServiceComponentRequest request) throws AmbariException;
+  public Set<ServiceComponentResponse> getComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException;
 
   /**
    * Get the hosts identified by the given request object.
@@ -138,7 +144,10 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException thrown if the resource cannot be read
    */
-  public Set<HostResponse> getHosts(HostRequest request) throws AmbariException;
+  public Set<HostResponse> getHosts(HostRequest request)
+      throws AmbariException;
+  public Set<HostResponse> getHosts(Set<HostRequest> requests)
+      throws AmbariException;
 
   /**
    * Get the host components identified by the given request object.
@@ -152,6 +161,8 @@ public interface AmbariManagementControl
    */
   public Set<ServiceComponentHostResponse> getHostComponents(
       ServiceComponentHostRequest request) throws AmbariException;
+  public Set<ServiceComponentHostResponse> getHostComponents(
+      Set<ServiceComponentHostRequest> requests) throws AmbariException;
 
   /**
    * Gets the configurations identified by the given request object.
@@ -162,7 +173,10 @@ public interface AmbariManagementControl
    *
    * @throws AmbariException if the configurations could not be read
    */
-  public Set<ConfigurationResponse> getConfigurations(ConfigurationRequest request) throws AmbariException;
+  public Set<ConfigurationResponse> getConfigurations(
+      ConfigurationRequest request) throws AmbariException;
+  public Set<ConfigurationResponse> getConfigurations(
+      Set<ConfigurationRequest> requests) throws AmbariException;
 
 
   // ----- Update -----------------------------------------------------------

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Thu Oct 25 00:34:31 2012
@@ -37,6 +37,7 @@ import org.apache.ambari.server.ServiceC
 import org.apache.ambari.server.actionmanager.ActionManager;
 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.metadata.RoleCommandOrder;
 import org.apache.ambari.server.stageplanner.RoleGraph;
 import org.apache.ambari.server.state.Cluster;
@@ -1174,52 +1175,60 @@ public class AmbariManagementControllerI
         for (ServiceComponentHost scHost :
             changedScHosts.get(compName).get(newState)) {
           RoleCommand roleCommand;
-          State oldSchState = scHost.getDesiredState();
+          State oldSchState = scHost.getState();
           ServiceComponentHostEvent event;
           switch(newState) {
             case INSTALLED:
               if (oldSchState == State.INIT
                   || oldSchState == State.UNINSTALLED
-                  || oldSchState == State.INSTALLED) {
+                  || oldSchState == State.INSTALLED
+                  || oldSchState == State.INSTALL_FAILED) {
                 roleCommand = RoleCommand.INSTALL;
                 event = new ServiceComponentHostInstallEvent(
                     scHost.getServiceComponentName(), scHost.getHostName(),
                     nowTimestamp);
-              } else if (oldSchState == State.STARTED) {
+              } else if (oldSchState == State.STARTED
+                  || oldSchState == State.STOP_FAILED) {
                 roleCommand = RoleCommand.STOP;
                 event = new ServiceComponentHostStopEvent(
                     scHost.getServiceComponentName(), scHost.getHostName(),
                     nowTimestamp);
               } else {
                 // FIXME throw correct error
-                throw new AmbariException("Invalid transition for "
+                throw new AmbariException("Invalid transition for"
+                    + " servicecomponenthost"
                     + ", clusterName=" + cluster.getClusterName()
                     + ", clusterId=" + cluster.getClusterId()
                     + ", serviceName=" + scHost.getServiceName()
                     + ", componentName=" + scHost.getServiceComponentName()
                     + ", hostname=" + scHost.getHostName()
-                    + ", currentDesiredState=" + oldSchState
-                    + ", newDesiredState" + newState);
+                    + ", currentState=" + oldSchState
+                    + ", newDesiredState=" + newState);
               }
               break;
             case STARTED:
-              if (oldSchState == State.INSTALLED) {
+              if (oldSchState == State.INSTALLED
+                  || oldSchState == State.START_FAILED) {
                 roleCommand = RoleCommand.START;
                 event = new ServiceComponentHostStartEvent(
                     scHost.getServiceComponentName(), scHost.getHostName(),
                     nowTimestamp);
               } else {
                 // FIXME throw correct error
-                throw new AmbariException("Invalid transition for "
+                throw new AmbariException("Invalid transition for"
+                    + " servicecomponenthost"
                     + ", clusterName=" + cluster.getClusterName()
                     + ", clusterId=" + cluster.getClusterId()
                     + ", serviceName=" + scHost.getServiceName()
                     + ", componentName=" + scHost.getServiceComponentName()
                     + ", hostname=" + scHost.getHostName()
-                    + ", currentDesiredState=" + oldSchState
-                    + ", newDesiredState" + newState);
+                    + ", currentState=" + oldSchState
+                    + ", newDesiredState=" + newState);
               }
               break;
+            case INIT:
+            case UNINSTALLED:
+              throw new AmbariException("Uninstall is currently not supported");
             default:
               // TODO fix handling other transitions
               throw new AmbariException("Unsupported state change operation");
@@ -1284,7 +1293,45 @@ public class AmbariManagementControllerI
     return new TrackActionResponse(requestId);
   }
 
-  private boolean isValidTransition(State oldState, State newState) {
+  private boolean isValidStateTransition(State oldState,
+      State newState) {
+    switch(newState) {
+      case INSTALLED:
+        if (oldState == State.INIT
+            || oldState == State.UNINSTALLED
+            || oldState == State.INSTALLED
+            || oldState == State.STARTED
+            || oldState == State.INSTALL_FAILED
+            || oldState == State.STOP_FAILED) {
+          return true;
+        }
+        break;
+      case STARTED:
+        if (oldState == State.INSTALLED
+            || oldState == State.STARTED
+            || oldState == State.START_FAILED) {
+          return true;
+        }
+        break;
+      case UNINSTALLED:
+        if (oldState == State.INSTALLED
+            || oldState == State.UNINSTALLED
+            || oldState == State.UNINSTALL_FAILED) {
+          return true;
+        }
+      case INIT:
+        if (oldState == State.UNINSTALLED
+            || oldState == State.INIT
+            || oldState == State.WIPEOUT_FAILED) {
+          return true;
+        }
+    }
+    return false;
+  }
+
+
+  private boolean isValidDesiredStateTransition(State oldState,
+      State newState) {
     switch(newState) {
       case INSTALLED:
         if (oldState == State.INIT
@@ -1306,17 +1353,17 @@ public class AmbariManagementControllerI
 
   private void safeToUpdateConfigsForServiceComponentHost(
       ServiceComponentHost sch,
-      State currentDesiredState, State newDesiredState)
+      State currentState, State newDesiredState)
           throws AmbariException {
-    if (currentDesiredState == State.STARTED) {
+    if (currentState == State.STARTED) {
       throw new AmbariException("Changing of configs not supported"
           + " in STARTED state"
           + ", clusterName=" + sch.getClusterName()
           + ", serviceName=" + sch.getServiceName()
           + ", componentName=" + sch.getServiceComponentName()
           + ", hostname=" + sch.getHostName()
-          + ", currentDesiredState=" + currentDesiredState
-          + ", newDesiredState" + newDesiredState);
+          + ", currentState=" + currentState
+          + ", newDesiredState=" + newDesiredState);
     }
 
     if (newDesiredState != null) {
@@ -1329,8 +1376,8 @@ public class AmbariManagementControllerI
             + ", serviceName=" + sch.getServiceName()
             + ", componentName=" + sch.getServiceComponentName()
             + ", hostname=" + sch.getHostName()
-            + ", currentDesiredState=" + currentDesiredState
-            + ", newDesiredState" + newDesiredState);
+            + ", currentState=" + currentState
+            + ", newDesiredState=" + newDesiredState);
       }
     }
   }
@@ -1346,7 +1393,7 @@ public class AmbariManagementControllerI
           + ", serviceName=" + sc.getServiceName()
           + ", componentName=" + sc.getName()
           + ", currentDesiredState=" + currentDesiredState
-          + ", newDesiredState" + newDesiredState);
+          + ", newDesiredState=" + newDesiredState);
     }
 
     if (newDesiredState != null) {
@@ -1359,13 +1406,13 @@ public class AmbariManagementControllerI
             + ", serviceName=" + sc.getServiceName()
             + ", componentName=" + sc.getName()
             + ", currentDesiredState=" + currentDesiredState
-            + ", newDesiredState" + newDesiredState);
+            + ", newDesiredState=" + newDesiredState);
       }
     }
     for (ServiceComponentHost sch :
       sc.getServiceComponentHosts().values()) {
       safeToUpdateConfigsForServiceComponentHost(sch,
-        sch.getDesiredState(), newDesiredState);
+        sch.getState(), newDesiredState);
     }
   }
 
@@ -1378,7 +1425,7 @@ public class AmbariManagementControllerI
           + ", clusterName=" + service.getCluster().getClusterName()
           + ", serviceName=" + service.getName()
           + ", currentDesiredState=" + currentDesiredState
-          + ", newDesiredState" + newDesiredState);
+          + ", newDesiredState=" + newDesiredState);
     }
 
     if (newDesiredState != null) {
@@ -1390,7 +1437,7 @@ public class AmbariManagementControllerI
             + ", clusterName=" + service.getCluster().getClusterName()
             + ", serviceName=" + service.getName()
             + ", currentDesiredState=" + currentDesiredState
-            + ", newDesiredState" + newDesiredState);
+            + ", newDesiredState=" + newDesiredState);
       }
     }
 
@@ -1510,14 +1557,15 @@ public class AmbariManagementControllerI
       seenNewStates.add(newState);
 
       if (newState != oldState) {
-        if (!isValidTransition(oldState, newState)) {
+        if (!isValidDesiredStateTransition(oldState, newState)) {
           // FIXME throw correct error
-          throw new AmbariException("Invalid transition for "
+          throw new AmbariException("Invalid transition for"
+              + " service"
               + ", clusterName=" + cluster.getClusterName()
               + ", clusterId=" + cluster.getClusterId()
               + ", serviceName=" + s.getName()
               + ", currentDesiredState=" + oldState
-              + ", newDesiredState" + newState);
+              + ", newDesiredState=" + newState);
 
         }
         if (!changedServices.containsKey(newState)) {
@@ -1542,15 +1590,16 @@ public class AmbariManagementControllerI
               !newState.isValidClientComponentState()) {
             continue;
           }
-          if (!isValidTransition(oldScState, newState)) {
+          if (!isValidDesiredStateTransition(oldScState, newState)) {
             // FIXME throw correct error
-            throw new AmbariException("Invalid transition for "
+            throw new AmbariException("Invalid transition for"
+                + " servicecomponent"
                 + ", clusterName=" + cluster.getClusterName()
                 + ", clusterId=" + cluster.getClusterId()
                 + ", serviceName=" + sc.getServiceName()
                 + ", componentName=" + sc.getName()
                 + ", currentDesiredState=" + oldScState
-                + ", newDesiredState" + newState);
+                + ", newDesiredState=" + newState);
           }
           if (!changedComps.containsKey(newState)) {
             changedComps.put(newState, new ArrayList<ServiceComponent>());
@@ -1566,15 +1615,16 @@ public class AmbariManagementControllerI
               + ", newDesiredState=" + newState);
         }
         for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()){
-          State oldSchState = sch.getDesiredState();
+          State oldSchState = sch.getState();
           if (newState == oldSchState) {
+            sch.setDesiredState(newState);
             if (LOG.isDebugEnabled()) {
               LOG.debug("Ignoring ServiceComponentHost"
                   + ", clusterName=" + request.getClusterName()
                   + ", serviceName=" + s.getName()
                   + ", componentName=" + sc.getName()
                   + ", hostname=" + sch.getHostName()
-                  + ", currentDesiredState=" + oldSchState
+                  + ", currentState=" + oldSchState
                   + ", newDesiredState=" + newState);
             }
             continue;
@@ -1583,16 +1633,17 @@ public class AmbariManagementControllerI
               !newState.isValidClientComponentState()) {
             continue;
           }
-          if (!isValidTransition(oldSchState, newState)) {
+          if (!isValidStateTransition(oldSchState, newState)) {
             // FIXME throw correct error
-            throw new AmbariException("Invalid transition for "
+            throw new AmbariException("Invalid transition for"
+                + " servicecomponenthost"
                 + ", clusterName=" + cluster.getClusterName()
                 + ", clusterId=" + cluster.getClusterId()
                 + ", serviceName=" + sch.getServiceName()
                 + ", componentName=" + sch.getServiceComponentName()
                 + ", hostname=" + sch.getHostName()
-                + ", currentDesiredState=" + oldSchState
-                + ", newDesiredState" + newState);
+                + ", currentState=" + oldSchState
+                + ", newDesiredState=" + newState);
           }
           if (!changedScHosts.containsKey(sc.getName())) {
             changedScHosts.put(sc.getName(),
@@ -1608,7 +1659,7 @@ public class AmbariManagementControllerI
                 + ", serviceName=" + s.getName()
                 + ", componentName=" + sc.getName()
                 + ", hostname=" + sch.getHostName()
-                + ", currentDesiredState=" + oldSchState
+                + ", currentState=" + oldSchState
                 + ", newDesiredState=" + newState);
           }
           changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -1779,15 +1830,16 @@ public class AmbariManagementControllerI
 
       State oldScState = sc.getDesiredState();
       if (newState != oldScState) {
-        if (!isValidTransition(oldScState, newState)) {
+        if (!isValidDesiredStateTransition(oldScState, newState)) {
           // FIXME throw correct error
-          throw new AmbariException("Invalid transition for "
+          throw new AmbariException("Invalid transition for"
+              + " servicecomponent"
               + ", clusterName=" + cluster.getClusterName()
               + ", clusterId=" + cluster.getClusterId()
               + ", serviceName=" + sc.getServiceName()
               + ", componentName=" + sc.getName()
               + ", currentDesiredState=" + oldScState
-              + ", newDesiredState" + newState);
+              + ", newDesiredState=" + newState);
         }
         if (!changedComps.containsKey(newState)) {
           changedComps.put(newState, new ArrayList<ServiceComponent>());
@@ -1808,29 +1860,31 @@ public class AmbariManagementControllerI
       // at some point do we need to do stuff based on live state?
 
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
-        State oldSchState = sch.getDesiredState();
+        State oldSchState = sch.getState();
         if (newState == oldSchState) {
+          sch.setDesiredState(newState);
           if (LOG.isDebugEnabled()) {
             LOG.debug("Ignoring ServiceComponentHost"
                 + ", clusterName=" + request.getClusterName()
                 + ", serviceName=" + s.getName()
                 + ", componentName=" + sc.getName()
                 + ", hostname=" + sch.getHostName()
-                + ", currentDesiredState=" + oldSchState
+                + ", currentState=" + oldSchState
                 + ", newDesiredState=" + newState);
           }
           continue;
         }
-        if (!isValidTransition(oldSchState, newState)) {
+        if (!isValidStateTransition(oldSchState, newState)) {
           // FIXME throw correct error
-          throw new AmbariException("Invalid transition for "
+          throw new AmbariException("Invalid transition for"
+              + " servicecomponenthost"
               + ", clusterName=" + cluster.getClusterName()
               + ", clusterId=" + cluster.getClusterId()
               + ", serviceName=" + sch.getServiceName()
               + ", componentName=" + sch.getServiceComponentName()
               + ", hostname=" + sch.getHostName()
-              + ", currentDesiredState=" + oldSchState
-              + ", newDesiredState" + newState);
+              + ", currentState=" + oldSchState
+              + ", newDesiredState=" + newState);
         }
         if (!changedScHosts.containsKey(sc.getName())) {
           changedScHosts.put(sc.getName(),
@@ -1846,7 +1900,7 @@ public class AmbariManagementControllerI
               + ", serviceName=" + s.getName()
               + ", componentName=" + sc.getName()
               + ", hostname=" + sch.getHostName()
-              + ", currentDesiredState=" + oldSchState
+              + ", currentState=" + oldSchState
               + ", newDesiredState=" + newState);
         }
         changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -2010,7 +2064,7 @@ public class AmbariManagementControllerI
         request.getComponentName());
       ServiceComponentHost sch = sc.getServiceComponentHost(
         request.getHostname());
-      State oldState = sch.getDesiredState();
+      State oldState = sch.getState();
       State newState = null;
       if (request.getDesiredState() != null) {
         newState = State.valueOf(request.getDesiredState());
@@ -2065,30 +2119,32 @@ public class AmbariManagementControllerI
 
       seenNewStates.add(newState);
 
-      State oldSchState = sch.getDesiredState();
+      State oldSchState = sch.getState();
       if (newState == oldSchState) {
+        sch.setDesiredState(newState);
         if (LOG.isDebugEnabled()) {
           LOG.debug("Ignoring ServiceComponentHost"
               + ", clusterName=" + request.getClusterName()
               + ", serviceName=" + s.getName()
               + ", componentName=" + sc.getName()
               + ", hostname=" + sch.getHostName()
-              + ", currentDesiredState=" + oldSchState
+              + ", currentState=" + oldSchState
               + ", newDesiredState=" + newState);
         }
         continue;
       }
 
-      if (!isValidTransition(oldSchState, newState)) {
+      if (!isValidStateTransition(oldSchState, newState)) {
         // FIXME throw correct error
-        throw new AmbariException("Invalid transition for "
+        throw new AmbariException("Invalid transition for"
+            + " servicecomponenthost"
             + ", clusterName=" + cluster.getClusterName()
             + ", clusterId=" + cluster.getClusterId()
             + ", serviceName=" + sch.getServiceName()
             + ", componentName=" + sch.getServiceComponentName()
             + ", hostname=" + sch.getHostName()
-            + ", currentDesiredState=" + oldSchState
-            + ", newDesiredState" + newState);
+            + ", currentState=" + oldSchState
+            + ", newDesiredState=" + newState);
       }
       if (!changedScHosts.containsKey(sc.getName())) {
         changedScHosts.put(sc.getName(),
@@ -2104,7 +2160,7 @@ public class AmbariManagementControllerI
             + ", serviceName=" + s.getName()
             + ", componentName=" + sc.getName()
             + ", hostname=" + sch.getHostName()
-            + ", currentDesiredState=" + oldSchState
+            + ", currentState=" + oldSchState
             + ", newDesiredState=" + newState);
       }
       changedScHosts.get(sc.getName()).get(newState).add(sch);
@@ -2209,4 +2265,67 @@ public class AmbariManagementControllerI
 
   }
 
+  @Override
+  public Set<ClusterResponse> getClusters(Set<ClusterRequest> requests)
+      throws AmbariException {
+    Set<ClusterResponse> response = new HashSet<ClusterResponse>();
+    for (ClusterRequest request : requests) {
+      response.addAll(getClusters(request));
+    }
+    return response;
+  }
+
+  @Override
+  public Set<ServiceResponse> getServices(Set<ServiceRequest> requests)
+      throws AmbariException {
+    Set<ServiceResponse> response = new HashSet<ServiceResponse>();
+    for (ServiceRequest request : requests) {
+      response.addAll(getServices(request));
+    }
+    return response;
+  }
+
+  @Override
+  public Set<ServiceComponentResponse> getComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException {
+    Set<ServiceComponentResponse> response =
+        new HashSet<ServiceComponentResponse>();
+    for (ServiceComponentRequest request : requests) {
+      response.addAll(getComponents(request));
+    }
+    return response;
+  }
+
+  @Override
+  public Set<HostResponse> getHosts(Set<HostRequest> requests)
+      throws AmbariException {
+    Set<HostResponse> response = new HashSet<HostResponse>();
+    for (HostRequest request : requests) {
+      response.addAll(getHosts(request));
+    }
+    return response;
+  }
+
+  @Override
+  public Set<ServiceComponentHostResponse> getHostComponents(
+      Set<ServiceComponentHostRequest> requests) throws AmbariException {
+    Set<ServiceComponentHostResponse> response =
+        new HashSet<ServiceComponentHostResponse>();
+    for (ServiceComponentHostRequest request : requests) {
+      response.addAll(getHostComponents(request));
+    }
+    return response;
+  }
+
+  @Override
+  public Set<ConfigurationResponse> getConfigurations(
+      Set<ConfigurationRequest> requests) throws AmbariException {
+    Set<ConfigurationResponse> response =
+        new HashSet<ConfigurationResponse>();
+    for (ConfigurationRequest request : requests) {
+      response.addAll(getConfigurations(request));
+    }
+    return response;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ClusterResponse.java Thu Oct 25 00:34:31 2012
@@ -77,4 +77,31 @@ public class ClusterResponse {
     sb.append("] }");
     return sb.toString();
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ClusterResponse that = (ClusterResponse) o;
+
+    if (clusterId != null ?
+        !clusterId.equals(that.clusterId) : that.clusterId != null) {
+      return false;
+    }
+    if (clusterName != null ?
+        !clusterName.equals(that.clusterName) : that.clusterName != null) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null ? clusterId.intValue() : 0;
+    result = 71 * result + (clusterName != null ? clusterName.hashCode() : 0);
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ConfigurationResponse.java Thu Oct 25 00:34:31 2012
@@ -88,4 +88,37 @@ public class ConfigurationResponse {
   public String getClusterName() {
     return clusterName;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ConfigurationResponse that =
+        (ConfigurationResponse) o;
+
+    if (clusterName != null ?
+        !clusterName.equals(that.clusterName) : that.clusterName != null) {
+      return false;
+    }
+    if (type != null ?
+        !type.equals(that.type) : that.type != null) {
+      return false;
+    }
+    if (versionTag != null ?
+        !versionTag.equals(that.versionTag) : that.versionTag != null){
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterName != null ? clusterName.hashCode() : 0;
+    result = 71 * result + (type != null ? type.hashCode() : 0);
+    result = 71 * result + (versionTag != null ? versionTag.hashCode():0);
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostRequest.java Thu Oct 25 00:34:31 2012
@@ -89,4 +89,5 @@ public class HostRequest {
     sb.append("] }");
     return sb.toString();
   }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/HostResponse.java Thu Oct 25 00:34:31 2012
@@ -384,4 +384,26 @@ public class HostResponse {
   public void setHealthStatus(HostHealthStatus healthStatus) {
     this.healthStatus = healthStatus;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    HostResponse that = (HostResponse) o;
+
+    if (hostname != null ?
+        !hostname.equals(that.hostname) : that.hostname != null) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = hostname != null ? hostname.hashCode() : 0;
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentHostResponse.java Thu Oct 25 00:34:31 2012
@@ -165,4 +165,42 @@ public class ServiceComponentHostRespons
   public void setClusterName(String clusterName) {
     this.clusterName = clusterName;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceComponentHostResponse that =
+        (ServiceComponentHostResponse) o;
+
+    if (clusterName != null ?
+        !clusterName.equals(that.clusterName) : that.clusterName != null) {
+      return false;
+    }
+    if (serviceName != null ?
+        !serviceName.equals(that.serviceName) : that.serviceName != null) {
+      return false;
+    }
+    if (componentName != null ?
+        !componentName.equals(that.componentName) : that.componentName != null){
+      return false;
+    }
+    if (hostname != null ?
+        !hostname.equals(that.hostname) : that.hostname != null) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterName != null ? clusterName.hashCode() : 0;
+    result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 71 * result + (componentName != null ? componentName.hashCode():0);
+    result = 71 * result + (hostname != null ? hostname.hashCode() : 0);
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceComponentResponse.java Thu Oct 25 00:34:31 2012
@@ -150,4 +150,38 @@ public class ServiceComponentResponse {
   public void setDesiredStackVersion(String desiredStackVersion) {
     this.desiredStackVersion = desiredStackVersion;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceComponentResponse that =
+        (ServiceComponentResponse) o;
+
+    if (clusterName != null ?
+        !clusterName.equals(that.clusterName) : that.clusterName != null) {
+      return false;
+    }
+    if (serviceName != null ?
+        !serviceName.equals(that.serviceName) : that.serviceName != null) {
+      return false;
+    }
+    if (componentName != null ?
+        !componentName.equals(that.componentName) : that.componentName != null){
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null? clusterId.intValue() : 0;
+    result = 71 * result + (clusterName != null ? clusterName.hashCode() : 0);
+    result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    result = 71 * result + (componentName != null ? componentName.hashCode():0);
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/ServiceResponse.java Thu Oct 25 00:34:31 2012
@@ -131,4 +131,36 @@ public class ServiceResponse {
   public void setDesiredStackVersion(String desiredStackVersion) {
     this.desiredStackVersion = desiredStackVersion;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    ServiceResponse that = (ServiceResponse) o;
+
+    if (clusterId != null ?
+        !clusterId.equals(that.clusterId) : that.clusterId != null) {
+      return false;
+    }
+    if (clusterName != null ?
+        !clusterName.equals(that.clusterName) : that.clusterName != null) {
+      return false;
+    }
+    if (serviceName != null ?
+        !serviceName.equals(that.serviceName) : that.serviceName != null) {
+      return false;
+    }
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int result = clusterId != null? clusterId.intValue() : 0;
+    result = 71 * result + (clusterName != null ? clusterName.hashCode() : 0);
+    result = 71 * result + (serviceName != null ? serviceName.hashCode() : 0);
+    return result;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCManagementController.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCManagementController.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCManagementController.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/controller/jdbc/JDBCManagementController.java Thu Oct 25 00:34:31 2012
@@ -716,7 +716,49 @@ public class JDBCManagementController im
   public void getOperations(Set<OperationRequest> request)
       throws AmbariException {
     // TODO Auto-generated method stub
-    
+
+  }
+
+  @Override
+  public Set<ClusterResponse> getClusters(Set<ClusterRequest> requests)
+      throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Set<ServiceResponse> getServices(Set<ServiceRequest> requests)
+      throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Set<ServiceComponentResponse> getComponents(
+      Set<ServiceComponentRequest> requests) throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Set<HostResponse> getHosts(Set<HostRequest> requests)
+      throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Set<ServiceComponentHostResponse> getHostComponents(
+      Set<ServiceComponentHostRequest> requests) throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
+  }
+
+  @Override
+  public Set<ConfigurationResponse> getConfigurations(
+      Set<ConfigurationRequest> requests) throws AmbariException {
+    // TODO Auto-generated method stub
+    return null;
   }
 }
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java?rev=1401933&r1=1401932&r2=1401933&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java Thu Oct 25 00:34:31 2012
@@ -48,6 +48,7 @@ import org.apache.ambari.server.state.Se
 import org.apache.ambari.server.state.StackVersion;
 import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.utils.StageUtils;
+import org.apache.commons.collections.bag.HashBag;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -1210,6 +1211,7 @@ public class AmbariManagementControllerT
       Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
       for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
         Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
+        Assert.assertEquals(State.INIT, sch.getState());
       }
     }
 
@@ -1231,6 +1233,15 @@ public class AmbariManagementControllerT
       }
     }
 
+    // manually change live state to installed as no running action manager
+    for (ServiceComponent sc :
+      clusters.getCluster(clusterName).getService(serviceName)
+      .getServiceComponents().values()) {
+      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+        sch.setState(State.INSTALLED);
+      }
+    }
+
     ServiceRequest r2 = new ServiceRequest(clusterName, serviceName, null,
         State.STARTED.toString());
     Set<ServiceRequest> requests2 = new HashSet<ServiceRequest>();
@@ -1419,6 +1430,17 @@ public class AmbariManagementControllerT
     r = new ServiceRequest(c2.getClusterName(), null, null, "INIT");
     resp = controller.getServices(r);
     Assert.assertEquals(1, resp.size());
+
+    ServiceRequest r1, r2, r3;
+    r1 = new ServiceRequest(c1.getClusterName(), null, null, "INSTALLED");
+    r2 = new ServiceRequest(c2.getClusterName(), null, null, "INIT");
+    r3 = new ServiceRequest(c2.getClusterName(), null, null, "INIT");
+
+    Set<ServiceRequest> reqs = new HashSet<ServiceRequest>();
+    reqs.addAll(Arrays.asList(r1, r2, r3));
+    resp = controller.getServices(reqs);
+    Assert.assertEquals(3, resp.size());
+
   }
 
 
@@ -1563,6 +1585,17 @@ public class AmbariManagementControllerT
     Assert.assertEquals(sc5.getName(),
         resps.iterator().next().getComponentName());
 
+    ServiceComponentRequest r1, r2, r3;
+    Set<ServiceComponentRequest> reqs = new HashSet<ServiceComponentRequest>();
+    r1 = new ServiceComponentRequest(c2.getClusterName(),
+        null, null, null, State.UNINSTALLED.toString());
+    r2 = new ServiceComponentRequest(c1.getClusterName(),
+        null, null, null, null);
+    r3 = new ServiceComponentRequest(c1.getClusterName(),
+        null, null, null, State.INIT.toString());
+    reqs.addAll(Arrays.asList(r1, r2, r3));
+    resps = controller.getComponents(reqs);
+    Assert.assertEquals(7, resps.size());
   }
 
   @Test
@@ -1766,6 +1799,18 @@ public class AmbariManagementControllerT
     resps = controller.getHostComponents(r);
     Assert.assertEquals(1, resps.size());
 
+    ServiceComponentHostRequest r1, r2, r3;
+    r1 = new ServiceComponentHostRequest(c1.getClusterName(), null,
+        null, "h3", null, null);
+    r2 = new ServiceComponentHostRequest(c1.getClusterName(), s3.getName(),
+        sc3.getName(), "h2", null, null);
+    r3 = new ServiceComponentHostRequest(c1.getClusterName(), null,
+        null, "h2", null, null);
+    Set<ServiceComponentHostRequest> reqs =
+        new HashSet<ServiceComponentHostRequest>();
+    reqs.addAll(Arrays.asList(r1, r2, r3));
+    resps = controller.getHostComponents(reqs);
+    Assert.assertEquals(4, resps.size());
   }
 
   @Test
@@ -2016,6 +2061,11 @@ public class AmbariManagementControllerT
     sch3.setDesiredState(State.INSTALLED);
     sch4.setDesiredState(State.INSTALLED);
     sch5.setDesiredState(State.INSTALLED);
+    sch1.setState(State.INSTALLED);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.INSTALLED);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
 
     Set<ServiceRequest> reqs = new HashSet<ServiceRequest>();
     ServiceRequest req1, req2;
@@ -2035,11 +2085,16 @@ public class AmbariManagementControllerT
     sc1.setDesiredState(State.STARTED);
     sc2.setDesiredState(State.INSTALLED);
     sc3.setDesiredState(State.STARTED);
-    sch1.setDesiredState(State.INIT);
+    sch1.setDesiredState(State.INSTALLED);
     sch2.setDesiredState(State.INSTALLED);
-    sch3.setDesiredState(State.INIT);
+    sch3.setDesiredState(State.INSTALLED);
     sch4.setDesiredState(State.INSTALLED);
     sch5.setDesiredState(State.INSTALLED);
+    sch1.setState(State.INIT);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.INIT);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
 
     try {
       reqs.clear();
@@ -2057,11 +2112,16 @@ public class AmbariManagementControllerT
     sc1.setDesiredState(State.STARTED);
     sc2.setDesiredState(State.INSTALLED);
     sc3.setDesiredState(State.STARTED);
-    sch1.setDesiredState(State.INSTALLED);
-    sch2.setDesiredState(State.INSTALLED);
-    sch3.setDesiredState(State.INSTALLED);
+    sch1.setDesiredState(State.STARTED);
+    sch2.setDesiredState(State.STARTED);
+    sch3.setDesiredState(State.STARTED);
     sch4.setDesiredState(State.STARTED);
-    sch5.setDesiredState(State.INSTALLED);
+    sch5.setDesiredState(State.STARTED);
+    sch1.setState(State.INSTALLED);
+    sch2.setState(State.START_FAILED);
+    sch3.setState(State.INSTALLED);
+    sch4.setState(State.STARTED);
+    sch5.setState(State.INSTALLED);
 
     reqs.clear();
     req1 = new ServiceRequest(clusterName, serviceName1, null,
@@ -2082,6 +2142,11 @@ public class AmbariManagementControllerT
     Assert.assertEquals(State.STARTED, sch3.getDesiredState());
     Assert.assertEquals(State.STARTED, sch4.getDesiredState());
     Assert.assertEquals(State.STARTED, sch5.getDesiredState());
+    Assert.assertEquals(State.INSTALLED, sch1.getState());
+    Assert.assertEquals(State.START_FAILED, sch2.getState());
+    Assert.assertEquals(State.INSTALLED, sch3.getState());
+    Assert.assertEquals(State.STARTED, sch4.getState());
+    Assert.assertEquals(State.INSTALLED, sch5.getState());
 
     long requestId = trackAction.getRequestId();
     List<Stage> stages = actionDB.getAllStages(requestId);
@@ -2116,6 +2181,13 @@ public class AmbariManagementControllerT
     Assert.assertNotNull(stage2.getExecutionCommand(host1, "HBASE_MASTER"));
     Assert.assertNull(stage1.getExecutionCommand(host2, "DATANODE"));
 
+    // manually set live state
+    sch1.setState(State.STARTED);
+    sch2.setState(State.STARTED);
+    sch3.setState(State.STARTED);
+    sch4.setState(State.STARTED);
+    sch5.setState(State.STARTED);
+
     // test no-op
     reqs.clear();
     req1 = new ServiceRequest(clusterName, serviceName1, null,
@@ -2201,6 +2273,11 @@ public class AmbariManagementControllerT
     sch3.setDesiredState(State.STARTED);
     sch4.setDesiredState(State.INSTALLED);
     sch5.setDesiredState(State.INSTALLED);
+    sch1.setState(State.INSTALLED);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.STARTED);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
 
     Set<ServiceComponentRequest> reqs =
         new HashSet<ServiceComponentRequest>();
@@ -2221,10 +2298,15 @@ public class AmbariManagementControllerT
     sc2.setDesiredState(State.INSTALLED);
     sc3.setDesiredState(State.STARTED);
     sch1.setDesiredState(State.INIT);
-    sch2.setDesiredState(State.INSTALLED);
+    sch2.setDesiredState(State.INIT);
     sch3.setDesiredState(State.INIT);
-    sch4.setDesiredState(State.INSTALLED);
-    sch5.setDesiredState(State.INSTALLED);
+    sch4.setDesiredState(State.INIT);
+    sch5.setDesiredState(State.INIT);
+    sch1.setState(State.INIT);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.INIT);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
 
     try {
       reqs.clear();
@@ -2241,11 +2323,16 @@ public class AmbariManagementControllerT
     sc1.setDesiredState(State.STARTED);
     sc2.setDesiredState(State.INIT);
     sc3.setDesiredState(State.STARTED);
-    sch1.setDesiredState(State.STARTED);
+    sch1.setDesiredState(State.INIT);
     sch2.setDesiredState(State.INIT);
-    sch3.setDesiredState(State.INSTALLED);
-    sch4.setDesiredState(State.STARTED);
+    sch3.setDesiredState(State.INIT);
+    sch4.setDesiredState(State.INIT);
     sch5.setDesiredState(State.INIT);
+    sch1.setState(State.STARTED);
+    sch2.setState(State.INIT);
+    sch3.setState(State.INSTALLED);
+    sch4.setState(State.STOP_FAILED);
+    sch5.setState(State.INIT);
 
     reqs.clear();
     req1 = new ServiceComponentRequest(clusterName, serviceName1,
@@ -2268,6 +2355,11 @@ public class AmbariManagementControllerT
     Assert.assertEquals(State.INSTALLED, sch3.getDesiredState());
     Assert.assertEquals(State.INSTALLED, sch4.getDesiredState());
     Assert.assertEquals(State.INSTALLED, sch5.getDesiredState());
+    Assert.assertEquals(State.STARTED, sch1.getState());
+    Assert.assertEquals(State.INIT, sch2.getState());
+    Assert.assertEquals(State.INSTALLED, sch3.getState());
+    Assert.assertEquals(State.STOP_FAILED, sch4.getState());
+    Assert.assertEquals(State.INIT, sch5.getState());
 
     long requestId = trackAction.getRequestId();
     List<Stage> stages = actionDB.getAllStages(requestId);
@@ -2281,6 +2373,13 @@ public class AmbariManagementControllerT
 
     // FIXME verify stages content - execution commands, etc
 
+    // maually set live state
+    sch1.setState(State.INSTALLED);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.INSTALLED);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
+
     // test no-op
     reqs.clear();
     req1 = new ServiceComponentRequest(clusterName, serviceName1,
@@ -2366,6 +2465,11 @@ public class AmbariManagementControllerT
     sch3.setDesiredState(State.INIT);
     sch4.setDesiredState(State.INSTALLED);
     sch5.setDesiredState(State.INSTALLED);
+    sch1.setState(State.INIT);
+    sch2.setState(State.INSTALL_FAILED);
+    sch3.setState(State.INIT);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
 
     ServiceComponentHostRequest req1, req2, req3, req4, req5;
     Set<ServiceComponentHostRequest> reqs =
@@ -2447,6 +2551,13 @@ public class AmbariManagementControllerT
 
     // FIXME verify stages content - execution commands, etc
 
+    // manually set live state
+    sch1.setState(State.INSTALLED);
+    sch2.setState(State.INSTALLED);
+    sch3.setState(State.INSTALLED);
+    sch4.setState(State.INSTALLED);
+    sch5.setState(State.INSTALLED);
+
     // test no-op
     reqs.clear();
     req1 = new ServiceComponentHostRequest(clusterName, serviceName1,