continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r727244 - in /continuum/branches/continuum-parallel-builds: continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-api/src/main/java/org/apache/continuum/taskqueue/ continuum-core/src/main/java/org/apache/continuum/buildma...
Date Wed, 17 Dec 2008 02:06:45 GMT
Author: oching
Date: Tue Dec 16 18:06:44 2008
New Revision: 727244

URL: http://svn.apache.org/viewvc?rev=727244&view=rev
Log:
additional fixes

Modified:
    continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
    continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
    continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
    continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp

Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.java
Tue Dec 16 18:06:44 2008
@@ -23,8 +23,8 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.continuum.taskqueue.OverallBuildQueue;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Project;
 import org.codehaus.plexus.taskqueue.Task;
 
@@ -207,9 +207,10 @@
     /**
      * Add an overall build queue.
      * 
-     * @param overallBuildQueue
+     * @param buildQueue
+     * @throws BuildManagerException TODO
      */
-    void addOverallBuildQueue( OverallBuildQueue overallBuildQueue );
+    void addOverallBuildQueue( BuildQueue buildQueue ) throws BuildManagerException;
 
     /**
      * Remove an overall build queue.

Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/OverallBuildQueue.java
Tue Dec 16 18:06:44 2008
@@ -21,8 +21,6 @@
 
 import java.util.List;
 
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
@@ -186,19 +184,15 @@
      * Cancel the build task of the corresponding project.
      * 
      * @param projectId
-     * @throws ComponentLookupException TODO
      */
-    void cancelBuildTask( int projectId )
-        throws ComponentLookupException;
+    void cancelBuildTask( int projectId );
 
     /**
      * Cancel the current build.
      * 
      * @return
-     * @throws ComponentLookupException TODO
      */
-    boolean cancelCurrentBuild()
-        throws ComponentLookupException;
+    boolean cancelCurrentBuild();
 
     /**
      * Remove the project matching the specified id, name, build definition and trigger from
the build queue.

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Tue Dec 16 18:06:44 2008
@@ -50,7 +50,6 @@
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
-import org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,7 +60,7 @@
  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  * @plexus.component role="org.apache.continuum.buildmanager.BuildsManager" role-hint="parallel"
  */
-public class ParallelBuildsManager
+public class ParallelBuildsManager    
     implements BuildsManager, Contextualizable
 {
     private Logger log = LoggerFactory.getLogger( ParallelBuildsManager.class );
@@ -213,23 +212,15 @@
     {
         synchronized ( overallBuildQueues )
         {
-            OverallBuildQueue overallBuildQueue = null;
-            try
+            OverallBuildQueue overallBuildQueue = null;            
+            overallBuildQueue = overallBuildQueues.get( buildQueueId );
+            if ( overallBuildQueue != null )
             {
-                overallBuildQueue = overallBuildQueues.get( buildQueueId );
-                if ( overallBuildQueue != null )
-                {
-                    overallBuildQueue.cancelCurrentBuild();
-                }
-                else
-                {
-                    log.warn( "Project not found in any of the build queues." );
-                }
+                overallBuildQueue.cancelCurrentBuild();
             }
-            catch ( ComponentLookupException e )
+            else
             {
-                log.error( e.getMessage() );
-                throw new BuildManagerException( e.getMessage() );
+                log.warn( "Project not found in any of the build queues." );
             }
 
             return true;
@@ -243,19 +234,10 @@
         {
             Set<Integer> keySet = overallBuildQueues.keySet();
             OverallBuildQueue overallBuildQueue = null;
-
-            try
-            {
-                for ( Integer key : keySet )
-                {
-                    overallBuildQueue = overallBuildQueues.get( key );
-                    overallBuildQueue.cancelCurrentBuild();
-                }
-            }
-            catch ( ComponentLookupException e )
+            for ( Integer key : keySet )
             {
-                log.error( e.getMessage() );
-                throw new BuildManagerException( e.getMessage() );
+                overallBuildQueue = overallBuildQueues.get( key );
+                overallBuildQueue.cancelCurrentBuild();
             }
 
             return true;
@@ -289,11 +271,7 @@
         {
             throw new BuildManagerException( "Error occurred while cancelling build: " +
e.getMessage() );
         }
-        catch ( ComponentLookupException e )
-        {
-            throw new BuildManagerException( e.getMessage() );
-        }
-
+        
         return true;
     }
 
@@ -623,17 +601,30 @@
         }
     }
     
-    public void addOverallBuildQueue( OverallBuildQueue overallBuildQueue )
-    {   
+    public void addOverallBuildQueue( BuildQueue buildQueue )
+        throws BuildManagerException
+    {
         synchronized ( overallBuildQueues )
         {
-            if ( overallBuildQueues.get( overallBuildQueue.getId() ) == null )
+            try
             {
-                this.overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue
);
+                OverallBuildQueue overallBuildQueue = (OverallBuildQueue) container.lookup(
OverallBuildQueue.class );
+                overallBuildQueue.setId( buildQueue.getId() );
+                overallBuildQueue.setName( buildQueue.getName() );
+                
+                if ( overallBuildQueues.get( buildQueue.getId() ) == null )
+                {
+                    log.info( "Adding overall build queue to map : " + overallBuildQueue.getName()
);
+                    overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue
);
+                }
+                else
+                {
+                    log.warn( "Overall build queue already in the map." );
+                }
             }
-            else
-            {
-                log.warn( "Overall build queue already in the map" );
+            catch ( ComponentLookupException e )
+            {                
+                throw new BuildManagerException( "Error creating overall build queue.", e
);
             }
         }
     }
@@ -733,24 +724,6 @@
             
             return currentBuilds;
         }
-        /*try
-        {
-            List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
-            for ( Object obj : objects )
-            {
-                log.info( "Task queue executor : " + obj );
-                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
-                Task task = executor.getCurrentTask();
-                if ( task instanceof BuildProjectTask )
-                {
-                    currentBuilds.add( task );
-                }
-            }
-        }
-        catch ( ComponentLookupException e )
-        {
-            throw new BuildManagerException( e.getMessage() );
-        }*/
     }
 
     public List<Task> getCurrentCheckouts()
@@ -936,9 +909,10 @@
             int size = 0;
             int idx = 0;
             try
-            {
+            {   
                 for ( BuildQueue buildQueue : buildQueues )
                 {
+                    log.info( "BUILD QUEUE : " + buildQueue.getId() + " : " + buildQueue.getName()
);                    
                     OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId()
);
                     if ( overallBuildQueue != null )
                     {
@@ -951,6 +925,8 @@
                         {
                             taskQueue = overallBuildQueue.getCheckoutQueue();
                         }
+                        
+                        log.info( "SIZE OF TASK QUEUE :: " + taskQueue.getQueueSnapshot().size()
);
 
                         if ( idx == 0 )
                         {
@@ -979,9 +955,19 @@
         }
 
         if ( whereToBeQueued == null )
-        {
-            // TODO queue in the default overall build queue
-            throw new BuildManagerException( "No build queue found." );
+        {     
+            Set<Integer> keySet = overallBuildQueues.keySet();
+            for( Integer key : keySet )
+            {
+                OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                log.info( "OVERALLBUILD QUEUE :: " + overallBuildQueue.getId() + " : "
+                          + overallBuildQueue.getName() );
+                if( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME
) )
+                {
+                    return overallBuildQueue;
+                }
+            }            
+            //throw new BuildManagerException( "No build queue found." );
         }
 
         return whereToBeQueued;

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/DefaultOverallBuildQueue.java
Tue Dec 16 18:06:44 2008
@@ -29,8 +29,6 @@
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.scm.queue.CheckOutTask;
 import org.apache.maven.continuum.store.ContinuumStoreException;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
@@ -45,7 +43,7 @@
  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  * @plexus.component role="org.apache.continuum.taskqueue.OverallBuildQueue" instantiation-strategy="per-lookup"
  */
-public class DefaultOverallBuildQueue
+public class DefaultOverallBuildQueue   
     implements OverallBuildQueue
 {
     /**
@@ -68,7 +66,7 @@
     private String name;
     
     private Logger log = LoggerFactory.getLogger( DefaultOverallBuildQueue.class );
-
+    
     public int getId()
     {
         return id;
@@ -281,7 +279,6 @@
      * @see OverallBuildQueue#cancelBuildTask(int)
      */
     public void cancelBuildTask( int projectId )
-        throws ComponentLookupException
     {
         BuildProjectTask task = (BuildProjectTask) buildTaskQueueExecutor.getCurrentTask();
         if( task != null && task.getProjectId() == projectId )
@@ -296,7 +293,6 @@
      * @see OverallBuildQueue#cancelCurrentBuild()
      */
     public boolean cancelCurrentBuild()
-        throws ComponentLookupException
     {
         Task task = buildTaskQueueExecutor.getCurrentTask();
         if( task != null )

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
Tue Dec 16 18:06:44 2008
@@ -108,14 +108,15 @@
     }
 
     private void setupOverallBuildQueues()
-    {
+        throws Exception
+    {   
         for ( int i = 2; i <= 5; i++ )
         {
-            OverallBuildQueue overallBuildQueue = (OverallBuildQueue) lookup( OverallBuildQueue.class
);
-            overallBuildQueue.setId( i );
-            overallBuildQueue.setName( "BUILD_QUEUE_" + String.valueOf( i ) );
-
-            buildsManager.addOverallBuildQueue( overallBuildQueue );
+            BuildQueue buildQueue = new BuildQueue();
+            buildQueue.setId( i );
+            buildQueue.setName( "BUILD_QUEUE_" + String.valueOf( i ) );
+                        
+            buildsManager.addOverallBuildQueue( buildQueue );
         }
 
         assertEquals( 5, buildsManager.getOverallBuildQueues().size() );
@@ -553,11 +554,11 @@
     public void testNoBuildQueuesConfigured()
         throws Exception
     {
-        OverallBuildQueue overallBuildQueue = (OverallBuildQueue) lookup( OverallBuildQueue.class
);
-        overallBuildQueue.setId( 1 );
-        overallBuildQueue.setName( "BUILD_QUEUE_1" );
+        BuildQueue buildQueue = new BuildQueue();
+        buildQueue.setId( 1 );
+        buildQueue.setName( "BUILD_QUEUE_1" );
 
-        buildsManager.addOverallBuildQueue( overallBuildQueue );
+        buildsManager.addOverallBuildQueue( buildQueue );
 
         BuildDefinition buildDef = new BuildDefinition();
         buildDef.setId( 1 );

Modified: continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildQueueAction.java
Tue Dec 16 18:06:44 2008
@@ -1,18 +1,5 @@
 package org.apache.maven.continuum.web.action.admin;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.continuum.dao.BuildQueueDao;
-import org.apache.continuum.taskqueue.DefaultOverallBuildQueue;
-import org.apache.continuum.taskqueue.OverallBuildQueue;
-import org.apache.maven.continuum.model.project.BuildQueue;
-import org.apache.maven.continuum.model.system.Installation;
-import org.apache.maven.continuum.store.ContinuumStoreException;
-
-import com.opensymphony.xwork2.Preparable;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -32,6 +19,15 @@
  * under the License.
  */
 
+import java.util.List;
+
+import org.apache.continuum.buildmanager.BuildManagerException;
+import org.apache.continuum.dao.BuildQueueDao;
+import org.apache.maven.continuum.model.project.BuildQueue;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+import com.opensymphony.xwork2.Preparable;
+
 /**
  *
  * @plexus.component role="com.opensymphony.xwork2.Action" role-hint="buildQueueAction"
@@ -39,7 +35,10 @@
 public class BuildQueueAction 
     extends AbstractBuildQueueAction
     implements Preparable
-{
+{    
+    //TODO:
+    // - move all access to buildQueueDao to Continuum class
+    
 	private String name;
 	
 	private int size;
@@ -55,8 +54,8 @@
 
     public void prepare()
         throws ContinuumStoreException
-    {
-	    this.buildQueueList = buildQueueDao.getAllBuildQueues();
+    {   
+        this.buildQueueList = buildQueueDao.getAllBuildQueues();        
     }
     
     public String input()
@@ -67,47 +66,90 @@
     public String list()
         throws Exception
     {
-        this.buildQueueList = buildQueueDao.getAllBuildQueues();
+        try
+        {
+            this.buildQueueList = buildQueueDao.getAllBuildQueues();
+        }
+        catch ( ContinuumStoreException e )
+        {
+            addActionError( "Cannot get build queues from the database : " + e.getMessage()
);
+            return ERROR;
+        }
         return SUCCESS;
     }
     
     public String save()
         throws Exception
-    {
-    	
+    {    	
     	int allowedBuilds = getContinuum().getConfiguration().getNumberOfBuildsInParallel();
-    	if ( allowedBuilds <= this.buildQueueList.size() )
+    	if ( allowedBuilds < this.buildQueueList.size() )
     	{
-    		addActionError(" You are only allowed " + allowedBuilds );
+    		addActionError( "You are only allowed " + allowedBuilds + " number of builds in parallel."
);
     		return ERROR;
     	}
     	else
     	{
-    		BuildQueue buildQueue = new BuildQueue();	
-        	buildQueue.setId( buildQueueList.size() + 1 );
-        	buildQueue.setName( name );
-        	buildQueueDao.addBuildQueue( buildQueue );
-        	
+    	    try
+    	    {
+        		BuildQueue buildQueue = new BuildQueue();
+            	buildQueue.setName( name );
+            	BuildQueue addedBuildQueue = buildQueueDao.addBuildQueue( buildQueue );
+            	
+            	getContinuum().getBuildsManager().addOverallBuildQueue( addedBuildQueue ); 
          	
+    	    }
+    	    catch ( ContinuumStoreException e )
+    	    {   
+    	        addActionError( "Error adding build queue to database: " + e.getMessage() );
+    	        return ERROR;
+    	    }
+    	    catch ( BuildManagerException e )
+    	    {
+    	        addActionError( "Error creating overall build queue: " + e.getMessage() );
+                return ERROR;
+    	    }
+    	    
         	return SUCCESS;
-    	}
-    	
+    	}    	
     }
     
     public String edit()
         throws Exception
     {
-        BuildQueue buildQueueToBeEdited = buildQueueDao.getBuildQueue( this.buildQueue.getId()
);
+        try
+        {
+            BuildQueue buildQueueToBeEdited = buildQueueDao.getBuildQueue( this.buildQueue.getId()
);
+        }
+        catch ( ContinuumStoreException e )
+        {
+            addActionError( "Error retrieving build queue from the database : " + e.getMessage()
);
+            return ERROR;
+        }
         return SUCCESS;
     }
     
     public String delete()
         throws Exception
     {
-    	BuildQueue buildQueueToBeDeleted = buildQueueDao.getBuildQueue( this.buildQueue.getId()
);
-    	buildQueueDao.removeBuildQueue( buildQueueToBeDeleted );
-
-    	this.buildQueueList = buildQueueDao.getAllBuildQueues();
-    	
+        try
+        {
+        	BuildQueue buildQueueToBeDeleted = buildQueueDao.getBuildQueue( this.buildQueue.getId()
);
+        	buildQueueDao.removeBuildQueue( buildQueueToBeDeleted );
+        	
+        	getContinuum().getBuildsManager().removeOverallBuildQueue( buildQueueToBeDeleted.getId()
);
+        	
+        	this.buildQueueList = buildQueueDao.getAllBuildQueues();    	
+        }
+        catch ( BuildManagerException e )
+        {
+            addActionError( "Cannot delete overall build queue: " + e.getMessage() );
+            return ERROR;
+        }
+        catch ( ContinuumStoreException e )
+        {
+            addActionError( "Cannot delete build queue from the database: " + e.getMessage()
);
+            return ERROR;
+        }
+        
         return SUCCESS;
     }
 

Modified: continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp?rev=727244&r1=727243&r2=727244&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/editParallelBuilds.jsp
Tue Dec 16 18:06:44 2008
@@ -34,7 +34,13 @@
   <div id="axial" class="h3">
     <h3><s:text name="parallel.build.queue.section.title"/></h3>
 
-    <s:actionerror />
+    <c:if test="${!empty actionErrors}">
+      <div class="errormessage">
+        <s:iterator value="actionErrors">
+          <p><s:text name="<s:property/>" /></p>
+        </s:iterator>
+      </div>
+    </c:if>
     
     <div class="axial">
       <s:form action="saveBuildQueue" method="post" validate="true">



Mime
View raw message