You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by oc...@apache.org on 2008/12/12 11:31:39 UTC
svn commit: r725959 [1/2] - in /continuum/branches/continuum-parallel-builds:
continuum-api/src/main/java/org/apache/continuum/buildmanager/
continuum-api/src/main/java/org/apache/continuum/taskqueue/
continuum-api/src/main/java/org/apache/continuum/ta...
Author: oching
Date: Fri Dec 12 02:31:37 2008
New Revision: 725959
URL: http://svn.apache.org/viewvc?rev=725959&view=rev
Log:
- started migrating components from TaskQueueManager to BuildsManager
- cleaned up some of the parallel builds code
Modified:
continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/resources/META-INF/plexus/components.xml
continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueueTest.java
continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/CancelBuildAction.java
continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SummaryAction.java
continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
continuum/branches/continuum-parallel-builds/continuum-xmlrpc/continuum-xmlrpc-server/src/main/java/org/apache/maven/continuum/xmlrpc/server/ContinuumServiceImpl.java
Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java Fri Dec 12 02:31:37 2008
@@ -28,6 +28,8 @@
import org.apache.maven.continuum.model.project.Project;
/**
+ * BuildsManager. All builds whether forced or triggered will go through (or have to be added through)
+ * a builds manager.
*
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
*
@@ -36,7 +38,7 @@
{
// NOTE: deng parallel builds
// I think we can move out the prepare build queue from the build manager?
- // only builds and checkouts should be executed in parallel? :D
+ // only builds and checkouts should be executed in parallel? :D <-- i don't think so :)
public void buildProjects( List<Project> projects, Map<Integer, BuildDefinition> projectsBuildDefinitionsMap, int trigger ) throws BuildManagerException;
@@ -44,7 +46,7 @@
//public void prepareBuildProjects( Collection<Map<Integer, Integer>> projectsBuildDefinitions, int trigger, int scheduleId );
- //public void prepareBuildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger, int scheduleId );
+ public void prepareBuildProject( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger ) throws BuildManagerException;
// project checkout doesn't require dependency checking
public void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername, String scmPassword, BuildDefinition defaultBuildDefinition ) throws BuildManagerException;
@@ -65,12 +67,19 @@
public void removeProjectFromBuildQueue( int projectId ) throws BuildManagerException;
+ public void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName ) throws BuildManagerException;
+
+ // TODO: should we throw an exception when one of the projects cannot be removed?
public void removeProjectsFromBuildQueue( int[] projectIds );
+ //TODO: implement this.. but how????
+ //public void removeProjectsFromBuildQueueWithHashcodes( int[] hashcodes ) throws BuildManagerException;
+
public void removeProjectFromCheckoutQueue( int projectId ) throws BuildManagerException;
public void removeProjectsFromCheckoutQueue( int[] projectIds );
+ //TODO: implement this!
//public void removeProjectFromPrepareBuildQueue( int projectId );
// public void removeProjectsFromPrepareBuildQueue( int[] projectIds );
@@ -79,4 +88,21 @@
public void removeOverallBuildQueue( int overallBuildQueueId ) throws BuildManagerException;
+ public boolean isInAnyBuildQueue( int projectId ) throws BuildManagerException;
+
+ public boolean isInAnyBuildQueue( int projectId, int buildDefinitionId ) throws BuildManagerException;
+
+ public boolean isInAnyCheckoutQueue( int projectId ) throws BuildManagerException;
+
+ public boolean isInPrepareBuildQueue( int projectId ) throws BuildManagerException;
+
+ public boolean isProjectInAnyCurrentBuild( int projectId ) throws BuildManagerException;
+
+ // TODO: deng - add the following methods (needed by QueuesAction in webapp)
+ // maybe these could return a new object which contains the name of the build queue (overall) and the current task?
+ // - add getCurrentBuilds(..)
+ // - add getCurrentCheckouts(..)
+ // - add getAllQueuedBuilds(..)
+ // - add getAllQueuedCheckouts(...)
+ // - buildInProgress() <-- used in purge (see taskQueuemanager for impl)
}
Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java Fri Dec 12 02:31:37 2008
@@ -22,6 +22,7 @@
import java.util.List;
import org.apache.maven.continuum.buildqueue.BuildProjectTask;
+import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.TaskQueue;
@@ -128,7 +129,7 @@
*
* @return
*/
- TaskQueue getPrepareBuildQueue();
+ //TaskQueue getPrepareBuildQueue();
/**
* Returns the task queue executor of the prepare-build-projects queue.
@@ -136,8 +137,8 @@
* @return
* @throws ComponentLookupException TODO
*/
- TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
- throws ComponentLookupException;
+ // TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+ // throws ComponentLookupException;
/**
* Add prepare build task to prepare-build-project queue.
@@ -145,8 +146,8 @@
* @param prepareBuildTask
* @throws TaskQueueException TODO
*/
- void addToPrepareBuildQueue( Task prepareBuildTask )
- throws TaskQueueException;
+ // void addToPrepareBuildQueue( Task prepareBuildTask )
+ // throws TaskQueueException;
/**
* Add prepare build tasks to prepare-build-project queue
@@ -154,8 +155,8 @@
* @param prepareBuildTasks
* @throws TaskQueueException TODO
*/
- void addToPrepareBuildQueue( List<Task> prepareBuildTasks )
- throws TaskQueueException;
+ // void addToPrepareBuildQueue( List<Task> prepareBuildTasks )
+ // throws TaskQueueException;
/**
* Checks if the project is in the prepare-build-projects queue.
@@ -164,8 +165,8 @@
* @return
* @throws TaskQueueException TODO
*/
- boolean isInPrepareBuildQueue( int projectId )
- throws TaskQueueException;
+ // boolean isInPrepareBuildQueue( int projectId )
+ // throws TaskQueueException;
/**
* Checks if the current prepare build task being executed is the specified project.
@@ -174,8 +175,8 @@
* @return
* @throws TaskQueueException TODO
*/
- boolean isCurrentPrepareBuildTaskInExecution( int projectId )
- throws TaskQueueException;
+ // boolean isCurrentPrepareBuildTaskInExecution( int projectId )
+ // throws TaskQueueException;
/* Build Queue */
@@ -192,8 +193,8 @@
* @return
* @throws ComponentLookupException TODO
*/
- TaskQueueExecutor getBuildTaskQueueExecutor()
- throws ComponentLookupException;
+ //TaskQueueExecutor getBuildTaskQueueExecutor()
+ // throws ComponentLookupException;
/**
* Add the build task to the build queue.
@@ -219,8 +220,8 @@
* @return
* @throws TaskQueueException TODO
*/
- int getProjectIdInCurrentBuild()
- throws TaskQueueException;
+ // int getProjectIdInCurrentBuild()
+ // throws TaskQueueException;
/**
* Returns the build tasks in the build queue.
@@ -237,8 +238,8 @@
* @return
* @throws TaskQueueException TODO
*/
- boolean isBuildInProgress()
- throws TaskQueueException;
+ //boolean isBuildInProgress()
+ // throws TaskQueueException;
/**
* Checks if the specified project is in the build queue.
@@ -265,19 +266,19 @@
* Cancel the build task of the corresponding project.
*
* @param projectId
- * @throws TaskQueueException TODO
+ * @throws ComponentLookupException TODO
*/
void cancelBuildTask( int projectId )
- throws TaskQueueException;
+ throws ComponentLookupException;
/**
* Cancel the current build.
*
* @return
- * @throws TaskQueueException TODO
+ * @throws ComponentLookupException TODO
*/
boolean cancelCurrentBuild()
- throws TaskQueueException;
+ throws ComponentLookupException;
/**
* Remove the project matching the specified id, name, build definition and trigger from the build queue.
@@ -320,4 +321,6 @@
*/
void removeProjectsFromBuildQueueWithHashCodes( int[] hashCodes )
throws TaskQueueException;
+
+ void setContainer( PlexusContainer container );
}
Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java Fri Dec 12 02:31:37 2008
@@ -20,13 +20,13 @@
boolean buildInProgress()
throws TaskQueueManagerException;
- void cancelBuildTask( int projectId )
- throws TaskQueueManagerException;
+ //void cancelBuildTask( int projectId )
+ // throws TaskQueueManagerException;
boolean cancelCurrentBuild()
throws TaskQueueManagerException;
- TaskQueue getBuildQueue();
+ //TaskQueue getBuildQueue();
TaskQueueExecutor getBuildTaskQueueExecutor()
throws TaskQueueManagerException;
@@ -36,10 +36,10 @@
List /* CheckOutTask */getCheckOutTasksInQueue()
throws TaskQueueManagerException;
- int getCurrentProjectIdBuilding()
- throws TaskQueueManagerException;
+ //int getCurrentProjectIdBuilding()
+ // throws TaskQueueManagerException;
- TaskQueue getPrepareBuildQueue();
+ //TaskQueue getPrepareBuildQueue();
TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
throws TaskQueueManagerException;
@@ -49,20 +49,20 @@
TaskQueue getPurgeQueue();
- boolean isInBuildingQueue( int projectId )
- throws TaskQueueManagerException;
+ //boolean isInBuildingQueue( int projectId )
+ // throws TaskQueueManagerException;
- boolean isInBuildingQueue( int projectId, int buildDefinitionId )
- throws TaskQueueManagerException;
+ //boolean isInBuildingQueue( int projectId, int buildDefinitionId )
+ // throws TaskQueueManagerException;
- boolean isInCheckoutQueue( int projectId )
- throws TaskQueueManagerException;
+ //boolean isInCheckoutQueue( int projectId )
+ // throws TaskQueueManagerException;
- boolean isInCurrentPrepareBuildTask( int projectId )
- throws TaskQueueManagerException;
+ //boolean isInCurrentPrepareBuildTask( int projectId )
+ // throws TaskQueueManagerException;
- boolean isInPrepareBuildQueue( int projectId )
- throws TaskQueueManagerException;
+ //boolean isInPrepareBuildQueue( int projectId )
+ // throws TaskQueueManagerException;
boolean isInPurgeQueue( int purgeConfigurationId )
throws TaskQueueManagerException;
@@ -90,8 +90,8 @@
boolean releaseInProgress()
throws TaskQueueManagerException;
- boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
- throws TaskQueueManagerException;
+ //boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
+ // throws TaskQueueManagerException;
/**
* Remove local repository from the purge queue
@@ -113,11 +113,11 @@
boolean removeFromPurgeQueue( int[] purgeConfigIds )
throws TaskQueueManagerException;
- boolean removeProjectFromBuildingQueue( int projectId )
- throws TaskQueueManagerException;
+// boolean removeProjectFromBuildingQueue( int projectId )
+ // throws TaskQueueManagerException;
- boolean removeProjectsFromBuildingQueue( int[] projectsId )
- throws TaskQueueManagerException;
+ //boolean removeProjectsFromBuildingQueue( int[] projectsId )
+ // throws TaskQueueManagerException;
/**
* @param hashCodes BuildProjectTask hashCodes
Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Fri Dec 12 02:31:37 2008
@@ -24,6 +24,7 @@
import java.util.List;
import java.util.Map;
+import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.model.release.ContinuumReleaseResult;
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.continuum.purge.ContinuumPurgeManager;
@@ -630,6 +631,11 @@
// ----------------------------------------------------------------------
TaskQueueManager getTaskQueueManager();
+ // ----------------------------------------------------------------------
+ // Builds Manager
+ // ----------------------------------------------------------------------
+ BuildsManager getBuildsManager();
+
public void startup()
throws ContinuumException;
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java Fri Dec 12 02:31:37 2008
@@ -33,40 +33,86 @@
import org.apache.maven.continuum.model.project.BuildQueue;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.scm.queue.CheckOutTask;
+import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+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.Task;
import org.codehaus.plexus.taskqueue.TaskQueue;
import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Parallel builds manager.
+ * Parallel builds manager.
*
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
* @plexus.component role="org.apache.continuum.buildmanager.BuildsManager" role-hint="parallel"
*/
public class ParallelBuildsManager
- implements BuildsManager
+ implements BuildsManager, Contextualizable
{
+ // TODO: deng parallel builds
+ // - move prepare build queue to parallel builds manager instead of moving it back to the
+ // task queue manager
+ // - prepare build queue must be a singleton, not per lookup, as we are maintaining only one
+ // prepare build queue :) <-- changed my mind, prepare build queue should be here except it
+ // should be a singleton and not added in the overallbuildqueue!
+
+ // NOTE: maybe we could also use the default build definition template?
+ // - take a look at AddProjectTest (add-projects-from-metadata)
+
private Logger log = LoggerFactory.getLogger( ParallelBuildsManager.class );
- // map must be synchronized
+ // map must be synchronized!
private Map<Integer, OverallBuildQueue> overallBuildQueues =
Collections.synchronizedMap( new HashMap<Integer, OverallBuildQueue>() );
private static final int BUILD_QUEUE = 1;
private static final int CHECKOUT_QUEUE = 2;
-
- private static final int PREPARE_BUILD_QUEUE = 3;
-
+
/**
* @plexus.requirement
*/
private BuildDefinitionDao buildDefinitionDao;
+
+ /**
+ * @plexus.requirement role-hint="prepare-build-project"
+ */
+ private TaskQueue prepareBuildQueue;
+
+ private PlexusContainer container;
+ public ParallelBuildsManager()
+ {
+ /*synchronized( overallBuildQueues )
+ {
+ try
+ {
+ OverallBuildQueue defaultOverallBuildQueue = ( OverallBuildQueue ) container.lookup( OverallBuildQueue.class );
+ defaultOverallBuildQueue.setId( 1 );
+ defaultOverallBuildQueue.setName( "DEFAULT_BUILD_QUEUE" );
+ }
+ catch ( ComponentLookupException e )
+ {
+ log.error( "Cannot create default build queue: " + e.getMessage() );
+ }
+ }*/
+ // - add a default OverallBuildQueue which cannot be deleted nor edited
+ // - this default overall build queue must be used whenever no build queue is found or configured
+ // NOTE: as a workaround for now.. just throw an exception when build or checkout is attempted without a
+ // build queue configured
+ }
+
// REQUIREMENTS:
// UI:
// - add a new page for adding a build queue. It should have a build queue name that
@@ -94,7 +140,7 @@
{
try
{
- if( isInQueue( projectId, BUILD_QUEUE ) )
+ if( isInQueue( projectId, BUILD_QUEUE, -1 ) )
{
log.warn( "Project already queued." );
return;
@@ -135,7 +181,7 @@
{
try
{
- if( !isInQueue( project.getId(), BUILD_QUEUE ) )
+ if( !isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
{
firstProjectId = project.getId();
break;
@@ -160,7 +206,7 @@
{
try
{
- if( isInQueue( project.getId(), BUILD_QUEUE ) )
+ if( isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
{
continue;
}
@@ -178,8 +224,10 @@
buildDefinitionLabel = buildDefinition.getGoals();
}
- Task buildTask = new BuildProjectTask( project.getId(), buildDefinition.getId(), trigger, project.getName(),
+ BuildProjectTask buildTask = new BuildProjectTask( project.getId(), buildDefinition.getId(), trigger, project.getName(),
buildDefinitionLabel);
+ buildTask.setMaxExecutionTime( buildDefinition.getSchedule().getMaxJobExecutionTime() * 1000 );
+
try
{
overallBuildQueue.addToBuildQueue( buildTask );
@@ -215,12 +263,18 @@
log.warn( "Project not found in any of the build queues." );
}
}
- catch ( TaskQueueException e )
+ /*catch ( TaskQueueException e )
{
log.error( "Cannot cancel build on build queue '" + overallBuildQueue.getName() + "'." );
throw new BuildManagerException( "Cannot cancel build on build queue '" + overallBuildQueue.getName() +
"': " + e.getMessage() );
- }
+ } */
+ catch ( ComponentLookupException e )
+ {
+ log.error( e.getMessage() );
+ throw new BuildManagerException( e.getMessage() );
+ }
+
return true;
}
}
@@ -240,12 +294,18 @@
overallBuildQueue.cancelCurrentBuild();
}
}
- catch ( TaskQueueException e )
+ /*catch ( TaskQueueException e )
{
log.error( "Cannot cancel build on build queue '" + overallBuildQueue.getName() + "'." );
throw new BuildManagerException( "Cannot cancel build on build queue '" + overallBuildQueue.getName() +
"': " + e.getMessage() );
- }
+ } */
+ catch ( ComponentLookupException e )
+ {
+ log.error( e.getMessage() );
+ throw new BuildManagerException( e.getMessage() );
+ }
+
return true;
}
}
@@ -262,18 +322,19 @@
return false;
}*/
- public boolean cancelBuild(int projectId) throws BuildManagerException
+ public boolean cancelBuild( int projectId ) throws BuildManagerException
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectId, BUILD_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
if( overallBuildQueue != null )
{
overallBuildQueue.cancelBuildTask( projectId );
}
else
{
- throw new BuildManagerException( "Project not found in any of the build queues." );
+ log.info( "Project '" + projectId + "' not found in any of the builds queues." );
+ //throw new BuildManagerException( "Project not found in any of the build queues." );
}
}
catch( TaskQueueException e )
@@ -281,6 +342,10 @@
throw new BuildManagerException( "Error occurred while cancelling build: " +
e.getMessage() );
}
+ catch ( ComponentLookupException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
return true;
}
@@ -290,7 +355,7 @@
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectId, CHECKOUT_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, CHECKOUT_QUEUE );
if( overallBuildQueue != null )
{
//overallBuildQueue.getCheckoutQueue()
@@ -315,11 +380,13 @@
return false;
}*/
- public void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername, String scmPassword, BuildDefinition defaultBuildDefinition ) throws BuildManagerException
+ public void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername,
+ String scmPassword, BuildDefinition defaultBuildDefinition )
+ throws BuildManagerException
{
try
{
- if( isInQueue( projectId, CHECKOUT_QUEUE ) )
+ if( isInQueue( projectId, CHECKOUT_QUEUE, -1 ) )
{
log.warn( "Project already in checkout queue." );
return;
@@ -344,31 +411,145 @@
throw new BuildManagerException( "Error occurred while adding project to checkout queue: " + e.getMessage() );
}
}
-
- /*public void prepareBuildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger, int scheduleId )
+
+ public boolean isInAnyBuildQueue( int projectId ) throws BuildManagerException
{
- // TODO Auto-generated method stub
-
- }*/
-
- /*public void prepareBuildProjects( Collection<Map<Integer, Integer>> projectsBuildDefinitions, int trigger, int scheduleId )
+ try
+ {
+ return isInQueue( projectId, BUILD_QUEUE, -1 );
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
+ }
+
+ public boolean isInAnyBuildQueue( int projectId, int buildDefinitionId ) throws BuildManagerException
{
- // TODO Auto-generated method stub
-
- }*/
+ try
+ {
+ return isInQueue( projectId, BUILD_QUEUE, buildDefinitionId );
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
+ }
+
+ public boolean isInAnyCheckoutQueue( int projectId ) throws BuildManagerException
+ {
+ try
+ {
+ return isInQueue( projectId, CHECKOUT_QUEUE, -1 );
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
+ }
+
+ public boolean isInPrepareBuildQueue( int projectId ) throws BuildManagerException
+ {
+ try
+ {
+ List<PrepareBuildProjectsTask> queue = prepareBuildQueue.getQueueSnapshot();
+ for ( PrepareBuildProjectsTask task : queue )
+ {
+ if ( task != null )
+ {
+ Map<Integer, Integer> map = ( (PrepareBuildProjectsTask) task ).getProjectsBuildDefinitionsMap();
+
+ if ( map.size() > 0 )
+ {
+ Set<Integer> projectIds = map.keySet();
+
+ if ( projectIds.contains( new Integer( projectId ) ) )
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
+
+ return false;
+ }
+
+ public boolean isProjectInAnyCurrentBuild( int projectId ) throws BuildManagerException
+ {
+ try
+ {
+ List<Object> objects = container.lookupList( TaskQueueExecutor.class );
+ for( Object obj : objects )
+ {
+ log.info( "\n object --> " + obj );
+ log.info( "\n object class --> " + obj.getClass() );
+ ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+ Task task = executor.getCurrentTask();
+ if( task instanceof BuildProjectTask )
+ {
+ log.info( "current task is a BuildProjectTask." );
+ return true;
+ }
+ }
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new BuildManagerException( e.getMessage() );
+ }
+
+ return false;
+ /*try
+ {
+ Task task = getBuildTaskQueueExecutor().getCurrentTask();
+ if ( task != null )
+ {
+ if ( task instanceof BuildProjectTask )
+ {
+ return ( (BuildProjectTask) task ).getProjectId();
+ }
+ }
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new TaskQueueException( "Error occurred while looking up the build task queue executor. " );
+ }
+
+ return -1;*/
+ }
+
+ public void prepareBuildProject( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger )
+ throws BuildManagerException
+ {
+ try
+ {
+ PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger );
+ prepareBuildQueue.put( task );
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( "Error occurred while creating prepare-build-project task: " +
+ e.getMessage() );
+ }
+ }
public void removeProjectFromBuildQueue( int projectId ) throws BuildManagerException
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectId, BUILD_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
if( overallBuildQueue != null )
{
overallBuildQueue.removeProjectFromBuildQueue( projectId );
}
else
{
- throw new BuildManagerException( "Project not found in any of the build queues." );
+ log.info( "Project '" + projectId + "' not found in any of the build queues." );
+ //throw new BuildManagerException( "Project not found in any of the build queues." );
}
}
catch ( TaskQueueException e )
@@ -377,19 +558,42 @@
e.getMessage() );
}
}
-
+
+ public void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName ) throws BuildManagerException
+ {
+ try
+ {
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
+ if( overallBuildQueue != null )
+ {
+ overallBuildQueue.removeProjectFromBuildQueue( projectId, buildDefinitionId, trigger, projectName );
+ }
+ else
+ {
+ log.info( "Project '" + projectId + "' not found in any of the build queues." );
+ //throw new BuildManagerException( "Project not found in any of the build queues." );
+ }
+ }
+ catch ( TaskQueueException e )
+ {
+ throw new BuildManagerException( "Error occurred while removing project from build queue: " +
+ e.getMessage() );
+ }
+ }
+
public void removeProjectFromCheckoutQueue( int projectId ) throws BuildManagerException
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectId, CHECKOUT_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, CHECKOUT_QUEUE );
if( overallBuildQueue != null )
{
overallBuildQueue.removeProjectFromCheckoutQueue( projectId );
}
else
{
- throw new BuildManagerException( "Project not found in any of the checkout queues." );
+ log.info( "Project '" + projectId + "' not found in any of the checkout queues." );
+ //throw new BuildManagerException( "Project not found in any of the checkout queues." );
}
}
catch ( TaskQueueException e )
@@ -411,7 +615,7 @@
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectIds[i], BUILD_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectIds[i], BUILD_QUEUE );
if( overallBuildQueue != null )
{
overallBuildQueue.removeProjectFromBuildQueue( projectIds[i] );
@@ -436,7 +640,7 @@
{
try
{
- OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectIds[i], CHECKOUT_QUEUE );
+ OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectIds[i], CHECKOUT_QUEUE );
if( overallBuildQueue != null )
{
overallBuildQueue.removeProjectFromCheckoutQueue( projectIds[i] );
@@ -455,13 +659,17 @@
}
}
- public void removeProjectsFromPrepareBuildQueue( int[] projectIds )
+ /*public void removeProjectsFromPrepareBuildQueue( int[] projectIds )
{
// TODO Auto-generated method stub
- }
+ }*/
public void addOverallBuildQueue( OverallBuildQueue overallBuildQueue )
{
+ // set the container which is used by overall build queue for getting the task queue executor
+ // trying to avoid implementing Contextualizable for the OverallBuildQueue!
+ overallBuildQueue.setContainer( container );
+
synchronized( overallBuildQueues )
{
this.overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue );
@@ -473,6 +681,11 @@
List<BuildProjectTask> tasks = null;
List<CheckOutTask> checkoutTasks = null;
+ /*if( overallBuildQueueId == 1 )
+ {
+ throw new BuildManagerException( "Default build queue cannot be deleted." );
+ }*/
+
synchronized( overallBuildQueues )
{
OverallBuildQueue overallBuildQueue = overallBuildQueues.get( overallBuildQueueId );
@@ -484,13 +697,19 @@
overallBuildQueue.getBuildQueue().removeAll( tasks );
overallBuildQueue.getCheckoutQueue().removeAll( checkoutTasks );
- overallBuildQueue = null;
+ container.release( overallBuildQueue );
}
catch ( TaskQueueException e )
{
throw new BuildManagerException(
"Cannot remove build queue. An error occurred while retrieving queued tasks." );
}
+ catch ( ComponentLifecycleException e )
+ {
+ throw new BuildManagerException(
+ "Cannot remove build queue. An error occurred while destroying the build queue: " +
+ e.getMessage() );
+ }
this.overallBuildQueues.remove( overallBuildQueueId );
}
@@ -522,7 +741,7 @@
return overallBuildQueues;
}
- private boolean isInQueue( int projectId, int typeOfQueue )
+ private boolean isInQueue( int projectId, int typeOfQueue, int buildDefinitionId )
throws TaskQueueException
{
synchronized( overallBuildQueues )
@@ -533,9 +752,19 @@
OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
if( typeOfQueue == BUILD_QUEUE )
{
- if( overallBuildQueue.isInBuildQueue( projectId ) )
+ if( buildDefinitionId < 0 )
{
- return true;
+ if( overallBuildQueue.isInBuildQueue( projectId ) )
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if( overallBuildQueue.isInBuildQueue( projectId, buildDefinitionId ) )
+ {
+ return true;
+ }
}
}
else if( typeOfQueue == CHECKOUT_QUEUE )
@@ -558,7 +787,8 @@
}
}
- private OverallBuildQueue getOverallBuildQueue( int projectId, int typeOfQueue )
+ // get overall queue where project is queued
+ private OverallBuildQueue getOverallBuildQueueWhereProjectIsQueued( int projectId, int typeOfQueue )
throws TaskQueueException
{
synchronized( overallBuildQueues )
@@ -585,14 +815,6 @@
break;
}
}
- /*else if( typeOfQueue == PREPARE_BUILD_QUEUE )
- {
- if( overallBuildQueue.isInPrepareBuildQueue( projectId ) )
- {
- whereQueued = overallBuildQueue;
- break;
- }
- }*/
}
return whereQueued;
@@ -628,10 +850,6 @@
{
taskQueue = overallBuildQueue.getCheckoutQueue();
}
- /*else if( typeOfQueue == PREPARE_BUILD_QUEUE )
- {
- taskQueue = overallBuildQueue.getPrepareBuildQueue();
- }*/
if( idx == 0 )
{
@@ -671,4 +889,15 @@
{
this.buildDefinitionDao = buildDefinitionDao;
}
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ }
+
+ public void setContainer( PlexusContainer container )
+ {
+ this.container = container;
+ }
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java Fri Dec 12 02:31:37 2008
@@ -21,40 +21,32 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.continuum.dao.BuildDefinitionDao;
-import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
import org.apache.maven.continuum.buildqueue.BuildProjectTask;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.scm.queue.CheckOutTask;
-import org.apache.maven.continuum.scm.queue.PrepareBuildProjectsTask;
import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.taskqueue.Task;
import org.codehaus.plexus.taskqueue.TaskQueue;
import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
+import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor;
import org.codehaus.plexus.util.StringUtils;
/**
- * "Overall" build queue which has a checkout queue, a prepare-build queue, and a build queue. All builds whether forced
- * or triggered will go through (or have to be added through) the "overall" build queue.
+ * "Overall" build queue which has a checkout queue and a build queue.
*
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
* @plexus.component role="org.apache.continuum.taskqueue.OverallBuildQueue" instantiation-strategy="per-lookup"
*/
public class DefaultOverallBuildQueue
extends AbstractLogEnabled
- implements OverallBuildQueue, Contextualizable
+ implements OverallBuildQueue
+ //, Contextualizable
{
// TODO: deng parallel builds
// - might need to set a task queue executor for each task queue!
@@ -76,7 +68,7 @@
/**
* @plexus.requirement role-hint="prepare-build-project"
*/
- private TaskQueue prepareBuildQueue;
+ //private TaskQueue prepareBuildQueue;
/**
* @plexus.requirement
@@ -111,7 +103,7 @@
/* Checkout Queue */
- public TaskQueueExecutor getCheckoutTaskQueueExecutor()
+ /*public TaskQueueExecutor getCheckoutTaskQueueExecutor()
throws TaskQueueManagerException
{
try
@@ -122,7 +114,7 @@
{
throw new TaskQueueManagerException( e.getMessage(), e );
}
- }
+ }*/
public void addToCheckoutQueue( Task checkoutTask )
throws TaskQueueException
@@ -225,7 +217,7 @@
/* Prepare-build-projects Queue */
- public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
+ /*public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
throws ComponentLookupException
{
return (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, "prepare-build-project" );
@@ -300,15 +292,15 @@
}
return false;
- }
+ }*/
/* Build Queue */
- public TaskQueueExecutor getBuildTaskQueueExecutor()
+ /*public TaskQueueExecutor getBuildTaskQueueExecutor()
throws ComponentLookupException
- {
+ {
return ( TaskQueueExecutor ) container.lookup( TaskQueueExecutor.class, "build-project" );
- }
+ }*/
public void addToBuildQueue( Task buildTask )
throws TaskQueueException
@@ -325,35 +317,13 @@
}
}
- public int getProjectIdInCurrentBuild()
- throws TaskQueueException
- {
- try
- {
- Task task = getBuildTaskQueueExecutor().getCurrentTask();
- if ( task != null )
- {
- if ( task instanceof BuildProjectTask )
- {
- return ( (BuildProjectTask) task ).getProjectId();
- }
- }
- }
- catch ( ComponentLookupException e )
- {
- throw new TaskQueueException( "Error occurred while looking up the build task queue executor. " );
- }
-
- return -1;
- }
-
public List<BuildProjectTask> getProjectsInBuildQueue()
throws TaskQueueException
{
return buildQueue.getQueueSnapshot();
}
- public boolean isBuildInProgress()
+ /*public boolean isBuildInProgress()
throws TaskQueueException
{
try
@@ -372,7 +342,7 @@
}
return false;
- }
+ }*/
public boolean isInBuildQueue( int projectId )
throws TaskQueueException
@@ -410,9 +380,29 @@
}
public void cancelBuildTask( int projectId )
- throws TaskQueueException
- {
- try
+ throws ComponentLookupException
+ {
+ getLogger().info( "\n========= [OverallBuildQueue] CANCEL BUILD TASK ============" );
+ List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
+ for( Object obj : objects )
+ {
+ getLogger().info( "\n object --> " + obj );
+ getLogger().info( "\n object class --> " + obj.getClass() );
+ ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+ Task task = executor.getCurrentTask();
+ if( task != null && task instanceof BuildProjectTask )
+ {
+ if( ( (BuildProjectTask) task ).getProjectId() == projectId )
+ {
+ getLogger().info( "Cancelling task for project " + projectId );
+ executor.cancelTask( task );
+ getLogger().info( "current task is a BuildProjectTask." );
+ }
+ }
+ }
+
+
+ /*try
{
Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
@@ -428,13 +418,30 @@
catch ( ComponentLookupException e )
{
throw new TaskQueueException( e.getMessage() );
- }
+ }*/
}
public boolean cancelCurrentBuild()
- throws TaskQueueException
+ throws ComponentLookupException
{
- try
+ getLogger().info( "\n========= [OverallBuildQueue] CANCEL CURRENT BUILD ============" );
+ List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
+ for( Object obj : objects )
+ {
+ getLogger().info( "\n object --> " + obj );
+ getLogger().info( "\n object class --> " + obj.getClass() );
+ ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+ Task task = executor.getCurrentTask();
+ if( task != null && task instanceof BuildProjectTask )
+ {
+ BuildProjectTask buildTask = (BuildProjectTask) task;
+ getLogger().info( "Cancelling build task for project '" + buildTask.getProjectId() );
+ executor.cancelTask( task );
+ getLogger().info( "current task is a BuildProjectTask." );
+ }
+ }
+
+ /*try
{
Task task = getBuildTaskQueueExecutor().getCurrentTask();
@@ -458,7 +465,7 @@
catch ( ComponentLookupException e )
{
throw new TaskQueueException( e.getMessage() );
- }
+ }*/
return false;
}
@@ -468,6 +475,9 @@
{
BuildDefinition buildDefinition;
+ // TODO: deng - maybe we could just pass the label as a parameter to eliminate
+ // dependency to BuildDefinitionDAO?
+
try
{
buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
@@ -557,31 +567,32 @@
}
}
- public void contextualize( Context context )
+ /*public void contextualize( Context context )
throws ContextException
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
- }
+ }*/
public TaskQueue getCheckoutQueue()
{
return checkoutQueue;
}
- public TaskQueue getPrepareBuildQueue()
- {
- return prepareBuildQueue;
- }
-
public TaskQueue getBuildQueue()
{
return buildQueue;
}
- private Task getCurrentTask( String task )
+ public void setContainer( PlexusContainer container )
+ {
+ this.container = container;
+ }
+ // TODO: change this!
+ /*private Task getCurrentTask( String task )
throws ComponentLookupException
{
+
TaskQueueExecutor executor = (TaskQueueExecutor) container.lookup( TaskQueueExecutor.class, task );
return executor.getCurrentTask();
- }
+ } */
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Fri Dec 12 02:31:37 2008
@@ -90,7 +90,7 @@
return false;
}
- public void cancelBuildTask( int projectId )
+ /*public void cancelBuildTask( int projectId )
throws TaskQueueManagerException
{
Task currentTask = getBuildTaskQueueExecutor().getCurrentTask();
@@ -103,7 +103,7 @@
getBuildTaskQueueExecutor().cancelTask( currentTask );
}
}
- }
+ }*/
public boolean cancelCurrentBuild()
throws TaskQueueManagerException
@@ -129,11 +129,11 @@
return false;
}
- public TaskQueue getBuildQueue()
+ /*public TaskQueue getBuildQueue()
{
return buildQueue;
}
-
+*/
public TaskQueueExecutor getBuildTaskQueueExecutor()
throws TaskQueueManagerException
{
@@ -147,7 +147,7 @@
}
}
- public TaskQueueExecutor getCheckoutTaskQueueExecutor()
+ /*public TaskQueueExecutor getCheckoutTaskQueueExecutor()
throws TaskQueueManagerException
{
try
@@ -158,7 +158,7 @@
{
throw new TaskQueueManagerException( e.getMessage(), e );
}
- }
+ }*/
public TaskQueue getCheckoutQueue()
{
@@ -178,7 +178,7 @@
}
}
- public int getCurrentProjectIdBuilding()
+ /*public int getCurrentProjectIdBuilding()
throws TaskQueueManagerException
{
Task task = getBuildTaskQueueExecutor().getCurrentTask();
@@ -195,7 +195,7 @@
public TaskQueue getPrepareBuildQueue()
{
return prepareBuildQueue;
- }
+ } */
public TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
throws TaskQueueManagerException
@@ -228,7 +228,7 @@
return purgeQueue;
}
- public boolean isInBuildingQueue( int projectId )
+ /*public boolean isInBuildingQueue( int projectId )
throws TaskQueueManagerException
{
return isInBuildingQueue( projectId, -1 );
@@ -261,9 +261,9 @@
}
return false;
- }
+ }*/
- public boolean isInCheckoutQueue( int projectId )
+ /*public boolean isInCheckoutQueue( int projectId )
throws TaskQueueManagerException
{
List<CheckOutTask> queue = getCheckOutTasksInQueue();
@@ -301,8 +301,8 @@
return false;
}
-
- public boolean isInPrepareBuildQueue( int projectId )
+*/
+ /*public boolean isInPrepareBuildQueue( int projectId )
throws TaskQueueManagerException
{
try
@@ -333,7 +333,7 @@
{
throw new TaskQueueManagerException( "Error while getting the tasks in prepare build queue", e );
}
- }
+ }*/
public boolean isInPurgeQueue( int purgeConfigId )
throws TaskQueueManagerException
@@ -406,7 +406,7 @@
return false;
}
- public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
+ /*public boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
throws TaskQueueManagerException
{
BuildDefinition buildDefinition;
@@ -428,7 +428,7 @@
BuildProjectTask buildProjectTask =
new BuildProjectTask( projectId, buildDefinitionId, trigger, projectName, buildDefinitionLabel );
return this.buildQueue.remove( buildProjectTask );
- }
+ }*/
public boolean removeFromPurgeQueue( int purgeConfigId )
throws TaskQueueManagerException
@@ -482,7 +482,7 @@
return false;
}
- public boolean removeProjectsFromBuildingQueue( int[] projectsId )
+ /*public boolean removeProjectsFromBuildingQueue( int[] projectsId )
throws TaskQueueManagerException
{
if ( projectsId == null )
@@ -534,7 +534,7 @@
}
return false;
- }
+ }*/
public boolean removeProjectsFromCheckoutQueue( int[] projectsId )
throws TaskQueueManagerException
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Fri Dec 12 02:31:37 2008
@@ -33,6 +33,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.continuum.buildmanager.BuildManagerException;
+import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.configuration.ContinuumConfigurationException;
import org.apache.continuum.dao.BuildDefinitionDao;
import org.apache.continuum.dao.BuildResultDao;
@@ -247,6 +249,11 @@
* @plexus.requirement
*/
private TaskQueueManager taskQueueManager;
+
+ /**
+ * @plexus.requirement role-hint="parallel"
+ */
+ private BuildsManager parallelBuildsManager;
public DefaultContinuum()
{
@@ -300,6 +307,11 @@
{
return purgeConfigurationService;
}
+
+ public BuildsManager getBuildsManager()
+ {
+ return parallelBuildsManager;
+ }
// ----------------------------------------------------------------------
// Project Groups
@@ -603,8 +615,14 @@
getLogger().info( "Remove project " + project.getName() + "(" + projectId + ")" );
try
- {
- if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+ {
+ parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
+
+ parallelBuildsManager.removeProjectFromBuildQueue( projectId );
+
+ parallelBuildsManager.cancelBuild( projectId );
+
+ /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
{
taskQueueManager.removeProjectFromCheckoutQueue( projectId );
}
@@ -612,15 +630,19 @@
if ( taskQueueManager.isInBuildingQueue( projectId ) )
{
taskQueueManager.removeProjectFromBuildingQueue( projectId );
- }
+ }*/
// cancel if currently building
- if ( taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+ /*if ( taskQueueManager.getCurrentProjectIdBuilding() == projectId )
{
taskQueueManager.cancelBuildTask( projectId );
- }
+ }*/
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -664,9 +686,19 @@
context.put( AbstractContinuumAction.KEY_PROJECT_ID, new Integer( projectId ) );
- // TODO: deng parallel builds
- // - add default build definition of project (schedule is attached to the build def) to context!
- executeAction( "add-project-to-checkout-queue", context );
+ try
+ {
+ BuildDefinition buildDefinition = buildDefinitionDao.getDefaultBuildDefinition( projectId );
+ context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, buildDefinition );
+
+ // TODO: deng parallel builds
+ // - add default build definition of project (schedule is attached to the build def) to context!
+ executeAction( "add-project-to-checkout-queue", context );
+ }
+ catch ( ContinuumStoreException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }
}
public Project getProject( int projectId )
@@ -892,8 +924,10 @@
{
try
{
- if ( buildDefId != null && !taskQueueManager.isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
- !taskQueueManager.isInCheckoutQueue( project.getId() ) && !taskQueueManager.isInPrepareBuildQueue( project.getId() ) )
+ //if ( buildDefId != null && !taskQueueManager.isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
+ // !taskQueueManager.isInCheckoutQueue( project.getId() ) && !taskQueueManager.isInPrepareBuildQueue( project.getId() ) )
+ if ( buildDefId != null && !parallelBuildsManager.isInAnyBuildQueue( project.getId(), buildDefId.intValue() ) &&
+ !parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) && !parallelBuildsManager.isInPrepareBuildQueue( project.getId() ) )
{
ProjectScmRoot scmRoot = getProjectScmRootByProject( project.getId() );
@@ -916,7 +950,11 @@
map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
}
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -951,14 +989,21 @@
try
{
- if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) ||
- taskQueueManager.isInCheckoutQueue( projectId ) ||
- taskQueueManager.isInPrepareBuildQueue( projectId ))
+ if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDef.getId() ) ||
+ parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
+ parallelBuildsManager.isInPrepareBuildQueue( projectId ) )
+ //if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) ||
+ // taskQueueManager.isInCheckoutQueue( projectId ) ||
+ // taskQueueManager.isInPrepareBuildQueue( projectId ))
{
return;
}
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -974,14 +1019,21 @@
{
try
{
- if ( taskQueueManager.isInBuildingQueue( projectId, buildDefinitionId ) ||
+ if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDefinitionId ) ||
+ parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
+ parallelBuildsManager.isInPrepareBuildQueue( projectId ))
+ /*if ( taskQueueManager.isInBuildingQueue( projectId, buildDefinitionId ) ||
taskQueueManager.isInCheckoutQueue( projectId ) ||
- taskQueueManager.isInPrepareBuildQueue( projectId ))
+ taskQueueManager.isInPrepareBuildQueue( projectId ))*/
{
return;
}
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -3210,17 +3262,26 @@
try
{
// check if project already in queue
- if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+ //if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+ if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
{
continue;
}
- if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+ /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
{
taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+ }*/
+ if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
+ {
+ parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
}
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -3306,14 +3367,20 @@
try
{
// check if project already in queue
- if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+ //if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
+ if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
{
continue;
}
- if ( taskQueueManager.isInCheckoutQueue( projectId ) )
+ /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
{
taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+ }*/
+
+ if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
+ {
+ parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
}
ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
@@ -3335,7 +3402,11 @@
map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
}
- catch ( TaskQueueManagerException e )
+ /*catch ( TaskQueueManagerException e )
+ {
+ throw new ContinuumException( e.getMessage(), e );
+ }*/
+ catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
}
@@ -3358,10 +3429,15 @@
{
try
{
- PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger );
- taskQueueManager.getPrepareBuildQueue().put( task );
+ parallelBuildsManager.prepareBuildProject( projectsBuildDefinitionsMap, trigger );
+ /*PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger );
+ taskQueueManager.getPrepareBuildQueue().put( task );*/
}
- catch ( TaskQueueException e )
+ /*catch ( TaskQueueException e )
+ {
+ throw logAndCreateException( "Error while creating enqueuing object.", e );
+ }*/
+ catch( BuildManagerException e )
{
throw logAndCreateException( "Error while creating enqueuing object.", e );
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AbstractContinuumAction.java Fri Dec 12 02:31:37 2008
@@ -46,6 +46,10 @@
public static final String KEY_PROJECT_ID = "project-id";
public static final String KEY_PROJECT = "project";
+
+ public static final String KEY_PROJECTS = "projects";
+
+ public static final String KEY_PROJECTS_BUILD_DEFINITIONS_MAP = "projects-build-definitions";
public static final String KEY_BUILD_DEFINITION_TEMPLATE = "build-definition-template";
@@ -220,6 +224,16 @@
{
return getInteger( context, KEY_OLD_BUILD_ID );
}
+
+ public static List<Project> getListOfProjects( Map context )
+ {
+ return (List<Project>) getObject( context, KEY_PROJECTS );
+ }
+
+ public static Map<Integer, BuildDefinition> getProjectsBuildDefinitionsMap( Map context )
+ {
+ return (Map<Integer, BuildDefinition>) getObject( context, KEY_PROJECTS_BUILD_DEFINITIONS_MAP );
+ }
// ----------------------------------------------------------------------
//
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java Fri Dec 12 02:31:37 2008
@@ -19,10 +19,10 @@
* under the License.
*/
+import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.dao.ProjectDao;
-import org.apache.continuum.taskqueue.manager.TaskQueueManager;
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.scm.queue.CheckOutTask;
import org.apache.maven.continuum.utils.WorkingDirectoryService;
import java.util.Map;
@@ -49,7 +49,12 @@
/**
* @plexus.requirement
*/
- private TaskQueueManager taskQueueManager;
+ //private TaskQueueManager taskQueueManager;
+
+ /**
+ * @plexus.requirement role-hint="parallel"
+ */
+ private BuildsManager parallelBuildsManager;
@SuppressWarnings("unchecked")
public void execute( Map context )
@@ -65,9 +70,14 @@
project = projectDao.getProject( getProjectId( context ) );
}
- CheckOutTask checkOutTask = new CheckOutTask( project.getId(), workingDirectoryService
+ BuildDefinition defaultBuildDefinition = ( BuildDefinition ) getBuildDefinition( context );
+ parallelBuildsManager.checkoutProject( project.getId(), project.getName(),
+ workingDirectoryService.getWorkingDirectory( project ),
+ project.getScmUsername(), project.getScmPassword(),
+ defaultBuildDefinition );
+ /*CheckOutTask checkOutTask = new CheckOutTask( project.getId(), workingDirectoryService
.getWorkingDirectory( project ), project.getName(), project.getScmUsername(), project.getScmPassword() );
- taskQueueManager.getCheckoutQueue().put( checkOutTask );
+ taskQueueManager.getCheckoutQueue().put( checkOutTask );*/
}
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java Fri Dec 12 02:31:37 2008
@@ -19,21 +19,18 @@
* under the License.
*/
+import java.util.ArrayList;
+import java.util.List;
import java.util.Map;
-import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.dao.ProjectDao;
-import org.apache.continuum.taskqueue.manager.TaskQueueManager;
-import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.buildqueue.BuildProjectTask;
import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
-import org.codehaus.plexus.util.StringUtils;
/**
* @author <a href="mailto:ctan@apache.org">Maria Catherine Tan</a>
@@ -45,7 +42,7 @@
/**
* @plexus.requirement
*/
- private TaskQueueManager taskQueueManager;
+ //private TaskQueueManager taskQueueManager;
/**
* @plexus.requirement
@@ -60,7 +57,12 @@
/**
* @plexus.requirement
*/
- private BuildDefinitionDao buildDefinitionDao;
+ //private BuildDefinitionDao buildDefinitionDao;
+
+ /**
+ * @plexus.requirement role-hint="parallel"
+ */
+ private BuildsManager parallelBuildsManager;
public synchronized void execute( Map context )
throws Exception
@@ -70,7 +72,75 @@
// - update the list of projects
// - pass this updated list + map of build definitions to builds manager
- Project project = AbstractContinuumAction.getProject( context );
+ List<Project> projects = AbstractContinuumAction.getListOfProjects( context );
+ Map<Integer, BuildDefinition> projectsBuildDefinitionsMap =
+ AbstractContinuumAction.getProjectsBuildDefinitionsMap( context );
+
+ List<Project> projectsToBeBuilt = new ArrayList<Project>();
+ int trigger = AbstractContinuumAction.getTrigger( context );
+
+ // update state of each project first
+ for( Project project : projects )
+ {
+ BuildDefinition buildDefinition = projectsBuildDefinitionsMap.get( project.getId() );
+ if ( parallelBuildsManager.isInAnyBuildQueue( project.getId(), buildDefinition.getId() ) )
+ {
+ return;
+ }
+
+ if ( parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) )
+ {
+ parallelBuildsManager.removeProjectFromCheckoutQueue( project.getId() );
+ }
+
+ try
+ {
+ if ( project.getState() != ContinuumProjectState.NEW &&
+ project.getState() != ContinuumProjectState.CHECKEDOUT &&
+ project.getState() != ContinuumProjectState.OK && project.getState() != ContinuumProjectState.FAILED &&
+ project.getState() != ContinuumProjectState.ERROR )
+ {
+ ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId() );
+
+ if ( executor.isBuilding( project ) || project.getState() == ContinuumProjectState.UPDATING )
+ {
+ // project is building
+ getLogger().info( "Project '" + project.getName() + "' already being built." );
+
+ continue;
+ }
+ else
+ {
+ project.setOldState( project.getState() );
+
+ project.setState( ContinuumProjectState.ERROR );
+
+ projectDao.updateProject( project );
+
+ project = projectDao.getProject( project.getId() );
+ }
+ }
+ else
+ {
+ project.setOldState( project.getState() );
+
+ projectDao.updateProject( project );
+
+ project = projectDao.getProject( project.getId() );
+ }
+
+ projectsToBeBuilt.add( project );
+ }
+ catch ( ContinuumStoreException e )
+ {
+ getLogger().error( "Error while creating build object", e );
+ //throw new ContinuumException( "Error while creating build object.", e );
+ }
+ }
+
+ parallelBuildsManager.buildProjects( projectsToBeBuilt, projectsBuildDefinitionsMap, trigger );
+
+ /*Project project = AbstractContinuumAction.getProject( context );
int buildDefinitionId = AbstractContinuumAction.getBuildDefinitionId( context );
int trigger = AbstractContinuumAction.getTrigger( context );
@@ -147,6 +217,6 @@
{
getLogger().error( "Error while enqueuing object", e );
throw new ContinuumException( "Error while enqueuing object.", e );
- }
+ }*/
}
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java Fri Dec 12 02:31:37 2008
@@ -1,5 +1,6 @@
package org.apache.maven.continuum.scm.queue;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -10,6 +11,7 @@
import org.apache.continuum.dao.ProjectScmRootDao;
import org.apache.continuum.model.project.ProjectScmRoot;
import org.apache.maven.continuum.core.action.AbstractContinuumAction;
+import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.project.ProjectGroup;
import org.apache.maven.continuum.model.scm.ChangeSet;
@@ -439,29 +441,47 @@
projectList = projectDao.getAllProjectsByName();
}
+ List<Project> projectsToBeBuilt = new ArrayList<Project>();
+ Map<Integer, BuildDefinition> projectsBuildDefinitionsMap = new HashMap<Integer, BuildDefinition>();
+
for ( Project project : projectList )
{
- boolean shouldBuild = false;
+ //boolean shouldBuild = false;
int buildDefinitionId = 0;
if ( projectsAndBuildDefinitionsMap.get( project.getId() ) != null )
{
- buildDefinitionId = projectsAndBuildDefinitionsMap.get( project.getId() );
- shouldBuild = true;
+ buildDefinitionId = projectsAndBuildDefinitionsMap.get( project.getId() );
+ //shouldBuild = true;
+ try
+ {
+ BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
+ projectsBuildDefinitionsMap.put( project.getId(), buildDefinition );
+ projectsToBeBuilt.add( project );
+ }
+ catch( ContinuumStoreException e )
+ {
+ getLogger().error( "Error while creating build object", e );
+ throw new TaskExecutionException( "Error while creating build object", e );
+ }
}
else if ( project.getState() == ContinuumProjectState.CHECKEDOUT || project.getState() == ContinuumProjectState.NEW ) //check if no build result yet for project
{
try
{
//get default build definition for project
- buildDefinitionId = buildDefinitionDao.getDefaultBuildDefinition( project.getId() ).getId();
+ //buildDefinitionId = buildDefinitionDao.getDefaultBuildDefinition( project.getId() ).getId();
+ BuildDefinition buildDefinition = buildDefinitionDao.getDefaultBuildDefinition( project.getId() );
+ projectsBuildDefinitionsMap.put( project.getId(), buildDefinition );
+ projectsToBeBuilt.add( project );
}
catch ( ContinuumStoreException e )
{
getLogger().error( "Error while creating build object", e );
throw new TaskExecutionException( "Error while creating build object", e );
}
- shouldBuild = true;
+ //shouldBuild = true;
+ projectsToBeBuilt.add( project );
}
// TODO: deng parallel builds..
@@ -469,7 +489,7 @@
// and also add the build definition into a map of <projectId,build definition>
// - set these in the context map
//
- if ( shouldBuild )
+ /*if ( shouldBuild )
{
try
{
@@ -491,7 +511,28 @@
getLogger().error( e.getMessage(), e );
throw new TaskExecutionException( "Error executing action 'build-project'", e );
}
- }
+ }*/
+ }
+
+ try
+ {
+ Map context = new HashMap();
+ context.put( AbstractContinuumAction.KEY_PROJECTS, projectsToBeBuilt );
+ context.put( AbstractContinuumAction.KEY_PROJECTS_BUILD_DEFINITIONS_MAP, projectsBuildDefinitionsMap );
+ context.put( AbstractContinuumAction.KEY_TRIGGER, trigger );
+
+ getLogger().info( "Performing action create-build-project-task" );
+ actionManager.lookup( "create-build-project-task" ).execute( context );
+ }
+ catch ( ActionNotFoundException e )
+ {
+ getLogger().error( "Error looking up action 'build-project'" );
+ throw new TaskExecutionException( "Error looking up action 'build-project'", e );
+ }
+ catch ( Exception e )
+ {
+ getLogger().error( e.getMessage(), e );
+ throw new TaskExecutionException( "Error executing action 'build-project'", e );
}
}
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/resources/META-INF/plexus/components.xml Fri Dec 12 02:31:37 2008
@@ -136,14 +136,14 @@
<role-hint>prepare-build-project</role-hint>
<implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
<lifecycle-handler>plexus-configurable</lifecycle-handler>
- <instantiation-strategy>per-lookup</instantiation-strategy>
+ <instantiation-strategy>singleton</instantiation-strategy>
</component>
<component>
<role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
<role-hint>prepare-build-project</role-hint>
<implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
+ <instantiation-strategy>singleton</instantiation-strategy>
<requirements>
<requirement>
<role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java?rev=725959&r1=725958&r2=725959&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java Fri Dec 12 02:31:37 2008
@@ -112,6 +112,16 @@
assertEquals( 5, buildsManager.getOverallBuildQueues().size() );
}
+ public void testContainer()
+ throws Exception
+ {
+ buildsManager.setContainer( getContainer() );
+
+ buildsManager.isProjectInAnyCurrentBuild( 1 );
+
+ assertTrue( true );
+ }
+
// start of tests...
public void testBuildProjectNoProjectQueuedInAnyOverallBuildQueues()
@@ -296,7 +306,7 @@
assertFalse( overallBuildQueues.get( 1 ).isInBuildQueue( 3, buildDef.getId() ) );
}
- public void testRemoveProjectFromBuildQueueProjectNotInAnyBuildQueue()
+ /*public void testRemoveProjectFromBuildQueueProjectNotInAnyBuildQueue()
throws Exception
{
setupOverallBuildQueues();
@@ -310,7 +320,7 @@
{
assertEquals( "Project not found in any of the build queues.", e.getMessage() );
}
- }
+ }*/
public void testRemoveProjectsFromBuildQueue()
throws Exception
@@ -475,7 +485,7 @@
assertFalse( overallBuildQueues.get( 1 ).isInCheckoutQueue( 3 ) );
}
- public void testRemoveProjectFromCheckoutQueueProjectNotInAnyCheckoutQueue()
+ /*public void testRemoveProjectFromCheckoutQueueProjectNotInAnyCheckoutQueue()
throws Exception
{
setupOverallBuildQueues();
@@ -489,7 +499,7 @@
{
assertEquals( "Project not found in any of the checkout queues.", e.getMessage() );
}
- }
+ }*/
public void testRemoveProjectsFromCheckoutQueue()
throws Exception