Return-Path: Delivered-To: apmail-continuum-commits-archive@www.apache.org Received: (qmail 4153 invoked from network); 5 Jan 2009 07:38:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jan 2009 07:38:06 -0000 Received: (qmail 94794 invoked by uid 500); 5 Jan 2009 07:38:06 -0000 Delivered-To: apmail-continuum-commits-archive@continuum.apache.org Received: (qmail 94743 invoked by uid 500); 5 Jan 2009 07:38:06 -0000 Mailing-List: contact commits-help@continuum.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@continuum.apache.org Delivered-To: mailing list commits@continuum.apache.org Received: (qmail 94734 invoked by uid 99); 5 Jan 2009 07:38:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Jan 2009 23:38:06 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Jan 2009 07:37:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F1C9A238899A; Sun, 4 Jan 2009 23:37:36 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r731477 - /continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java Date: Mon, 05 Jan 2009 07:37:36 -0000 To: commits@continuum.apache.org From: oching@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090105073736.F1C9A238899A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: oching Date: Sun Jan 4 23:37:36 2009 New Revision: 731477 URL: http://svn.apache.org/viewvc?rev=731477&view=rev Log: use the default overall build queue if no build queue is attached to the schedule 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=731477&r1=731476&r2=731477&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 Jan 4 23:37:36 2009 @@ -351,13 +351,19 @@ OverallBuildQueue overallBuildQueue = getOverallBuildQueue( projectId, CHECKOUT_QUEUE, defaultBuildDefinition.getSchedule().getBuildQueues() ); - CheckOutTask checkoutTask = new CheckOutTask( projectId, workingDirectory, projectName, scmUsername, scmPassword ); try { - log.info( "Project '" + projectName + "' added to overall build queue '" + overallBuildQueue.getName() + "'." ); - overallBuildQueue.addToCheckoutQueue( checkoutTask ); + if( overallBuildQueue != null ) + { + log.info( "Project '" + projectName + "' added to overall build queue '" + overallBuildQueue.getName() + "'." ); + overallBuildQueue.addToCheckoutQueue( checkoutTask ); + } + else + { + throw new BuildManagerException( "Unable to add project to checkout queue. No overall build queue configured." ); + } } catch ( TaskQueueException e ) { @@ -1018,6 +1024,11 @@ 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? + try { for ( BuildQueue buildQueue : buildQueues ) @@ -1061,23 +1072,51 @@ } } + // use default overall build queue if none is configured if ( whereToBeQueued == null ) { + boolean found = false; Set keySet = overallBuildQueues.keySet(); for( Integer key : keySet ) { - OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key ); + OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key ); if( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME ) ) { + found = true; return overallBuildQueue; } } - //throw new BuildManagerException( "No build queue found." ); + + // 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." ); + } + } } return whereToBeQueued; } - + public void setBuildDefinitionDao( BuildDefinitionDao buildDefinitionDao ) { this.buildDefinitionDao = buildDefinitionDao; @@ -1086,22 +1125,17 @@ public void contextualize( Context context ) throws ContextException { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); synchronized ( overallBuildQueues ) { try { // create all the build queues configured in the database, not just the default! - List buildQueues = buildQueueDao.getAllBuildQueues(); + List buildQueues = buildQueueDao.getAllBuildQueues(); for( BuildQueue buildQueue : buildQueues ) - { - OverallBuildQueue defaultOverallBuildQueue = - (OverallBuildQueue) container.lookup( OverallBuildQueue.class ); - defaultOverallBuildQueue.setId( buildQueue.getId() ); - defaultOverallBuildQueue.setName( buildQueue.getName() ); - - overallBuildQueues.put( defaultOverallBuildQueue.getId(), defaultOverallBuildQueue ); + { + createOverallBuildQueue( buildQueue ); } //BuildQueue defaultBuildQueue = configurationService.getDefaultBuildQueue(); } @@ -1120,4 +1154,17 @@ { this.container = container; } + + private OverallBuildQueue createOverallBuildQueue( BuildQueue defaultBuildQueue ) + throws ComponentLookupException + { + OverallBuildQueue overallBuildQueue = + (OverallBuildQueue) container.lookup( OverallBuildQueue.class ); + overallBuildQueue.setId( defaultBuildQueue.getId() ); + overallBuildQueue.setName( defaultBuildQueue.getName() ); + + overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue ); + + return overallBuildQueue; + } }