You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by oc...@apache.org on 2009/01/14 07:07:30 UTC
svn commit: r734343 -
/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
Author: oching
Date: Tue Jan 13 22:07:29 2009
New Revision: 734343
URL: http://svn.apache.org/viewvc?rev=734343&view=rev
Log:
get current builds from parallel builds manager instead of directly looking up the build-project task queue executor
Modified:
continuum/trunk/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
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=734343&r1=734342&r2=734343&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 Tue Jan 13 22:07:29 2009
@@ -21,8 +21,12 @@
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
+import org.apache.continuum.buildmanager.BuildManagerException;
+import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.dao.ProjectDao;
import org.apache.continuum.model.repository.LocalRepository;
import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
@@ -80,6 +84,11 @@
*/
private PurgeConfigurationService purgeConfigurationService;
+ /**
+ * @plexus.requirement role-hint="parallel"
+ */
+ private BuildsManager buildsManager;
+
private PlexusContainer container;
public TaskQueue getPurgeQueue()
@@ -121,28 +130,40 @@
public boolean isRepositoryInUse( int repositoryId )
throws TaskQueueManagerException
{
- try
- {
- Task task = getCurrentTask( "build-project" );
-
- if ( task != null && task instanceof BuildProjectTask )
- {
- int projectId = ( (BuildProjectTask) task ).getProjectId();
-
- Project project = projectDao.getProject( projectId );
- LocalRepository repository = project.getProjectGroup().getLocalRepository();
-
- if ( repository != null && repository.getId() == repositoryId )
+ try
+ {
+ Map<String, Task> currentBuilds = buildsManager.getCurrentBuilds();
+ Set<String> keys = currentBuilds.keySet();
+
+ for( String key : keys )
+ {
+ Task task = currentBuilds.get( key );
+ if ( task != null && task instanceof BuildProjectTask )
{
- return true;
+ int projectId = ( (BuildProjectTask) task ).getProjectId();
+
+ Project project = projectDao.getProject( projectId );
+ LocalRepository repository = project.getProjectGroup().getLocalRepository();
+
+ if ( repository != null && repository.getId() == repositoryId )
+ {
+ return true;
+ }
}
- }
+ }
+
return false;
- }
- catch ( ContinuumStoreException e )
- {
- throw new TaskQueueManagerException( e.getMessage(), e );
- }
+ }
+ catch ( BuildManagerException e )
+ {
+ log.error( "Error occured while getting current builds: " + e.getMessage() );
+ throw new TaskQueueManagerException( e.getMessage(), e );
+ }
+ catch ( ContinuumStoreException e )
+ {
+ log.error( "Error occured while getting project details: " + e.getMessage() );
+ throw new TaskQueueManagerException( e.getMessage(), e );
+ }
}
public boolean isProjectInReleaseStage( String releaseId )