usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [30/50] [abbrv] git commit: Continue to fix start, stop and reset resources to reflect the changes of stack state transitions
Date Mon, 07 Jul 2014 18:16:47 GMT
Continue to 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/61596df8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/61596df8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/61596df8

Branch: refs/heads/two-dot-o
Commit: 61596df853a31faea25c898073ef138552083cb3
Parents: 08b2a1a
Author: Furkan Bicak <bicak.cs@safehaus.org>
Authored: Sat Jun 28 17:58:52 2014 +0300
Committer: Furkan Bicak <bicak.cs@safehaus.org>
Committed: Sat Jun 28 17:58:52 2014 +0300

----------------------------------------------------------------------
 .../usergrid/chop/api/CoordinatorFig.java       |  7 +++
 .../apache/usergrid/chop/client/ssh/Job.java    |  2 +-
 .../apache/usergrid/chop/runner/Controller.java | 64 +++++++++++++++++++-
 .../usergrid/chop/runner/IController.java       |  7 +++
 .../usergrid/chop/stack/SetupStackState.java    | 36 +++++------
 chop/webapp/pom.xml                             |  1 +
 .../webapp/coordinator/StackCoordinator.java    |  6 +-
 .../coordinator/rest/DestroyResource.java       |  6 +-
 .../coordinator/rest/RunManagerResource.java    | 37 ++---------
 .../rest/RunnerRegistryResource.java            | 36 ++++++++++-
 .../webapp/coordinator/rest/UploadResource.java | 37 ++++++++++-
 11 files changed, 179 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/api/src/main/java/org/apache/usergrid/chop/api/CoordinatorFig.java
----------------------------------------------------------------------
diff --git a/chop/api/src/main/java/org/apache/usergrid/chop/api/CoordinatorFig.java b/chop/api/src/main/java/org/apache/usergrid/chop/api/CoordinatorFig.java
index a238f59..6a5fdaa 100644
--- a/chop/api/src/main/java/org/apache/usergrid/chop/api/CoordinatorFig.java
+++ b/chop/api/src/main/java/org/apache/usergrid/chop/api/CoordinatorFig.java
@@ -92,6 +92,13 @@ public interface CoordinatorFig extends GuicyFig {
     String getRunnersUnregisterPath();
 
 
+    String RUNNERS_COMPLETED_PATH = "coordinator.endpoint.runners.completed";
+    String RUNNERS_COMPLETED_PATH_DEFAULT = "/runners/completed";
+    @Key( RUNNERS_COMPLETED_PATH )
+    @Default( RUNNERS_COMPLETED_PATH_DEFAULT )
+    String getRunnersCompletedPath();
+
+
     String ENDPOINT = "coordinator.endpoint";
     String ENDPOINT_DEFAULT = "https://localhost:8443";
     @Key( ENDPOINT )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/client/src/main/java/org/apache/usergrid/chop/client/ssh/Job.java
----------------------------------------------------------------------
diff --git a/chop/client/src/main/java/org/apache/usergrid/chop/client/ssh/Job.java b/chop/client/src/main/java/org/apache/usergrid/chop/client/ssh/Job.java
index ec2831b..2412aa6 100644
--- a/chop/client/src/main/java/org/apache/usergrid/chop/client/ssh/Job.java
+++ b/chop/client/src/main/java/org/apache/usergrid/chop/client/ssh/Job.java
@@ -51,7 +51,7 @@ public class Job implements Callable<ResponseInfo> {
 
     private static final Logger LOG = LoggerFactory.getLogger( Job.class );
 
-    protected static final int SESSION_CONNECT_TIMEOUT = 50000;
+    protected static final int SESSION_CONNECT_TIMEOUT = 100000;
 
     protected Collection<Command> commands;
     protected SshValues value;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/runner/src/main/java/org/apache/usergrid/chop/runner/Controller.java
----------------------------------------------------------------------
diff --git a/chop/runner/src/main/java/org/apache/usergrid/chop/runner/Controller.java b/chop/runner/src/main/java/org/apache/usergrid/chop/runner/Controller.java
index eb97d81..7fc9b3d 100644
--- a/chop/runner/src/main/java/org/apache/usergrid/chop/runner/Controller.java
+++ b/chop/runner/src/main/java/org/apache/usergrid/chop/runner/Controller.java
@@ -21,6 +21,8 @@ package org.apache.usergrid.chop.runner;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -29,8 +31,15 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import org.apache.usergrid.chop.api.CoordinatorFig;
+import org.apache.usergrid.chop.api.RestParams;
 import org.apache.usergrid.chop.runner.drivers.Driver;
 import org.apache.usergrid.chop.runner.drivers.TimeDriver;
+import org.apache.usergrid.chop.stack.CoordinatedStack;
+import org.apache.usergrid.chop.stack.SetupStackSignal;
+import org.apache.usergrid.chop.stack.SetupStackState;
 import org.reflections.Reflections;
 import org.apache.usergrid.chop.api.Project;
 import org.apache.usergrid.chop.api.Runner;
@@ -46,6 +55,7 @@ import org.apache.usergrid.chop.stack.ChopCluster;
 import org.apache.usergrid.chop.stack.ICoordinatedCluster;
 import org.apache.usergrid.chop.stack.Instance;
 
+import org.safehaus.jettyjam.utils.CertUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -53,14 +63,20 @@ import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 
+import javax.ws.rs.core.MediaType;
+
 
 /**
  * The Controller controls the process of executing chops on test classes.
  */
 @Singleton
-public class Controller implements IController, Runnable {
+public class Controller implements IController, Runnable, RestParams {
     private static final Logger LOG = LoggerFactory.getLogger( Controller.class );
 
+    private CoordinatorFig coordinatorFig;
+    private URL endpoint;
+
+
     // @todo make this configurable and also put this into the project or runner fig
     private static final long DEFAULT_LAGER_WAIT_TIMEOUT_MILLIS = 120000;
     private final Object lock = new Object();
@@ -105,6 +121,25 @@ public class Controller implements IController, Runnable {
     }
 
 
+    @Inject
+    private void setCoordinatorConfig( CoordinatorFig coordinatorFig ) {
+        this.coordinatorFig = coordinatorFig;
+
+        try {
+            endpoint = new URL( coordinatorFig.getEndpoint() );
+        }
+        catch ( MalformedURLException e ) {
+            LOG.error( "Failed to parse URL for coordinator", e );
+        }
+
+        // Need to get the configuration information for the coordinator
+        if ( ! CertUtils.isTrusted( endpoint.getHost() ) ) {
+            CertUtils.preparations( endpoint.getHost(), endpoint.getPort() );
+        }
+        Preconditions.checkState( CertUtils.isTrusted( endpoint.getHost() ), "coordinator
must be trusted" );
+    }
+
+
     private void setProject( Project project ) {
         // if the project is null which should never really happen we just return
         // and stay in the INACTIVE state waiting for a load to activate this runner
@@ -444,5 +479,32 @@ public class Controller implements IController, Runnable {
         LOG.info( "The controller has completed." );
         currentDriver = null;
         state = state.next( Signal.COMPLETED );
+        SetupStackState setupStackState = sendCompleteSignalToSetupStack();
+        LOG.info( "Coordinator stack state: {}", setupStackState );
+    }
+
+    public SetupStackState sendCompleteSignalToSetupStack() {
+        LOG.info( "Sending complete signal to Coordinator" );
+        WebResource resource = Client.create().resource( coordinatorFig.getEndpoint() );
+
+        LOG.info( "USERNAME: {}", coordinatorFig.getUsername() );
+        LOG.info( "MODULE_GROUPID: {}", project.getGroupId() );
+        LOG.info( "MODULE_ARTIFACTID: {}", project.getArtifactId() );
+        LOG.info( "MODULE_VERSION: {}", project.getVersion() );
+        LOG.info( "COMMIT_ID: {}", project.getVcsVersion() );
+
+        SetupStackState result = resource.path( coordinatorFig.getRunnersCompletedPath()
)
+                .queryParam( USERNAME, coordinatorFig.getUsername() )
+                .queryParam( MODULE_GROUPID, project.getGroupId() )
+                .queryParam( MODULE_ARTIFACTID, project.getArtifactId() )
+                .queryParam( MODULE_VERSION, project.getVersion() )
+                .queryParam( COMMIT_ID, project.getVcsVersion() )
+                .type( MediaType.APPLICATION_JSON )
+                .get( SetupStackState.class );
+
+
+        return result;
     }
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/runner/src/main/java/org/apache/usergrid/chop/runner/IController.java
----------------------------------------------------------------------
diff --git a/chop/runner/src/main/java/org/apache/usergrid/chop/runner/IController.java b/chop/runner/src/main/java/org/apache/usergrid/chop/runner/IController.java
index cb79943..c540622 100644
--- a/chop/runner/src/main/java/org/apache/usergrid/chop/runner/IController.java
+++ b/chop/runner/src/main/java/org/apache/usergrid/chop/runner/IController.java
@@ -23,6 +23,7 @@ import org.apache.usergrid.chop.api.Signal;
 import org.apache.usergrid.chop.api.StatsSnapshot;
 import org.apache.usergrid.chop.api.Project;
 import org.apache.usergrid.chop.api.State;
+import org.apache.usergrid.chop.stack.SetupStackState;
 
 
 /**
@@ -86,4 +87,10 @@ public interface IController {
      * @return the project being chopped up
      */
     Project getProject();
+
+    /**
+     * sends signal to coordinator to inform that all runners are finished
+     * @return Setup stack state of coordinator after signal sent
+     */
+    SetupStackState sendCompleteSignalToSetupStack();
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackState.java
----------------------------------------------------------------------
diff --git a/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackState.java
b/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackState.java
index 809c12c..4015d2c 100644
--- a/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackState.java
+++ b/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackState.java
@@ -38,56 +38,57 @@ import com.google.common.base.Preconditions;
  */
 public enum SetupStackState {
     // Running ==> (Complete signal) ==> SetUp
-    // Running ==> (Destroy signal) ==> NotSetUp
+    // Running ==> (Destroy signal) ==> Destroying
     // Running ==> (Stop signal) ==> Stopped
-    Running( 7, new SetupStackSignal[] { SetupStackSignal.STOP, SetupStackSignal.DESTROY,
SetupStackSignal.COMPLETE }, new Integer[] { 6, 3, 0 },
+    Running( 7, new SetupStackSignal[] { SetupStackSignal.STOP, SetupStackSignal.DESTROY,
SetupStackSignal.COMPLETE }, new Integer[] { 6, 4, 0 },
             "Running tests on stack.",
-            "%s signal rejected. When Running only a STOP, DESTROY and COMPLETE signal(s)
which cause to transition into " +
-                    "Stopped, NotSetUp and SetUp state(s) respectively" ),
+            "%s signal rejected. When Running only STOP, DESTROY and COMPLETE signal(s) which
cause to transition into " +
+                    "Stopped, Destroying and SetUp state(s) respectively" ),
 
     // Stopped ==> (reset signal) ==> SetUp
-    Stopped( 6, new SetupStackSignal[] { SetupStackSignal.RESET }, new Integer[] { 0 },
+    Stopped( 6, new SetupStackSignal[] { SetupStackSignal.RESET, SetupStackSignal.DESTROY
}, new Integer[] { 0, 4 },
             "Tests are stopped while running, please reset first.",
-            "%s signal rejected. When Stopped only a RESET signal(s) which cause to transition
into " +
-                    "SetUp state(s) respectively" ),
+            "%s signal rejected. When Stopped only RESET and DESTROY signal(s) which cause
to transition into " +
+                    "SetUp, Destroying state(s) respectively" ),
 
     // JarNotFound ==> (deploy signal) ==> NotSetUp
     JarNotFound( 5, new SetupStackSignal[] { SetupStackSignal.DEPLOY, SetupStackSignal.SETUP
}, new Integer[] { 3, 1 },
             "No runner jars found with given parameters, deploy first.",
-            "%s signal rejected. When JarNotFound only a DEPLOY and SETUP signal(s) which
cause to transition into " +
+            "%s signal rejected. When JarNotFound only DEPLOY and SETUP signal(s) which cause
to transition into " +
                     "NotSetUp and SettingUp state(s) respectively" ),
 
     // Destroying ==> (Complete signal) ==> NotSetUp
     Destroying( 4, new SetupStackSignal[] { SetupStackSignal.COMPLETE }, new Integer[] {
3 },
             "Currently being destroyed. Wait until it is finished to set up again.",
-            "%s signal rejected. When Destroying only a COMPLETE signal(s) can be sent which
cause to " +
+            "%s signal rejected. When Destroying only COMPLETE signal(s) can be sent which
cause to " +
                     "transition into NotSetUp state(s) respectively" ),
 
     // NotSetUp ==> (setup signal) ==> NotSetUp
     // NotSetUp ==> (setup signal) ==> SettingUp
     NotSetUp( 3, new SetupStackSignal[] { SetupStackSignal.SETUP, SetupStackSignal.DEPLOY
}, new Integer[] { 1, 3 },
             "Jar is deployed but no stack set up with it.",
-            "%s signal rejected. When NotSetUp only a SETUP and DEPLOY signal(s) which cause
to transition into " +
+            "%s signal rejected. When NotSetUp only SETUP and DEPLOY signal(s) which cause
to transition into " +
                     "SettingUp and NotSetUp state(s) respectively" ),
 
     // SetupFailed ==> (setup deploy) ==> NotSetUp
     // SetupFailed ==> (setup signal) ==> SettingUp
     SetupFailed( 2, new SetupStackSignal[] { SetupStackSignal.SETUP, SetupStackSignal.DEPLOY
}, new Integer[] { 1, 3 },
             "Stack was registered, however its setup failed. Call setup again to restart.",
-            "%s signal rejected. When SetupFailed only a SETUP and DEPLOY signal(s) which
cause to transition into " +
+            "%s signal rejected. When SetupFailed only SETUP and DEPLOY signal(s) which cause
to transition into " +
                     "SettingUp and NotSetUp state(s) respectively" ),
 
     // SettingUp ==> (Complete signal) ==> SetUp
-    SettingUp( 1, new SetupStackSignal[] { SetupStackSignal.COMPLETE, SetupStackSignal.FAIL
}, new Integer[] { 0, 2 },
+    SettingUp( 1, new SetupStackSignal[] { SetupStackSignal.COMPLETE, SetupStackSignal.FAIL
+            , SetupStackSignal.DESTROY}, new Integer[] { 0, 2, 4 },
             "Setting up the stack right now.",
-            "%s signal rejected. When SettingUp only a COMPLETE signal(s) can be sent which
cause to " +
-                    "transition into SetUp state(s) respectively" ),
+            "%s signal rejected. When SettingUp only COMPLETE, FAIL and DESTROY signal(s)
can be sent which " +
+                    "cause to transition into SetUp, SetupFailed and Destroying state(s)
respectively" ),
 
     // SetUp ==> (start signal) ==> Running
     // SetUp ==> (destroy signal) ==> NotSetUp
     SetUp( 0, new SetupStackSignal[] { SetupStackSignal.DESTROY, SetupStackSignal.START },
new Integer[] { 4, 7 },
             "Stack is set up and ready to start the tests.",
-            "%s signal rejected. When SetUp only a DESTROY and SetUp signal(s) which cause
to transition into " +
+            "%s signal rejected. When SetUp only DESTROY and SetUp signal(s) which cause
to transition into " +
                     "NotSetUp and SetUp state(s) respectively" );
 
     private static final Logger LOG = LoggerFactory.getLogger( SetupStackState.class );
@@ -100,7 +101,8 @@ public enum SetupStackState {
     private final String rejectedMessage;
 
 
-    private SetupStackState( int stateID, SetupStackSignal[] signals, Integer[] states, String
stackStateMessage, String rejectedMessage ) {
+    private SetupStackState( int stateID, SetupStackSignal[] signals, Integer[] states, String
stackStateMessage,
+            String rejectedMessage ) {
         Assert.assertTrue( states.length == signals.length );
         this.stackStateMessage = stackStateMessage;
         this.stateID = stateID;
@@ -216,7 +218,7 @@ public enum SetupStackState {
             return null;
         }
 
-        LOG.info( "Got signal {} in {} state: stateID = " + stateID, signal, toString() );
+        LOG.debug( "Got signal {} in {} state: stateID = " + stateID, signal, toString()
);
 
         return get( stateID );
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/chop/webapp/pom.xml b/chop/webapp/pom.xml
index 117bdb6..caef3aa 100644
--- a/chop/webapp/pom.xml
+++ b/chop/webapp/pom.xml
@@ -170,6 +170,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
+        <version>2.2</version>
         <executions>
           <execution>
             <phase>package</phase>

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/StackCoordinator.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/StackCoordinator.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/StackCoordinator.java
index 5b88cce..bdc5231 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/StackCoordinator.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/StackCoordinator.java
@@ -173,7 +173,7 @@ public class StackCoordinator {
         }
 
         synchronized ( coordinatedStack ) {
-            if ( coordinatedStack.getSetupState() != SetupStackState.SetUp ) {
+            if ( coordinatedStack.getSetupState().accepts( SetupStackSignal.DESTROY ) ) {
                 LOG.info( "Stack is in {} state, will not destroy.", coordinatedStack.getSetupState().toString()
);
                 return;
             }
@@ -362,9 +362,7 @@ public class StackCoordinator {
         CoordinatedStack coordinatedStack = getCoordinatedStack( stack, user, commit, module
);
         if ( coordinatedStack != null ) {
             LOG.info( "Stack {} is already registered", stack.getName() );
-            if ( coordinatedStack.getSetupState() == SetupStackState.SetUp ) {
-                return coordinatedStack;
-            }
+            return coordinatedStack;
         }
         else {
             coordinatedStack = new CoordinatedStack( stack, user, commit, module, runnerCount
);

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/DestroyResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/DestroyResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/DestroyResource.java
index cecb274..ff1ff21 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/DestroyResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/DestroyResource.java
@@ -26,6 +26,7 @@ import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import org.apache.usergrid.chop.api.RestParams;
 import org.apache.usergrid.chop.api.Runner;
+import org.apache.usergrid.chop.stack.SetupStackSignal;
 import org.apache.usergrid.chop.stack.SetupStackState;
 import org.apache.usergrid.chop.webapp.coordinator.RunnerCoordinator;
 import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
@@ -103,14 +104,15 @@ public class DestroyResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        if( ! status.equals( SetupStackState.SetUp ) ) {
+        if( ! status.accepts( SetupStackSignal.DESTROY ) ) {
             return Response.status( Response.Status.OK )
                            .entity( "Stack is " + status.toString() + ", will not destroy."
)
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
 
-        /** SetupStackState.SetUp */
+        /** SetupStackState.SetUp or SetupStackState.SettingUp
+         * or SetupStackState.Running or SetupStackState.Stopped */
 
         // Unregister runners first
         String moduleId = BasicModule.createId( groupId, artifactId, version );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/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 b4cf702..a4ff74c 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,9 +24,6 @@ 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;
@@ -36,11 +33,6 @@ 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;
@@ -58,7 +50,12 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.annotation.Nullable;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
@@ -81,12 +78,6 @@ public class RunManagerResource extends TestableResource implements RestParams
{
     @Inject
     private RunnerDao runnerDao;
 
-    @Inject
-    private RunnerCoordinator runnerCoordinator;
-
-    @Inject
-    private StackCoordinator stackCoordinator;
-
 
     protected RunManagerResource() {
         super( ENDPOINT );
@@ -171,22 +162,6 @@ 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/61596df8/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunnerRegistryResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunnerRegistryResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunnerRegistryResource.java
index 665122c..2704efa 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunnerRegistryResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/RunnerRegistryResource.java
@@ -26,7 +26,10 @@ import com.google.inject.Singleton;
 import org.apache.usergrid.chop.api.Module;
 import org.apache.usergrid.chop.api.RestParams;
 import org.apache.usergrid.chop.api.Runner;
+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.ModuleDao;
 import org.apache.usergrid.chop.webapp.dao.model.BasicModule;
 import org.safehaus.jettyjam.utils.TestMode;
@@ -54,7 +57,7 @@ import java.util.Collections;
 @Produces( MediaType.APPLICATION_JSON )
 @Consumes( MediaType.APPLICATION_JSON )
 @Path( RunnerRegistryResource.ENDPOINT )
-public class RunnerRegistryResource extends TestableResource {
+public class RunnerRegistryResource extends TestableResource implements RestParams {
     public final static String ENDPOINT = "/runners";
 
     private static final Logger LOG = LoggerFactory.getLogger( RunnerRegistryResource.class
);
@@ -65,6 +68,9 @@ public class RunnerRegistryResource extends TestableResource {
     @Inject
     private RunnerCoordinator runnerCoordinator;
 
+    @Inject
+    private StackCoordinator stackCoordinator;
+
 
     public RunnerRegistryResource() {
         super( ENDPOINT );
@@ -190,4 +196,32 @@ public class RunnerRegistryResource extends TestableResource {
 
         return Response.ok( result ).build();
     }
+
+
+    @SuppressWarnings( "unchecked" )
+    @GET
+    @Path( "/completed" )
+    @Consumes( MediaType.APPLICATION_JSON )
+    @Produces( MediaType.APPLICATION_JSON )
+    public Response runnersCompleted(
+            @QueryParam( USERNAME ) String username,
+            @QueryParam( MODULE_GROUPID ) String groupId,
+            @QueryParam( MODULE_ARTIFACTID ) String artifactId,
+            @QueryParam( MODULE_VERSION ) String version,
+            @QueryParam( COMMIT_ID ) String commitId
+    ) {
+
+        LOG.info( "USERNAME: {}", username );
+        LOG.info( "MODULE_GROUPID: {}", groupId );
+        LOG.info( "MODULE_ARTIFACTID: {}", artifactId );
+        LOG.info( "MODULE_VERSION: {}", version );
+        LOG.info( "COMMIT_ID: {}", commitId );
+
+        CoordinatedStack stack = stackCoordinator.findCoordinatedStack( commitId, artifactId,
groupId, version, username );
+        if ( stack.getSetupState().accepts( SetupStackSignal.COMPLETE ) ) {
+            stack.setSetupState( SetupStackSignal.COMPLETE );
+        }
+
+        return Response.status( Response.Status.OK ).entity( stack.getSetupState() ).build();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/61596df8/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/UploadResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/UploadResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/UploadResource.java
index 6caaa22..f7378ab 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/UploadResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/UploadResource.java
@@ -27,6 +27,8 @@ import java.io.InputStreamReader;
 import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Date;
+import java.util.List;
 import java.util.Properties;
 
 import javax.annotation.Nullable;
@@ -39,20 +41,23 @@ import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
+import org.apache.usergrid.chop.stack.SetupStackState;
+import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
 import org.safehaus.jettyjam.utils.TestMode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.usergrid.chop.api.Commit;
 import org.apache.usergrid.chop.api.Constants;
+import org.apache.usergrid.chop.api.Module;
 import org.apache.usergrid.chop.api.Project;
 import org.apache.usergrid.chop.api.RestParams;
-import org.apache.usergrid.chop.stack.SetupStackState;
 import org.apache.usergrid.chop.webapp.ChopUiFig;
 import org.apache.usergrid.chop.webapp.coordinator.CoordinatorUtils;
-import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
 import org.apache.usergrid.chop.webapp.dao.CommitDao;
 import org.apache.usergrid.chop.webapp.dao.ModuleDao;
-import org.apache.usergrid.chop.webapp.dao.UserDao;
+import org.apache.usergrid.chop.webapp.dao.model.BasicCommit;
+import org.apache.usergrid.chop.webapp.dao.model.BasicModule;
 
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -230,6 +235,32 @@ public class UploadResource extends TestableResource implements RestParams,
Cons
         // - this is bad news because we will get commits of other users :(
         // - we also need to qualify the commit with username, groupId,
         //   and the version of module as well
+
+        Commit commit = null;
+        Module module = null;
+
+        List<Commit> commits = commitDao.getByModule( artifactId );
+        for ( Commit returnedCommit : commits ) {
+            Module commitModule = moduleDao.get( returnedCommit.getModuleId() );
+            if ( commitModule.getArtifactId().equals( artifactId ) &&
+                    commitModule.getGroupId().equals( groupId ) &&
+                    commitModule.getVersion().equals( version ) )
+            {
+                commit = returnedCommit;
+                module = commitModule;
+            }
+        }
+
+        if ( module == null ) {
+            module = new BasicModule( groupId, artifactId, version, vcsRepoUrl, testPackage
);
+            moduleDao.save( module );
+        }
+
+        if ( commit == null ) {
+            commit = new BasicCommit( commitId, module.getId(), md5, new Date(), runnerJar.getAbsolutePath()
);
+            commitDao.save( commit );
+        }
+
         stackCoordinator.registerStack( commitId, artifactId, groupId, version, username,
runnerCount );
 
         return Response.status( Response.Status.CREATED ).entity( runnerJar.getAbsolutePath()
).build();


Mime
View raw message