continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r724658 - in /continuum/branches/continuum-distributed-builds: continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/ continuum-api/src/main/java/org/apache/maven/continuum/ continuum-builder/ continuum-builder/src/ma...
Date Tue, 09 Dec 2008 10:36:00 GMT
Author: ctan
Date: Tue Dec  9 02:35:57 2008
New Revision: 724658

URL: http://svn.apache.org/viewvc?rev=724658&view=rev
Log:
- refactored distributed build manager
- fix add build agent


Modified:
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/resources/META-INF/spring-context.xml
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/DistributedBuildManager.java
Tue Dec  9 02:35:57 2008
@@ -4,10 +4,14 @@
 import java.util.Map;
 
 import org.apache.continuum.builder.distributed.BuildAgentListener;
+import org.apache.continuum.scm.queue.PrepareBuildProjectsTask;
 import org.apache.maven.continuum.ContinuumException;
 
 public interface DistributedBuildManager
 {
+    void buildProjectsInQueue()
+        throws ContinuumException;
+    
     void updateProjectScmRoot( Map context )
         throws ContinuumException;
 
@@ -16,6 +20,8 @@
 
     List<BuildAgentListener> getBuildAgentListeners();
 
+    List<PrepareBuildProjectsTask> getDistributedBuildQueue();
+
     void reload()
         throws ContinuumException;
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
Tue Dec  9 02:35:57 2008
@@ -649,5 +649,4 @@
     
     String getReleaseOutput( int releaseResultId )
         throws ContinuumException;
-
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/pom.xml Tue Dec  9 02:35:57
2008
@@ -67,4 +67,26 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>merge</id>
+            <goals>
+              <goal>merge-descriptors</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Tue Dec  9 02:35:57 2008
@@ -70,46 +70,24 @@
      */
     private BuildResultDao buildResultDao;
 
-    private List<PrepareBuildProjectsTask> projectsBuildInQueue;
+    private List<PrepareBuildProjectsTask> distributedBuildQueue;
     
     private List<BuildAgentListener> listeners;
 
     public void initialize()
         throws ContinuumException
     {
-        List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
-
         if ( listeners == null )
         {
             listeners = new ArrayList<BuildAgentListener>();
         }
-        
-        if ( agents != null )
-        {
-            for ( BuildAgentConfiguration agent : agents )
-            {
-                boolean found = false;
 
-                for ( BuildAgentListener listener : listeners )
-                {
-                    if ( listener.getUrl().equals( agent.getUrl() ) )
-                    {
-                        found = true;
-                        listener.setEnabled( agent.isEnabled() );
-                        break;
-                    }
-                }
-
-                if ( !found )
-                {
-                    BuildAgentListener listener = new DefaultBuildAgentListener( agent.getUrl(),
false, agent.isEnabled() );
-                    listeners.add( listener );
-                    log.info( "add listener for build agent '" + agent.getUrl() + "'" );
-                }
-            }
+        if ( distributedBuildQueue == null )
+        {
+            distributedBuildQueue = new ArrayList<PrepareBuildProjectsTask>();
         }
 
-        buildProjectsInQueue();
+        loadData();
     }
 
     public ConfigurationService getConfigurationService()
@@ -162,28 +140,22 @@
         this.projectScmRootDao = projectScmRootDao;
     }
 
-    public void buildProjects( Map<Integer, Integer> projectsAndBuildDefinitionsMap,
int trigger )
-        throws ContinuumException
-    {
-        buildProjects( projectsAndBuildDefinitionsMap, trigger, false );
-    }
-
     public void buildProjectsInQueue()
         throws ContinuumException
     {
-        if ( projectsBuildInQueue != null )
+        if ( distributedBuildQueue != null )
         {
-            for ( PrepareBuildProjectsTask task : projectsBuildInQueue )
+            for ( PrepareBuildProjectsTask task : distributedBuildQueue )
             {
                 Map projectsAndBuildDefinitions = task.getProjectsBuildDefinitionsMap();
                 int trigger = task.getTrigger();
                 
-                buildProjects( projectsAndBuildDefinitions, trigger, true );
+                buildProjects( projectsAndBuildDefinitions, trigger );
             }
         }
     }
 
-    public synchronized void buildProjects( Map<Integer, Integer> projectsAndBuildDefinitionsMap,
int trigger, boolean inBuildQueue )
+    public synchronized void buildProjects( Map<Integer, Integer> projectsAndBuildDefinitionsMap,
int trigger )
         throws ContinuumException
     {
         boolean found = false;
@@ -228,19 +200,6 @@
                 found = true;
             }
         }
-
-        if ( !found && !inBuildQueue )
-        {
-            // all build agents are busy, put into projectBuildQueue for now
-            if ( projectsBuildInQueue == null )
-            {
-                projectsBuildInQueue = new ArrayList<PrepareBuildProjectsTask>();
-            }
-
-            log.info( "no build agent available, put in queue" );
-            PrepareBuildProjectsTask prepareBuildTask = new PrepareBuildProjectsTask( projectsAndBuildDefinitionsMap,
trigger );
-            projectsBuildInQueue.add( prepareBuildTask );
-        }
     }
 
     public void updateProjectScmRoot( Map context )
@@ -370,7 +329,18 @@
     public void reload()
         throws ContinuumException
     {
-        this.initialize();
+        loadData();
+        buildProjectsInQueue();
+    }
+
+    public List<BuildAgentListener> getBuildAgentListeners()
+    {
+        return listeners;
+    }
+
+    public List<PrepareBuildProjectsTask> getDistributedBuildQueue()
+    {
+        return distributedBuildQueue;
     }
 
     private List initializeBuildContext( Map<Integer, Integer> projectsAndBuildDefinitions,

@@ -596,8 +566,33 @@
         }
     }
 
-    public List<BuildAgentListener> getBuildAgentListeners()
+    private void loadData()
     {
-        return listeners;
+        List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
+
+        if ( agents != null )
+        {
+            for ( BuildAgentConfiguration agent : agents )
+            {
+                boolean found = false;
+
+                for ( BuildAgentListener listener : listeners )
+                {
+                    if ( listener.getUrl().equals( agent.getUrl() ) )
+                    {
+                        found = true;
+                        listener.setEnabled( agent.isEnabled() );
+                        break;
+                    }
+                }
+
+                if ( !found )
+                {
+                    BuildAgentListener listener = new DefaultBuildAgentListener( agent.getUrl(),
false, agent.isEnabled() );
+                    listeners.add( listener );
+                    log.info( "add listener for build agent '" + agent.getUrl() + "'" );
+                }
+            }
+        }
     }
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/resources/META-INF/spring-context.xml?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/resources/META-INF/spring-context.xml
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/resources/META-INF/spring-context.xml
Tue Dec  9 02:35:57 2008
@@ -33,13 +33,4 @@
     </property>
   </bean>
 
-  <bean name="continuumBuilder#distributedBuild"
-        class="org.apache.continuum.builder.distributed.manager.DefaultDistributedBuildManager"
-        init-method="initialize">
-    <property name="configurationService" ref="configurationService"/>
-    <property name="projectDao" ref="projectDao"/>
-    <property name="buildDefinitionDao" ref="buildDefinitionDao"/>
-    <property name="buildResultDao" ref="buildResultDao"/>
-    <property name="projectScmRootDao" ref="projectScmRootDao"/>
-  </bean>
 </beans>

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/continuum/web/action/admin/BuildAgentAction.java
Tue Dec  9 02:35:57 2008
@@ -115,6 +115,8 @@
     public String save()
         throws Exception
     {
+        boolean found = false;
+
         ConfigurationService configuration = getContinuum().getConfiguration();
 
         if ( configuration.getBuildAgents() != null )
@@ -127,14 +129,16 @@
                     agent.setEnabled( buildAgent.isEnabled() );
 
                     configuration.updateBuildAgent( agent );
-                }
-                else
-                {
-                    configuration.addBuildAgent( buildAgent );
+                    found = true;
                 }
             }
         }
 
+        if ( !found )
+        {
+            configuration.addBuildAgent( buildAgent );
+        }
+
         distributedBuildManager.reload();
 
         return SUCCESS;

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java?rev=724658&r1=724657&r2=724658&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
Tue Dec  9 02:35:57 2008
@@ -19,9 +19,12 @@
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.lang.ArrayUtils;
+import org.apache.continuum.builder.distributed.BuildAgentListener;
+import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.model.project.Project;
@@ -29,6 +32,7 @@
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.exception.AuthenticationRequiredException;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
+import org.apache.maven.continuum.web.model.DistributedBuildSummary;
 import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.redback.rbac.Resource;
 import org.codehaus.plexus.taskqueue.Task;
@@ -47,7 +51,8 @@
     extends AbstractBuildQueueAction
     implements SecureAction, LogEnabled
 {
-    
+    private static final String DISTRIBUTED_BUILD_SUCCESS = "distributed-build-success";
+
     /**
      * @plexus.requirement role-hint='build-project'
      */
@@ -83,6 +88,15 @@
      */
     private TaskQueueManager taskQueueManager;
 
+    /**
+     * @plexus.requirement
+     */
+    DistributedBuildManager distributedBuildManager;
+
+    private List<DistributedBuildSummary> distributedBuildSummary;
+
+    private String buildAgentUrl;
+
     // -----------------------------------------------------
     //  webwork
     // -----------------------------------------------------     
@@ -155,11 +169,36 @@
     public String display()
         throws Exception
     {
-        this.setCurrentBuildProjectTask( (BuildProjectTask) taskQueueExecutor.getCurrentTask()
);        
-        this.setBuildProjectTasks( taskQueueManager.getProjectsInBuildQueue() );
-        this.setCurrentCheckOutTask( (CheckOutTask) checkoutTaskQueueExecutor.getCurrentTask()
);
-        this.setCurrentCheckOutTasks( taskQueueManager.getCheckOutTasksInQueue() );
-        return SUCCESS;
+        if ( getContinuum().getConfiguration().isDistributedBuildEnabled() )
+        {
+            distributedBuildSummary = new ArrayList<DistributedBuildSummary>();
+            
+            for ( BuildAgentListener listener : distributedBuildManager.getBuildAgentListeners()
)
+            {
+                if ( listener.hasProjects() )
+                {
+                    for ( Project project : listener.getProjects() )
+                    {
+                        DistributedBuildSummary summary = new DistributedBuildSummary();
+                        summary.setProjectId( project.getId() );
+                        summary.setProjectName( project.getName() );
+                        summary.setUrl( listener.getUrl() );
+                        
+                        distributedBuildSummary.add( summary );
+                    }
+                }
+            }
+
+            return DISTRIBUTED_BUILD_SUCCESS;
+        }
+        else
+        {
+            this.setCurrentBuildProjectTask( (BuildProjectTask) taskQueueExecutor.getCurrentTask()
);        
+            this.setBuildProjectTasks( taskQueueManager.getProjectsInBuildQueue() );
+            this.setCurrentCheckOutTask( (CheckOutTask) checkoutTaskQueueExecutor.getCurrentTask()
);
+            this.setCurrentCheckOutTasks( taskQueueManager.getCheckOutTasksInQueue() );
+            return SUCCESS;
+        }
     }
 
     public String remove()



Mime
View raw message