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 2008/12/15 04:18:41 UTC
svn commit: r726609 - in /continuum/branches/continuum-parallel-builds:
continuum-api/src/main/java/org/apache/continuum/buildmanager/
continuum-core/src/main/java/org/apache/maven/continuum/
continuum-core/src/main/java/org/apache/maven/continuum/core...
Author: oching
Date: Sun Dec 14 19:18:41 2008
New Revision: 726609
URL: http://svn.apache.org/viewvc?rev=726609&view=rev
Log:
-cleanup code
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/maven/continuum/DefaultContinuum.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.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=726609&r1=726608&r2=726609&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 Sun Dec 14 19:18:41 2008
@@ -24,7 +24,6 @@
import java.util.Map;
import org.apache.continuum.taskqueue.OverallBuildQueue;
-import org.apache.maven.continuum.buildqueue.BuildProjectTask;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.codehaus.plexus.taskqueue.Task;
@@ -109,10 +108,4 @@
Map<String, List<Task>> getProjectsInCheckoutQueues() throws BuildManagerException;
boolean isBuildInProgress() throws BuildManagerException;
- // maybe these could return a new object which contains the name of the build queue (overall) and the current task?
- // - add getCurrentBuilds(..)
- // - add getCurrentCheckouts(..)
- // - add getAllQueuedBuilds(..)
- // - add getAllQueuedCheckouts(...)
- // - buildInProgress() <-- used in purge (see taskQueuemanager for impl)
}
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=726609&r1=726608&r2=726609&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 Sun Dec 14 19:18:41 2008
@@ -51,7 +51,6 @@
import org.apache.continuum.purge.PurgeConfigurationService;
import org.apache.continuum.repository.RepositoryService;
import org.apache.continuum.taskqueue.manager.TaskQueueManager;
-import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
import org.apache.maven.continuum.build.settings.SchedulesActivationException;
import org.apache.maven.continuum.build.settings.SchedulesActivator;
import org.apache.maven.continuum.builddefinition.BuildDefinitionService;
@@ -620,28 +619,8 @@
parallelBuildsManager.removeProjectFromBuildQueue( projectId );
- parallelBuildsManager.cancelBuild( projectId );
-
- /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
- {
- taskQueueManager.removeProjectFromCheckoutQueue( projectId );
- }
-
- if ( taskQueueManager.isInBuildingQueue( projectId ) )
- {
- taskQueueManager.removeProjectFromBuildingQueue( projectId );
- }*/
-
- // cancel if currently building
- /*if ( taskQueueManager.getCurrentProjectIdBuilding() == projectId )
- {
- taskQueueManager.cancelBuildTask( projectId );
- }*/
+ parallelBuildsManager.cancelBuild( projectId );
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -924,8 +903,6 @@
{
try
{
- //if ( buildDefId != null && !taskQueueManager.isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
- // !taskQueueManager.isInCheckoutQueue( project.getId() ) && !taskQueueManager.isInPrepareBuildQueue( project.getId() ) )
if ( buildDefId != null && !parallelBuildsManager.isInAnyBuildQueue( project.getId(), buildDefId.intValue() ) &&
!parallelBuildsManager.isInAnyCheckoutQueue( project.getId() ) && !parallelBuildsManager.isInPrepareBuildQueue( project.getId() ) )
{
@@ -950,10 +927,6 @@
map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
}
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -991,18 +964,11 @@
{
if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDef.getId() ) ||
parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
- parallelBuildsManager.isInPrepareBuildQueue( projectId ) )
- //if ( taskQueueManager.isInBuildingQueue( projectId, buildDef.getId() ) ||
- // taskQueueManager.isInCheckoutQueue( projectId ) ||
- // taskQueueManager.isInPrepareBuildQueue( projectId ))
+ parallelBuildsManager.isInPrepareBuildQueue( projectId ) )
{
return;
}
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -1022,17 +988,10 @@
if ( parallelBuildsManager.isInAnyBuildQueue( projectId, buildDefinitionId ) ||
parallelBuildsManager.isInAnyCheckoutQueue( projectId ) ||
parallelBuildsManager.isInPrepareBuildQueue( projectId ))
- /*if ( taskQueueManager.isInBuildingQueue( projectId, buildDefinitionId ) ||
- taskQueueManager.isInCheckoutQueue( projectId ) ||
- taskQueueManager.isInPrepareBuildQueue( projectId ))*/
{
return;
}
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -3283,25 +3242,16 @@
try
{
// check if project already in queue
- //if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
{
continue;
}
- /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
- {
- taskQueueManager.removeProjectFromCheckoutQueue( projectId );
- }*/
if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
{
parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
}
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -3388,17 +3338,11 @@
try
{
// check if project already in queue
- //if ( taskQueueManager.isInBuildingQueue( projectId ) || taskQueueManager.getCurrentProjectIdBuilding() == projectId )
if ( parallelBuildsManager.isInAnyBuildQueue( projectId ) || parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
{
continue;
}
- /*if ( taskQueueManager.isInCheckoutQueue( projectId ) )
- {
- taskQueueManager.removeProjectFromCheckoutQueue( projectId );
- }*/
-
if ( parallelBuildsManager.isInAnyCheckoutQueue( projectId ) )
{
parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
@@ -3423,10 +3367,6 @@
map.put( scmRootAddress, projectsAndBuildDefinitionsMap );
}
- /*catch ( TaskQueueManagerException e )
- {
- throw new ContinuumException( e.getMessage(), e );
- }*/
catch ( BuildManagerException e )
{
throw new ContinuumException( e.getMessage(), e );
@@ -3450,14 +3390,8 @@
{
try
{
- parallelBuildsManager.prepareBuildProject( projectsBuildDefinitionsMap, trigger );
- /*PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger );
- taskQueueManager.getPrepareBuildQueue().put( task );*/
+ parallelBuildsManager.prepareBuildProject( projectsBuildDefinitionsMap, trigger );
}
- /*catch ( TaskQueueException e )
- {
- throw logAndCreateException( "Error while creating enqueuing object.", e );
- }*/
catch( BuildManagerException e )
{
throw logAndCreateException( "Error while creating enqueuing object.", e );
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java?rev=726609&r1=726608&r2=726609&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/AddProjectToCheckOutQueueAction.java Sun Dec 14 19:18:41 2008
@@ -45,11 +45,6 @@
* @plexus.requirement
*/
private ProjectDao projectDao;
-
- /**
- * @plexus.requirement
- */
- //private TaskQueueManager taskQueueManager;
/**
* @plexus.requirement role-hint="parallel"
@@ -60,10 +55,6 @@
public void execute( Map context )
throws Exception
{
-
- //TODO: deng parallel builds
- // - get the default build definition from context and pass to parallel builds manager!
-
Project project = (Project) getObject( context, KEY_PROJECT, null );
if ( project == null )
{
@@ -75,9 +66,5 @@
workingDirectoryService.getWorkingDirectory( project ),
project.getScmUsername(), project.getScmPassword(),
defaultBuildDefinition );
- /*CheckOutTask checkOutTask = new CheckOutTask( project.getId(), workingDirectoryService
- .getWorkingDirectory( project ), project.getName(), project.getScmUsername(), project.getScmPassword() );
-
- taskQueueManager.getCheckoutQueue().put( checkOutTask );*/
}
}
Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java?rev=726609&r1=726608&r2=726609&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/core/action/CreateBuildProjectTaskAction.java Sun Dec 14 19:18:41 2008
@@ -42,22 +42,12 @@
/**
* @plexus.requirement
*/
- //private TaskQueueManager taskQueueManager;
-
- /**
- * @plexus.requirement
- */
private BuildExecutorManager executorManager;
/**
* @plexus.requirement
*/
private ProjectDao projectDao;
-
- /**
- * @plexus.requirement
- */
- //private BuildDefinitionDao buildDefinitionDao;
/**
* @plexus.requirement role-hint="parallel"
@@ -67,11 +57,6 @@
public synchronized void execute( Map context )
throws Exception
{
- // TODO: deng parallel builds
- // - context now contains a "list" of projects and a "map" of projectId, build definition ket-value pair
- // - update the list of projects
- // - pass this updated list + map of build definitions to builds manager
-
List<Project> projects = AbstractContinuumAction.getListOfProjects( context );
Map<Integer, BuildDefinition> projectsBuildDefinitionsMap =
AbstractContinuumAction.getProjectsBuildDefinitionsMap( context );
@@ -138,85 +123,6 @@
}
}
- parallelBuildsManager.buildProjects( projectsToBeBuilt, projectsBuildDefinitionsMap, trigger );
-
- /*Project project = AbstractContinuumAction.getProject( context );
- int buildDefinitionId = AbstractContinuumAction.getBuildDefinitionId( context );
- int trigger = AbstractContinuumAction.getTrigger( context );
-
- if ( taskQueueManager.isInBuildingQueue( project.getId(), buildDefinitionId ) )
- {
- return;
- }
-
- if ( taskQueueManager.isInCheckoutQueue( project.getId() ) )
- {
- taskQueueManager.removeProjectFromCheckoutQueue( project.getId() );
- }
-
- try
- {
- if ( project.getState() != ContinuumProjectState.NEW &&
- project.getState() != ContinuumProjectState.CHECKEDOUT &&
- project.getState() != ContinuumProjectState.OK && project.getState() != ContinuumProjectState.FAILED &&
- project.getState() != ContinuumProjectState.ERROR )
- {
- ContinuumBuildExecutor executor = executorManager.getBuildExecutor( project.getExecutorId() );
-
- if ( executor.isBuilding( project ) || project.getState() == ContinuumProjectState.UPDATING )
- {
- // project is building
- getLogger().info( "Project '" + project.getName() + "' already being built." );
-
- return;
- }
- else
- {
- project.setOldState( project.getState() );
-
- project.setState( ContinuumProjectState.ERROR );
-
- projectDao.updateProject( project );
-
- project = projectDao.getProject( project.getId() );
- }
- }
- else
- {
- project.setOldState( project.getState() );
-
- projectDao.updateProject( project );
-
- project = projectDao.getProject( project.getId() );
- }
-
- BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
- String buildDefinitionLabel = buildDefinition.getDescription();
- if ( StringUtils.isEmpty( buildDefinitionLabel ) )
- {
- buildDefinitionLabel = buildDefinition.getGoals();
- }
-
- getLogger().info( "Enqueuing '" + project.getName() + "' with build definition '" + buildDefinitionLabel +
- "' - id=" + buildDefinitionId + ")." );
-
- BuildProjectTask task = new BuildProjectTask( project.getId(), buildDefinitionId, trigger, project
- .getName(), buildDefinitionLabel );
-
- task.setMaxExecutionTime( buildDefinition.getSchedule()
- .getMaxJobExecutionTime() * 1000 );
-
- taskQueueManager.getBuildQueue().put( task );
- }
- catch ( ContinuumStoreException e )
- {
- getLogger().error( "Error while creating build object", e );
- throw new ContinuumException( "Error while creating build object.", e );
- }
- catch ( TaskQueueException e )
- {
- getLogger().error( "Error while enqueuing object", e );
- throw new ContinuumException( "Error while enqueuing object.", e );
- }*/
+ parallelBuildsManager.buildProjects( projectsToBeBuilt, projectsBuildDefinitionsMap, trigger );
}
}
Modified: continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java?rev=726609&r1=726608&r2=726609&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java (original)
+++ continuum/branches/continuum-parallel-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java Sun Dec 14 19:18:41 2008
@@ -19,7 +19,11 @@
* under the License.
*/
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.apache.commons.lang.ArrayUtils;
import org.apache.continuum.buildmanager.BuildsManager;
@@ -47,11 +51,7 @@
public class QueuesAction
extends AbstractBuildQueueAction
implements SecureAction, LogEnabled
-{
-
- // TODO: deng - parallel builds
- // see TODO comments below!!!
-
+{
/**
* @plexus.requirement role-hint='build-project'
*/
@@ -87,10 +87,18 @@
*/
private TaskQueueManager taskQueueManager;
+ // TODO: deng parallel builds
+
/**
* @plexus.requirement role-hint="parallel"
*/
private BuildsManager parallelBuildsManager;
+
+ private List<BuildProjectTask> currentBuildProjectTasks = new ArrayList<BuildProjectTask>();
+
+ private Map<String, List<BuildProjectTask>> buildsInQueue = new HashMap<String, List<BuildProjectTask>>();
+
+ private Map<String, List<CheckOutTask>> checkoutsInQueue = new HashMap<String, List<CheckOutTask>>();
// -----------------------------------------------------
// webwork
@@ -135,8 +143,9 @@
addActionError( e.getMessage() );
return REQUIRES_AUTHENTICATION;
}
-
- taskQueueManager.removeProjectFromCheckoutQueue( projectId );
+
+ parallelBuildsManager.removeProjectFromCheckoutQueue( projectId );
+ //taskQueueManager.removeProjectFromCheckoutQueue( projectId );
return SUCCESS;
}
@@ -164,15 +173,56 @@
public String display()
throws Exception
{
- // TODO: deng parallel builds
- // - need to get all the build queues and their current tasks
- // - need to get all the build queues and their queued tasks
-
- this.setCurrentBuildProjectTask( (BuildProjectTask) taskQueueExecutor.getCurrentTask() );
+ // current builds
+ for( Task task : parallelBuildsManager.getCurrentBuilds() )
+ {
+ BuildProjectTask buildTask = (BuildProjectTask) task;
+ this.currentBuildProjectTasks.add( buildTask );
+ }
+
+ // queued builds
+ Map<String, List<Task>> builds = parallelBuildsManager.getProjectsInBuildQueues();
+ Set<String> keySet = builds.keySet();
+ List<BuildProjectTask> buildTasks = new ArrayList<BuildProjectTask>();
+ for( String key : keySet )
+ {
+ for( Task task : builds.get( key ) )
+ {
+ BuildProjectTask buildTask = (BuildProjectTask) task;
+ buildTasks.add( buildTask );
+ }
+ buildsInQueue.put( key, buildTasks );
+ }
+
+ // current checkouts
+ for( Task task : parallelBuildsManager.getCurrentCheckouts() )
+ {
+ CheckOutTask checkoutTask = (CheckOutTask) task;
+ this.currentCheckOutTasks.add( checkoutTask );
+ }
+
+ // queued checkouts
+ Map<String, List<Task>> checkouts = parallelBuildsManager.getProjectsInCheckoutQueues();
+ keySet = builds.keySet();
+ List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
+ for( String key : keySet )
+ {
+ for( Task task : checkouts.get( key ) )
+ {
+ CheckOutTask checkoutTask = (CheckOutTask) task;
+ checkoutTasks.add( checkoutTask );
+ }
+ checkoutsInQueue.put( key, checkoutTasks );
+ }
+
+ //this.setCurrentBuildProjectTask( (BuildProjectTask) taskQueueExecutor.getCurrentTask() );
+ //this.setBuildProjectTasks( taskQueueManager.getProjectsInBuildQueue() );
+
+ /*this.setCurrentBuildProjectTask( (BuildProjectTask) taskQueueExecutor.getCurrentTask() );
this.setBuildProjectTasks( taskQueueManager.getProjectsInBuildQueue() );
this.setCurrentCheckOutTask( (CheckOutTask) checkoutTaskQueueExecutor.getCurrentTask() );
- this.setCurrentCheckOutTasks( taskQueueManager.getCheckOutTasksInQueue() );
+ this.setCurrentCheckOutTasks( taskQueueManager.getCheckOutTasksInQueue() );*/
return SUCCESS;
}
@@ -193,8 +243,7 @@
addActionError( e.getMessage() );
return REQUIRES_AUTHENTICATION;
}
-
- //taskQueueManager.removeFromBuildingQueue( projectId, buildDefinitionId, trigger, projectName );
+
parallelBuildsManager.removeProjectFromBuildQueue( projectId, buildDefinitionId, trigger, projectName );
Project project = getContinuum().getProject( projectId );
project.setState( project.getOldState() );
@@ -435,6 +484,13 @@
this.selectedCheckOutTaskHashCodes = selectedCheckOutTaskHashCodes;
}
+ public List<BuildProjectTask> getCurrentBuildProjectTasks()
+ {
+ return currentBuildProjectTasks;
+ }
-
+ public void setCurrentBuildProjectTasks( List<BuildProjectTask> currentBuildProjectTasks )
+ {
+ this.currentBuildProjectTasks = currentBuildProjectTasks;
+ }
}