usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [35/50] [abbrv] git commit: Reduce coupling by differentiating runner states with setup stack states
Date Mon, 07 Jul 2014 18:16:52 GMT
Reduce coupling by differentiating runner states with setup stack states


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

Branch: refs/heads/two-dot-o
Commit: 87ccf72bd27cbd8b6e15dab5f47f996218a11b5e
Parents: 63a80af
Author: Furkan Bicak <bicak.cs@safehaus.org>
Authored: Mon Jun 30 08:50:43 2014 +0300
Committer: Furkan Bicak <bicak.cs@safehaus.org>
Committed: Mon Jun 30 08:50:43 2014 +0300

----------------------------------------------------------------------
 .../usergrid/chop/api/CoordinatorFig.java       |  7 ---
 .../apache/usergrid/chop/runner/Controller.java | 50 +-------------------
 .../usergrid/chop/runner/IController.java       |  5 --
 .../usergrid/chop/stack/SetupStackSignal.java   | 17 +++----
 .../usergrid/chop/stack/SetupStackState.java    | 29 ++----------
 .../webapp/coordinator/rest/ResetResource.java  |  7 +--
 .../rest/RunnerRegistryResource.java            | 33 -------------
 .../webapp/coordinator/rest/StartResource.java  |  3 --
 .../webapp/coordinator/rest/StopResource.java   |  9 +---
 .../webapp/coordinator/rest/UploadResource.java |  6 +--
 10 files changed, 18 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 6a5fdaa..a238f59 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,13 +92,6 @@ 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/87ccf72b/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 7fc9b3d..cf7d639 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
@@ -70,12 +70,9 @@ import javax.ws.rs.core.MediaType;
  * The Controller controls the process of executing chops on test classes.
  */
 @Singleton
-public class Controller implements IController, Runnable, RestParams {
+public class Controller implements IController, Runnable {
     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;
@@ -121,25 +118,6 @@ public class Controller implements IController, Runnable, RestParams
{
     }
 
 
-    @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
@@ -479,32 +457,6 @@ public class Controller implements IController, Runnable, RestParams
{
         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/87ccf72b/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 c540622..aaa7d8b 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
@@ -88,9 +88,4 @@ public interface IController {
      */
     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/87ccf72b/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackSignal.java
----------------------------------------------------------------------
diff --git a/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackSignal.java
b/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackSignal.java
index 96caa4b..2a4523d 100644
--- a/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackSignal.java
+++ b/chop/stack/src/main/java/org/apache/usergrid/chop/stack/SetupStackSignal.java
@@ -22,7 +22,7 @@ package org.apache.usergrid.chop.stack;
 
 public enum SetupStackSignal {
 
-    START( 0 ), STOP( 1 ), RESET( 2 ), DESTROY( 3 ), DEPLOY( 4 ), SETUP( 5 ), FAIL ( 6 ),
COMPLETE ( 7 );
+    DESTROY( 0 ), DEPLOY( 1 ), SETUP( 2 ), FAIL ( 3 ), COMPLETE ( 4 );
 
     private final int signalID;
 
@@ -40,20 +40,15 @@ public enum SetupStackSignal {
     public SetupStackSignal get( int id ) {
         switch ( id ) {
             case 0:
-                return START;
-            case 1:
-                return STOP;
-            case 2:
-                return RESET;
-            case 3:
                 return DESTROY;
-            case 4:
+
+            case 1:
                 return DEPLOY;
-            case 5:
+            case 2:
                 return SETUP;
-            case 6:
+            case 3:
                 return FAIL;
-            case 7:
+            case 4:
                 return COMPLETE;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 3e6fdba..1847914 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
@@ -37,22 +37,6 @@ import com.google.common.base.Preconditions;
  * Represents the setup state of a stack
  */
 public enum SetupStackState {
-    // Running ==> (Complete signal) ==> SetUp
-    // Running ==> (Destroy signal) ==> Destroying
-    // Running ==> (Stop signal) ==> Stopped
-    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 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, SetupStackSignal.DESTROY
},
-            new Integer[] { 0, 4 },
-            "Tests are stopped while running, please reset first.",
-            "%s signal rejected. When Stopped only RESET and DESTROY signal(s) which cause
to transition into " +
-                    "SetUp, Destroying state(s) respectively" ),
-
     // JarNotFound ==> (setup signal) ==> SettingUp
     // JarNotFound ==> (deploy signal) ==> NotSetUp
     JarNotFound( 5, new SetupStackSignal[] { SetupStackSignal.DEPLOY, SetupStackSignal.SETUP
},
@@ -92,13 +76,12 @@ public enum SetupStackState {
             "%s signal rejected. When SettingUp only COMPLETE and FAIL signal(s) can be sent
which " +
                     "cause to transition into SetUp and SetupFailed state(s) respectively"
),
 
-    // SetUp ==> (start signal) ==> Running
     // SetUp ==> (destroy signal) ==> NotSetUp
-    SetUp( 0, new SetupStackSignal[] { SetupStackSignal.DESTROY, SetupStackSignal.START },
-            new Integer[] { 4, 7 },
+    SetUp( 0, new SetupStackSignal[] { SetupStackSignal.DESTROY },
+            new Integer[] { 4 },
             "Stack is set up and ready to start the tests.",
-            "%s signal rejected. When SetUp only DESTROY and SetUp signal(s) which cause
to transition into " +
-                    "NotSetUp and SetUp state(s) respectively" );
+            "%s signal rejected. When SetUp only DESTROY signal(s) which cause to transition
into " +
+                    "NotSetUp state(s) respectively" );
 
     private static final Logger LOG = LoggerFactory.getLogger( SetupStackState.class );
     private static final String SUCCESS_MSG = "%s signal accepted, transitioning from %s
state to %s";
@@ -206,10 +189,6 @@ public enum SetupStackState {
                 return Destroying;
             case 5:
                 return JarNotFound;
-            case 6:
-                return Stopped;
-            case 7:
-                return Running;
         }
 
         throw new RuntimeException( "Should never get here!" );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 48f3159..c40a530 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,13 +108,13 @@ public class ResetResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        if( ! status.equals( SetupStackState.Stopped ) ) {
+        if( ! status.equals( SetupStackState.SetUp ) ) {
             return Response.status( Response.Status.OK )
                            .entity( "Stack is " + status.toString() + ", cannot reset tests."
)
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
-        /** SetupStackState.Stopped */
+        /** SetupStackState.SetUp */
         LOG.info( "Stack is stopped, checking runner states..." );
 
         /** Check state of all runners */
@@ -197,9 +197,6 @@ public class ResetResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        CoordinatedStack stack = stackCoordinator.findCoordinatedStack( commitId, artifactId,
groupId, version, user );
-        stack.setSetupState( SetupStackSignal.RESET );
-
         return Response.status( Response.Status.CREATED )
                        .entity( "All stopped runners have been reset." )
                        .type( MediaType.APPLICATION_JSON )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 781a2b3..9f248d5 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,10 +26,7 @@ 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;
@@ -68,10 +65,6 @@ public class RunnerRegistryResource extends TestableResource implements
RestPara
     @Inject
     private RunnerCoordinator runnerCoordinator;
 
-    @Inject
-    private StackCoordinator stackCoordinator;
-
-
     public RunnerRegistryResource() {
         super( ENDPOINT );
     }
@@ -197,30 +190,4 @@ public class RunnerRegistryResource extends TestableResource implements
RestPara
         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.debug( "USERNAME: {}", username );
-        LOG.debug( "MODULE_GROUPID: {}", groupId );
-        LOG.debug( "MODULE_ARTIFACTID: {}", artifactId );
-        LOG.debug( "MODULE_VERSION: {}", version );
-        LOG.debug( "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/87ccf72b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StartResource.java
----------------------------------------------------------------------
diff --git a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StartResource.java
b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StartResource.java
index 55dc11c..4a43ef6 100644
--- a/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StartResource.java
+++ b/chop/webapp/src/main/java/org/apache/usergrid/chop/webapp/coordinator/rest/StartResource.java
@@ -30,7 +30,6 @@ import org.apache.usergrid.chop.api.RestParams;
 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.stack.SetupStackState;
 import org.apache.usergrid.chop.webapp.coordinator.RunnerCoordinator;
 import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
@@ -194,8 +193,6 @@ public class StartResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        stack.setSetupState( SetupStackSignal.START );
-
         return Response.status( Response.Status.CREATED )
                        .entity( "Started chop tests" )
                        .type( MediaType.APPLICATION_JSON )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 8baabbd..a8c8694 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
@@ -29,8 +29,6 @@ import com.google.inject.Singleton;
 import org.apache.usergrid.chop.api.RestParams;
 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.stack.SetupStackState;
 import org.apache.usergrid.chop.webapp.coordinator.RunnerCoordinator;
 import org.apache.usergrid.chop.webapp.coordinator.StackCoordinator;
@@ -108,13 +106,13 @@ public class StopResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        if( ! status.equals( SetupStackState.Running ) ) {
+        if( ! status.equals( SetupStackState.SetUp ) ) {
             return Response.status( Response.Status.OK )
                            .entity( "Stack is " + status.toString() + ", cannot stop tests."
)
                            .type( MediaType.APPLICATION_JSON )
                            .build();
         }
-        /** SetupStackState.Running */
+        /** SetupStackState.Setup */
         LOG.info( "Stack is set up, checking runner states..." );
 
         /** Check state of all runners */
@@ -184,9 +182,6 @@ public class StopResource extends TestableResource implements RestParams
{
                            .build();
         }
 
-        CoordinatedStack stack = stackCoordinator.findCoordinatedStack( commitId, artifactId,
groupId, version, user );
-        stack.setSetupState( SetupStackSignal.STOP );
-
         return Response.status( Response.Status.CREATED )
                        .entity( "All running runners have been stopped." )
                        .type( MediaType.APPLICATION_JSON )

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/87ccf72b/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 f7378ab..edc0550 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
@@ -195,8 +195,8 @@ public class UploadResource extends TestableResource implements RestParams,
Cons
         LOG.debug( "extracted {} = {}", RestParams.MODULE_VERSION, version );
         LOG.debug( "extracted {} = {}", RestParams.USERNAME, username );
         LOG.debug( "extracted {} = {}", RestParams.VCS_REPO_URL, vcsRepoUrl );
-        LOG.debug( "extracted {} = {}", RestParams.TEST_PACKAGE, runnerCount );
-        LOG.debug( "extracted {} = {}", RestParams.RUNNER_COUNT, testPackage );
+        LOG.debug( "extracted {} = {}", RestParams.TEST_PACKAGE, testPackage );
+        LOG.debug( "extracted {} = {}", RestParams.RUNNER_COUNT, runnerCount );
         LOG.debug( "extracted {} = {}", RestParams.MD5, md5 );
 
         if( inTestMode( testMode ) ) {
@@ -261,7 +261,7 @@ public class UploadResource extends TestableResource implements RestParams,
Cons
             commitDao.save( commit );
         }
 
-        stackCoordinator.registerStack( commitId, artifactId, groupId, version, username,
runnerCount );
+//        stackCoordinator.registerStack( commitId, artifactId, groupId, version, username,
runnerCount );
 
         return Response.status( Response.Status.CREATED ).entity( runnerJar.getAbsolutePath()
).build();
     }


Mime
View raw message