ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hit...@apache.org
Subject svn commit: r1395858 - 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/state/ ambari-server/src/main/java/org/apache/ambari/server/state/...
Date Tue, 09 Oct 2012 04:47:45 GMT
Author: hitesh
Date: Tue Oct  9 04:47:45 2012
New Revision: 1395858

URL: http://svn.apache.org/viewvc?rev=1395858&view=rev
Log:
AMBARI-830. Various fixes and tests for controller implementation. (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/AmbariManagementControllerImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackVersion.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
    incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.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=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Tue Oct  9 04:47:45 2012
@@ -213,6 +213,8 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-830. Various fixes and tests for controller implementation. (hitesh)
+
   AMBARI-808. Handle appropriate start/stop/install/.. events at their respective
   failed states. (hitesh)
 

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=1395858&r1=1395857&r2=1395858&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
Tue Oct  9 04:47:45 2012
@@ -845,6 +845,7 @@ public class AmbariManagementControllerI
         sch.setDesiredState(newState);
       }
     }
+    s.setDesiredState(newState);
 
     if (LOG.isDebugEnabled()) {
       LOG.debug("Triggering Action Manager"
@@ -991,6 +992,7 @@ public class AmbariManagementControllerI
     for (ServiceComponentHost sch : changedScHosts) {
       sch.setDesiredState(newState);
     }
+    sc.setDesiredState(newState);
 
     actionManager.sendActions(stages);
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Cluster.java
Tue Oct  9 04:47:45 2012
@@ -87,4 +87,6 @@ public interface Cluster {
 
   public ClusterResponse convertToResponse();
 
+  public void debugDump(StringBuilder sb);
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Clusters.java
Tue Oct  9 04:47:45 2012
@@ -94,4 +94,6 @@ public interface Clusters {
   public void mapHostsToCluster(List<String> hostnames, String clusterName)
       throws AmbariException;
 
+  public void debugDump(StringBuilder sb);
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/Service.java
Tue Oct  9 04:47:45 2012
@@ -60,4 +60,6 @@ public interface Service {
 
   public ServiceResponse convertToResponse();
 
+  public void debugDump(StringBuilder sb);
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
Tue Oct  9 04:47:45 2012
@@ -62,4 +62,6 @@ public interface ServiceComponent {
       throws AmbariException ;
 
   public ServiceComponentResponse convertToResponse();
+
+  public void debugDump(StringBuilder sb);
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
Tue Oct  9 04:47:45 2012
@@ -97,4 +97,6 @@ public interface ServiceComponentHost {
 
   public ServiceComponentHostResponse convertToResponse();
 
+  public void debugDump(StringBuilder sb);
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
Tue Oct  9 04:47:45 2012
@@ -209,4 +209,26 @@ public class ServiceComponentImpl implem
     return service.getCluster().getClusterName();
   }
 
+  @Override
+  public synchronized void debugDump(StringBuilder sb) {
+    sb.append("ServiceComponent={ serviceComponentName=" + componentName
+        + ", clusterName=" + service.getCluster().getClusterName()
+        + ", clusterId=" + service.getCluster().getClusterId()
+        + ", serviceName=" + service.getName()
+        + ", desiredStackVersion=" + desiredStackVersion
+        + ", desiredState=" + desiredState
+        + ", hostcomponents=[ ");
+    boolean first = true;
+    for(ServiceComponentHost sch : hostComponents.values()) {
+      if (!first) {
+        sb.append(" , ");
+        first = false;
+      }
+      sb.append("\n        ");
+      sch.debugDump(sb);
+      sb.append(" ");
+    }
+    sb.append(" ] }");
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
Tue Oct  9 04:47:45 2012
@@ -193,4 +193,25 @@ public class ServiceImpl implements Serv
     return cluster;
   }
 
+  @Override
+  public synchronized void debugDump(StringBuilder sb) {
+    sb.append("Service={ serviceName=" + serviceName
+        + ", clusterName=" + cluster.getClusterName()
+        + ", clusterId=" + cluster.getClusterId()
+        + ", desiredStackVersion=" + desiredStackVersion.getStackVersion()
+        + ", desiredState=" + desiredState.toString()
+        + ", components=[ ");
+    boolean first = true;
+    for(ServiceComponent sc : components.values()) {
+      if (!first) {
+        sb.append(" , ");
+        first = false;
+      }
+      sb.append("\n      ");
+      sc.debugDump(sb);
+      sb.append(" ");
+    }
+    sb.append(" ] }");
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackVersion.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackVersion.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackVersion.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/StackVersion.java
Tue Oct  9 04:47:45 2012
@@ -58,4 +58,8 @@ public class StackVersion {
     return result;
   }
 
+  public String toString() {
+    return this.stackVersion;
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
Tue Oct  9 04:47:45 2012
@@ -219,8 +219,8 @@ public class ClusterImpl implements Clus
       LOG.debug("Changing DesiredStackVersion of Cluster"
         + ", clusterName=" + clusterName
         + ", clusterId=" + clusterId
-        + ", currentStackVersion=" + this.desiredStackVersion
-        + ", newStackVersion=" + stackVersion);
+        + ", currentDesiredStackVersion=" + this.desiredStackVersion
+        + ", newDesiredStackVersion=" + stackVersion);
     }
     this.desiredStackVersion = stackVersion;
   }
@@ -264,4 +264,22 @@ public class ClusterImpl implements Clus
     return r;
   }
 
+  public void debugDump(StringBuilder sb) {
+    sb.append("Cluster={ clusterName=" + clusterName
+        + ", clusterId=" + clusterId
+        + ", desiredStackVersion=" + desiredStackVersion.getStackVersion()
+        + ", services=[ ");
+    boolean first = true;
+    for(Service s : services.values()) {
+      if (!first) {
+        sb.append(" , ");
+        first = false;
+      }
+      sb.append("\n    ");
+      s.debugDump(sb);
+      sb.append(" ");
+    }
+    sb.append(" ] }");
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
Tue Oct  9 04:47:45 2012
@@ -156,4 +156,20 @@ public class ClustersImpl implements Clu
       }
     }
   }
+
+  public void debugDump(StringBuilder sb) {
+    sb.append("Clusters=[ ");
+    boolean first = true;
+    for(Cluster c : clusters.values()) {
+      if (!first) {
+        sb.append(" , ");
+        first = false;
+      }
+      sb.append("\n  ");
+      c.debugDump(sb);
+      sb.append(" ");
+    }
+    sb.append(" ]");
+  }
+
 }

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
Tue Oct  9 04:47:45 2012
@@ -745,4 +745,23 @@ public class ServiceComponentHostImpl im
     return serviceComponent.getClusterName();
   }
 
+  @Override
+  public void debugDump(StringBuilder sb) {
+    try {
+      readLock.lock();
+      sb.append("ServiceComponentHost={ hostname=" + hostName
+          + ", serviceComponentName=" + serviceComponent.getName()
+          + ", clusterName=" + serviceComponent.getClusterName()
+          + ", serviceName=" + serviceComponent.getServiceName()
+          + ", desiredStackVersion=" + desiredStackVersion
+          + ", desiredState=" + desiredState
+          + ", stackVersion=" + stackVersion
+          + ", state=" + getState()
+          + " }");
+    }
+    finally {
+      readLock.unlock();
+    }
+  }
+
 }

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=1395858&r1=1395857&r2=1395858&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
Tue Oct  9 04:47:45 2012
@@ -32,6 +32,8 @@ import org.apache.ambari.server.actionma
 import org.apache.ambari.server.actionmanager.Stage;
 import org.apache.ambari.server.agent.ActionQueue;
 import org.apache.ambari.server.state.Clusters;
+import org.apache.ambari.server.state.ServiceComponent;
+import org.apache.ambari.server.state.ServiceComponentHost;
 import org.apache.ambari.server.state.State;
 import org.apache.ambari.server.state.cluster.ClustersImpl;
 import org.apache.ambari.server.utils.StageUtils;
@@ -338,6 +340,17 @@ public class AmbariManagementControllerT
         State.INSTALLED.toString());
 
     controller.updateService(r1);
+    Assert.assertEquals(State.INSTALLED,
+        clusters.getCluster(clusterName).getService(serviceName)
+        .getDesiredState());
+    for (ServiceComponent sc :
+      clusters.getCluster(clusterName).getService(serviceName)
+      .getServiceComponents().values()) {
+      Assert.assertEquals(State.INSTALLED, sc.getDesiredState());
+      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+        Assert.assertEquals(State.INSTALLED, sch.getDesiredState());
+      }
+    }
 
     // TODO validate stages?
     List<Stage> stages = db.getAllStages(1);
@@ -361,6 +374,17 @@ public class AmbariManagementControllerT
         State.STARTED.toString());
 
     controller.updateService(r2);
+    Assert.assertEquals(State.STARTED,
+        clusters.getCluster(clusterName).getService(serviceName)
+        .getDesiredState());
+    for (ServiceComponent sc :
+      clusters.getCluster(clusterName).getService(serviceName)
+      .getServiceComponents().values()) {
+      Assert.assertEquals(State.STARTED, sc.getDesiredState());
+      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
+        Assert.assertEquals(State.STARTED, sch.getDesiredState());
+      }
+    }
 
     // TODO validate stages?
     stages = db.getAllStages(2);
@@ -380,6 +404,10 @@ public class AmbariManagementControllerT
       }
     }
 
+    StringBuilder sb = new StringBuilder();
+    clusters.debugDump(sb);
+    LOG.info("Cluster Dump: " + sb.toString());
+
   }
 
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.java?rev=1395858&r1=1395857&r2=1395858&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.java
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-server/src/test/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImplTest.java
Tue Oct  9 04:47:45 2012
@@ -302,7 +302,6 @@ public class ServiceComponentHostImplTes
         State.WIPING_OUT,
         State.WIPEOUT_FAILED,
         State.INIT);
-
   }
 
 }



Mime
View raw message