continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r732660 - in /continuum/branches/continuum-parallel-builds: continuum-api/src/main/java/org/apache/continuum/buildmanager/ continuum-core/src/main/java/org/apache/continuum/buildmanager/ continuum-core/src/main/java/org/apache/continuum/tas...
Date Thu, 08 Jan 2009 09:26:40 GMT
Author: oching
Date: Thu Jan  8 01:26:39 2009
New Revision: 732660

URL: http://svn.apache.org/viewvc?rev=732660&view=rev
Log:
fix test for removing project groups

Modified:
    continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/buildmanager/BuildsManager.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/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java

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=732660&r1=732659&r2=732660&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
Thu Jan  8 01:26:39 2009
@@ -251,6 +251,16 @@
      */
     boolean isInAnyCheckoutQueue( int projectId )
         throws BuildManagerException;
+    
+    /**
+     * Checks if at least one of the projects is currently being checked out.
+     * 
+     * @param projectIds
+     * @return
+     * @throws BuildManagerException
+     */
+    boolean isAnyProjectCurrentlyBeingCheckedOut( int[] projectIds )
+        throws BuildManagerException;
 
     /**
      * Checks whether the project is already in the prepare-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=732660&r1=732659&r2=732660&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
Thu Jan  8 01:26:39 2009
@@ -460,6 +460,27 @@
     }
 
     /**
+     * @see BuildsManager#isAnyProjectCurrentlyBeingCheckedOut(int[])
+     */
+    public boolean isAnyProjectCurrentlyBeingCheckedOut( int[] projectIds )
+        throws BuildManagerException
+    {        
+        for( int i = 0; i < projectIds.length; i++ )
+        {
+            Map<String, Task> checkouts = getCurrentCheckouts();
+            Set<String> keySet = checkouts.keySet();
+            for( String key : keySet )
+            {
+                CheckOutTask task = (CheckOutTask) checkouts.get( key );
+                if( task.getProjectId() == projectIds[i] )
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    /**
      * @see BuildsManager#isInPrepareBuildQueue(int)
      */
     public boolean isInPrepareBuildQueue( int projectId )

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=732660&r1=732659&r2=732660&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
Thu Jan  8 01:26:39 2009
@@ -300,7 +300,7 @@
         {
             log.info( "Cancelling checkout task for project '" + projectId + "' in task executor
'" +
                                  checkoutTaskQueueExecutor );
-            checkoutTaskQueueExecutor.cancelTask( task );
+            checkoutTaskQueueExecutor.cancelTask( task );            
         }    
     }
 

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java?rev=732660&r1=732659&r2=732660&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/taskqueueexecutor/ParallelBuildsThreadedTaskQueueExecutor.java
Thu Jan  8 01:26:39 2009
@@ -43,7 +43,6 @@
 
 /**
  * 
- * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  */
 public class ParallelBuildsThreadedTaskQueueExecutor
     implements TaskQueueExecutor, Initializable, Startable

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=732660&r1=732659&r2=732660&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Thu Jan  8 01:26:39 2009
@@ -369,10 +369,35 @@
         ProjectGroup projectGroup = getProjectGroupWithProjects( projectGroupId );
 
         if ( projectGroup != null )
-        {
-            for ( Object o : projectGroup.getProjects() )
+        {   
+            List<Project> projects = projectGroup.getProjects();
+            int[] projectIds = new int[projects.size()];
+            
+            int idx = 0;
+            for( Project project : projects )
+            {
+                projectIds[idx] = project.getId();
+                idx++;
+            }
+            
+            // check if any project is still being checked out
+            // canceling the checkout and proceeding with the delete results to a cannot
delete directory error!
+            try
+            {            
+                if( parallelBuildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds
) )
+                {
+                    throw new ContinuumException(
+                                                  "Unable to delete group. At least one project
in group is still being checked out." );
+                }
+            }
+            catch ( BuildManagerException e )
+            {
+                throw new ContinuumException( "Unable to delete group.", e );
+            }
+        
+            for ( int i = 0; i < projectIds.length; i++ )
             {
-                removeProject( ( (Project) o ).getId() );
+                removeProject( projectIds[i] );
             }
 
             List<ProjectScmRoot> projectScmRoots = getProjectScmRootByProjectGroup(
projectGroupId );
@@ -624,7 +649,7 @@
                 
                 parallelBuildsManager.removeProjectFromBuildQueue( projectId );         
      
                 
-                parallelBuildsManager.cancelCheckout( projectId );
+                //parallelBuildsManager.cancelCheckout( projectId );
                 
                 parallelBuildsManager.cancelBuild( projectId );                
             }

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=732660&r1=732659&r2=732660&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
Thu Jan  8 01:26:39 2009
@@ -30,7 +30,6 @@
 import org.apache.continuum.model.release.ContinuumReleaseResult;
 import org.apache.continuum.model.repository.LocalRepository;
 import org.apache.continuum.repository.RepositoryService;
-import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
@@ -260,7 +259,24 @@
         projectGroup = (ProjectGroup) projectGroupList.iterator().next();
 
         assertNotNull( projectGroup );
-
+        
+        BuildsManager buildsManager = continuum.getBuildsManager();
+        
+        List<Project> projects = projectGroup.getProjects();
+        int[] projectIds = new int[ projects.size() ];
+        
+        int idx = 0;
+        for( Project project : projects )
+        {
+            projectIds[ idx ] = project.getId();
+            idx++;
+        }
+        
+        while( buildsManager.isAnyProjectCurrentlyBeingCheckedOut( projectIds ) )
+        {
+            continue;
+        }
+        
         continuum.removeProjectGroup( projectGroup.getId() );
 
         projectGroupList = continuum.getAllProjectGroupsWithProjects();



Mime
View raw message