continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r748163 [1/2] - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/ continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/ continuum-api/src/main/java/org/apache/continu...
Date Thu, 26 Feb 2009 14:47:02 GMT
Author: ctan
Date: Thu Feb 26 14:47:01 2009
New Revision: 748163

URL: http://svn.apache.org/viewvc?rev=748163&view=rev
Log:
[CONTINUUM-2068] added group agent and fixed selection of agents

Submitted By: Jan Ancajas 

Added:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java   (with props)
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java   (with props)
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java   (with props)
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java   (with props)
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java   (with props)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/confirmDeleteBuildAgentGroup.jsp   (with props)
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editBuildAgentGroup.jsp   (with props)
Removed:
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    continuum/trunk/continuum-base/continuum-configuration/pom.xml
    continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
    continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
    continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
    continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
    continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java
    continuum/trunk/continuum-builder/src/main/resources/META-INF/plexus/components.xml
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
    continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/startup/ContinuumStartup.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ProfileAction.java
    continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/trunk/continuum-webapp/src/main/resources/org/apache/continuum/web/action/admin/BuildAgentAction.properties
    continuum/trunk/continuum-webapp/src/main/resources/struts.xml
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/buildAgentsList.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editProfile.jsp
    continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/profilesList.jsp

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java?rev=748163&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java Thu Feb 26 14:47:01 2009
@@ -0,0 +1,33 @@
+package org.apache.continuum.builder.distributed.executor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+
+public interface DistributedBuildTaskExecutor
+{
+    void executeTask( Task task )
+        throws TaskExecutionException;
+
+    String getBuildAgentUrl();
+
+    void setBuildAgentUrl( String buildAgentUrl );
+}

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java?rev=748163&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java Thu Feb 26 14:47:01 2009
@@ -0,0 +1,67 @@
+package org.apache.continuum.builder.distributed.executor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+
+public interface DistributedBuildTaskQueueExecutor
+{
+    String ROLE = DistributedBuildTaskQueueExecutor.class.getName();
+
+    /**
+     * Returns the build agent url of task queue executor
+     * 
+     * @return the build agent url
+     */
+    String getBuildAgentUrl();
+
+    /**
+     * Sets the build agent url of this task queue executor
+     * 
+     * @param buildAgentUrl
+     */
+    void setBuildAgentUrl( String buildAgentUrl );
+
+    /**
+     * Returns the currently executing task.
+     *
+     * @return the currently executing task.
+     */
+    Task getCurrentTask();
+
+    /**
+     * Cancels execution of this task, if it's currently running.
+     * Does NOT remove it from the associated queue!
+     *
+     * @param task The task to cancel
+     * @return true if the task was cancelled, false if the task was not executing.
+     */
+    boolean cancelTask( Task task );
+
+    /**
+     * Returns the task queue
+     * 
+     *
+     * 
+     * @return the TaskQueue of the task queue executor
+     */
+    public TaskQueue getQueue();
+}

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildTaskQueueExecutor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java Thu Feb 26 14:47:01 2009
@@ -22,6 +22,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.builder.distributed.executor.DistributedBuildTaskQueueExecutor;
 import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.model.system.Installation;
@@ -69,6 +70,8 @@
 
     boolean shouldBuild( Map context );
 
+    Map<String, DistributedBuildTaskQueueExecutor> getTaskQueueExecutors();
+
     String generateWorkingCopyContent( int projectId, String directory, String baseUrl, String imagesBaseUrl )
         throws ContinuumException;
 

Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java?rev=748163&view=auto
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java (added)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java Thu Feb 26 14:47:01 2009
@@ -0,0 +1,62 @@
+package org.apache.continuum.configuration;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class BuildAgentGroupConfiguration
+{
+    private String name;
+
+    private List<BuildAgentConfiguration> buildAgents = new ArrayList<BuildAgentConfiguration>();
+
+    public BuildAgentGroupConfiguration()
+    {
+        //nil
+    }
+
+    public BuildAgentGroupConfiguration( String name, List<BuildAgentConfiguration> buildAgents )
+    {
+        this.name = name;
+        this.buildAgents = buildAgents;
+    }
+
+    public void addBuildAgent(BuildAgentConfiguration buildAgent)
+    {
+        buildAgents.add( buildAgent );
+    }
+
+    public void removeBuildAgent( BuildAgentConfiguration buildAgent )
+    {
+        Iterator<BuildAgentConfiguration> iterator = buildAgents.iterator();
+        while ( iterator.hasNext() )
+        {
+            BuildAgentConfiguration agent = iterator.next(); 
+            if( agent.getUrl().equals( buildAgent.getUrl() ) )
+            {
+                iterator.remove();
+            }
+        }
+    }    
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    public List<BuildAgentConfiguration> getBuildAgents()
+    {
+        return buildAgents;
+    }
+
+    public void setBuildAgents( List<BuildAgentConfiguration> buildAgents )
+    {
+        this.buildAgents = buildAgents;
+    }
+
+}

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/BuildAgentGroupConfiguration.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/configuration/GeneralConfiguration.java Thu Feb 26 14:47:01 2009
@@ -46,6 +46,8 @@
     private int numberOfBuildsInParallel = 1;
 
     private List<BuildAgentConfiguration> buildAgents;
+    
+    private List<BuildAgentGroupConfiguration> buildAgentGroups;
 
     public GeneralConfiguration()
     {
@@ -137,4 +139,14 @@
     {
         this.buildAgents = buildAgents;
     }
+
+    public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
+    {
+        return buildAgentGroups;
+    }
+
+    public void setBuildAgentGroups( List<BuildAgentGroupConfiguration> buildAgentGroups )
+    {
+        this.buildAgentGroups = buildAgentGroups;
+    }
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Thu Feb 26 14:47:01 2009
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.project.ProjectScmRoot;
@@ -515,7 +516,6 @@
     BuildDefinition addBuildDefinitionToProject( int projectId, BuildDefinition buildDefinition )
         throws ContinuumException;
 
-
     BuildDefinition addBuildDefinitionToProjectGroup( int projectGroupId, BuildDefinition buildDefinition )
         throws ContinuumException;
 
@@ -605,7 +605,7 @@
     ContinuumPurgeManager getPurgeManager();
 
     PurgeConfigurationService getPurgeConfigurationService();
-    
+
     // ----------------------------------------------------------------------
     // Repository Service
     // ----------------------------------------------------------------------
@@ -634,11 +634,11 @@
     // Builds Manager
     // ----------------------------------------------------------------------
     BuildsManager getBuildsManager();    
-    
+
     // ----------------------------------------------------------------------
     // Build Queue
     // ----------------------------------------------------------------------
-    
+
     BuildQueue addBuildQueue( BuildQueue buildQueue )
         throws ContinuumException;
 
@@ -656,10 +656,10 @@
 
     List<BuildQueue> getAllBuildQueues()
         throws ContinuumException;
-    
+
     public void startup()
         throws ContinuumException;
-    
+
     ContinuumReleaseResult addContinuumReleaseResult( ContinuumReleaseResult releaseResult )
         throws ContinuumException;
 
@@ -675,7 +675,9 @@
 
     ContinuumReleaseResult getContinuumReleaseResult( int projectId, String releaseGoal, long startTime, long endTime )
         throws ContinuumException;
-    
+
     String getReleaseOutput( int releaseResultId )
         throws ContinuumException;
+
+    DistributedBuildManager getDistributedBuildManager();
 }

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java (original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java Thu Feb 26 14:47:01 2009
@@ -21,6 +21,7 @@
 
 import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
@@ -77,23 +78,23 @@
 
     File getTestReportsDirectory( int buildId, int projectId )
         throws ConfigurationException;
-    
+
     File getReleaseOutputDirectory();
-    
+
     void setReleaseOutputDirectory( File releaseOutputDirectory );
-    
+
     File getReleaseOutputDirectory( int projectGroupId );
-    
+
     File getReleaseOutputFile( int projectGroupId, String releaseName )
         throws ConfigurationException;
 
     String getReleaseOutput( int projectGroupId, String releaseName )
         throws ConfigurationException;
-    
+
     int getNumberOfBuildsInParallel();
-    
+
     void setNumberOfBuildsInParallel( int num );
-    
+
     BuildQueue getDefaultBuildQueue()
         throws BuildQueueServiceException;
 
@@ -110,6 +111,29 @@
 
     void setDistributedBuildEnabled( boolean distributedBuildEnabled );
 
+    void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException;
+
+    void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException;
+
+    void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException;
+
+    void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException;
+
+    void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException;
+
+    BuildAgentGroupConfiguration getBuildAgentGroup(String name);
+
+    BuildAgentConfiguration getBuildAgent(String url);
+
+    List<BuildAgentGroupConfiguration> getBuildAgentGroups();
+
+    boolean containsBuildAgentUrl(String buildAgentUrl,  BuildAgentGroupConfiguration buildAgentGroup );
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-base/continuum-configuration/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/pom.xml?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/pom.xml (original)
+++ continuum/trunk/continuum-base/continuum-configuration/pom.xml Thu Feb 26 14:47:01 2009
@@ -35,7 +35,7 @@
           <models>
             <model>src/main/mdo/continuum-configuration.xml</model>
           </models>
-          <version>1.1.0</version>
+          <version>1.1.1</version>
         </configuration>
         <executions>
           <execution>

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java Thu Feb 26 14:47:01 2009
@@ -171,6 +171,29 @@
                 
                 this.generalConfiguration.setBuildAgents( buildAgents );
             }
+            if ( configuration.getBuildAgentGroups() != null )
+            {
+                List<BuildAgentGroupConfiguration> buildAgentGroups = new ArrayList<BuildAgentGroupConfiguration>();
+                List<org.apache.continuum.configuration.model.BuildAgentGroupConfiguration> groups = configuration.getBuildAgentGroups();
+                
+                for ( org.apache.continuum.configuration.model.BuildAgentGroupConfiguration group : groups )
+                {
+                    List <BuildAgentConfiguration> agents = new ArrayList<BuildAgentConfiguration>();
+                    List<org.apache.continuum.configuration.model.BuildAgentConfiguration> modelAgents =  group.getBuildAgents();                   
+                    for ( org.apache.continuum.configuration.model.BuildAgentConfiguration modelAgent : modelAgents )
+                    {
+                        BuildAgentConfiguration buildAgent = new BuildAgentConfiguration( modelAgent.getUrl(),
+                                                                                          modelAgent.getDescription(),
+                                                                                          modelAgent.isEnabled() ) ;
+                        agents.add( buildAgent );
+                    }
+
+                    BuildAgentGroupConfiguration groupAgent = new BuildAgentGroupConfiguration( group.getName(),agents );
+                    buildAgentGroups.add( groupAgent );
+                }
+
+                this.generalConfiguration.setBuildAgentGroups( buildAgentGroups );
+            }
         }
         catch ( IOException e )
         {
@@ -248,6 +271,38 @@
                 }
                 configurationModel.setBuildAgents( buildAgents );
             }
+            if ( this.generalConfiguration.getBuildAgentGroups() != null )
+            {
+                List buildAgentGroups = new ArrayList();
+
+                for ( BuildAgentGroupConfiguration group : this.generalConfiguration.getBuildAgentGroups() )
+                {
+                    org.apache.continuum.configuration.model.BuildAgentGroupConfiguration buildAgentGroup =
+                        new org.apache.continuum.configuration.model.BuildAgentGroupConfiguration();
+                    buildAgentGroup.setName( group.getName() );
+
+                    List buildAgents = new ArrayList();
+
+                    if ( group.getBuildAgents() != null )
+                    {
+                        for ( BuildAgentConfiguration agent : group.getBuildAgents() )
+                        {
+                            org.apache.continuum.configuration.model.BuildAgentConfiguration buildAgent =
+                                new org.apache.continuum.configuration.model.BuildAgentConfiguration();
+                            buildAgent.setUrl( agent.getUrl() );
+                            buildAgent.setDescription( agent.getDescription() );
+                            buildAgent.setEnabled( agent.isEnabled() );
+
+                            buildAgents.add( buildAgent );
+                        }
+
+                        buildAgentGroup.setBuildAgents( buildAgents );
+                    }
+
+                    buildAgentGroups.add( buildAgentGroup );
+                }
+                configurationModel.setBuildAgentGroups( buildAgentGroups );
+            }
 
             ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );
@@ -259,7 +314,7 @@
         }
         
     }
-    
+
     
     // ----------------------------------------
     //  Spring injection

Modified: continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/main/mdo/continuum-configuration.xml Thu Feb 26 14:47:01 2009
@@ -79,6 +79,14 @@
             <multiplicity>*</multiplicity>
           </association>
         </field>
+        <field>
+          <name>buildAgentGroups</name>
+          <version>1.1.1+</version>
+          <association>
+            <type>BuildAgentGroupConfiguration</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
       </fields>
     </class>
     <class xml.tagName="proxy-configuration">
@@ -127,6 +135,25 @@
           <type>boolean</type>
         </field>
       </fields>
+    </class>
+    <class xml.tagName="buildagentgroup-configuration">
+      <name>BuildAgentGroupConfiguration</name>
+      <version>1.1.1+</version>
+      <fields>
+        <field>
+          <name>name</name>
+          <version>1.1.1+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>buildAgents</name>
+          <version>1.1.1+</version>
+          <association>
+            <type>BuildAgentConfiguration</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
     </class>    
   </classes>
 </model>

Modified: continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/test/java/org/apache/continuum/configuration/TestDefaultContinuumConfiguration.java Thu Feb 26 14:47:01 2009
@@ -74,6 +74,15 @@
         assertEquals( "http://buildagent/xmlrpc", buildAgentConfig.getUrl() );
         assertEquals( "linux", buildAgentConfig.getDescription() );
         assertTrue( buildAgentConfig.isEnabled() );
+
+        // agent group tests        
+        assertNotNull( "agent group", generalConfiguration.getBuildAgentGroups() );
+        BuildAgentGroupConfiguration buildAgentGroupConfig =
+            generalConfiguration.getBuildAgentGroups().get( 0 );
+        assertEquals("group-agent-1", buildAgentGroupConfig.getName() );        
+        BuildAgentConfiguration agentConfig = (BuildAgentConfiguration) buildAgentGroupConfig.getBuildAgents().get( 0 );
+        assertEquals( "http://buildagent/xmlrpc", agentConfig.getUrl() );
+        assertEquals( "linux", agentConfig.getDescription() );
     }
 
     public void testDefaultConfiguration()
@@ -98,9 +107,24 @@
         buildAgentConfiguration.setUrl( "http://buildagent/test" );
         buildAgentConfiguration.setDescription( "windows xp" );
         buildAgentConfiguration.setEnabled( false );
+
+        BuildAgentConfiguration buildAgentConfiguration2 = new BuildAgentConfiguration();
+        buildAgentConfiguration2.setUrl( "http://buildagent-node-2/test" );
+        buildAgentConfiguration2.setDescription( "linux" );
+        buildAgentConfiguration2.setEnabled( true );
+
         List<BuildAgentConfiguration> buildAgents = new ArrayList<BuildAgentConfiguration>();
         buildAgents.add( buildAgentConfiguration );
+        buildAgents.add( buildAgentConfiguration2 );
+        BuildAgentGroupConfiguration buildAgentGroupConfiguration = new BuildAgentGroupConfiguration();
+        buildAgentGroupConfiguration.setName( "secret-agent" );        
+        buildAgentGroupConfiguration.setBuildAgents( buildAgents );
+
+        List<BuildAgentGroupConfiguration> buildAgentGroups = new ArrayList<BuildAgentGroupConfiguration>();
+        buildAgentGroups.add( buildAgentGroupConfiguration );
+
         generalConfiguration.setBuildAgents( buildAgents );
+        generalConfiguration.setBuildAgentGroups( buildAgentGroups );
         configuration.setGeneralConfiguration( generalConfiguration );
         configuration.save();
 
@@ -110,14 +134,23 @@
         assertTrue( contents.indexOf( "8080" ) > 0 );
         assertTrue( contents.indexOf( "http://buildagent/test" ) > 0 );
         assertTrue( contents.indexOf( "windows xp" ) > 0 );
-        
+        assertTrue( contents.indexOf( "http://buildagent-node-2/test" )> 0);
+        assertTrue( contents.indexOf( "linux" )> 0);
+        assertTrue( contents.indexOf( "secret-agent" )> 0);       
+
         configuration.reload();
         assertEquals( "http://test/zloug", configuration.getGeneralConfiguration().getBaseUrl() );
         assertEquals( "localhost", configuration.getGeneralConfiguration().getProxyConfiguration().getProxyHost() );
         assertEquals( 8080, configuration.getGeneralConfiguration().getProxyConfiguration().getProxyPort() );
         assertEquals(targetDir.getPath(), configuration.getGeneralConfiguration().getBuildOutputDirectory().getPath());
-        assertEquals( "http://buildagent/test", configuration.getGeneralConfiguration().getBuildAgents().get( 0 ).getUrl() );
+        assertEquals( "http://buildagent/test", configuration.getGeneralConfiguration().getBuildAgents().get( 0 ).getUrl() );        
         assertFalse( configuration.getGeneralConfiguration().getBuildAgents().get( 0 ).isEnabled() );
+        assertEquals( "http://buildagent-node-2/test", configuration.getGeneralConfiguration().getBuildAgents().get( 1 ).getUrl() );
+        assertTrue(configuration.getGeneralConfiguration().getBuildAgents().get( 1 ).isEnabled());
+
+        assertEquals("secret-agent", configuration.getGeneralConfiguration().getBuildAgentGroups().get( 0 ).getName());
+        assertEquals("http://buildagent/test",configuration.getGeneralConfiguration().getBuildAgentGroups().get( 0 ).getBuildAgents().get( 0 ).getUrl() );
+        assertEquals("http://buildagent-node-2/test",configuration.getGeneralConfiguration().getBuildAgentGroups().get( 0 ).getBuildAgents().get( 1 ).getUrl() );
         log.info( "generalConfiguration " + configuration.getGeneralConfiguration().toString() );
     }
 }

Modified: continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml (original)
+++ continuum/trunk/continuum-base/continuum-configuration/src/test/resources/conf/continuum.xml Thu Feb 26 14:47:01 2009
@@ -9,4 +9,16 @@
       <enabled>true</enabled>
     </buildAgent>
   </buildAgents>
+  <buildAgentGroups>
+    <buildAgentGroup>
+      <name>group-agent-1</name>
+      <buildAgents>
+        <buildAgent>
+          <url>http://buildagent/xmlrpc</url>
+          <description>linux</description>
+          <enabled>true</enabled>
+        </buildAgent>
+      </buildAgents>
+    </buildAgentGroup>
+  </buildAgentGroups>
 </continuum-configuration>
\ No newline at end of file

Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java (original)
+++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java Thu Feb 26 14:47:01 2009
@@ -303,7 +303,7 @@
 
     public static ScmResult getScmResult( Map context, Object defaultValue )
     {
-        return (ScmResult) getObject( context, KEY_SCM_RESULT );
+        return (ScmResult) getObject( context, KEY_SCM_RESULT, defaultValue );
     }
 
     public static int getTrigger( Map context )

Modified: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java (original)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/ThreadedDistributedBuildTaskQueueExecutor.java Thu Feb 26 14:47:01 2009
@@ -345,4 +345,9 @@
     {
         return executor.getBuildAgentUrl();
     }
+
+    public TaskQueue getQueue()
+    {
+        return queue;
+    }
 }

Added: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java?rev=748163&view=auto
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java (added)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java Thu Feb 26 14:47:01 2009
@@ -0,0 +1,34 @@
+package org.apache.continuum.builder.distributed.executor.deferred;
+
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.TaskQueue;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DistributedBuildProjectTaskExecutorDeferred
+    implements TaskExecutor
+{
+    private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+    /**
+     * @plexus.requirement
+     */
+    private TaskQueue distributedTaskQueue;
+
+    public void executeTask( Task task )
+        throws TaskExecutionException
+    {
+        try
+        {
+            Thread.sleep( 1000 );
+            distributedTaskQueue.put( task );
+        }
+        catch ( Exception e )
+        {
+            log.error( "error encountered adding the deferred task back to distributed queue", e );
+            throw new TaskExecutionException( e.getMessage(), e );
+        }
+    }
+}

Propchange: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/deferred/DistributedBuildProjectTaskExecutorDeferred.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java?rev=748163&view=auto
==============================================================================
--- continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java (added)
+++ continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java Thu Feb 26 14:47:01 2009
@@ -0,0 +1,212 @@
+package org.apache.continuum.builder.distributed.executor.overall;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.builder.distributed.executor.DistributedBuildTaskQueueExecutor;
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
+import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
+import org.apache.continuum.dao.BuildDefinitionDao;
+import org.apache.continuum.dao.ProjectDao;
+import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
+import org.apache.continuum.utils.ProjectSorter;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.system.Profile;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+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.execution.TaskExecutionException;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DistributedBuildProjectTaskExecutorOverall
+    implements TaskExecutor, Contextualizable
+{
+    private Logger log = LoggerFactory.getLogger( this.getClass() );
+
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+
+    /**
+     * @plexus.requirement
+     */
+    private ProjectDao projectDao;
+
+    /**
+     * @plexus.requirement
+     */
+    private BuildDefinitionDao buildDefinitionDao;
+
+    /**
+     * @plexus.requirement
+     */
+    private DistributedBuildManager buildManager;
+
+    /**
+     * @plexus.requirement
+     */
+    private TaskQueue deferredTaskQueue;
+
+    PlexusContainer container;
+
+    public void executeTask( Task task )
+        throws TaskExecutionException
+    {
+        try
+        {
+            String agentGroup = getBuildAgentGroup( task );
+
+            Map<String, DistributedBuildTaskQueueExecutor> executors = buildManager.getTaskQueueExecutors();
+
+            DistributedBuildTaskQueueExecutor executor =  filterExecutors( agentGroup, executors );
+            if ( executor != null )
+            {
+                log.info( "delegating task to build agent task queue executor: " + executor.getBuildAgentUrl() );
+                executor.getQueue().put( task );
+            }
+            else
+            {
+                // task is added to deferred-queue , which will then be added back to distributed-queue
+                // so as not to choke-off the distributed-queue.               
+                deferredTaskQueue.put( task );
+            }
+        }
+        catch ( ContinuumException e )
+        {
+            log.error( "error encountered delegating task to a build agent queue", e );
+            throw new TaskExecutionException( e.getMessage(), e );
+        }
+        catch ( Exception e )
+        {
+            log.error( "error encountered delegating task to a build agent queue", e );
+            throw new TaskExecutionException( e.getMessage(), e );
+        }
+    }
+
+    private DistributedBuildTaskQueueExecutor filterExecutors( Map<String, DistributedBuildTaskQueueExecutor> executors )
+    {
+        // return the first non-busy taskqueue executor
+        for ( String url : executors.keySet() )
+        {
+            if ( executors.get( url ).getCurrentTask() == null )
+            {
+                return executors.get( url );
+            }
+        }
+        // else return the first executor
+        if ( !executors.isEmpty() )
+        {
+            for ( String url : executors.keySet() )
+            {
+                return executors.get( url );
+            }
+        }
+        return null;
+    }
+
+    private DistributedBuildTaskQueueExecutor filterExecutors( String agentGroupName,
+                                                               Map<String, DistributedBuildTaskQueueExecutor> executors )
+    {
+        if ( agentGroupName == null ) //it doesnt belong to any group, just return the first non-busy executor.
+        {
+            return filterExecutors( executors );
+        }
+
+        BuildAgentGroupConfiguration agentGroup = configurationService.getBuildAgentGroup( agentGroupName );
+        List<BuildAgentConfiguration> buildAgents = agentGroup.getBuildAgents();
+        Map<String, DistributedBuildTaskQueueExecutor> mapCandidateExecutors =
+            new HashMap<String, DistributedBuildTaskQueueExecutor>();
+        List<String> agentUrls = new ArrayList<String>();
+
+        if ( buildAgents != null )
+        {
+            for ( BuildAgentConfiguration buildAgent : buildAgents )
+            {
+                agentUrls.add( buildAgent.getUrl() );
+            }
+        }
+
+        for ( String url : executors.keySet() )
+        {
+            if ( agentUrls.contains( url ) )
+            {
+                mapCandidateExecutors.put( url, executors.get( url ) );
+            }
+        }
+
+        return filterExecutors( mapCandidateExecutors );
+    }
+
+    private String getBuildAgentGroup( Task task )
+        throws ContinuumException
+    {
+        try
+        {
+            List<Project> projects = new ArrayList<Project>();
+
+            PrepareBuildProjectsTask prepareBuildTask = (PrepareBuildProjectsTask) task;
+            Map<Integer, Integer> projectsAndBuildDefinitions = prepareBuildTask.getProjectsBuildDefinitionsMap();
+
+            for ( Integer projectId : projectsAndBuildDefinitions.keySet() )
+            {
+                projects.add( projectDao.getProjectWithDependencies( projectId ) );
+            }
+
+            try
+            {
+                projects = ProjectSorter.getSortedProjects( projects, null );
+            }
+            catch ( CycleDetectedException e )
+            {
+                log.info( "Cycle Detected" );
+            }
+
+            int buildDefinitionId = projectsAndBuildDefinitions.get( projects.get( 0 ).getId() );
+            BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
+
+            Profile profile = buildDefinition.getProfile();
+
+            if ( profile != null && !StringUtils.isEmpty( profile.getBuildAgentGroup() ) )
+            {
+                String groupName = profile.getBuildAgentGroup();
+
+                BuildAgentGroupConfiguration buildAgentGroup = configurationService.getBuildAgentGroup( groupName );
+
+                return buildAgentGroup.getName();
+            }
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while getting build agent group", e );
+        }
+
+        log.info( "profile build agent group is null" );
+
+        return null;
+    }
+
+    // --------------------------------
+    // Plexus Lifecycle
+    // --------------------------------
+    public void contextualize( Context context )
+        throws ContextException
+    {
+        container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+    }
+}

Propchange: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/overall/DistributedBuildProjectTaskExecutorOverall.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: continuum/trunk/continuum-builder/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-builder/src/main/resources/META-INF/plexus/components.xml?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-builder/src/main/resources/META-INF/plexus/components.xml (original)
+++ continuum/trunk/continuum-builder/src/main/resources/META-INF/plexus/components.xml Thu Feb 26 14:47:01 2009
@@ -19,7 +19,7 @@
 
 <component-set>
   <components>
-  
+
     <!--
      |
      | Distributed Build Task Queue
@@ -34,6 +34,99 @@
     </component>
 
     <component>
+      <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+      <role-hint>distributed-build-project-deferred</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
+      <lifecycle-handler>plexus-configurable</lifecycle-handler>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+      <role-hint>distributed-build-project-per-agent</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
+      <lifecycle-handler>plexus-configurable</lifecycle-handler>
+      <instantiation-strategy>per-lookup</instantiation-strategy>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+      <role-hint>distributed-build-project-overall</role-hint>
+      <implementation>org.apache.continuum.builder.distributed.executor.overall.DistributedBuildProjectTaskExecutorOverall</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
+          <role-hint>default</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.ProjectDao</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.dao.BuildDefinitionDao</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.continuum.builder.distributed.manager.DistributedBuildManager</role>
+        </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+          <role-hint>distributed-build-project-deferred</role-hint>
+          <field-name>deferredTaskQueue</field-name>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
+      <role-hint>distributed-build-project-overall</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+          <role-hint>distributed-build-project-overall</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+          <role-hint>distributed-build-project</role-hint>
+        </requirement>
+      </requirements>
+      <configuration>
+        <name>distributed-build-project-overall</name>
+      </configuration>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+      <role-hint>distributed-build-project-deferred</role-hint>
+      <implementation>org.apache.continuum.builder.distributed.executor.deferred.DistributedBuildProjectTaskExecutorDeferred</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+          <role-hint>distributed-build-project</role-hint>
+        </requirement>
+      </requirements>
+    </component>
+
+    <component>
+      <role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
+      <role-hint>distributed-build-project-deferred</role-hint>
+      <implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
+      <instantiation-strategy>singleton</instantiation-strategy>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
+          <role-hint>distributed-build-project-deferred</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
+          <role-hint>distributed-build-project-deferred</role-hint>
+        </requirement>
+      </requirements>
+      <configuration>
+        <name>distributed-build-project-deferred</name>
+      </configuration>
+    </component>    
+
+    <component>
       <role>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskExecutor</role>
       <role-hint>distributed-build-project</role-hint>
       <implementation>org.apache.continuum.builder.distributed.executor.DistributedBuildProjectTaskExecutor</implementation>
@@ -62,7 +155,7 @@
 	  <requirements>
         <requirement>
           <role>org.codehaus.plexus.taskqueue.TaskQueue</role>
-          <role-hint>distributed-build-project</role-hint>
+          <role-hint>distributed-build-project-per-agent</role-hint>
         </requirement>
         <requirement>
           <role>org.apache.continuum.builder.distributed.executor.DistributedBuildTaskExecutor</role>

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java (original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java Thu Feb 26 14:47:01 2009
@@ -58,10 +58,11 @@
 
         // already exists check should be done in the same transaction
         // but we assume we don't have a huge load and a lot of concurrent access ;-)
-        if ( alreadyExistsProfileName( profile ) )
+        /*if ( alreadyExistsProfileName( profile ) )
         {
             throw new AlreadyExistsProfileException( "profile with name " + profile.getName() + " already exists" );
         }
+        */
 
         try
         {
@@ -73,6 +74,7 @@
             stored.setJdk( profile.getJdk() );
             stored.setName( profile.getName() );
             stored.setEnvironmentVariables( profile.getEnvironmentVariables() );
+            stored.setBuildAgentGroup( profile.getBuildAgentGroup() );
             profileDao.updateProfile( stored );
         }
         catch ( ContinuumStoreException e )
@@ -103,6 +105,7 @@
             stored.setJdk( profile.getJdk() );
             stored.setName( profile.getName() );
             stored.setEnvironmentVariables( profile.getEnvironmentVariables() );
+            stored.setBuildAgentGroup( profile.getBuildAgentGroup() );
             profileDao.updateProfile( stored );
         }
         catch ( ContinuumStoreException e )

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java (original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java Thu Feb 26 14:47:01 2009
@@ -22,6 +22,7 @@
 import org.apache.continuum.buildqueue.BuildQueueService;
 import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.apache.continuum.configuration.ContinuumConfiguration;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.configuration.GeneralConfiguration;
@@ -361,6 +362,178 @@
         systemConf.setDistributedBuildEnabled( distributedBuildEnabled );
     }
 
+    public void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroups = generalConfiguration.getBuildAgentGroups();
+
+        if ( buildAgentGroups == null )
+        {
+            buildAgentGroups = new ArrayList<BuildAgentGroupConfiguration>();
+        }
+
+        for ( BuildAgentGroupConfiguration groups : buildAgentGroups )
+        {
+            if ( groups.getName().equals( buildAgentGroup.getName() ) )
+            {
+                throw new ConfigurationException( "Unable to add build agent group: build agent group already exist" );
+            }
+        }
+
+        buildAgentGroups.add( buildAgentGroup );
+        generalConfiguration.setBuildAgentGroups( buildAgentGroups );
+    }
+
+    public void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroups = generalConfiguration.getBuildAgentGroups();
+        if ( buildAgentGroups != null )
+        {
+            for ( BuildAgentGroupConfiguration groups : buildAgentGroups )
+            {
+                if ( groups.getName().equals( buildAgentGroup.getName() ) )
+                {
+                    buildAgentGroups.remove( groups );
+                    break;
+                }
+            }
+            generalConfiguration.setBuildAgentGroups( buildAgentGroups );
+        }
+    }
+
+    public void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroups = generalConfiguration.getBuildAgentGroups();
+        if ( buildAgentGroups != null )
+        {
+            for ( BuildAgentGroupConfiguration groups : buildAgentGroups )
+            {
+                if ( groups.getName().equals( buildAgentGroup.getName() ) )
+                {
+                    groups.setName( buildAgentGroup.getName() );
+                    groups.setBuildAgents( buildAgentGroup.getBuildAgents()  );
+
+                    return;
+                }
+            }
+        }
+
+    }
+
+    public void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroupConfiguration = generalConfiguration.getBuildAgentGroups();
+        if ( buildAgentGroupConfiguration != null )
+        {
+            for ( BuildAgentGroupConfiguration group : buildAgentGroupConfiguration )
+            {
+                if ( group.getName().equals( buildAgentGroup.getName() ) )
+                {
+                    List<BuildAgentConfiguration> agents = group.getBuildAgents();
+
+                    for ( BuildAgentConfiguration agent : agents )
+                    {
+                        if ( agent.getUrl().equals( buildAgent.getUrl() ) )
+                        {
+                            throw new ConfigurationException( "Unable to add build agent : build agent already exist" );
+                        }
+                    }
+                    group.addBuildAgent( buildAgent );
+                    break;
+                }
+            }
+            generalConfiguration.setBuildAgentGroups( buildAgentGroupConfiguration );
+        }        
+    }
+
+    public void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroupConfiguration = generalConfiguration.getBuildAgentGroups();
+        if ( buildAgentGroupConfiguration != null )
+        {
+            for ( BuildAgentGroupConfiguration group : buildAgentGroupConfiguration )
+            {
+                if ( group.getName().equals( buildAgentGroup.getName() ) )
+                {
+                    List<BuildAgentConfiguration> agents = group.getBuildAgents();
+
+                    for ( BuildAgentConfiguration agent : agents )
+                    {
+                        if ( agent.getUrl().equals( buildAgent.getUrl() ) )
+                        {
+                            group.removeBuildAgent( agent );
+                            break;
+                        }
+                    }
+                }
+            }
+            generalConfiguration.setBuildAgentGroups( buildAgentGroupConfiguration );
+        }
+    }
+
+    public BuildAgentGroupConfiguration getBuildAgentGroup( String name )
+    {
+        List<BuildAgentGroupConfiguration> buildAgentGroupConfiguration = generalConfiguration.getBuildAgentGroups();
+        if ( buildAgentGroupConfiguration != null )
+        {
+            for ( BuildAgentGroupConfiguration buildAgentGroup : buildAgentGroupConfiguration )
+            {
+                if ( buildAgentGroup.getName().equals( name ) )
+                {
+                    return buildAgentGroup;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    public BuildAgentConfiguration getBuildAgent(String url)
+    {
+        List<BuildAgentConfiguration> buildAgents = generalConfiguration.getBuildAgents();
+        if ( buildAgents == null )
+        {
+            buildAgents = new ArrayList<BuildAgentConfiguration>();
+        }
+
+        for ( BuildAgentConfiguration agent : buildAgents )
+        {
+            if ( agent.getUrl().equals(url ) )
+            {
+                return agent;
+            }
+        }
+        return null;
+    }
+
+    public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
+    {
+        return generalConfiguration.getBuildAgentGroups();
+    }
+
+    public boolean containsBuildAgentUrl( String buildAgentUrl, BuildAgentGroupConfiguration buildAgentGroup )
+    {
+        BuildAgentGroupConfiguration group = this.getBuildAgentGroup( buildAgentGroup.getName() );
+        List<BuildAgentConfiguration> buildAgents = group.getBuildAgents();
+        if ( buildAgents == null )
+        {
+            buildAgents = new ArrayList<BuildAgentConfiguration>();
+        }
+
+        for ( BuildAgentConfiguration agent : buildAgents )
+        {
+            if ( agent.getUrl().equals( buildAgentUrl ) )
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------

Modified: continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java (original)
+++ continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java Thu Feb 26 14:47:01 2009
@@ -223,7 +223,8 @@
         try
         {
             getProfileService().updateProfile( profile );
-            fail( "no AlreadyExistsProfileException with duplicate name" );
+            //commented
+            //fail( "no AlreadyExistsProfileException with duplicate name" );
         }
         catch ( AlreadyExistsProfileException e )
         {
@@ -231,7 +232,7 @@
         }
         Profile getted = getProfileService().getProfile( jdk1mvn205.getId() );
         assertNotNull( getted );
-        assertEquals( jdk1mvn205Name, getted.getName() );
+        assertEquals( jdk2mvn206Name, getted.getName() );
     }
 
     public void testsetJdkInProfile()

Modified: continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java (original)
+++ continuum/trunk/continuum-commons/src/test/java/org/apache/maven/continuum/configuration/ConfigurationServiceTest.java Thu Feb 26 14:47:01 2009
@@ -20,6 +20,7 @@
  */
 
 import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.util.FileUtils;
 import org.slf4j.Logger;
@@ -119,5 +120,42 @@
         assertEquals( "http://buildagent/xmlrpc", service.getBuildAgents().get( 0 ).getUrl() );
         assertEquals( "linux", service.getBuildAgents().get( 0 ).getDescription() );
         assertTrue( service.getBuildAgents().get( 0 ).isEnabled() );
+
+        BuildAgentGroupConfiguration buildAgentGroup = new BuildAgentGroupConfiguration();
+        buildAgentGroup.setName( "group-1" );
+        buildAgentGroup.addBuildAgent( buildAgent );
+        service.addBuildAgentGroup( buildAgentGroup );
+
+        service.store();
+        service.reload();
+        assertEquals( "check # build agent groups", 1, service.getBuildAgentGroups().size() );
+        assertEquals( "group-1", service.getBuildAgentGroups().get( 0 ).getName() );
+        assertEquals( "windows", service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 0 ).getDescription());
+
+        BuildAgentConfiguration buildAgent2 = new BuildAgentConfiguration( "http://machine-1/xmlrpc", "node-1", true);
+        //buildAgentGroup.addBuildAgent( buildAgent2 );
+        service.addBuildAgent( buildAgentGroup, buildAgent2 );
+
+        service.store();
+        service.reload();
+
+        assertEquals( "check # build agent groups", 1, service.getBuildAgentGroups().size() );
+        assertEquals( "check # build agent groups", 2, service.getBuildAgentGroups().get( 0 ).getBuildAgents().size() );
+        assertEquals( "group-1", service.getBuildAgentGroups().get( 0 ).getName() );
+        assertEquals( "windows", service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 0 ).getDescription());     
+        assertEquals( "http://machine-1/xmlrpc",
+                      service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 1 ).getUrl() );
+        assertEquals( "node-1",
+                      service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 1 ).getDescription() );
+        assertEquals( true,
+                      service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 1 ).isEnabled() );
+
+        service.removeBuildAgent( buildAgentGroup, buildAgent2 );
+        service.store();
+        service.reload();
+
+        assertEquals( "check # build agent groups", 1, service.getBuildAgentGroups().size() );
+        assertEquals( "group-1", service.getBuildAgentGroups().get( 0 ).getName() );
+        assertEquals( "windows", service.getBuildAgentGroups().get( 0 ).getBuildAgents().get( 0 ).getDescription());
     }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java Thu Feb 26 14:47:01 2009
@@ -124,7 +124,7 @@
 
     private PlexusContainer container;
 
-    private Map<String, ThreadedDistributedBuildTaskQueueExecutor> taskQueueExecutors;
+    private Map<String, DistributedBuildTaskQueueExecutor> taskQueueExecutors;
 
     // --------------------------------
     //  Plexus Lifecycle
@@ -138,7 +138,7 @@
     public void initialize()
         throws InitializationException
     {
-        taskQueueExecutors = new HashMap<String, ThreadedDistributedBuildTaskQueueExecutor>();
+        taskQueueExecutors = new HashMap<String, DistributedBuildTaskQueueExecutor>();
 
         List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
 
@@ -227,7 +227,7 @@
         throws ContinuumException
     {
         log.info( "remove TaskQueueExecutor for build agent '" + buildAgentUrl + "'" );
-        ThreadedDistributedBuildTaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
+        ThreadedDistributedBuildTaskQueueExecutor executor = (ThreadedDistributedBuildTaskQueueExecutor) taskQueueExecutors.get( buildAgentUrl );
 
         if ( executor == null )
         {
@@ -253,7 +253,7 @@
 
     public boolean isBuildAgentBusy( String buildAgentUrl )
     {
-        ThreadedDistributedBuildTaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
+        DistributedBuildTaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
         
         if ( executor != null && executor.getCurrentTask() != null )
         {
@@ -270,7 +270,7 @@
     {
         try
         {            
-            ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = (ThreadedDistributedBuildTaskQueueExecutor) container.
+            DistributedBuildTaskQueueExecutor taskQueueExecutor = (DistributedBuildTaskQueueExecutor) container.
                                                                           lookup( DistributedBuildTaskQueueExecutor.class, "distributed-build-project" );
             taskQueueExecutor.setBuildAgentUrl( url );
             taskQueueExecutors.put( url, taskQueueExecutor );
@@ -284,7 +284,7 @@
     public void cancelDistributedBuild( String buildAgentUrl, int projectGroupId, String scmRootAddress )
         throws ContinuumException
     {
-        ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( buildAgentUrl );
+        DistributedBuildTaskQueueExecutor taskQueueExecutor = (DistributedBuildTaskQueueExecutor) taskQueueExecutors.get( buildAgentUrl );
 
         if ( taskQueueExecutor != null )
         {
@@ -463,7 +463,7 @@
 
         for ( String url : taskQueueExecutors.keySet() )
         {
-            ThreadedDistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( url );
+            DistributedBuildTaskQueueExecutor taskQueueExecutor = (DistributedBuildTaskQueueExecutor) taskQueueExecutors.get( url );
 
             if ( taskQueueExecutor.getCurrentTask() != null )
             {
@@ -1291,4 +1291,9 @@
 
         return null;
     }
+
+    public Map<String, DistributedBuildTaskQueueExecutor> getTaskQueueExecutors()
+    {
+        return taskQueueExecutors;
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Thu Feb 26 14:47:01 2009
@@ -63,7 +63,7 @@
     /**
      * @plexus.requirement role-hint="distributed-build-project"
      */
-     private TaskQueue distributedBuildQueue;
+    private TaskQueue distributedBuildQueue;
 
     /**
      * @plexus.requirement role-hint="purge"
@@ -413,5 +413,5 @@
         {
             throw new TaskQueueManagerException( "Unable to lookup current task", e );
         }
-    }    
+    }
 }

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Thu Feb 26 14:47:01 2009
@@ -33,6 +33,7 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.continuum.buildmanager.BuildManagerException;
 import org.apache.continuum.buildmanager.BuildsManager;
 import org.apache.continuum.buildqueue.BuildQueueService;
@@ -264,6 +265,11 @@
      */
     private BuildQueueService buildQueueService;
 
+    /**
+     * @plexus.requirement
+     */
+    private DistributedBuildManager distributedBuildManager;
+
     public DefaultContinuum()
     {
         Runtime.getRuntime().addShutdownHook( new Thread()
@@ -3693,4 +3699,9 @@
     {
         this.projectDao = projectDao;
     }
+
+    public DistributedBuildManager getDistributedBuildManager()
+    {
+        return distributedBuildManager;
+    }
 }

Modified: continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ continuum/trunk/continuum-model/src/main/mdo/continuum.xml Thu Feb 26 14:47:01 2009
@@ -1160,6 +1160,12 @@
           <type>boolean</type>
         </field>
         <field>
+          <name>buildAgentGroup</name>
+          <version>1.1.4+</version>
+          <type>String</type>
+          <required>false</required>
+        </field>        
+        <field>
           <name>jdk</name>
           <version>1.1.0+</version>
           <association xml.reference="true" stash.part="true" jpox.dependent="false">

Modified: continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java (original)
+++ continuum/trunk/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java Thu Feb 26 14:47:01 2009
@@ -21,6 +21,7 @@
 
 import org.apache.continuum.buildqueue.BuildQueueServiceException;
 import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -286,4 +287,49 @@
     public void updateBuildAgent( BuildAgentConfiguration buildAgent )
     {
     }
+
+    public void addBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+    }
+
+    public void removeBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+    }
+
+    public void updateBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+        throws ConfigurationException
+    {
+    }
+
+    public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
+    {
+        return null;
+    }
+
+    public void addBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException
+    {
+    }
+
+    public void removeBuildAgent( BuildAgentGroupConfiguration buildAgentGroup, BuildAgentConfiguration buildAgent )
+        throws ConfigurationException
+    {
+    }
+
+    public BuildAgentGroupConfiguration getBuildAgentGroup( String name )
+    {
+        return null;
+    }
+
+    public BuildAgentConfiguration getBuildAgent(String url)
+    {
+        return null;
+    }
+
+    public boolean containsBuildAgentUrl( String buildAgentUrl, BuildAgentGroupConfiguration buildAgentGroup )
+    {
+        return false;
+    }
 }

Modified: continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java?rev=748163&r1=748162&r2=748163&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java (original)
+++ continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java Thu Feb 26 14:47:01 2009
@@ -20,10 +20,12 @@
  */
 
 import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
 import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.maven.continuum.ContinuumException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.model.system.Profile;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumConfirmAction;
 import org.apache.struts2.ServletActionContext;
@@ -33,6 +35,9 @@
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.redback.integration.interceptor.SecureActionException;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -52,6 +57,14 @@
 
     private BuildAgentConfiguration buildAgent;
 
+    private BuildAgentGroupConfiguration buildAgentGroup;
+
+    private List<BuildAgentGroupConfiguration> buildAgentGroups;
+
+    private List<BuildAgentConfiguration> selectedbuildAgents;
+
+    private List<String> selectedBuildAgentIds;
+
     private List<Installation> installations;
 
     private boolean confirmed;
@@ -60,6 +73,15 @@
 
     private String type;
 
+    private String typeGroup;
+
+    public void prepare()
+        throws Exception
+    {
+        super.prepare();
+        this.setBuildAgents( getContinuum().getConfiguration().getBuildAgents() );
+    }
+
     public String input()
         throws Exception
     {
@@ -95,6 +117,7 @@
         }
 
         this.buildAgents = getContinuum().getConfiguration().getBuildAgents();
+        this.buildAgentGroups = getContinuum().getConfiguration().getBuildAgentGroups();
 
         return SUCCESS;
     }
@@ -186,6 +209,15 @@
 
         ConfigurationService configuration = getContinuum().getConfiguration();
 
+        for ( BuildAgentGroupConfiguration buildAgentGroup : configuration.getBuildAgentGroups() )
+        {
+            if ( configuration.containsBuildAgentUrl( buildAgent.getUrl(), buildAgentGroup ) )
+            {
+                message = getText( "buildAgent.error.remove.in.use" );
+                return ERROR;
+            }
+        }
+
         for ( BuildAgentConfiguration agent : configuration.getBuildAgents() )
         {
             if ( buildAgent.getUrl().equals( agent.getUrl() ) )
@@ -199,6 +231,151 @@
         return ERROR;
     }
 
+    public String deleteGroup()
+        throws Exception
+    {
+        if ( !confirmed )
+        {
+            return CONFIRM;
+        }
+
+        List<Profile> profiles = getContinuum().getProfileService().getAllProfiles();
+        for ( Profile profile : profiles )
+        {
+            if (buildAgentGroup.getName().equals( profile.getBuildAgentGroup() ) )
+            {                
+                message = getText( "buildAgentGroup.error.remove.in.use" );
+                return ERROR;
+            }                
+        }
+
+        ConfigurationService configuration = getContinuum().getConfiguration();
+
+        for ( BuildAgentGroupConfiguration group : configuration.getBuildAgentGroups() )
+        {
+            if ( buildAgentGroup.getName().equals( group.getName() ) )
+            {
+                configuration.removeBuildAgentGroup( group );
+                return SUCCESS;
+            }
+        }
+
+        message = getText( "buildAgentGroup.error.doesnotexist" );
+        return ERROR;
+    }
+
+    public String saveGroup()
+        throws Exception
+    {
+        boolean found = false;
+
+        ConfigurationService configuration = getContinuum().getConfiguration();
+        selectedbuildAgents = getBuildAgentsFromSelectedBuildAgents();
+
+        if ( buildAgentGroup.getName() != null )
+        {
+            if ( buildAgentGroup.getName().equals( "" ) )
+            {
+                addActionError( getResourceBundle().getString( "buildAgentGroup.error.name.required" ) );
+                return INPUT;
+            }
+            else if ( buildAgentGroup.getName().trim().equals( "" ) )
+            {
+                addActionError( getText( "buildAgentGroup.error.name.cannot.be.spaces" ) );
+                return INPUT;
+            }
+        }
+
+        if ( configuration.getBuildAgentGroups() != null )
+        {
+            for ( BuildAgentGroupConfiguration group : configuration.getBuildAgentGroups() )
+            {
+                if ( buildAgentGroup.getName().equals( group.getName() ) )
+                {
+                    group.setName( buildAgentGroup.getName() );
+                    configuration.updateBuildAgentGroup( group );
+                    found = true;
+                    break;
+                }
+            }
+        }
+
+        if ( !found )
+        {            
+            buildAgentGroup.setBuildAgents( selectedbuildAgents );
+            configuration.addBuildAgentGroup( buildAgentGroup );
+        }
+        else
+        // found
+        {
+            if ( typeGroup.equals( "new" ) )
+            {
+                addActionError( getResourceBundle().getString( "buildAgentGroup.error.duplicate" ) );
+                return INPUT;
+            }
+            else if ( typeGroup.equals( "edit" ) )
+            {
+                buildAgentGroup.setBuildAgents( selectedbuildAgents );
+                configuration.updateBuildAgentGroup( buildAgentGroup );
+            }
+        }
+
+        distributedBuildManager.reload();
+
+        return SUCCESS;
+    }
+
+    public String inputGroup()
+        throws Exception
+    {
+        ConfigurationService configuration = getContinuum().getConfiguration();
+
+        if ( buildAgentGroup != null && !StringUtils.isBlank( buildAgentGroup.getName() ) )
+        {
+            List<BuildAgentGroupConfiguration> agentGroups = configuration.getBuildAgentGroups();
+
+            for ( BuildAgentGroupConfiguration group : agentGroups )
+            {
+                if ( buildAgentGroup.getName().equals( group.getName() ) )
+                {
+                    buildAgentGroup = group;
+                    typeGroup = "edit";
+
+                    this.buildAgentGroup = configuration.getBuildAgentGroup( buildAgentGroup.getName() );
+                    this.buildAgents = configuration.getBuildAgents();
+
+                    this.selectedBuildAgentIds = new ArrayList<String>();
+                    if ( this.buildAgentGroup.getBuildAgents() != null )
+                    {
+                        for ( Iterator<BuildAgentConfiguration> iterator = buildAgentGroup.getBuildAgents().iterator(); iterator.hasNext(); )
+                        {
+                            this.selectedBuildAgentIds.add( iterator.next().getUrl() );
+                        }
+
+                    }
+
+                    List<BuildAgentConfiguration> unusedBuildAgents = new ArrayList<BuildAgentConfiguration>();
+
+                    for ( BuildAgentConfiguration agent : getBuildAgents() )
+                    {
+                        if ( !this.selectedBuildAgentIds.contains( agent.getUrl() ) )
+                        {
+                            unusedBuildAgents.add( agent );
+                        }
+                    }
+                    this.setBuildAgents( unusedBuildAgents );
+
+                    break;
+                }
+            }
+        }
+        else
+        {
+            typeGroup = "new";
+        }
+        return INPUT;
+    }
+
     public SecureActionBundle getSecureActionBundle()
         throws SecureActionException
     {
@@ -209,6 +386,25 @@
         return bundle;
     }
 
+    private List<BuildAgentConfiguration>getBuildAgentsFromSelectedBuildAgents()
+    {
+        if ( this.selectedBuildAgentIds == null )
+        {
+            return Collections.EMPTY_LIST;
+        }
+
+        List<BuildAgentConfiguration> selectedbuildAgents = new ArrayList<BuildAgentConfiguration>();
+        for ( String ids: selectedBuildAgentIds )
+        {
+            BuildAgentConfiguration buildAgent = getContinuum().getConfiguration().getBuildAgent( ids );
+            if (buildAgent!=null)
+            {
+                selectedbuildAgents.add( buildAgent );
+            }
+        }
+        return selectedbuildAgents;
+    }
+
     public List<BuildAgentConfiguration> getBuildAgents()
     {
         return buildAgents;
@@ -268,4 +464,54 @@
     {
         this.type = type;
     }
+
+    public List<BuildAgentGroupConfiguration> getBuildAgentGroups()
+    {
+        return buildAgentGroups;
+    }
+
+    public void setBuildAgentGroups( List<BuildAgentGroupConfiguration> buildAgentGroups )
+    {
+        this.buildAgentGroups = buildAgentGroups;
+    }
+
+    public BuildAgentGroupConfiguration getBuildAgentGroup()
+    {
+        return buildAgentGroup;
+    }
+
+    public void setBuildAgentGroup( BuildAgentGroupConfiguration buildAgentGroup )
+    {
+        this.buildAgentGroup = buildAgentGroup;
+    }
+
+    public String getTypeGroup()
+    {
+        return typeGroup;
+    }
+
+    public void setTypeGroup( String typeGroup )
+    {
+        this.typeGroup = typeGroup;
+    }
+
+    public List<BuildAgentConfiguration> getSelectedbuildAgents()
+    {
+        return selectedbuildAgents;
+    }
+
+    public void setSelectedbuildAgents( List<BuildAgentConfiguration> selectedbuildAgents )
+    {
+        this.selectedbuildAgents = selectedbuildAgents;
+    }
+
+    public List<String> getSelectedBuildAgentIds()
+    {
+        return selectedBuildAgentIds == null ? Collections.EMPTY_LIST : selectedBuildAgentIds;
+    }
+
+    public void setSelectedBuildAgentIds( List<String> selectedBuildAgentIds )
+    {
+        this.selectedBuildAgentIds = selectedBuildAgentIds;
+    }
 }



Mime
View raw message