continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r725313 - in /continuum/branches/continuum-distributed-builds: ./ continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/ continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/ continuum-builder/ continuum...
Date Wed, 10 Dec 2008 15:43:12 GMT
Author: ctan
Date: Wed Dec 10 07:43:11 2008
New Revision: 725313

URL: http://svn.apache.org/viewvc?rev=725313&view=rev
Log:
more changes in implementation of distributed buils

Added:
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java   (contents, props changed)
      - copied, changed from r725038, continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java   (contents, props changed)
      - copied, changed from r725038, continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
Removed:
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/spring-context.xml
Modified:
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/plexus/components.xml
    continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/pom.xml
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/src/main/java/org/apache/continuum/distributed/transport/master/ProxySlaveAgentTransportService.java
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp
    continuum/branches/continuum-distributed-builds/pom.xml

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java Wed Dec 10 07:43:11 2008
@@ -3,11 +3,14 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.system.Installation;
 
 public interface DistributedBuildManager
 {
+    String ROLE = DistributedBuildManager.class.getName();
+
     void cancelDistributedBuild( String buildAgentUrl, int projectGroupId, String scmRootAddress )
         throws ContinuumException;
 
@@ -26,4 +29,6 @@
 
     List<Installation> getAvailableInstallations( String buildAgentUrl )
         throws ContinuumException;
+
+    Map<String, PrepareBuildProjectsTask> getDistributedBuildProjects();
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java Wed Dec 10 07:43:11 2008
@@ -62,6 +62,9 @@
     boolean isInCurrentPrepareBuildTask( int projectId )
         throws TaskQueueManagerException;
 
+    boolean isInDistributedBuildQueue( int projectGroupId, String scmRootAddress )
+        throws TaskQueueManagerException;
+
     boolean isInPrepareBuildQueue( int projectId )
         throws TaskQueueManagerException;
 

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml Wed Dec 10 07:43:11 2008
@@ -33,6 +33,16 @@
     <dependency>
       <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-api</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.archiva</groupId>
+          <artifactId>archiva-common</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.apache.archiva</groupId>
+          <artifactId>archiva-repository-layer</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.continuum</groupId>
@@ -47,10 +57,6 @@
       <artifactId>continuum-distributed-build-transport-master</artifactId>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-spring</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.apache.xmlrpc</groupId>
       <artifactId>xmlrpc-server</artifactId>
       <version>3.0</version>

Copied: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java (from r725038, continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java)
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java?p2=continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java&p1=continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java&r1=725038&r2=725313&rev=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java Wed Dec 10 07:43:11 2008
@@ -31,12 +31,12 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class DistributedBuildTaskExecutor
-    implements TaskExecutor
+public class DistributedBuildProjectTaskExecutor
+    implements DistributedBuildTaskExecutor
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    private String agentUrl;
+    private String buildAgentUrl;
 
     private long startTime;
 
@@ -62,14 +62,14 @@
      */
     private BuildResultDao buildResultDao;
 
-    public void setAgentUrl( String agentUrl )
+    public void setBuildAgentUrl( String buildAgentUrl )
     {
-        this.agentUrl = agentUrl;
+        this.buildAgentUrl = buildAgentUrl;
     }
 
-    public String getAgentUrl()
+    public String getBuildAgentUrl()
     {
-        return agentUrl;
+        return buildAgentUrl;
     }
 
     public void executeTask( Task task )
@@ -79,7 +79,7 @@
 
         try
         {
-            ProxySlaveAgentTransportService client = new ProxySlaveAgentTransportService( new URL( agentUrl ) );
+            ProxySlaveAgentTransportService client = new ProxySlaveAgentTransportService( new URL( buildAgentUrl ) );
 
             log.info( "initializing buildContext" );
             List buildContext = initializeBuildContext( prepareBuildTask.getProjectsBuildDefinitionsMap(), 
@@ -91,7 +91,7 @@
         }
         catch ( MalformedURLException e )
         {
-            log.error( "Invalid URL " + agentUrl, e );
+            log.error( "Invalid URL " + buildAgentUrl, e );
             endTime = System.currentTimeMillis();
             createBuildResult( prepareBuildTask.getProjectsBuildDefinitionsMap(), prepareBuildTask.getTrigger(),
                                     ContinuumUtils.throwableToString( e ) );

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Dec 10 07:43:11 2008
@@ -0,0 +1,2 @@
+/continuum/branches/continuum-1.2.x/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java:690684,690689-690799,698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487,724016,724024
+/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java:713270-724659

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java Wed Dec 10 07:43:11 2008
@@ -1,214 +1,14 @@
 package org.apache.continuum.builder.distributed.executor;
 
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.continuum.builder.utils.ContinuumBuildConstant;
-import org.apache.continuum.dao.BuildDefinitionDao;
-import org.apache.continuum.dao.BuildResultDao;
-import org.apache.continuum.dao.ProjectDao;
-import org.apache.continuum.dao.ProjectScmRootDao;
-import org.apache.continuum.distributed.transport.master.ProxySlaveAgentTransportService;
-import org.apache.continuum.model.project.ProjectScmRoot;
-import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
-import org.apache.continuum.utils.ContinuumUtils;
-import org.apache.continuum.utils.ProjectSorter;
-import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.model.project.BuildDefinition;
-import org.apache.maven.continuum.model.project.BuildResult;
-import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.apache.xmlrpc.XmlRpcException;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
-import org.codehaus.plexus.util.dag.CycleDetectedException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-public class DistributedBuildTaskExecutor
-    implements TaskExecutor
+public interface DistributedBuildTaskExecutor
 {
-    private Logger log = LoggerFactory.getLogger( this.getClass() );
-
-    private String agentUrl;
-
-    private long startTime;
-
-    private long endTime;
-
-    /**
-     * @plexus.requirement
-     */
-    private ProjectDao projectDao;
-
-    /**
-     * @plexus.requirement
-     */
-    private ProjectScmRootDao projectScmRootDao;
-
-    /**
-     * @plexus.requirement
-     */
-    private BuildDefinitionDao buildDefinitionDao;
-
-    /**
-     * @plexus.requirement
-     */
-    private BuildResultDao buildResultDao;
-
-    public void setAgentUrl( String agentUrl )
-    {
-        this.agentUrl = agentUrl;
-    }
-
-    public String getAgentUrl()
-    {
-        return agentUrl;
-    }
-
-    public void executeTask( Task task )
-        throws TaskExecutionException
-    {
-        PrepareBuildProjectsTask prepareBuildTask = (PrepareBuildProjectsTask) task;
-
-        try
-        {
-            ProxySlaveAgentTransportService client = new ProxySlaveAgentTransportService( new URL( agentUrl ) );
-
-            log.info( "initializing buildContext" );
-            List buildContext = initializeBuildContext( prepareBuildTask.getProjectsBuildDefinitionsMap(), 
-                                                        prepareBuildTask.getTrigger() );
-
-            startTime = System.currentTimeMillis();
-            client.buildProjects( buildContext );
-            endTime = System.currentTimeMillis();
-        }
-        catch ( MalformedURLException e )
-        {
-            log.error( "Invalid URL " + agentUrl, e );
-            endTime = System.currentTimeMillis();
-            createBuildResult( prepareBuildTask.getProjectsBuildDefinitionsMap(), prepareBuildTask.getTrigger(),
-                                    ContinuumUtils.throwableToString( e ) );
-        }
-        catch ( Exception e )
-        {
-            log.error( "Error occurred while performing task", e );
-            endTime = System.currentTimeMillis();
-            createBuildResult( prepareBuildTask.getProjectsBuildDefinitionsMap(), prepareBuildTask.getTrigger(),
-                               ContinuumUtils.throwableToString( e ) );
-        }
-    }
-
-    private List initializeBuildContext( Map<Integer, Integer> projectsAndBuildDefinitions, 
-                                         int trigger )
-        throws ContinuumException
-    {
-        List buildContext = new ArrayList();
-        List<Project> projects = new ArrayList<Project>();
-
-        try
-        {
-            for ( Integer projectId : projectsAndBuildDefinitions.keySet() )
-            {
-                Project project = projectDao.getProjectWithDependencies( projectId );
-                projects.add( project );
-            }
-
-            try
-            {
-                projects = ProjectSorter.getSortedProjects( projects, null );
-            }
-            catch ( CycleDetectedException e )
-            {
-                log.info( "Cycle Detected" );
-            }
-
-            int ctr = 0;
-            
-            for ( Project project : projects )
-            {
-                if ( ctr == 0 )
-                {
-                    List<ProjectScmRoot> scmRoots = projectScmRootDao.getProjectScmRootByProjectGroup( project.getProjectGroup().getId() );
-                    for ( ProjectScmRoot scmRoot : scmRoots )
-                    {
-                        if ( project.getScmUrl().startsWith( scmRoot.getScmRootAddress() ) )
-                        {
-                            scmRoot.setOldState( scmRoot.getState() );
-                            scmRoot.setState( ContinuumProjectState.UPDATING );
-                            projectScmRootDao.updateProjectScmRoot( scmRoot );
-                            break;
-                        }
-                    }
-                }
-                
-                int buildDefinitionId = projectsAndBuildDefinitions.get( project.getId() );
-                BuildDefinition buildDef = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
-                BuildResult oldBuildResult =
-                    buildResultDao.getLatestBuildResultForBuildDefinition( project.getId(), buildDefinitionId );
-
-                Map context = new HashMap();
-                context.put( ContinuumBuildConstant.KEY_PROJECT_ID, project.getId() );
-                context.put( ContinuumBuildConstant.KEY_EXECUTOR_ID, project.getExecutorId() );
-                context.put( ContinuumBuildConstant.KEY_SCM_URL, project.getScmUrl() );
-                context.put( ContinuumBuildConstant.KEY_SCM_USERNAME, project.getScmUsername() );
-                context.put( ContinuumBuildConstant.KEY_SCM_PASSWORD, project.getScmPassword() );
-                context.put( ContinuumBuildConstant.KEY_BUILD_DEFINITION_ID, buildDefinitionId );
-                context.put( ContinuumBuildConstant.KEY_BUILD_FILE, buildDef.getBuildFile() );
-                context.put( ContinuumBuildConstant.KEY_GOALS, buildDef.getGoals() );
-                context.put( ContinuumBuildConstant.KEY_ARGUMENTS, buildDef.getArguments() );
-                context.put( ContinuumBuildConstant.KEY_TRIGGER, trigger );
-                context.put( ContinuumBuildConstant.KEY_BUILD_FRESH, buildDef.isBuildFresh() );
-                
-                buildContext.add( context );
-                ctr++;
-            }
-
-            return buildContext;
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new ContinuumException( "Error while initializing build context", e );
-        }
-    }
-
-    private void createBuildResult( Map<Integer, Integer> map, int trigger, String error )
-        throws TaskExecutionException
-    {
-        try
-        {
-            for ( Integer projectId : map.keySet() )
-            {
-                int buildDefinitionId = map.get( projectId );
-                Project project = projectDao.getProject( projectId );
-                BuildDefinition buildDef = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
+    void executeTask( Task task )
+        throws TaskExecutionException;
 
-                BuildResult latestBuildResult = buildResultDao.
-                                                    getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
-                if ( ( latestBuildResult.getStartTime() >= startTime && latestBuildResult.getEndTime() > 0 && 
-                       latestBuildResult.getEndTime() < endTime ) || latestBuildResult.getStartTime() < startTime )
-                {
-                    BuildResult buildResult = new BuildResult();
-                    buildResult.setBuildDefinition( buildDef );
-                    buildResult.setError( error );
-                    buildResult.setState( ContinuumProjectState.ERROR );
-                    buildResult.setTrigger( trigger );
-                    buildResult.setStartTime( startTime );
-                    buildResult.setEndTime( endTime );
+    String getBuildAgentUrl();
 
-                    buildResultDao.addBuildResult( project, buildResult );
-                }
-            }
-        }
-        catch ( ContinuumStoreException e )
-        {
-            throw new TaskExecutionException( "" );
-        }
-    }
+    void setBuildAgentUrl( String buildAgentUrl );
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java Wed Dec 10 07:43:11 2008
@@ -1,332 +1,38 @@
 package org.apache.continuum.builder.distributed.executor;
 
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
 import org.codehaus.plexus.taskqueue.Task;
-import org.codehaus.plexus.taskqueue.TaskQueue;
-import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
-import org.codehaus.plexus.util.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
-import edu.emory.mathcs.backport.java.util.concurrent.CancellationException;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutionException;
-import edu.emory.mathcs.backport.java.util.concurrent.ExecutorService;
-import edu.emory.mathcs.backport.java.util.concurrent.Executors;
-import edu.emory.mathcs.backport.java.util.concurrent.Future;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
-import edu.emory.mathcs.backport.java.util.concurrent.TimeoutException;
-
-/**
- * Codes were taken from Plexus' ThreadedTaskQueueExecutor
- */
-public class DistributedBuildTaskQueueExecutor
-    implements TaskQueueExecutor, Initializable, Startable
+public interface DistributedBuildTaskQueueExecutor
 {
-    private static final int SHUTDOWN = 1;
-
-    private static final int CANCEL_TASK = 2;
-
-    private Logger log = LoggerFactory.getLogger( this.getClass() );
-
-    /** @requirement */
-    private TaskQueue queue;
+    String ROLE = DistributedBuildTaskQueueExecutor.class.getName();
 
     /**
-     * @requirement
+     * Returns the build agent url of task queue executor
+     * 
+     * @return the build agent url
      */
-    private DistributedBuildTaskExecutor executor;
-
-    /** @configuration */
-    private String name;
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private ExecutorRunnable executorRunnable;
-
-    private ExecutorService executorService;
-
-    private Task currentTask;
-
-    private class ExecutorRunnable
-        extends Thread
-    {
-        private volatile int command;
-
-        private boolean done;
-
-        public void run()
-        {
-            while ( command != SHUTDOWN )
-            {
-                final Task task;
-
-                currentTask = null;
-
-                try
-                {
-                    task = queue.poll( 100, TimeUnit.MILLISECONDS );
-                }
-                catch ( InterruptedException e )
-                {
-                    log.info( "Executor thread interrupted, command: "
-                        + ( command == SHUTDOWN ? "Shutdown" : command == CANCEL_TASK ? "Cancel task" : "Unknown" ) );
-                    continue;
-                }
-
-                if ( task == null )
-                {
-                    continue;
-                }
-
-                currentTask = task;
-
-                Future future = executorService.submit( new Runnable()
-                {
-                    public void run()
-                    {
-                        try
-                        {
-                            executor.executeTask( task );
-                        }
-                        catch ( TaskExecutionException e )
-                        {
-                            log.error( "Error executing task", e );
-                        }
-                    }
-                } );
-
-                try
-                {
-                    waitForTask( task, future );
-                }
-                catch ( ExecutionException e )
-                {
-                    log.error( "Error executing task", e );
-                }
-            }
-
-            currentTask = null;
-
-            log.info( "Executor thread '" + name + "' exited." );
-
-            done = true;
-
-            synchronized ( this )
-            {
-                notifyAll();
-            }
-        }
-
-        private void waitForTask( Task task, Future future )
-            throws ExecutionException
-        {
-            boolean stop = false;
-
-            while ( !stop )
-            {
-                try
-                {
-                    if ( task.getMaxExecutionTime() == 0 )
-                    {
-                        log.debug( "Waiting indefinitely for task to complete" );
-                        future.get();
-                        return;
-                    }
-                    else
-                    {
-                        log.debug( "Waiting at most " + task.getMaxExecutionTime() + "ms for task completion" );
-                        future.get( task.getMaxExecutionTime(), TimeUnit.MILLISECONDS );
-                        log.debug( "Task completed within " + task.getMaxExecutionTime() + "ms" );
-                        return;
-                    }
-                }
-                catch ( InterruptedException e )
-                {
-                    switch ( command )
-                    {
-                        case SHUTDOWN:
-                        {
-                            log.info( "Shutdown command received. Cancelling task." );
-                            cancel( future );
-                            return;
-                        }
-
-                        case CANCEL_TASK:
-                        {
-                            command = 0;
-                            log.info( "Cancelling task" );
-                            cancel( future );
-                            return;
-                        }
-
-                        default:
-                            // when can this thread be interrupted, and should we ignore it if shutdown = false?
-                            log.warn( "Interrupted while waiting for task to complete; ignoring", e );
-                            break;
-                    }
-                }
-                catch ( TimeoutException e )
-                {
-                    log.warn( "Task " + task + " didn't complete within time, cancelling it." );
-                    cancel( future );
-                    return;
-                }
-                catch ( CancellationException e )
-                {
-                    log.warn( "The task was cancelled", e );
-                    return;
-                }
-            }
-        }
-
-        private void cancel( Future future )
-        {
-            if ( !future.cancel( true ) )
-            {
-                if ( !future.isDone() && !future.isCancelled() )
-                {
-                    log.warn( "Unable to cancel task" );
-                }
-                else
-                {
-                    log.warn( "Task not cancelled (Flags: done: " + future.isDone() + " cancelled: "
-                        + future.isCancelled() + ")" );
-                }
-            }
-            else
-            {
-                log.debug( "Task successfully cancelled" );
-            }
-        }
-
-        public synchronized void shutdown()
-        {
-            log.debug( "Signalling executor thread to shutdown" );
-
-            command = SHUTDOWN;
+    String getBuildAgentUrl();
 
-            interrupt();
-        }
-
-        public synchronized boolean cancelTask( Task task )
-        {
-            if ( !task.equals( currentTask ) )
-            {
-                log.debug( "Not cancelling task - it is not running" );
-                return false;
-            }
-
-            if ( command != SHUTDOWN )
-            {
-                log.debug( "Signalling executor thread to cancel task" );
-
-                command = CANCEL_TASK;
-
-                interrupt();
-            }
-            else
-            {
-                log.debug( "Executor thread already stopping; task will be cancelled automatically" );
-            }
-
-            return true;
-        }
-
-        public boolean isDone()
-        {
-            return done;
-        }
-    }
-
-    // ----------------------------------------------------------------------
-    // Component lifecycle
-    // ----------------------------------------------------------------------
-
-    public void initialize()
-        throws InitializationException
-    {
-        if ( StringUtils.isEmpty( name ) )
-        {
-            throw new IllegalArgumentException( "'name' must be set." );
-        }
-    }
-
-    public void start()
-        throws StartingException
-    {
-        log.info( "Starting task executor, thread name '" + name + "'." );
-
-        this.executorService = Executors.newSingleThreadExecutor();
-
-        executorRunnable = new ExecutorRunnable();
-
-        executorRunnable.setDaemon( true );
-
-        executorRunnable.start();
-    }
-
-    public void stop()
-        throws StoppingException
-    {
-        executorRunnable.shutdown();
-
-        int maxSleep = 10 * 1000; // 10 seconds
-
-        int interval = 1000;
-
-        long endTime = System.currentTimeMillis() + maxSleep;
-
-        while ( !executorRunnable.isDone() && executorRunnable.isAlive() )
-        {
-            if ( System.currentTimeMillis() > endTime )
-            {
-                log.warn( "Timeout waiting for executor thread '" + name + "' to stop, aborting" );
-                break;
-            }
-
-            log.info( "Waiting until task executor '" + name + "' is idling..." );
-
-            try
-            {
-                synchronized ( executorRunnable )
-                {
-                    executorRunnable.wait( interval );
-                }
-            }
-            catch ( InterruptedException ex )
-            {
-                // ignore
-            }
-
-            // notify again, just in case.
-            executorRunnable.shutdown();
-        }
-    }
-
-    public Task getCurrentTask()
-    {
-        return currentTask;
-    }
-
-    public synchronized boolean cancelTask( Task task )
-    {
-        return executorRunnable.cancelTask( task );
-    }
+    /**
+     * Sets the build agent url of this task queue executor
+     * 
+     * @param buildAgentUrl
+     */
+    void setBuildAgentUrl( String buildAgentUrl );
 
-    public void setBuildAgentUrl( String buildAgentUrl )
-    {
-        executor.setAgentUrl( buildAgentUrl );
-    }
+    /**
+     * Returns the currently executing task.
+     *
+     * @return the currently executing task.
+     */
+    Task getCurrentTask();
 
-    public String getBuildAgentUrl()
-    {
-        return executor.getAgentUrl();
-    }
+    /**
+     * Cancels execution of this task, if it's currently running.
+     * Does NOT remove it from the associated queue!
+     *
+     * @param task The task to cancel
+     * @return true if the task was cancelled, false if the task was not executing.
+     */
+    boolean cancelTask( Task task );
 }

Copied: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java (from r725038, continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java)
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java?p2=continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java&p1=continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java&r1=725038&r2=725313&rev=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java Wed Dec 10 07:43:11 2008
@@ -8,7 +8,6 @@
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -24,8 +23,8 @@
 /**
  * Codes were taken from Plexus' ThreadedTaskQueueExecutor
  */
-public class DistributedBuildTaskQueueExecutor
-    implements TaskQueueExecutor, Initializable, Startable
+public class ThreadedDistributedBuildTaskQueueExecutor
+    implements DistributedBuildTaskQueueExecutor, Initializable, Startable
 {
     private static final int SHUTDOWN = 1;
 
@@ -36,9 +35,7 @@
     /** @requirement */
     private TaskQueue queue;
 
-    /**
-     * @requirement
-     */
+    /** @requirement */
     private DistributedBuildTaskExecutor executor;
 
     /** @configuration */
@@ -322,11 +319,11 @@
 
     public void setBuildAgentUrl( String buildAgentUrl )
     {
-        executor.setAgentUrl( buildAgentUrl );
+        executor.setBuildAgentUrl( buildAgentUrl );
     }
 
     public String getBuildAgentUrl()
     {
-        return executor.getAgentUrl();
+        return executor.getBuildAgentUrl();
     }
 }

Propchange: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Dec 10 07:43:11 2008
@@ -0,0 +1,2 @@
+/continuum/branches/continuum-1.2.x/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java:690684,690689-690799,698449-698533,698817-698819,699529,700250,700273,700936,705894,705910,708339,722279,722624,723119,723487,724016,724024
+/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java:713270-724659

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java Wed Dec 10 07:43:11 2008
@@ -1,5 +1,6 @@
 package org.apache.continuum.builder.distributed.manager;
 
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -7,6 +8,7 @@
 import java.util.Map;
 
 import org.apache.continuum.builder.distributed.executor.DistributedBuildTaskQueueExecutor;
+import org.apache.continuum.builder.distributed.executor.ThreadedDistributedBuildTaskQueueExecutor;
 import org.apache.continuum.builder.utils.ContinuumBuildConstant;
 import org.apache.continuum.configuration.BuildAgentConfiguration;
 import org.apache.continuum.dao.BuildDefinitionDao;
@@ -16,6 +18,7 @@
 import org.apache.continuum.distributed.transport.master.ProxySlaveAgentTransportService;
 import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
+import org.apache.continuum.utils.ContinuumUtils;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
@@ -33,7 +36,8 @@
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,7 +46,7 @@
  * @author Maria Catherine Tan
  */
 public class DefaultDistributedBuildManager
-    implements DistributedBuildManager, Contextualizable
+    implements DistributedBuildManager, Contextualizable, Initializable
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
@@ -73,57 +77,7 @@
 
     private PlexusContainer container;
 
-    private Map<String, DistributedBuildTaskQueueExecutor> taskQueueExecutors;
-
-    public ConfigurationService getConfigurationService()
-    {
-        return configurationService;
-    }
-
-    public void setConfigurationService( ConfigurationService configurationService )
-    {
-        this.configurationService = configurationService;
-    }
-
-    public ProjectDao getProjectDao()
-    {
-        return projectDao;
-    }
-
-    public void setProjectDao( ProjectDao projectDao )
-    {
-        this.projectDao = projectDao;
-    }
-
-    public BuildDefinitionDao getBuildDefinitionDao()
-    {
-        return buildDefinitionDao;
-    }
-
-    public void setBuildDefinitionDao( BuildDefinitionDao buildDefinitionDao )
-    {
-        this.buildDefinitionDao = buildDefinitionDao;
-    }
-
-    public BuildResultDao getBuildResultDao()
-    {
-        return buildResultDao;
-    }
-
-    public void setBuildResultDao( BuildResultDao buildResultDao )
-    {
-        this.buildResultDao = buildResultDao;
-    }
-
-    public ProjectScmRootDao getProjectScmRootDao()
-    {
-        return projectScmRootDao;
-    }
-
-    public void setProjectScmRootDao( ProjectScmRootDao projectScmRootDao )
-    {
-        this.projectScmRootDao = projectScmRootDao;
-    }
+    private Map<String, ThreadedDistributedBuildTaskQueueExecutor> taskQueueExecutors;
 
     // --------------------------------
     //  Plexus Lifecycle
@@ -135,9 +89,9 @@
     }
 
     public void initialize()
-        throws ContinuumException, ComponentLookupException
+        throws InitializationException
     {
-        taskQueueExecutors = new HashMap<String, DistributedBuildTaskQueueExecutor>();
+        taskQueueExecutors = new HashMap<String, ThreadedDistributedBuildTaskQueueExecutor>();
 
         List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
 
@@ -147,8 +101,33 @@
             {
                 if ( agent.isEnabled() )
                 {
-                    log.info( "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
-                    addTaskQueueExecutor( agent.getUrl() );
+                    try
+                    {
+                        ProxySlaveAgentTransportService client = new ProxySlaveAgentTransportService( new URL( agent.getUrl() ) );
+                        
+                        if ( client.ping() )
+                        {
+                            log.info( "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
+                            addTaskQueueExecutor( agent.getUrl() );
+                        }
+                        else
+                        {
+                            log.info( "unable to ping build agent '" + agent.getUrl() + "'" );
+                        }
+                    }
+                    catch ( MalformedURLException e )
+                    {
+                        // do not throw exception, just log it
+                        log.info( "Invalid URL " + agent.getUrl() + ", not creating task queue executor" );
+                    }
+                    catch ( ContinuumException e )
+                    {
+                        throw new InitializationException( "Error while initializing distributed build task queue executors", e );
+                    }
+                    catch ( Exception e )
+                    {
+                        log.info( "unable to ping build agent '" + agent.getUrl() + "': " + ContinuumUtils.throwableToString( e ) );
+                    }
                 }
             }
         }
@@ -163,8 +142,29 @@
         {
             if ( agent.isEnabled() && !taskQueueExecutors.containsKey( agent.getUrl() ) )
             {
-                log.info( "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
-                addTaskQueueExecutor( agent.getUrl() );
+                try
+                {
+                    ProxySlaveAgentTransportService client = new ProxySlaveAgentTransportService( new URL( agent.getUrl() ) );
+                    
+                    if ( client.ping() )
+                    {
+                        log.info( "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
+                        addTaskQueueExecutor( agent.getUrl() );
+                    }
+                    else
+                    {
+                        log.info( "unable to ping build agent '" + agent.getUrl() + "'" );
+                    }
+                }
+                catch ( MalformedURLException e )
+                {
+                    // do not throw exception, just log it
+                    log.info( "Invalid URL " + agent.getUrl() + ", not creating task queue executor" );
+                }
+                catch ( Exception e )
+                {
+                    log.info( "unable to ping build agent '" + agent.getUrl() + "': " + ContinuumUtils.throwableToString( e ) );
+                }
             }
             else if ( !agent.isEnabled() && taskQueueExecutors.containsKey( agent.getUrl() ) )
             {
@@ -182,7 +182,7 @@
 
     public boolean isBuildAgentBusy( String buildAgentUrl )
     {
-        TaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
+        ThreadedDistributedBuildTaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
         
         if ( executor != null && executor.getCurrentTask() != null )
         {
@@ -198,21 +198,21 @@
         throws ContinuumException
     {
         try
-        {
-            DistributedBuildTaskQueueExecutor taskQueueExecutor = (DistributedBuildTaskQueueExecutor) container.
-                                                                                lookup( DistributedBuildTaskQueueExecutor.class );
+        {            
+            ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = (ThreadedDistributedBuildTaskQueueExecutor) container.
+                                                                          lookup( DistributedBuildTaskQueueExecutor.class, "distributed-build-project" );
             taskQueueExecutor.setBuildAgentUrl( url );
             taskQueueExecutors.put( url, taskQueueExecutor );
         }
         catch ( ComponentLookupException e )
         {
-            throw new ContinuumException( "Unable to lookup TaskQueueExecutor for distributed-build", e );
+            throw new ContinuumException( "Unable to lookup TaskQueueExecutor for distributed-build-project", e );
         }
     }
 
     public void cancelDistributedBuild( String buildAgentUrl, int projectGroupId, String scmRootAddress )
     {
-        DistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( buildAgentUrl );
+        ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( buildAgentUrl );
 
         if ( taskQueueExecutor != null )
         {
@@ -372,6 +372,25 @@
         }
     }
 
+    public Map<String, PrepareBuildProjectsTask> getDistributedBuildProjects()
+    {
+        Map<String, PrepareBuildProjectsTask> map = new HashMap<String, PrepareBuildProjectsTask>();
+
+        for ( String url : taskQueueExecutors.keySet() )
+        {
+            ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( url );
+
+            if ( taskQueueExecutor.getCurrentTask() != null )
+            {
+                PrepareBuildProjectsTask task = (PrepareBuildProjectsTask) taskQueueExecutor.getCurrentTask();
+                
+                map.put( url, task );
+            }
+        }
+
+        return map;
+    }
+
     public List<Installation> getAvailableInstallations( String buildAgentUrl )
         throws ContinuumException
     {

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/plexus/components.xml?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/resources/META-INF/plexus/components.xml Wed Dec 10 07:43:11 2008
@@ -19,6 +19,30 @@
 
 <component-set>
   <components>
+    
+    <component>
+      <role>org.apache.continuum.builder.distributed.manager.DistributedBuildManager</role>
+      <role-hint>default</role-hint>
+      <implementation>org.apache.continuum.builder.distributed.manager.DefaultDistributedBuildManager</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.ProjectDao</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.ProjectScmRootDao</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.BuildResultDao</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.BuildDefinitionDao</role>
+        </requirement>
+      </requirements>
+    </component>
+  
     <!--
      |
      | Distributed Build Task Queue
@@ -33,9 +57,9 @@
     </component>
 
     <component>
-      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+      <role>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskExecutor</role>
       <role-hint>distributed-build-project</role-hint>
-      <implementation>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskExecutor</implementation>
+      <implementation>org.apache.continuum.builder.distributed.executor.DistributedBuildProjectTaskExecutor</implementation>
       <requirements>
         <requirement>
           <role>org.apache.continuum.dao.ProjectDao</role>
@@ -54,12 +78,18 @@
 
     <component>
       <role>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskQueueExecutor</role>
+      <role-hint>distributed-build-project</role-hint>
+      <implementation>org.apache.continuum.builder.distributed.executor.ThreadedDistributedBuildTaskQueueExecutor</implementation>
       <instantiation-strategy>per-lookup</instantiation-strategy>
 	  <requirements>
         <requirement>
           <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
           <role-hint>distributed-build-project</role-hint>
         </requirement>
+        <requirement>
+          <role>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskExecutor</role>
+          <role-hint>distributed-build-project</role-hint>
+        </requirement>
       </requirements>
       <configuration>
         <name>distributed-build-project</name>

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/test/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManagerTest.java Wed Dec 10 07:43:11 2008
@@ -25,13 +25,9 @@
     {
         super.setUp();
 
-        //distributedBuildManager = (DistributedBuildManager) lookup( "distributedBuildManager" );
+        distributedBuildManager = (DistributedBuildManager) lookup( DistributedBuildManager.class );
     }
 
-    public void testSomething()
-    {
-    }
-/*
     public void testUpdateScmResult()
         throws Exception
     {
@@ -133,5 +129,4 @@
         assertEquals( expected.getException(), actual.getException() );
         assertEquals( expected.getProviderMessage(), actual.getProviderMessage() );
     }
-    */
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Wed Dec 10 07:43:11 2008
@@ -78,7 +78,7 @@
     private PlexusContainer container;
 
     /**
-     * @plexus.requirement role-hint="distributed-build"
+     * @plexus.requirement role-hint="distributed-build-project"
      */
     private TaskQueue distributedBuildQueue;
 
@@ -359,7 +359,33 @@
         
         return false;
     }
-    
+
+    public boolean isInDistributedBuildQueue( int projectGroupId, String scmRootAddress )
+        throws TaskQueueManagerException
+    {
+        try
+        {
+            List<PrepareBuildProjectsTask> queue = distributedBuildQueue.getQueueSnapshot();
+
+            for ( PrepareBuildProjectsTask task : queue )
+            {
+                if ( task != null )
+                {
+                    if ( task.getProjectGroupId() == projectGroupId && task.getScmRootAddress().equals( scmRootAddress ) )
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new TaskQueueManagerException( "Error while getting the tasks in distributed build queue", e );
+        }
+    }
+
     public boolean isInPrepareBuildQueue( int projectId )
         throws TaskQueueManagerException
     {
@@ -371,7 +397,7 @@
             {
                 if ( task != null )
                 {
-                    Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task).getProjectsBuildDefinitionsMap();
+                    Map<Integer, Integer> map = task.getProjectsBuildDefinitionsMap();
                     
                     if ( map.size() > 0 )
                     {

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Wed Dec 10 07:43:11 2008
@@ -603,6 +603,12 @@
 
             try
             {
+                if ( taskQueueManager.isInPrepareBuildQueue( projectId ) )
+                {
+                    taskQueueManager.removeFromPrepareBuildQueue( project.getProjectGroup().getId(), 
+                                                                  getProjectScmRootByProject( projectId ).getScmRootAddress() );
+                }
+
                 if ( taskQueueManager.isInCheckoutQueue( projectId ) )
                 {
                     taskQueueManager.removeProjectFromCheckoutQueue( projectId );
@@ -3344,13 +3350,21 @@
         {
             if ( configurationService.isDistributedBuildEnabled() )
             {
-                taskQueueManager.getDistributedBuildQueue().put( task );
+                // check if 
+                if ( !taskQueueManager.isInDistributedBuildQueue( projectGroupId, scmRootAddress ) )
+                {
+                    taskQueueManager.getDistributedBuildQueue().put( task );
+                }
             }
             else
             {
                 taskQueueManager.getPrepareBuildQueue().put( task );
             }
         }
+        catch ( TaskQueueManagerException e )
+        {
+            throw logAndCreateException( e.getMessage(), e );
+        }
         catch ( TaskQueueException e )
         {
             throw logAndCreateException( "Error while creating enqueuing object.", e );

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/pom.xml?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/pom.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/pom.xml Wed Dec 10 07:43:11 2008
@@ -30,10 +30,6 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.continuum</groupId>
-      <artifactId>continuum-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.continuum</groupId>
       <artifactId>continuum-distributed-build-transport-common</artifactId>
     </dependency>
   </dependencies>

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/src/main/java/org/apache/continuum/distributed/transport/master/ProxySlaveAgentTransportService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/src/main/java/org/apache/continuum/distributed/transport/master/ProxySlaveAgentTransportService.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/src/main/java/org/apache/continuum/distributed/transport/master/ProxySlaveAgentTransportService.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-distributed-build-transport/continuum-distributed-build-transport-master/src/main/java/org/apache/continuum/distributed/transport/master/ProxySlaveAgentTransportService.java Wed Dec 10 07:43:11 2008
@@ -76,8 +76,10 @@
     {
         try
         {
-            slave.buildProjects( projectsBuildContext );
+            //slave.buildProjects( projectsBuildContext );
             log.info( "Building projects." );
+            Thread.sleep( 2000000 );
+            log.info( "Build finished" );
         }
         catch ( Exception e )
         {
@@ -147,8 +149,9 @@
     public boolean ping()
         throws Exception
     {
-        boolean result = slave.ping();
-        
+        //boolean result = slave.ping();
+        boolean result = true;
+
         log.info( "Ping " + (result ? "ok" : "failed") );
         
         return result;

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java Wed Dec 10 07:43:11 2008
@@ -21,13 +21,19 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.builder.distributed.BuildAgentListener;
 import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
+import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.dao.ProjectGroupDao;
+import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectGroup;
 import org.apache.maven.continuum.scm.queue.CheckOutTask;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumActionSupport;
@@ -98,12 +104,34 @@
 
     private String buildAgentUrl;
 
-    private List<Integer> selectedProjects;
+    private int projectGroupId;
+
+    private String scmRootAddress;
 
     // -----------------------------------------------------
     //  webwork
     // -----------------------------------------------------     
 
+    public int getProjectGroupId()
+    {
+        return projectGroupId;
+    }
+
+    public void setProjectGroupId( int projectGroupId )
+    {
+        this.projectGroupId = projectGroupId;
+    }
+
+    public String getScmRootAddress()
+    {
+        return scmRootAddress;
+    }
+
+    public void setScmRootAddress( String scmRootAddress )
+    {
+        this.scmRootAddress = scmRootAddress;
+    }
+
     public String cancelCurrent()
         throws Exception
     {
@@ -174,24 +202,27 @@
     public String display()
         throws Exception
     {
-        if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
+        Continuum continuum = getContinuum();
+
+        if ( continuum.getConfiguration().isDistributedBuildEnabled() )
         {
             distributedBuildSummary = new ArrayList<DistributedBuildSummary>();
-            
-            for ( BuildAgentListener listener : distributedBuildManager.getBuildAgentListeners() )
+
+            Map<String, PrepareBuildProjectsTask> map = distributedBuildManager.getDistributedBuildProjects();
+
+            for ( String url : map.keySet() )
             {
-                if ( listener.hasProjects() )
-                {
-                    for ( Project project : listener.getProjects() )
-                    {
-                        DistributedBuildSummary summary = new DistributedBuildSummary();
-                        summary.setProjectId( project.getId() );
-                        summary.setProjectName( project.getName() );
-                        summary.setUrl( listener.getUrl() );
-                        
-                        distributedBuildSummary.add( summary );
-                    }
-                }
+               PrepareBuildProjectsTask task = map.get( url );
+               
+               ProjectGroup projectGroup = continuum.getProjectGroup( task.getProjectGroupId() );
+               
+               DistributedBuildSummary summary = new DistributedBuildSummary();
+               summary.setUrl( url );
+               summary.setProjectGroupId( task.getProjectGroupId() );
+               summary.setProjectGroupName( projectGroup.getName() );
+               summary.setScmRootAddress( task.getScmRootAddress() );
+
+               distributedBuildSummary.add( summary );
             }
 
             return DISTRIBUTED_BUILD_SUCCESS;
@@ -295,7 +326,7 @@
             return REQUIRES_AUTHENTICATION;
         }
 
-        distributedBuildManager.cancelDistributedBuild( buildAgentUrl, projectId );
+        distributedBuildManager.cancelDistributedBuild( buildAgentUrl, projectGroupId, scmRootAddress );
 
         return SUCCESS;
     }
@@ -469,14 +500,4 @@
     {
         this.buildAgentUrl = buildAgentUrl;
     }
-
-    public List<Integer> getSelectedProjects()
-    {
-        return selectedProjects;
-    }
-
-    public void setSelectedProjects( List<Integer> selectedProjects )
-    {
-        this.selectedProjects = selectedProjects;
-    }
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo Wed Dec 10 07:43:11 2008
@@ -480,24 +480,31 @@
       <version>1.0.0+</version>
       <fields>
         <field>
-          <name>projectId</name>
+          <name>url</name>
           <version>1.0.0</version>
           <required>true</required>
-          <description>ID of the project</description>
+          <description>URL of the build agent</description>
+          <type>String</type>
+        </field>
+        <field>
+          <name>projectGroupId</name>
+          <version>1.0.0</version>
+          <required>true</required>
+          <description>ID of the project group</description>
           <type>int</type>
         </field>
         <field>
-          <name>projectName</name>
+          <name>projectGroupName</name>
           <version>1.0.0</version>
           <required>true</required>
-          <description>Name of the project</description>
+          <description>Name of the project group</description>
           <type>String</type>
         </field>
         <field>
-          <name>url</name>
+          <name>scmRootAddress</name>
           <version>1.0.0</version>
           <required>true</required>
-          <description>URL of the build agent</description>
+          <description>Scm root address of projects</description>
           <type>String</type>
         </field>
       </fields>

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties Wed Dec 10 07:43:11 2008
@@ -983,4 +983,13 @@
 # ----------------------------------------------------------------------
 deleteBuildAgent.page.title = Continuum - Delete Build Agent
 deleteBuildAgent.section.title = Delete Build Agent
-deleteBuildAgent.confirmation.message = Are you sure you want to delete build agent {0} ?
\ No newline at end of file
+deleteBuildAgent.confirmation.message = Are you sure you want to delete build agent {0} ?
+
+# ----------------------------------------------------------------------
+# Page: View Distributed Build
+# ----------------------------------------------------------------------
+distributedBuilds.page.title = Continuum - View Distributed Builds
+distributedBuilds.section.title = View Distributed Builds
+distributedBuild.table.projectGroupName = Project Group Name
+distributedBuild.table.scmRootAddress = Scm Root Address
+distributedBuild.table.agentUrl = Build Agent URL
\ No newline at end of file

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml Wed Dec 10 07:43:11 2008
@@ -908,10 +908,7 @@
     <action name="viewBuildAgent" class="buildAgent" method="view">
       <result name="success">/WEB-INF/jsp/admin/viewBuildAgent.jsp</result>
     </action>
-    
-    <action name="viewDistributedBuilds" class="distributedBuild" method="view">
-      <result name="success">/WEB-INF/jsp/admin/viewDistributedBuilds.jsp</result>
-    </action>
+
   </package>
 
   <package name="component" extends="default">

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp Wed Dec 10 07:43:11 2008
@@ -47,11 +47,13 @@
                     sortable="false"
                     filterable="false">
             <ec:row>
-              <ec:column property="projectName" title="distributedBuild.table.project"/>
+              <ec:column property="projectGroupName" title="distributedBuild.table.projectGroupName"/>
+              <ec:column property="scmRootAddress" title="distributedBuild.table.scmRootAddress"/>
               <ec:column property="url" title="distributedBuild.table.agentUrl"/>
               <ec:column property="cancelEntry" title="&nbsp;" width="1%">
                 <s:url id="cancelUrl" action="cancelDistributedBuild" method="cancelDistributedBuild" namespace="/">
-                  <s:param name="projectId">${pageScope.distributedBuild.projectId}</s:param>
+                  <s:param name="projectGroupId">${pageScope.distributedBuild.projectGroupId}</s:param>
+                  <s:param name="scmRootAddress">${pageScope.distributedBuild.scmRootAddress}</s:param>
                   <s:param name="buildAgentUrl">${pageScope.distributedBuild.url}</s:param>
                 </s:url>
                 <s:a href="%{cancelUrl}"><img src="<s:url value='/images/cancelbuild.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0"></s:a>

Modified: continuum/branches/continuum-distributed-builds/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/pom.xml?rev=725313&r1=725312&r2=725313&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/pom.xml (original)
+++ continuum/branches/continuum-distributed-builds/pom.xml Wed Dec 10 07:43:11 2008
@@ -572,10 +572,20 @@
       </dependency>
       <dependency>
         <groupId>org.apache.continuum</groupId>
+        <artifactId>continuum-distributed-build-transport-common</artifactId>
+        <version>${pom.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.continuum</groupId>
         <artifactId>continuum-distributed-build-transport-master</artifactId>
         <version>${pom.version}</version>
       </dependency>
       <dependency>
+        <groupId>org.apache.continuum</groupId>
+        <artifactId>continuum-distributed-build-transport-slave</artifactId>
+        <version>${pom.version}</version>
+      </dependency>
+      <dependency>
         <groupId>net.sf.ehcache</groupId>
         <artifactId>ehcache</artifactId>
         <version>1.5.0</version>



Mime
View raw message