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/15 07:36:02 UTC

svn commit: r726625 [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-core/src/main/java/org/apache/continuum/b...

Author: oching
Date: Sun Dec 14 22:36:01 2008
New Revision: 726625

URL: http://svn.apache.org/viewvc?rev=726625&view=rev
Log:
-added additional methods in BuildsManager
-more code/comments cleanup

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-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/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.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=726625&r1=726624&r2=726625&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 Sun Dec 14 22:36:01 2008
@@ -29,75 +29,102 @@
 import org.codehaus.plexus.taskqueue.Task;
 
 /**
- * BuildsManager. All builds whether forced or triggered will go through (or have to be added through) 
- * a builds manager.
+ * 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>
- *
  */
 public interface BuildsManager
-{       
-    void buildProjects( List<Project> projects, Map<Integer, BuildDefinition> projectsBuildDefinitionsMap, int trigger ) throws BuildManagerException;
-    
-    void buildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger ) throws BuildManagerException;
-    
-    void prepareBuildProject( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger ) throws BuildManagerException;
-    
-    void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername, String scmPassword, BuildDefinition defaultBuildDefinition ) throws BuildManagerException;
-        
-    boolean cancelBuild( int projectId ) throws BuildManagerException;
-    
-    boolean cancelAllBuilds() throws BuildManagerException;
-    
-    boolean cancelBuildInQueue( int buildQueueId ) throws BuildManagerException;
-    
-    boolean cancelCheckout(int projectId) throws BuildManagerException;
-    
-    boolean cancelAllCheckouts() throws BuildManagerException;
-    
-    //public boolean cancelPrepareBuild(int projectId) throws BuildManagerException;
-    
-    //public boolean cancelAllPrepareBuilds() throws BuildManagerException;
-    
-    void removeProjectFromBuildQueue( int projectId ) throws BuildManagerException;
-    
-    void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName ) throws BuildManagerException;
-    
+{
+    void buildProjects( List<Project> projects, Map<Integer, BuildDefinition> projectsBuildDefinitionsMap, int trigger )
+        throws BuildManagerException;
+
+    void buildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger )
+        throws BuildManagerException;
+
+    void prepareBuildProject( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger )
+        throws BuildManagerException;
+
+    void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername,
+                          String scmPassword, BuildDefinition defaultBuildDefinition )
+        throws BuildManagerException;
+
+    boolean cancelBuild( int projectId )
+        throws BuildManagerException;
+
+    boolean cancelAllBuilds()
+        throws BuildManagerException;
+
+    boolean cancelBuildInQueue( int buildQueueId )
+        throws BuildManagerException;
+
+    boolean cancelCheckout( int projectId )
+        throws BuildManagerException;
+
+    boolean cancelAllCheckouts()
+        throws BuildManagerException;
+
+    // public boolean cancelPrepareBuild(int projectId) throws BuildManagerException;
+
+    // public boolean cancelAllPrepareBuilds() throws BuildManagerException;
+
+    void removeProjectFromBuildQueue( int projectId )
+        throws BuildManagerException;
+
+    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?
     void removeProjectsFromBuildQueue( int[] projectIds );
-        
-    void removeProjectFromCheckoutQueue( int projectId ) throws BuildManagerException;
-    
- // TODO: implement this.. but how?
+
+    void removeProjectsFromBuildQueueWithHashcodes( int[] hascodes )
+        throws BuildManagerException;
+
+    void removeProjectFromCheckoutQueue( int projectId )
+        throws BuildManagerException;
+
     void removeProjectsFromCheckoutQueue( int[] projectIds );
-    
-    //TODO: implement this!
-    //public void removeProjectFromPrepareBuildQueue( int projectId );
-    
-   //  public void removeProjectsFromPrepareBuildQueue( int[] projectIds );
-    
+
+    void removeProjectsFromCheckoutQueueWithHashcodes( int[] hashcodes )
+        throws BuildManagerException;
+
+    // TODO: implement this!
+    // public void removeProjectFromPrepareBuildQueue( int projectId );
+
+    // public void removeProjectsFromPrepareBuildQueue( int[] projectIds );
+
     void addOverallBuildQueue( OverallBuildQueue overallBuildQueue );
-    
-    void removeOverallBuildQueue( int overallBuildQueueId ) throws BuildManagerException;
 
-    boolean isInAnyBuildQueue( int projectId ) throws BuildManagerException;
-    
-    boolean isInAnyBuildQueue( int projectId, int buildDefinitionId ) throws BuildManagerException;
-    
-    boolean isInAnyCheckoutQueue( int projectId ) throws BuildManagerException;  
-    
-    boolean isInPrepareBuildQueue( int projectId ) throws BuildManagerException;
-    
-    boolean isProjectInAnyCurrentBuild( int projectId ) throws BuildManagerException;
-    
+    void removeOverallBuildQueue( int overallBuildQueueId )
+        throws BuildManagerException;
+
+    boolean isInAnyBuildQueue( int projectId )
+        throws BuildManagerException;
+
+    boolean isInAnyBuildQueue( int projectId, int buildDefinitionId )
+        throws BuildManagerException;
+
+    boolean isInAnyCheckoutQueue( int projectId )
+        throws BuildManagerException;
+
+    boolean isInPrepareBuildQueue( int projectId )
+        throws BuildManagerException;
+
+    boolean isProjectInAnyCurrentBuild( int projectId )
+        throws BuildManagerException;
+
     // needed in QueuesAction
-    List<Task> getCurrentBuilds() throws BuildManagerException;
-    
-    List<Task> getCurrentCheckouts() throws BuildManagerException;
-    
-    Map<String, List<Task>> getProjectsInBuildQueues() throws BuildManagerException;
-    
-    Map<String, List<Task>> getProjectsInCheckoutQueues() throws BuildManagerException;
-    
-    boolean isBuildInProgress() throws BuildManagerException; 
+    List<Task> getCurrentBuilds()
+        throws BuildManagerException;
+
+    List<Task> getCurrentCheckouts()
+        throws BuildManagerException;
+
+    Map<String, List<Task>> getProjectsInBuildQueues()
+        throws BuildManagerException;
+
+    Map<String, List<Task>> getProjectsInCheckoutQueues()
+        throws BuildManagerException;
+
+    boolean isBuildInProgress()
+        throws BuildManagerException;
 }

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=726625&r1=726624&r2=726625&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 Sun Dec 14 22:36:01 2008
@@ -26,8 +26,11 @@
 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;
 
+/**
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
 public interface OverallBuildQueue
 {       
     /**
@@ -121,62 +124,6 @@
     void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
         throws TaskQueueException;
 
-    /* Prepare Build Projects Queue */
-    
-    /**
-     * Returns the prepare-build-projects queue.
-     * 
-     * @return
-     */
-    //TaskQueue getPrepareBuildQueue();
-
-    /**
-     * Returns the task queue executor of the prepare-build-projects queue.
-     * 
-     * @return
-     * @throws ComponentLookupException TODO
-     */
-   // TaskQueueExecutor getPrepareBuildTaskQueueExecutor()
-   //     throws ComponentLookupException;
-
-    /**
-     * Add prepare build task to prepare-build-project queue.
-     * 
-     * @param prepareBuildTask
-     * @throws TaskQueueException TODO
-     */
-   // void addToPrepareBuildQueue( Task prepareBuildTask )
-    //    throws TaskQueueException;
-    
-    /**
-     * Add prepare build tasks to prepare-build-project queue
-     * 
-     * @param prepareBuildTasks
-     * @throws TaskQueueException TODO
-     */
-  //  void addToPrepareBuildQueue( List<Task> prepareBuildTasks )
-  //      throws TaskQueueException;
-
-    /**
-     * Checks if the project is in the prepare-build-projects queue.
-     * 
-     * @param projectId
-     * @return
-     * @throws TaskQueueException TODO
-     */
-  //  boolean isInPrepareBuildQueue( int projectId )
-  //      throws TaskQueueException;
-
-    /**
-     * Checks if the current prepare build task being executed is the specified project.
-     * 
-     * @param projectId
-     * @return
-     * @throws TaskQueueException TODO
-     */
-  //  boolean isCurrentPrepareBuildTaskInExecution( int projectId )
-  //      throws TaskQueueException;
-    
     /* Build Queue */
 
     /**
@@ -187,15 +134,6 @@
     TaskQueue getBuildQueue();
 
     /**
-     * Returns the task queue executor for the build queue.
-     * 
-     * @return
-     * @throws ComponentLookupException TODO
-     */
-    //TaskQueueExecutor getBuildTaskQueueExecutor()
-    //    throws ComponentLookupException;
-
-    /**
      * Add the build task to the build queue.
      * 
      * @param buildTask
@@ -214,15 +152,6 @@
         throws TaskQueueException;
 
     /**
-     * Returns the project id of the project currently being built.
-     * 
-     * @return
-     * @throws TaskQueueException TODO
-     */
-   // int getProjectIdInCurrentBuild()
-    //    throws TaskQueueException;
-
-    /**
      * Returns the build tasks in the build queue.
      * 
      * @return
@@ -232,15 +161,6 @@
         throws TaskQueueException;
 
     /**
-     * Checks if there is a build in progress.
-     * 
-     * @return
-     * @throws TaskQueueException TODO
-     */
-    //boolean isBuildInProgress()
-    //    throws TaskQueueException;
-
-    /**
      * Checks if the specified project is in the build queue.
      * 
      * @param projectId

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=726625&r1=726624&r2=726625&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 Sun Dec 14 22:36:01 2008
@@ -27,6 +27,7 @@
 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.OverallBuildQueue;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
@@ -60,62 +61,40 @@
  */
 public class ParallelBuildsManager
     implements BuildsManager, Contextualizable
-{    
+{
     private Logger log = LoggerFactory.getLogger( ParallelBuildsManager.class );
-        
+
     // 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;
-        
+
     /**
      * @plexus.requirement
      */
     private BuildDefinitionDao buildDefinitionDao;
-    
+
     /**
      * @plexus.requirement role-hint="prepare-build-project"
      */
     private TaskQueue prepareBuildQueue;
-    
+
     /**
      * @plexus.requirement
      */
     private ConfigurationService configurationService;
-    
-    private PlexusContainer container;     
-    
-    // REQUIREMENTS:
-    // UI:
-    // - add a new page for adding a build queue. It should have a build queue name that 
-    //   will be used to associate it with a schedule. The number of build queues that can 
-    //   be added should respect the "Number of Allowed Builds in Parallel" set in the 
-    //   General Configuration.
-    // - in the add/edit schedule page, add a list box that contains the build queues which 
-    //   would allow the user to select which build queue(s) to associate with the schedule.
-    //
-    // Back-end:
-    // 1. when a build is triggered:
-    //    * check for available build queue(s) associated with the schedule. Get the first available 
-    //          build queue.
-    //    * add the project to the associated build queue's checkout queue or build queue depending 
-    //          whether the project is configured to always "build fresh"
-    //    * once the build finishes, remove the project build instance from the associated build queue
-    //    * build the next project in the queue
-    //2. for releases:
-    //    * projects to be released will be built in sequence in a queue of their own. As long as 
-    //          they don't modify the build state or working copy it is ok to build the original 
-    //          project simultaneously. If the working copy changes are made in place for bumping 
-    //          versions, suggest blocking it and being built elsewhere.
-        
-    public void buildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger ) throws BuildManagerException
-    {   
+
+    private PlexusContainer container;
+
+    public void buildProject( int projectId, BuildDefinition buildDefinition, String projectName, int trigger )
+        throws BuildManagerException
+    {
         try
         {
-            if( isInQueue( projectId, BUILD_QUEUE, -1 ) )
+            if ( isInQueue( projectId, BUILD_QUEUE, -1 ) )
             {
                 log.warn( "Project already queued." );
                 return;
@@ -123,43 +102,43 @@
         }
         catch ( TaskQueueException e )
         {
-            throw new BuildManagerException( "Error occurred while checking if the project is already in queue: " + e.getMessage() );
+            throw new BuildManagerException( "Error occurred while checking if the project is already in queue: " +
+                e.getMessage() );
         }
-        
+
         OverallBuildQueue overallBuildQueue =
             getOverallBuildQueue( projectId, BUILD_QUEUE, buildDefinition.getSchedule().getBuildQueues() );
-        
-        log.info( "\n+++++ project :: " + projectId );
-        log.info( "+++++overall build queue :: " + overallBuildQueue.getId() );
-        
+
         String buildDefinitionLabel = buildDefinition.getDescription();
         if ( StringUtils.isEmpty( buildDefinitionLabel ) )
         {
             buildDefinitionLabel = buildDefinition.getGoals();
         }
-        
-        Task buildTask = new BuildProjectTask( projectId, buildDefinition.getId(), trigger, projectName,
-                                                 buildDefinitionLabel);
+
+        Task buildTask =
+            new BuildProjectTask( projectId, buildDefinition.getId(), trigger, projectName, buildDefinitionLabel );
         try
-        {   
+        {
+            log.info( "Queueing project '" + projectId + "' in build queue '" + overallBuildQueue.getName() );
             overallBuildQueue.addToBuildQueue( buildTask );
         }
         catch ( TaskQueueException e )
         {
-            throw new BuildManagerException( "Error occurred while adding project to build queue: "  + e.getMessage() );
-        }        
+            throw new BuildManagerException( "Error occurred while adding project to build queue: " + e.getMessage() );
+        }
     }
-    
-    public void buildProjects( List<Project> projects,
-                   Map<Integer, BuildDefinition> projectsBuildDefinitionsMap, int trigger ) throws BuildManagerException
-    {   
-        int firstProjectId = 0;        
+
+    public void buildProjects( List<Project> projects, Map<Integer, BuildDefinition> projectsBuildDefinitionsMap,
+                               int trigger )
+        throws BuildManagerException
+    {
+        int firstProjectId = 0;
         // get id of the first project in the list that is not yet in the build queue
-        for( Project project : projects )
+        for ( Project project : projects )
         {
             try
             {
-                if( !isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
+                if ( !isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
                 {
                     firstProjectId = project.getId();
                     break;
@@ -171,20 +150,21 @@
                 continue;
             }
         }
-         
-        if( firstProjectId != 0 )
+
+        if ( firstProjectId != 0 )
         {
             BuildDefinition buildDef = projectsBuildDefinitionsMap.get( firstProjectId );
             OverallBuildQueue overallBuildQueue =
-                getOverallBuildQueue( firstProjectId, BUILD_QUEUE, buildDef.getSchedule().getBuildQueues() );;
-            
-            if( overallBuildQueue != null )
+                getOverallBuildQueue( firstProjectId, BUILD_QUEUE, buildDef.getSchedule().getBuildQueues() );
+            ;
+
+            if ( overallBuildQueue != null )
             {
-                for( Project project :  projects )
-                {   
+                for ( Project project : projects )
+                {
                     try
                     {
-                        if( isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
+                        if ( isInQueue( project.getId(), BUILD_QUEUE, -1 ) )
                         {
                             continue;
                         }
@@ -194,25 +174,27 @@
                         log.warn( "Error occurred while verifying if project is already queued." );
                         continue;
                     }
-                    
+
                     BuildDefinition buildDefinition = projectsBuildDefinitionsMap.get( project.getId() );
                     String buildDefinitionLabel = buildDefinition.getDescription();
                     if ( StringUtils.isEmpty( buildDefinitionLabel ) )
                     {
                         buildDefinitionLabel = buildDefinition.getGoals();
                     }
-                    
-                    BuildProjectTask buildTask = new BuildProjectTask( project.getId(), buildDefinition.getId(), trigger, project.getName(),
-                                                             buildDefinitionLabel);
+
+                    BuildProjectTask buildTask =
+                        new BuildProjectTask( project.getId(), buildDefinition.getId(), trigger, project.getName(),
+                                              buildDefinitionLabel );
                     buildTask.setMaxExecutionTime( buildDefinition.getSchedule().getMaxJobExecutionTime() * 1000 );
-                    
+
                     try
-                    {   
+                    {
                         overallBuildQueue.addToBuildQueue( buildTask );
                     }
                     catch ( TaskQueueException e )
                     {
-                        throw new BuildManagerException( "Error occurred while adding project to build queue: "  + e.getMessage() );
+                        throw new BuildManagerException( "Error occurred while adding project to build queue: " +
+                            e.getMessage() );
                     }
                 }
             }
@@ -222,17 +204,18 @@
             log.error( "Projects are already in build queue." );
             throw new BuildManagerException( "Projects are already in build queue." );
         }
-    }    
-    
-    public boolean cancelBuildInQueue( int buildQueueId ) throws BuildManagerException
-    {            
-        synchronized( overallBuildQueues )
-        {       
+    }
+
+    public boolean cancelBuildInQueue( int buildQueueId )
+        throws BuildManagerException
+    {
+        synchronized ( overallBuildQueues )
+        {
             OverallBuildQueue overallBuildQueue = null;
             try
-            {                
+            {
                 overallBuildQueue = overallBuildQueues.get( buildQueueId );
-                if( overallBuildQueue != null )
+                if ( overallBuildQueue != null )
                 {
                     overallBuildQueue.cancelCurrentBuild();
                 }
@@ -246,56 +229,53 @@
                 log.error( e.getMessage() );
                 throw new BuildManagerException( e.getMessage() );
             }
-            
+
             return true;
-        }                
+        }
     }
 
-    public boolean cancelAllBuilds() throws BuildManagerException
-    {   
-        synchronized( overallBuildQueues )
+    public boolean cancelAllBuilds()
+        throws BuildManagerException
+    {
+        synchronized ( overallBuildQueues )
         {
             Set<Integer> keySet = overallBuildQueues.keySet();
             OverallBuildQueue overallBuildQueue = null;
-            
+
             try
-            {                
-                for( Integer key : keySet )
+            {
+                for ( Integer key : keySet )
                 {
-                    overallBuildQueue = overallBuildQueues.get( key );                
-                    overallBuildQueue.cancelCurrentBuild();                
+                    overallBuildQueue = overallBuildQueues.get( key );
+                    overallBuildQueue.cancelCurrentBuild();
                 }
-            }        
+            }
             catch ( ComponentLookupException e )
             {
                 log.error( e.getMessage() );
                 throw new BuildManagerException( e.getMessage() );
             }
-            
+
             return true;
         }
     }
 
-    public boolean cancelAllCheckouts() throws BuildManagerException
+    public boolean cancelAllCheckouts()
+        throws BuildManagerException
     {
         // TODO Auto-generated method stub
         return false;
     }
 
-    /*public boolean cancelAllPrepareBuilds() throws BuildManagerException
+    public boolean cancelBuild( int projectId )
+        throws BuildManagerException
     {
-        // TODO Auto-generated method stub
-        return false;
-    }*/
-
-    public boolean cancelBuild( int projectId ) throws BuildManagerException
-    {   
         try
         {
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
-            if( overallBuildQueue != null )
+            if ( overallBuildQueue != null )
             {
-                overallBuildQueue.cancelBuildTask(  projectId );
+                overallBuildQueue.cancelBuildTask( projectId );
             }
             else
             {
@@ -303,26 +283,27 @@
                 //throw new BuildManagerException( "Project not found in any of the build queues." );
             }
         }
-        catch( TaskQueueException e )
+        catch ( TaskQueueException e )
         {
-            throw new BuildManagerException( "Error occurred while cancelling build: " +
-                 e.getMessage() );        
+            throw new BuildManagerException( "Error occurred while cancelling build: " + e.getMessage() );
         }
         catch ( ComponentLookupException e )
-        {            
+        {
             throw new BuildManagerException( e.getMessage() );
         }
-        
+
         return true;
     }
 
-    // TODO: should this be permitted? (might need to execute svn cleanup?)
-    public boolean cancelCheckout(int projectId) throws BuildManagerException
+    public boolean cancelCheckout( int projectId )
+        throws BuildManagerException
     {
+        // TODO: should this be permitted? (might need to execute svn cleanup?)
+
         try
         {
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, CHECKOUT_QUEUE );
-            if( overallBuildQueue != null )
+            if ( overallBuildQueue != null )
             {
                 //overallBuildQueue.getCheckoutQueue()
             }
@@ -331,28 +312,21 @@
                 throw new BuildManagerException( "Project not found in any of the checkout queues." );
             }
         }
-        catch( TaskQueueException e )
+        catch ( TaskQueueException e )
         {
-            throw new BuildManagerException( "Error occurred while cancelling build: " +
-                 e.getMessage() );        
+            throw new BuildManagerException( "Error occurred while cancelling build: " + e.getMessage() );
         }
-        
+
         return true;
     }
 
-    /*public boolean cancelPrepareBuild(int projectId) throws BuildManagerException
-    {
-        // TODO Auto-generated method stub
-        return false;
-    }*/
-
     public void checkoutProject( int projectId, String projectName, File workingDirectory, String scmUsername,
                                  String scmPassword, BuildDefinition defaultBuildDefinition )
         throws BuildManagerException
-    {   
+    {
         try
         {
-            if( isInQueue( projectId, CHECKOUT_QUEUE, -1 ) )
+            if ( isInQueue( projectId, CHECKOUT_QUEUE, -1 ) )
             {
                 log.warn( "Project already in checkout queue." );
                 return;
@@ -360,12 +334,13 @@
         }
         catch ( TaskQueueException e )
         {
-            throw new BuildManagerException( "Error occurred while checking if the project is already in queue: " + e.getMessage() );
+            throw new BuildManagerException( "Error occurred while checking if the project is already in queue: " +
+                e.getMessage() );
         }
-        
+
         OverallBuildQueue overallBuildQueue =
             getOverallBuildQueue( projectId, CHECKOUT_QUEUE, defaultBuildDefinition.getSchedule().getBuildQueues() );
-        
+
         CheckOutTask checkoutTask =
             new CheckOutTask( projectId, workingDirectory, projectName, scmUsername, scmPassword );
         try
@@ -375,10 +350,11 @@
         catch ( TaskQueueException e )
         {
             throw new BuildManagerException( "Error occurred while adding project to checkout queue: " + e.getMessage() );
-        }        
+        }
     }
-    
-    public boolean isInAnyBuildQueue( int projectId ) throws BuildManagerException
+
+    public boolean isInAnyBuildQueue( int projectId )
+        throws BuildManagerException
     {
         try
         {
@@ -389,8 +365,9 @@
             throw new BuildManagerException( e.getMessage() );
         }
     }
-    
-    public boolean isInAnyBuildQueue( int projectId, int buildDefinitionId ) throws BuildManagerException
+
+    public boolean isInAnyBuildQueue( int projectId, int buildDefinitionId )
+        throws BuildManagerException
     {
         try
         {
@@ -401,8 +378,9 @@
             throw new BuildManagerException( e.getMessage() );
         }
     }
-    
-    public boolean isInAnyCheckoutQueue( int projectId ) throws BuildManagerException
+
+    public boolean isInAnyCheckoutQueue( int projectId )
+        throws BuildManagerException
     {
         try
         {
@@ -413,22 +391,23 @@
             throw new BuildManagerException( e.getMessage() );
         }
     }
-    
-    public boolean isInPrepareBuildQueue( int projectId ) throws BuildManagerException
+
+    public boolean isInPrepareBuildQueue( int projectId )
+        throws BuildManagerException
     {
         try
         {
-            List<PrepareBuildProjectsTask> queue = prepareBuildQueue.getQueueSnapshot();    
+            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;
@@ -441,36 +420,36 @@
         {
             throw new BuildManagerException( e.getMessage() );
         }
-        
-        return false;        
+
+        return false;
     }
-    
-    public boolean isProjectInAnyCurrentBuild( int projectId ) throws BuildManagerException
+
+    public boolean isProjectInAnyCurrentBuild( int projectId )
+        throws BuildManagerException
     {
         try
         {
             List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
-            for( Object obj : objects )
+            for ( Object obj : objects )
             {
-                log.info( "\n object --> " + obj );
-                log.info( "\n object class --> " + obj.getClass() );                
-                ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+                log.info( "Task queue executor : " + obj );
+                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
                 Task task = executor.getCurrentTask();
-                if( task instanceof BuildProjectTask )
+                if ( task instanceof BuildProjectTask )
                 {
                     log.info( "current task is a BuildProjectTask." );
                     return true;
                 }
-            }            
+            }
         }
         catch ( ComponentLookupException e )
         {
             throw new BuildManagerException( e.getMessage() );
         }
-        
+
         return false;
     }
-    
+
     public void prepareBuildProject( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger )
         throws BuildManagerException
     {
@@ -483,15 +462,16 @@
         {
             throw new BuildManagerException( "Error occurred while creating prepare-build-project task: " +
                 e.getMessage() );
-        }        
+        }
     }
 
-    public void removeProjectFromBuildQueue( int projectId ) throws BuildManagerException
+    public void removeProjectFromBuildQueue( int projectId )
+        throws BuildManagerException
     {
         try
         {
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
-            if( overallBuildQueue != null )
+            if ( overallBuildQueue != null )
             {
                 overallBuildQueue.removeProjectFromBuildQueue( projectId );
             }
@@ -507,13 +487,14 @@
                 e.getMessage() );
         }
     }
-    
-    public void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName ) throws BuildManagerException
+
+    public void removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
+        throws BuildManagerException
     {
         try
         {
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, BUILD_QUEUE );
-            if( overallBuildQueue != null )
+            if ( overallBuildQueue != null )
             {
                 overallBuildQueue.removeProjectFromBuildQueue( projectId, buildDefinitionId, trigger, projectName );
             }
@@ -529,13 +510,14 @@
                 e.getMessage() );
         }
     }
-        
-    public void removeProjectFromCheckoutQueue( int projectId ) throws BuildManagerException
+
+    public void removeProjectFromCheckoutQueue( int projectId )
+        throws BuildManagerException
     {
         try
         {
             OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectId, CHECKOUT_QUEUE );
-            if( overallBuildQueue != null )
+            if ( overallBuildQueue != null )
             {
                 overallBuildQueue.removeProjectFromCheckoutQueue( projectId );
             }
@@ -552,20 +534,15 @@
         }
     }
 
-    /*public void removeProjectFromPrepareBuildQueue( int projectId )
-    {
-        // TODO Auto-generated method stub
-
-    }*/
-
     public void removeProjectsFromBuildQueue( int[] projectIds )
     {
-        for( int i = 0; i < projectIds.length; i++ )
+        for ( int i = 0; i < projectIds.length; i++ )
         {
             try
             {
-                OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectIds[i], BUILD_QUEUE );
-                if( overallBuildQueue != null )
+                OverallBuildQueue overallBuildQueue =
+                    getOverallBuildQueueWhereProjectIsQueued( projectIds[i], BUILD_QUEUE );
+                if ( overallBuildQueue != null )
                 {
                     overallBuildQueue.removeProjectFromBuildQueue( projectIds[i] );
                 }
@@ -585,12 +562,13 @@
 
     public void removeProjectsFromCheckoutQueue( int[] projectIds )
     {
-        for( int i = 0; i < projectIds.length; i++ )
+        for ( int i = 0; i < projectIds.length; i++ )
         {
             try
             {
-                OverallBuildQueue overallBuildQueue = getOverallBuildQueueWhereProjectIsQueued( projectIds[i], CHECKOUT_QUEUE );
-                if( overallBuildQueue != null )
+                OverallBuildQueue overallBuildQueue =
+                    getOverallBuildQueueWhereProjectIsQueued( projectIds[i], CHECKOUT_QUEUE );
+                if ( overallBuildQueue != null )
                 {
                     overallBuildQueue.removeProjectFromCheckoutQueue( projectIds[i] );
                 }
@@ -608,160 +586,219 @@
         }
     }
 
-    /*public void removeProjectsFromPrepareBuildQueue( int[] projectIds )
+    public void removeProjectsFromCheckoutQueueWithHashcodes( int[] hashcodes )
+        throws BuildManagerException
     {
-        // TODO Auto-generated method stub
-    }*/
-    
+        try
+        {
+            synchronized ( overallBuildQueues )
+            {
+                Set<Integer> keySet = overallBuildQueues.keySet();
+                for ( Integer key : keySet )
+                {
+                    OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                    overallBuildQueue.removeTasksFromCheckoutQueueWithHashCodes( hashcodes );
+                    /*List<CheckOutTask> tasks = overallBuildQueue.getCheckOutTasksInQueue();
+                    for ( CheckOutTask task : tasks )
+                    {
+                        if ( ArrayUtils.contains( hashcodes, task.hashCode() ) )
+                        {
+                            overallBuildQueue.getCheckoutQueue().remove( task );
+                        }
+                    }*/
+                }
+            }
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new BuildManagerException( "Error encountered while removing project(s) from checkout queue.", e );
+        }
+    }
+
+    public void removeProjectsFromBuildQueueWithHashcodes( int[] hashcodes )
+        throws BuildManagerException
+    {
+        try
+        {
+            synchronized ( overallBuildQueues )
+            {
+                Set<Integer> keySet = overallBuildQueues.keySet();
+                for ( Integer key : keySet )
+                {
+                    OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                    overallBuildQueue.removeProjectsFromBuildQueueWithHashCodes( hashcodes );
+                    /*List<Task> tasks = overallBuildQueue.getProjectsInBuildQueue();
+                    for ( Task task : tasks )
+                    {
+                        if ( ArrayUtils.contains( hashcodes, task.hashCode() ) )
+                        {
+                            overallBuildQueue.getBuildQueue().remove( task );
+                        }
+                    }*/
+                }
+            }
+        }
+        catch ( TaskQueueException e )
+        {
+            throw new BuildManagerException( "Error encountered while removing project(s) from build queue.", e );
+        }
+    }
+
     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 )
+
+        synchronized ( overallBuildQueues )
         {
-            if( overallBuildQueues.get( overallBuildQueue.getId() ) == null )
+            if ( overallBuildQueues.get( overallBuildQueue.getId() ) == null )
             {
                 this.overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue );
             }
             else
-            {   
+            {
                 log.warn( "Overall build queue already in the map" );
             }
         }
     }
-    
-    public void removeOverallBuildQueue( int overallBuildQueueId ) throws BuildManagerException
+
+    public void removeOverallBuildQueue( int overallBuildQueueId )
+        throws BuildManagerException
     {
         List<Task> tasks = null;
         List<CheckOutTask> checkoutTasks = null;
-        
+
         /*if( overallBuildQueueId == 1 )
         {
             throw new BuildManagerException( "Default build queue cannot be deleted." );
         }*/
-        
-        synchronized( overallBuildQueues )        
-        {   
+
+        synchronized ( overallBuildQueues )
+        {
             OverallBuildQueue overallBuildQueue = overallBuildQueues.get( overallBuildQueueId );
-            if( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME ) )
+            if ( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME ) )
             {
                 throw new BuildManagerException( "Cannot remove default build queue." );
             }
-            
+
             try
             {
-                tasks = overallBuildQueue.getProjectsInBuildQueue();                
+                tasks = overallBuildQueue.getProjectsInBuildQueue();
                 checkoutTasks = overallBuildQueue.getCheckOutTasksInQueue();
-                
+
                 overallBuildQueue.getBuildQueue().removeAll( tasks );
                 overallBuildQueue.getCheckoutQueue().removeAll( checkoutTasks );
-                 
+
                 container.release( overallBuildQueue );
             }
             catch ( TaskQueueException e )
             {
                 throw new BuildManagerException(
-                         "Cannot remove build queue. An error occurred while retrieving queued tasks." );
+                                                 "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() );
+                                                 "Cannot remove build queue. An error occurred while destroying the build queue: " +
+                                                     e.getMessage() );
             }
-                        
+
             this.overallBuildQueues.remove( overallBuildQueueId );
         }
-        
+
         try
         {
-            for( Task task : tasks )
+            for ( Task task : tasks )
             {
-                BuildProjectTask buildTask = ( BuildProjectTask ) task;
-                BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildTask.getBuildDefinitionId() );
-                buildProject( buildTask.getProjectId(), buildDefinition, buildTask.getProjectName(), buildTask.getTrigger() );                    
+                BuildProjectTask buildTask = (BuildProjectTask) task;
+                BuildDefinition buildDefinition =
+                    buildDefinitionDao.getBuildDefinition( buildTask.getBuildDefinitionId() );
+                buildProject( buildTask.getProjectId(), buildDefinition, buildTask.getProjectName(),
+                              buildTask.getTrigger() );
             }
-         
-            for( CheckOutTask task : checkoutTasks )
+
+            for ( CheckOutTask task : checkoutTasks )
             {
                 BuildDefinition buildDefinition = buildDefinitionDao.getDefaultBuildDefinition( task.getProjectId() );
                 checkoutProject( task.getProjectId(), task.getProjectName(), task.getWorkingDirectory(),
-                                      task.getScmUserName(), task.getScmPassword(), buildDefinition );                    
+                                 task.getScmUserName(), task.getScmPassword(), buildDefinition );
             }
         }
         catch ( ContinuumStoreException e )
         {
-            throw new BuildManagerException(
-                "Cannot remove build queue: " + e.getMessage() );
+            throw new BuildManagerException( "Cannot remove build queue: " + e.getMessage() );
         }
     }
-    
+
     public Map<Integer, OverallBuildQueue> getOverallBuildQueues()
-    {   
+    {
         return overallBuildQueues;
     }
-    
-    public List<Task> getCurrentBuilds() throws BuildManagerException
-    {   
-        List<Task> currentBuilds = new ArrayList<Task>();        
+
+    public List<Task> getCurrentBuilds()
+        throws BuildManagerException
+    {
+        List<Task> currentBuilds = new ArrayList<Task>();
         try
         {
             List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
-            for( Object obj : objects )
+            for ( Object obj : objects )
             {
-                ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+                log.info( "Task queue executor : " + obj );
+                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
                 Task task = executor.getCurrentTask();
-                if( task instanceof BuildProjectTask )
+                if ( task instanceof BuildProjectTask )
                 {
-                    currentBuilds.add( task );                    
+                    currentBuilds.add( task );
                 }
-            }            
+            }
         }
         catch ( ComponentLookupException e )
         {
             throw new BuildManagerException( e.getMessage() );
         }
-        
+
         return currentBuilds;
     }
-    
-    public List<Task> getCurrentCheckouts() throws BuildManagerException
+
+    public List<Task> getCurrentCheckouts()
+        throws BuildManagerException
     {
-        List<Task> currentCheckouts = new ArrayList<Task>();        
+        List<Task> currentCheckouts = new ArrayList<Task>();
         try
         {
             List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
-            for( Object obj : objects )
+            for ( Object obj : objects )
             {
-                ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
                 Task task = executor.getCurrentTask();
-                if( task instanceof CheckOutTask )
+                if ( task instanceof CheckOutTask )
                 {
-                    currentCheckouts.add( task );                    
+                    currentCheckouts.add( task );
                 }
-            }            
+            }
         }
         catch ( ComponentLookupException e )
         {
             throw new BuildManagerException( e.getMessage() );
         }
-        
+
         return currentCheckouts;
     }
-    
-    public Map<String, List<Task>> getProjectsInBuildQueues() throws BuildManagerException
-    {   
-        synchronized( overallBuildQueues )
-        {            
+
+    public Map<String, List<Task>> getProjectsInBuildQueues()
+        throws BuildManagerException
+    {
+        synchronized ( overallBuildQueues )
+        {
             Map<String, List<Task>> buildsInQueue = new HashMap<String, List<Task>>();
             Set<Integer> keySet = overallBuildQueues.keySet();
-            for( Integer key : keySet )
+            for ( Integer key : keySet )
             {
                 OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
                 try
-                {                    
+                {
                     buildsInQueue.put( overallBuildQueue.getName(), overallBuildQueue.getProjectsInBuildQueue() );
                 }
                 catch ( TaskQueueException e )
@@ -769,22 +806,23 @@
                     throw new BuildManagerException( "Error occurred while getting projects in build queue '" +
                         overallBuildQueue.getName() + "'.", e );
                 }
-            }                
-            return buildsInQueue;            
+            }
+            return buildsInQueue;
         }
     }
-    
-    public Map<String, List<Task>> getProjectsInCheckoutQueues() throws BuildManagerException
+
+    public Map<String, List<Task>> getProjectsInCheckoutQueues()
+        throws BuildManagerException
     {
-        synchronized( overallBuildQueues )
-        {            
+        synchronized ( overallBuildQueues )
+        {
             Map<String, List<Task>> checkoutsInQueue = new HashMap<String, List<Task>>();
             Set<Integer> keySet = overallBuildQueues.keySet();
-            for( Integer key : keySet )
+            for ( Integer key : keySet )
             {
                 OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
                 try
-                {                    
+                {
                     checkoutsInQueue.put( overallBuildQueue.getName(), overallBuildQueue.getCheckOutTasksInQueue() );
                 }
                 catch ( TaskQueueException e )
@@ -792,140 +830,133 @@
                     throw new BuildManagerException( "Error occurred while getting projects in checkout queue '" +
                         overallBuildQueue.getName() + "'.", e );
                 }
-            }                
-            return checkoutsInQueue;            
+            }
+            return checkoutsInQueue;
         }
     }
-    
-    public boolean isBuildInProgress() throws BuildManagerException
+
+    public boolean isBuildInProgress()
+        throws BuildManagerException
     {
         return false;
     }
-    
+
     private boolean isInQueue( int projectId, int typeOfQueue, int buildDefinitionId )
         throws TaskQueueException
-    {   
-        synchronized( overallBuildQueues )
+    {
+        synchronized ( overallBuildQueues )
         {
-            Set<Integer> keySet = overallBuildQueues.keySet();        
-            for( Integer key : keySet )
+            Set<Integer> keySet = overallBuildQueues.keySet();
+            for ( Integer key : keySet )
             {
                 OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
-                if( typeOfQueue == BUILD_QUEUE )
+                if ( typeOfQueue == BUILD_QUEUE )
                 {
-                    if( buildDefinitionId < 0 )
+                    if ( buildDefinitionId < 0 )
                     {
-                        if( overallBuildQueue.isInBuildQueue( projectId ) )
+                        if ( overallBuildQueue.isInBuildQueue( projectId ) )
                         {
                             return true;
                         }
                     }
                     else
                     {
-                        if( overallBuildQueue.isInBuildQueue( projectId, buildDefinitionId ) )
+                        if ( overallBuildQueue.isInBuildQueue( projectId, buildDefinitionId ) )
                         {
                             return true;
                         }
                     }
                 }
-                else if( typeOfQueue == CHECKOUT_QUEUE )
+                else if ( typeOfQueue == CHECKOUT_QUEUE )
                 {
-                    if( overallBuildQueue.isInCheckoutQueue( projectId ) )
+                    if ( overallBuildQueue.isInCheckoutQueue( projectId ) )
                     {
                         return true;
                     }
                 }
-                /*else if( typeOfQueue == PREPARE_BUILD_QUEUE )
-                {
-                    if( overallBuildQueue.isInPrepareBuildQueue( projectId ) )
-                    {
-                        return true;
-                    }
-                }*/
             }
-            
+
             return false;
         }
     }
-    
+
     // get overall queue where project is queued
-    private OverallBuildQueue getOverallBuildQueueWhereProjectIsQueued( int projectId, int typeOfQueue )    
+    private OverallBuildQueue getOverallBuildQueueWhereProjectIsQueued( int projectId, int typeOfQueue )
         throws TaskQueueException
     {
-        synchronized( overallBuildQueues )
+        synchronized ( overallBuildQueues )
         {
             OverallBuildQueue whereQueued = null;
             Set<Integer> keySet = overallBuildQueues.keySet();
-            
-            for( Integer key : keySet )
+
+            for ( Integer key : keySet )
             {
                 OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
-                if( typeOfQueue == BUILD_QUEUE )
+                if ( typeOfQueue == BUILD_QUEUE )
                 {
-                    if( overallBuildQueue.isInBuildQueue( projectId ) )
+                    if ( overallBuildQueue.isInBuildQueue( projectId ) )
                     {
                         whereQueued = overallBuildQueue;
                         break;
                     }
                 }
-                else if( typeOfQueue == CHECKOUT_QUEUE )
+                else if ( typeOfQueue == CHECKOUT_QUEUE )
                 {
-                    if( overallBuildQueue.isInCheckoutQueue( projectId ) )
+                    if ( overallBuildQueue.isInCheckoutQueue( projectId ) )
                     {
                         whereQueued = overallBuildQueue;
                         break;
                     }
                 }
             }
-            
+
             return whereQueued;
         }
     }
-    
+
+    // get overall queue where project will be queued
     private OverallBuildQueue getOverallBuildQueue( int projectId, int typeOfQueue, List<BuildQueue> buildQueues )
         throws BuildManagerException
     {
-        OverallBuildQueue whereToBeQueued = null; 
-        synchronized( overallBuildQueues )
+        OverallBuildQueue whereToBeQueued = null;
+        synchronized ( overallBuildQueues )
         {
-            if( overallBuildQueues == null || overallBuildQueues.isEmpty() )
+            if ( overallBuildQueues == null || overallBuildQueues.isEmpty() )
             {
                 throw new BuildManagerException( "No build queues configured." );
             }
-            
-            System.out.println( "+++++build queues size : " + buildQueues.size() );
+
             int size = 0;
             int idx = 0;
             try
             {
-                for( BuildQueue buildQueue : buildQueues )
+                for ( BuildQueue buildQueue : buildQueues )
                 {
-                    System.out.println( "+++++build queue id : " + buildQueue.getId() );
-                    OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId() ); 
-                    if( overallBuildQueue != null )
+                    OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId() );
+                    if ( overallBuildQueue != null )
                     {
                         TaskQueue taskQueue = null;
-                        if( typeOfQueue == BUILD_QUEUE )
+                        if ( typeOfQueue == BUILD_QUEUE )
                         {
                             taskQueue = overallBuildQueue.getBuildQueue();
                         }
-                        else if( typeOfQueue == CHECKOUT_QUEUE )
-                        {   
+                        else if ( typeOfQueue == CHECKOUT_QUEUE )
+                        {
                             taskQueue = overallBuildQueue.getCheckoutQueue();
                         }
-                                                
-                        if( idx == 0 )
+
+                        if ( idx == 0 )
                         {
                             size = taskQueue.getQueueSnapshot().size();
                             whereToBeQueued = overallBuildQueue;
                         }
-                        
-                        if( taskQueue.getQueueSnapshot().size() < size )
+
+                        if ( taskQueue.getQueueSnapshot().size() < size )
                         {
                             whereToBeQueued = overallBuildQueue;
                             size = taskQueue.getQueueSnapshot().size();
                         }
-                        
+
                         idx++;
                     }
                     else
@@ -939,13 +970,13 @@
                 throw new BuildManagerException( "Error occurred while retrieving task quueue: " + e.getMessage() );
             }
         }
-        
-        if( whereToBeQueued == null )
+
+        if ( whereToBeQueued == null )
         {
             // TODO queue in the default overall build queue
             throw new BuildManagerException( "No build queue found." );
         }
-        
+
         return whereToBeQueued;
     }
 
@@ -953,23 +984,24 @@
     {
         this.buildDefinitionDao = buildDefinitionDao;
     }
-    
+
     public void contextualize( Context context )
         throws ContextException
-    {   
+    {
         container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
-        
-        synchronized( overallBuildQueues )
+
+        synchronized ( overallBuildQueues )
         {
             try
-            {   
+            {
                 BuildQueue defaultBuildQueue = configurationService.getDefaultBuildQueue();
-                
-                OverallBuildQueue defaultOverallBuildQueue = ( OverallBuildQueue ) container.lookup( OverallBuildQueue.class );
+
+                OverallBuildQueue defaultOverallBuildQueue =
+                    (OverallBuildQueue) container.lookup( OverallBuildQueue.class );
                 defaultOverallBuildQueue.setId( defaultBuildQueue.getId() );
                 defaultOverallBuildQueue.setName( defaultBuildQueue.getName() );
                 defaultOverallBuildQueue.setContainer( container );
-                
+
                 overallBuildQueues.put( defaultOverallBuildQueue.getId(), defaultOverallBuildQueue );
             }
             catch ( ComponentLookupException e )

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=726625&r1=726624&r2=726625&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 Sun Dec 14 22:36:01 2008
@@ -38,7 +38,7 @@
 import org.codehaus.plexus.util.StringUtils;
 
 /**
- * "Overall" build queue which has a checkout queue and a 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"
@@ -46,7 +46,7 @@
 public class DefaultOverallBuildQueue
     extends AbstractLogEnabled
     implements OverallBuildQueue
-{   
+{
     /**
      * @plexus.requirement role-hint="build-project"
      */
@@ -63,11 +63,11 @@
     private BuildDefinitionDao buildDefinitionDao;
 
     private PlexusContainer container;
-    
+
     private int id;
-    
+
     private String name;
-    
+
     public int getId()
     {
         return id;
@@ -77,23 +77,29 @@
     {
         this.id = id;
     }
-    
+
     public String getName()
     {
         return name;
     }
-    
+
     public void setName( String name )
     {
         this.name = name;
     }
 
+    /**
+     * @see OverallBuildQueue#addToCheckoutQueue(Task)
+     */
     public void addToCheckoutQueue( Task checkoutTask )
         throws TaskQueueException
     {
         checkoutQueue.put( checkoutTask );
     }
 
+    /**
+     * @see OverallBuildQueue#addToCheckoutQueue(List)
+     */
     public void addToCheckoutQueue( List<Task> checkoutTasks )
         throws TaskQueueException
     {
@@ -103,12 +109,18 @@
         }
     }
 
+    /**
+     * @see OverallBuildQueue#getCheckOutTasksInQueue()
+     */
     public List<CheckOutTask> getCheckOutTasksInQueue()
         throws TaskQueueException
     {
-        return checkoutQueue.getQueueSnapshot();       
+        return checkoutQueue.getQueueSnapshot();
     }
 
+    /**
+     * @see OverallBuildQueue#isInCheckoutQueue(int)
+     */
     public boolean isInCheckoutQueue( int projectId )
         throws TaskQueueException
     {
@@ -125,6 +137,9 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectFromCheckoutQueue(int)
+     */
     public boolean removeProjectFromCheckoutQueue( int projectId )
         throws TaskQueueException
     {
@@ -141,6 +156,9 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectsFromCheckoutQueue(int[])
+     */
     public boolean removeProjectsFromCheckoutQueue( int[] projectsId )
         throws TaskQueueException
     {
@@ -173,6 +191,9 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeTasksFromCheckoutQueueWithHashCodes(int[])
+     */
     public void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
         throws TaskQueueException
     {
@@ -186,13 +207,19 @@
             }
         }
     }
-    
+
+    /**
+     * @see OverallBuildQueue#addToBuildQueue(Task)
+     */
     public void addToBuildQueue( Task buildTask )
         throws TaskQueueException
     {
         buildQueue.put( buildTask );
     }
 
+    /**
+     * @see OverallBuildQueue#addToBuildQueue(List)
+     */
     public void addToBuildQueue( List<Task> buildTasks )
         throws TaskQueueException
     {
@@ -202,18 +229,27 @@
         }
     }
 
+    /**
+     * @see OverallBuildQueue#getProjectsInBuildQueue()
+     */
     public List<Task> getProjectsInBuildQueue()
         throws TaskQueueException
-    {   
-        return buildQueue.getQueueSnapshot();        
+    {
+        return buildQueue.getQueueSnapshot();
     }
 
+    /**
+     * @see OverallBuildQueue#isInBuildQueue(int)
+     */
     public boolean isInBuildQueue( int projectId )
         throws TaskQueueException
     {
         return isInBuildQueue( projectId, -1 );
     }
 
+    /**
+     * @see OverallBuildQueue#isInBuildQueue(int, int)
+     */
     public boolean isInBuildQueue( int projectId, int buildDefinitionId )
         throws TaskQueueException
     {
@@ -243,60 +279,63 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#cancelBuildTask(int)
+     */
     public void cancelBuildTask( int projectId )
         throws ComponentLookupException
-    {  
-        getLogger().info( "\n========= [OverallBuildQueue] CANCEL BUILD TASK ============" );
+    {
         List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
-        for( Object obj : objects )
+        for ( Object obj : objects )
         {
-            getLogger().info( "\n object --> " + obj );
-            getLogger().info( "\n object class --> " + obj.getClass() );                
-            ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+            ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
             Task task = executor.getCurrentTask();
-            if( task != null && task instanceof BuildProjectTask )
+            if ( task != null && task instanceof BuildProjectTask )
             {
-                if( ( (BuildProjectTask) task ).getProjectId() == projectId )
+                if ( ( (BuildProjectTask) task ).getProjectId() == projectId )
                 {
-                    getLogger().info( "Cancelling task for project " + projectId );
+                    getLogger().info(
+                                      "Cancelling build task for project '" + projectId + "' in task executor '" +
+                                          executor );
                     executor.cancelTask( task );
-                    getLogger().info( "current task is a BuildProjectTask." );
                 }
             }
-        }           
-        
+        }
+
     }
 
+    /**
+     * @see OverallBuildQueue#cancelCurrentBuild()
+     */
     public boolean cancelCurrentBuild()
         throws ComponentLookupException
     {
-        getLogger().info( "\n========= [OverallBuildQueue] CANCEL CURRENT BUILD ============" );
         List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class );
-        for( Object obj : objects )
+        for ( Object obj : objects )
         {
-            getLogger().info( "\n object --> " + obj );
-            getLogger().info( "\n object class --> " + obj.getClass() );                
-            ThreadedTaskQueueExecutor executor = ( ThreadedTaskQueueExecutor ) obj;
+            ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
             Task task = executor.getCurrentTask();
-            if( task != null && task instanceof BuildProjectTask )
-            {   
+            if ( task != null && task instanceof BuildProjectTask )
+            {
                 BuildProjectTask buildTask = (BuildProjectTask) task;
-                getLogger().info( "Cancelling build task for project '" + buildTask.getProjectId() );
+                getLogger().info(
+                                  "Cancelling task for project '" + buildTask.getProjectId() + "' in task executor '" +
+                                      executor );
                 executor.cancelTask( task );
-                getLogger().info( "current task is a BuildProjectTask." );
             }
         }
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectFromBuildQueue(int, int, int, String)
+     */
     public boolean removeProjectFromBuildQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
         throws TaskQueueException
     {
         BuildDefinition buildDefinition;
 
-        // TODO: deng - maybe we could just pass the label as a parameter to eliminate 
-        //          dependency to BuildDefinitionDAO?
-        
+        // maybe we could just pass the label as a parameter to eliminate dependency to BuildDefinitionDAO?
         try
         {
             buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
@@ -311,13 +350,16 @@
         {
             buildDefinitionLabel = buildDefinition.getGoals();
         }
-        
+
         BuildProjectTask buildProjectTask =
             new BuildProjectTask( projectId, buildDefinitionId, trigger, projectName, buildDefinitionLabel );
-        
+
         return this.buildQueue.remove( buildProjectTask );
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectsFromBuildQueue(int[])
+     */
     public boolean removeProjectsFromBuildQueue( int[] projectIds )
         throws TaskQueueException
     {
@@ -357,6 +399,9 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectFromBuildQueue(int)
+     */
     public boolean removeProjectFromBuildQueue( int projectId )
         throws TaskQueueException
     {
@@ -374,12 +419,15 @@
         return false;
     }
 
+    /**
+     * @see OverallBuildQueue#removeProjectsFromBuildQueueWithHashCodes(int[])
+     */
     public void removeProjectsFromBuildQueueWithHashCodes( int[] hashCodes )
         throws TaskQueueException
     {
         List<Task> queue = getProjectsInBuildQueue();
-        for ( Task task : queue )        
-        {            
+        for ( Task task : queue )
+        {
             if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
             {
                 buildQueue.remove( task );
@@ -387,11 +435,17 @@
         }
     }
 
+    /** 
+     * @see OverallBuildQueue#getCheckoutQueue()
+     */
     public TaskQueue getCheckoutQueue()
     {
         return checkoutQueue;
     }
 
+    /**
+     * @see OverallBuildQueue#getBuildQueue()
+     */
     public TaskQueue getBuildQueue()
     {
         return buildQueue;