continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r724705 - in /continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder: DistributedContinuumBuilder.java distributed/manager/AbstractDistributedBuildManager.java
Date Tue, 09 Dec 2008 14:01:27 GMT
Author: ctan
Date: Tue Dec  9 06:01:27 2008
New Revision: 724705

URL: http://svn.apache.org/viewvc?rev=724705&view=rev
Log:
more refactoring

Added:
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
  (with props)
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
  (with props)

Added: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java?rev=724705&view=auto
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
(added)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
Tue Dec  9 06:01:27 2008
@@ -0,0 +1,50 @@
+package org.apache.continuum.builder;
+
+import java.util.List;
+
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
+import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
+import org.apache.maven.continuum.ContinuumException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Maria Catherine Tan
+ * @plexus.component role="org.apache.continuum.builder.ContinuumBuilder" role-hint="distributedBuild"
+ */
+public class DistributedContinuumBuilder
+    implements ContinuumBuilder
+{
+    private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+    /**
+     * @plexus.requirement
+     */
+    private DistributedBuildManager distributedBuildManager;
+    
+    public void buildProjects( PrepareBuildProjectsTask task )
+        throws ContinuumException
+    {
+        List<PrepareBuildProjectsTask> tasks = distributedBuildManager.getDistributedBuildQueue();
+        boolean found = false;
+        
+        for ( PrepareBuildProjectsTask t : tasks )
+        {
+            if ( t.getProjectGroupId() == task.getProjectGroupId() && t.getScmRootAddress().equals(
task.getScmRootAddress() ) )
+            {
+                found = true;
+            }
+        }
+
+        if ( found )
+        {
+            log.info( "build task already in queue, waiting for available build agent..."
);
+        }
+        else
+        {
+            log.info( "add build task to queue" );
+            distributedBuildManager.getDistributedBuildQueue().add( task );
+            distributedBuildManager.buildProjectsInQueue();
+        }
+    }
+}

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/DistributedContinuumBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java?rev=724705&view=auto
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
(added)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
Tue Dec  9 06:01:27 2008
@@ -0,0 +1,213 @@
+package org.apache.continuum.builder.distributed.manager;
+
+import java.util.Map;
+
+public abstract class AbstractDistributedBuildManager
+    implements DistributedBuildManager
+{
+    public static final String KEY_PROJECT_ID = "project-id";
+
+    public static final String KEY_BUILD_DEFINITION_ID = "builddefinition-id";
+
+    public static final String KEY_TRIGGER = "trigger";
+
+    public static final String KEY_EXECUTOR_ID = "executor-id";
+
+    public static final String KEY_SCM_URL = "scm-url";
+
+    public static final String KEY_SCM_USERNAME = "scm-username";
+
+    public static final String KEY_SCM_PASSWORD = "scm-password";
+
+    public static final String KEY_BUILD_FILE = "build-file";
+
+    public static final String KEY_GOALS = "goals";
+
+    public static final String KEY_ARGUMENTS = "arguments";
+
+    public static final String KEY_BUILD_FRESH = "build-fresh";
+
+    public static final String KEY_BUILD_START = "build-start";
+
+    public static final String KEY_BUILD_END = "build-end";
+
+    public static final String KEY_BUILD_ERROR = "build-error";
+
+    public static final String KEY_BUILD_EXIT_CODE = "build-exit-code";
+
+    public static final String KEY_BUILD_STATE = "build-state";
+
+    public static final String KEY_SCM_COMMAND_OUTPUT = "scm-command-output";
+
+    public static final String KEY_SCM_COMMAND_LINE = "scm-command-line";
+
+    public static final String KEY_SCM_PROVIDER_MESSAGE = "scm-provider-message";
+
+    public static final String KEY_SCM_EXCEPTION = "scm-exception";
+
+    public static final String KEY_PREPARE_BUILD_FINISHED = "prepare-build-finished";
+
+    public static int getProjectId( Map context )
+    {
+        return getInteger( context, KEY_PROJECT_ID );
+    }
+
+    public static int getBuildDefinitionId( Map context )
+    {
+        return getInteger( context, KEY_BUILD_DEFINITION_ID );
+    }
+
+    public static String getBuildError( Map context )
+    {
+        return getString( context, KEY_BUILD_ERROR );
+    }
+
+    public static int getTrigger( Map context )
+    {
+        return getInteger( context, KEY_TRIGGER );
+    }
+
+    public static long getBuildStart( Map context )
+    {
+        return getLong( context, KEY_BUILD_START );
+    }
+
+    public static long getBuildEnd( Map context )
+    {
+        return getLong( context, KEY_BUILD_END );
+    }
+
+    public static int getBuildExitCode( Map context )
+    {
+        return getInteger( context, KEY_BUILD_EXIT_CODE );
+    }
+
+    public static int getBuildState( Map context )
+    {
+        return getInteger( context, KEY_BUILD_STATE );
+    }
+
+    public static String getScmCommandLine( Map context )
+    {
+        return getString( context, KEY_SCM_COMMAND_LINE );
+    }
+
+    public static String getScmCommandOutput( Map context )
+    {
+        return getString( context, KEY_SCM_COMMAND_OUTPUT );
+    }
+
+    public static String getScmException( Map context )
+    {
+        return getString( context, KEY_SCM_EXCEPTION );
+    }
+
+    public static String getScmProviderMessage( Map context )
+    {
+        return getString( context, KEY_SCM_PROVIDER_MESSAGE );
+    }
+
+    public static boolean isPrepareBuildFinished( Map context )
+    {
+        return getBoolean( context, KEY_PREPARE_BUILD_FINISHED );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    protected static String getString( Map context, String key )
+    {
+        Object obj = getObject( context, key, null );
+
+        if ( obj == null )
+        {
+            return null;
+        }
+        else
+        {
+            return (String) obj;
+        }
+    }
+
+    protected static String getString( Map context, String key, String defaultValue )
+    {
+        return (String) getObject( context, key, defaultValue );
+    }
+
+    protected static boolean getBoolean( Map context, String key )
+    {
+        Object obj = getObject( context, key, null );
+        
+        if ( obj == null )
+        {
+            return false;
+        }
+        else
+        {
+            return ( (Boolean) obj ).booleanValue();
+        }
+    }
+    
+    protected static boolean getBoolean( Map context, String key, boolean defaultValue )
+    {
+        return ( (Boolean) getObject( context, key, Boolean.valueOf( defaultValue ) ) ).booleanValue();
+    }    
+
+    protected static int getInteger( Map context, String key )
+    {
+        Object obj = getObject( context, key, null );
+        
+        if ( obj == null )
+        {
+            return 0;
+        }
+        else
+        {
+            return ( (Integer) obj ).intValue();
+        }
+    }
+
+    protected static long getLong( Map context, String key )
+    {
+        Object obj = getObject( context, key, null );
+        
+        if ( obj == null )
+        {
+            return 0;
+        }
+        else
+        {
+            return ( (Long) obj ).longValue();
+        }
+    }
+
+    protected static Object getObject( Map context, String key )
+    {
+        if ( !context.containsKey( key ) )
+        {
+            throw new RuntimeException( "Missing key '" + key + "'." );
+        }
+
+        Object value = context.get( key );
+
+        if ( value == null )
+        {
+            throw new RuntimeException( "Missing value for key '" + key + "'." );
+        }
+
+        return value;
+    }
+
+    protected static Object getObject( Map context, String key, Object defaultValue )
+    {
+        Object value = context.get( key );
+
+        if ( value == null )
+        {
+            return defaultValue;
+        }
+
+        return value;
+    }
+}

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/AbstractDistributedBuildManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message