continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r731514 - /continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Date Mon, 05 Jan 2009 10:13:30 GMT
Author: oching
Date: Mon Jan  5 02:13:30 2009
New Revision: 731514

URL: http://svn.apache.org/viewvc?rev=731514&view=rev
Log:
o respect the number of allowed builds in parallel each time a build is triggered
o create the default over build queue when starting up the parallel builds manager

Modified:
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java

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=731514&r1=731513&r2=731514&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
Mon Jan  5 02:13:30 2009
@@ -94,7 +94,7 @@
     private BuildQueueDao buildQueueDao;
 
     private PlexusContainer container;
-
+    
     /**
      * @see BuildsManager#buildProject(int, BuildDefinition, String, int)
      */
@@ -1023,47 +1023,53 @@
             }
 
             int size = 0;
-            int idx = 0;
-            
-            // TODO: 
-            // - the number of build queues to be used should respect the number of allowed
builds in parallel!
-            // - what to do when the number of allowed builds in parallel is reduced and
there are queued tasks?
+            int idx = 0;            
+            int allowedBuilds = configurationService.getNumberOfBuildsInParallel();
             
             try
-            {   
+            {
+                int count = 1;             
                 for ( BuildQueue buildQueue : buildQueues )
-                {                                        
-                    OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId()
);
-                    if ( overallBuildQueue != null )
-                    {
-                        TaskQueue taskQueue = null;
-                        if ( typeOfQueue == BUILD_QUEUE )
+                {            
+                    if( count <= allowedBuilds )
+                    {   
+                        OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId()
);
+                        if ( overallBuildQueue != null )
                         {
-                            taskQueue = overallBuildQueue.getBuildQueue();
-                        }
-                        else if ( typeOfQueue == CHECKOUT_QUEUE )
-                        {
-                            taskQueue = overallBuildQueue.getCheckoutQueue();
-                        }
-                        
-                        if ( idx == 0 )
-                        {
-                            size = taskQueue.getQueueSnapshot().size();
-                            whereToBeQueued = overallBuildQueue;
+                            TaskQueue taskQueue = null;
+                            if ( typeOfQueue == BUILD_QUEUE )
+                            {
+                                taskQueue = overallBuildQueue.getBuildQueue();
+                            }
+                            else if ( typeOfQueue == CHECKOUT_QUEUE )
+                            {
+                                taskQueue = overallBuildQueue.getCheckoutQueue();
+                            }
+                            
+                            if ( idx == 0 )
+                            {
+                                size = taskQueue.getQueueSnapshot().size();
+                                whereToBeQueued = overallBuildQueue;
+                            }
+    
+                            if ( taskQueue.getQueueSnapshot().size() < size )
+                            {
+                                whereToBeQueued = overallBuildQueue;
+                                size = taskQueue.getQueueSnapshot().size();
+                            }
+    
+                            idx++;
                         }
-
-                        if ( taskQueue.getQueueSnapshot().size() < size )
+                        else
                         {
-                            whereToBeQueued = overallBuildQueue;
-                            size = taskQueue.getQueueSnapshot().size();
+                            log.error( "Build queue not found." );                      
     
                         }
-
-                        idx++;
+                        count++;
                     }
                     else
                     {
-                        log.error( "Build queue not found." );
-                    }
+                        break;
+                    }   
                 }
             }
             catch ( TaskQueueException e )
@@ -1085,32 +1091,6 @@
                     found = true;
                     return overallBuildQueue;
                 }
-            }            
-            
-            // no default "overall" build queue configured
-            if( !found )
-            {
-                try
-                {
-                    // add the default build queue to the map                    
-                    BuildQueue defaultBuildQueue = buildQueueDao.getBuildQueueByName( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME
);
-                    if( defaultBuildQueue != null )
-                    {
-                        return createOverallBuildQueue( defaultBuildQueue );            
           
-                    }
-                    else
-                    {
-                        throw new BuildManagerException( "No default build queue configured."
);
-                    }
-                }
-                catch ( ContinuumStoreException e )
-                {
-                    throw new BuildManagerException( "Error encountered while retrieving
default build queue from the database." );
-                }
-                catch ( ComponentLookupException e )
-                {
-                    throw new BuildManagerException( "Error occurred while creating default
build queue." );
-                }
             }
         }
 
@@ -1137,7 +1117,13 @@
                 {   
                     createOverallBuildQueue( buildQueue );
                 }               
-                //BuildQueue defaultBuildQueue = configurationService.getDefaultBuildQueue();
+
+                // add default overall build queue if not yet added to the map
+                BuildQueue defaultBuildQueue = configurationService.getDefaultBuildQueue();
+                if( overallBuildQueues.get( defaultBuildQueue.getId() ) == null )
+                {
+                    createOverallBuildQueue( defaultBuildQueue );
+                }
             }
             catch ( ComponentLookupException e )
             {



Mime
View raw message