continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r726931 - in /continuum/branches/continuum-parallel-builds: continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ continuum-commons/src/main/java/org/apache/maven/continuum/configuration/ continuum-core/sr...
Date Tue, 16 Dec 2008 03:03:12 GMT
Author: oching
Date: Mon Dec 15 19:03:11 2008
New Revision: 726931

URL: http://svn.apache.org/viewvc?rev=726931&view=rev
Log:
o updated some of the implementation of parallel builds manager & overall build queue
o fixed number of builds in parallel not being saved in configuration

Modified:
    continuum/branches/continuum-parallel-builds/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.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-model/src/main/mdo/continuum.xml
    continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java
    continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/resources/localization/Continuum.properties

Modified: continuum/branches/continuum-parallel-builds/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
Mon Dec 15 19:03:11 2008
@@ -155,8 +155,6 @@
                     .getReleaseOutputDirectory() ) );
             }
             
-            
-            
         }
         catch ( IOException e )
         {
@@ -178,15 +176,15 @@
         {
             ContinuumConfigurationModel configurationModel = new ContinuumConfigurationModel();
             configurationModel.setBaseUrl( this.generalConfiguration.getBaseUrl() );
-
-            
+            configurationModel.setNumberOfBuildsInParallel( this.generalConfiguration.getNumberOfBuildsInParallel()
);
+                        
             // normally not null but NPE free is better !
             if ( this.generalConfiguration.getBuildOutputDirectory() != null )
             {
                 configurationModel.setBuildOutputDirectory( this.generalConfiguration.getBuildOutputDirectory()
-                    .getPath() );
-                configurationModel.setNumberOfBuildsInParallel( this.generalConfiguration.getNumberOfBuildsInParallel()
);
+                    .getPath() );                
             }
+                        
             if ( this.generalConfiguration.getWorkingDirectory() != null )
             {
                 configurationModel.setWorkingDirectory( this.generalConfiguration.getWorkingDirectory().getPath()
);
@@ -219,8 +217,6 @@
                 configurationModel.setReleaseOutputDirectory( this.generalConfiguration.getReleaseOutputDirectory()
                     .getPath() );
             }
-
-            
             
             ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );

Modified: continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
Mon Dec 15 19:03:11 2008
@@ -46,7 +46,7 @@
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    // when adding requirement the template in spring-context.xml must be updated CONTINUUM-1207
+    // when adding a requirement, the template in spring-context.xml must be updated CONTINUUM-1207
 
     /**
      * @plexus.configuration default-value="${plexus.home}"

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=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Mon Dec 15 19:03:11 2008
@@ -428,27 +428,20 @@
     public boolean isProjectInAnyCurrentBuild( int projectId )
         throws BuildManagerException
     {
-        try
+        synchronized( overallBuildQueues )
         {
-            List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
-            for ( Object obj : objects )
+            Set<Integer> keys = overallBuildQueues.keySet();
+            for( Integer key : keys )
             {
-                log.info( "Task queue executor : " + obj );
-                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
-                Task task = executor.getCurrentTask();
-                if ( task instanceof BuildProjectTask )
+                OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                BuildProjectTask task = (BuildProjectTask) overallBuildQueue.getBuildTaskQueueExecutor().getCurrentTask();
+                if( task != null && task.getProjectId() == projectId )
                 {
-                    log.info( "current task is a BuildProjectTask." );
                     return true;
                 }
             }
+            return false;
         }
-        catch ( ComponentLookupException e )
-        {
-            throw new BuildManagerException( e.getMessage() );
-        }
-
-        return false;
     }
 
     public void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap,
int trigger )
@@ -727,8 +720,23 @@
     public List<Task> getCurrentBuilds()
         throws BuildManagerException
     {
-        List<Task> currentBuilds = new ArrayList<Task>();
-        try
+        synchronized( overallBuildQueues )
+        {
+            List<Task> currentBuilds = new ArrayList<Task>();           
+            Set<Integer> keys = overallBuildQueues.keySet();
+            for( Integer key : keys )
+            {
+                OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                Task task = overallBuildQueue.getBuildTaskQueueExecutor().getCurrentTask();
+                if( task != null )
+                {
+                    currentBuilds.add( task );
+                }
+            }
+            
+            return currentBuilds;
+        }
+        /*try
         {
             List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
             for ( Object obj : objects )
@@ -745,34 +753,28 @@
         catch ( ComponentLookupException e )
         {
             throw new BuildManagerException( e.getMessage() );
-        }
-
-        return currentBuilds;
+        }*/
     }
 
     public List<Task> getCurrentCheckouts()
         throws BuildManagerException
     {
-        List<Task> currentCheckouts = new ArrayList<Task>();
-        try
+        synchronized( overallBuildQueues )
         {
-            List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
-            for ( Object obj : objects )
+            List<Task> currentCheckouts = new ArrayList<Task>();           
+            Set<Integer> keys = overallBuildQueues.keySet();
+            for( Integer key : keys )
             {
-                ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
-                Task task = executor.getCurrentTask();
-                if ( task instanceof CheckOutTask )
+                OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );
+                Task task = overallBuildQueue.getCheckoutTaskQueueExecutor().getCurrentTask();
+                if( task != null )
                 {
                     currentCheckouts.add( task );
                 }
             }
+            
+            return currentCheckouts;
         }
-        catch ( ComponentLookupException e )
-        {
-            throw new BuildManagerException( e.getMessage() );
-        }
-
-        return currentCheckouts;
     }
 
     public Map<String, List<Task>> getProjectsInBuildQueues()

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=726931&r1=726930&r2=726931&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
Mon Dec 15 19:03:11 2008
@@ -31,13 +31,13 @@
 import org.apache.maven.continuum.store.ContinuumStoreException;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.logging.AbstractLogEnabled;
 import org.codehaus.plexus.taskqueue.Task;
 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;
 
 /**
  * "Overall" build queue which has a checkout queue and a build queue.
@@ -46,25 +46,12 @@
  * @plexus.component role="org.apache.continuum.taskqueue.OverallBuildQueue" instantiation-strategy="per-lookup"
  */
 public class DefaultOverallBuildQueue
-    extends AbstractLogEnabled
     implements OverallBuildQueue
 {
     /**
-     * @plexus.requirement role-hint="build-project"
-     */
-    //private TaskQueue buildQueue;
-
-    /**
-     * @plexus.requirement role-hint="check-out-project"
-     */
-    //private TaskQueue checkoutQueue;
-
-    /**
      * @plexus.requirement
      */
     private BuildDefinitionDao buildDefinitionDao;
-
-    private PlexusContainer container;
     
     /**
      * @plexus.requirement role-hint="build-project"
@@ -79,6 +66,8 @@
     private int id;
 
     private String name;
+    
+    private Logger log = LoggerFactory.getLogger( DefaultOverallBuildQueue.class );
 
     public int getId()
     {
@@ -145,7 +134,6 @@
                 return true;
             }
         }
-
         return false;
     }
 
@@ -164,7 +152,6 @@
                 return getCheckoutQueue().remove( task );
             }
         }
-
         return false;
     }
 
@@ -296,23 +283,13 @@
     public void cancelBuildTask( int projectId )
         throws ComponentLookupException
     {
-        List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
-        for ( Object obj : objects )
+        BuildProjectTask task = (BuildProjectTask) buildTaskQueueExecutor.getCurrentTask();
+        if( task != null && task.getProjectId() == projectId )
         {
-            ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
-            Task task = executor.getCurrentTask();
-            if ( task != null && task instanceof BuildProjectTask )
-            {
-                if ( ( (BuildProjectTask) task ).getProjectId() == projectId )
-                {
-                    getLogger().info(
-                                      "Cancelling build task for project '" + projectId +
"' in task executor '" +
-                                          executor );
-                    executor.cancelTask( task );
-                }
-            }
-        }
-
+            log.info( "Cancelling build task for project '" + projectId + "' in task executor
'" +
+                                 buildTaskQueueExecutor );
+            buildTaskQueueExecutor.cancelTask( task );
+        }        
     }
 
     /**
@@ -321,20 +298,13 @@
     public boolean cancelCurrentBuild()
         throws ComponentLookupException
     {
-        List<Object> objects = container.lookupList( ThreadedTaskQueueExecutor.class
);
-        for ( Object obj : objects )
+        Task task = buildTaskQueueExecutor.getCurrentTask();
+        if( task != null )
         {
-            ThreadedTaskQueueExecutor executor = (ThreadedTaskQueueExecutor) obj;
-            Task task = executor.getCurrentTask();
-            if ( task != null && task instanceof BuildProjectTask )
-            {
-                BuildProjectTask buildTask = (BuildProjectTask) task;
-                getLogger().info(
-                                  "Cancelling task for project '" + buildTask.getProjectId()
+ "' in task executor '" +
-                                      executor );
-                executor.cancelTask( task );
-            }
+            return buildTaskQueueExecutor.cancelTask( task );
         }
+        
+        log.info( "No build task currently executing on build executor: " + buildTaskQueueExecutor
);
         return false;
     }
 
@@ -400,7 +370,7 @@
 
         for ( BuildProjectTask buildProjectTask : tasks )
         {
-            getLogger().info( "cancel build for project " + buildProjectTask.getProjectId()
);
+            log.info( "cancel build for project " + buildProjectTask.getProjectId() );
         }
         if ( !tasks.isEmpty() )
         {
@@ -426,7 +396,6 @@
                 return getBuildQueue().remove( task );
             }
         }
-
         return false;
     }
 
@@ -462,11 +431,6 @@
         return ( ( ParallelBuildsThreadedTaskQueueExecutor ) buildTaskQueueExecutor ).getQueue();
     }
 
-    /*public void setContainer( PlexusContainer container )
-    {
-        this.container = container;
-    }*/
-
     public TaskQueueExecutor getBuildTaskQueueExecutor()
     {
         return buildTaskQueueExecutor;

Modified: continuum/branches/continuum-parallel-builds/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-model/src/main/mdo/continuum.xml?rev=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-model/src/main/mdo/continuum.xml
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-model/src/main/mdo/continuum.xml
Mon Dec 15 19:03:11 2008
@@ -1273,6 +1273,12 @@
           <type>String</type>
           <defaultValue>release-output-directory</defaultValue>
         </field>
+        <field>
+          <name>numberOfBuildsInParallel</name>
+          <version>1.1.4+</version>
+          <type>int</type>
+          <defaultValue>1</defaultValue>
+        </field>
       </fields>
     </class>
 

Modified: continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java?rev=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigurationAction.java
Mon Dec 15 19:03:11 2008
@@ -57,7 +57,7 @@
     
     private String releaseOutputDirectory;
 
-    private int numberOfAllowedBuildsinParallel;
+    private int numberOfAllowedBuildsinParallel = 1;
     
     private boolean requireReleaseOutput;
     
@@ -101,11 +101,11 @@
             releaseOutputDirectory = releaseOutputDirectoryFile.getAbsolutePath();
         }
         
-        if ( requireParallelBuilds )
-        {
-            numberOfAllowedBuildsinParallel = configuration.getNumberOfBuildsInParallel();

-        }
-        
+        //if ( requireParallelBuilds )
+        //{
+        numberOfAllowedBuildsinParallel = configuration.getNumberOfBuildsInParallel();	
+        //}
+                
         String requireRelease = ServletActionContext.getRequest().getParameter( "requireReleaseOutput"
);
         setRequireReleaseOutput( new Boolean( requireRelease ) );
     }
@@ -116,6 +116,11 @@
         {
             addActionError( "configuration.releaseOutputDirectory.required" );
         }
+                
+        if( numberOfAllowedBuildsinParallel <= 0 )
+        {
+            addActionError( "configuration.numberOfBuildsInParallel.invalid" );
+        }
         
         return INPUT;
     }
@@ -129,10 +134,10 @@
 
         configuration.setBuildOutputDirectory( new File( buildOutputDirectory ) );
         
-        if ( requireParallelBuilds )
-        {
+        //if ( requireParallelBuilds )
+        //{
             configuration.setNumberOfBuildsInParallel( numberOfAllowedBuildsinParallel );

-        }
+        //}
         
         if ( StringUtils.isNotEmpty( deploymentRepositoryDirectory ) )
         {
@@ -255,6 +260,4 @@
 	{
 	    this.requireParallelBuilds = requireParallelBuilds;
 	}
-    
-    
 }

Modified: continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=726931&r1=726930&r2=726931&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
Mon Dec 15 19:03:11 2008
@@ -246,6 +246,7 @@
 configuration.releaseOutputDirectory.label = Release Output Directory
 configuration.releaseOutputDirectory.message = Enter the release output directory of the
Continuum web application
 configuration.releaseOutputDirectory.required = You must define a release output directory
+configuration.numberOfBuildsInParallel.invalid = Number of Allowed Builds in Parallel must
be greater than zero
 
 # ----------------------------------------------------------------------
 # Page: Add Project



Mime
View raw message