usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [09/50] [abbrv] git commit: Fix start, stop and reset resources to reflect the changes of stack state transitions
Date Mon, 07 Jul 2014 18:16:26 GMT
Fix start, stop and reset resources to reflect the changes of stack state transitions


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

Branch: refs/heads/two-dot-o
Commit: 08b2a1a477bbd0e3193ab4dd01193ccb908b9544
Parents: 5e42dbf
Author: Furkan Bicak <bicak.cs@safehaus.org>
Authored: Fri Jun 27 19:33:16 2014 +0300
Committer: Furkan Bicak <bicak.cs@safehaus.org>
Committed: Fri Jun 27 19:33:16 2014 +0300

----------------------------------------------------------------------
 .../webapp/coordinator/rest/ResetResource.java  |  6 ++--
 .../coordinator/rest/RunManagerResource.java    | 29 ++++++++++++++++++++
 .../webapp/coordinator/rest/StopResource.java   |  4 +--
 3 files changed, 34 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08b2a1a4/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/ResetResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/ResetResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/ResetResource.java
index 8ef5eb6..48f3159 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/ResetResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/ResetResource.java
@@ -108,14 +108,14 @@ public class ResetResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        if( ! status.equals( SetupStackState.SetUp ) ) {
+        if( ! status.equals( SetupStackState.Stopped ) ) {
             return Response.status( Response.Status.OK )
                            .entity( "Stack is " + status.toString() + ", cannot reset tests."
)
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
-        /** SetupStackState.SetUp */
-        LOG.info( "Stack is set up, checking runner states..." );
+        /** SetupStackState.Stopped */
+        LOG.info( "Stack is stopped, checking runner states..." );
 
         /** Check state of all runners */
         String moduleId = BasicModule.createId( groupId, artifactId, version );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08b2a1a4/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunManagerResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunManagerResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunManagerResource.java
index b51934e..b4cf702 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunManagerResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunManagerResource.java
@@ -24,7 +24,9 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
@@ -34,6 +36,11 @@ import com.sun.jersey.multipart.FormDataParam;
 import org.apache.usergrid.chop.api.RestParams;
 import org.apache.usergrid.chop.api.Run;
 import org.apache.usergrid.chop.api.Runner;
+import org.apache.usergrid.chop.api.State;
+import org.apache.usergrid.chop.stack.CoordinatedStack;
+import org.apache.usergrid.chop.stack.SetupStackSignal;
+import org.apache.usergrid.chop.webapp.coordinator.RunnerCoordinator;
+import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
 import org.apache.usergrid.chop.webapp.dao.RunDao;
 import org.apache.usergrid.chop.webapp.dao.RunResultDao;
 import org.apache.usergrid.chop.webapp.dao.RunnerDao;
@@ -74,6 +81,12 @@ public class RunManagerResource extends TestableResource implements RestParams
{
     @Inject
     private RunnerDao runnerDao;
 
+    @Inject
+    private RunnerCoordinator runnerCoordinator;
+
+    @Inject
+    private StackCoordinator stackCoordinator;
+
 
     protected RunManagerResource() {
         super( ENDPOINT );
@@ -158,6 +171,22 @@ public class RunManagerResource extends TestableResource implements RestParams
{
         Collection<Run> runs = runDao.getMap( commitId, runNumber, testClass, runners
).values() ;
 
         Boolean allFinished = runs.size() == runners.size();
+        CoordinatedStack stack = stackCoordinator.findCoordinatedStack( commitId, artifactId,
groupId, version, username );
+
+        Map<Runner, State> states = runnerCoordinator.getStates( runners );
+
+        Collection<Runner> readyRunners = new LinkedList<Runner>();
+        for ( Runner runner: runners ) {
+            State state = states.get( runner );
+            if( state == State.READY ) {
+                readyRunners.add( runner );
+            }
+        }
+
+        if( readyRunners.size() == runners.size() ) {
+            LOG.info( "All runners are ready, sending " + SetupStackSignal.COMPLETE + " signal.."
);
+            stack.setSetupState( SetupStackSignal.COMPLETE );
+        }
 
         return Response.status( Response.Status.CREATED ).entity( allFinished ).build();
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08b2a1a4/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StopResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StopResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StopResource.java
index 74d91aa..8baabbd 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StopResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StopResource.java
@@ -108,13 +108,13 @@ public class StopResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        if( ! status.equals( SetupStackState.SetUp ) ) {
+        if( ! status.equals( SetupStackState.Running ) ) {
             return Response.status( Response.Status.OK )
                            .entity( "Stack is " + status.toString() + ", cannot stop tests."
)
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
-        /** SetupStackState.SetUp */
+        /** SetupStackState.Running */
         LOG.info( "Stack is set up, checking runner states..." );
 
         /** Check state of all runners */


Mime
View raw message