Skip to content

Commit

Permalink
Fix execution of two build definitions of a project attached to the s…
Browse files Browse the repository at this point in the history
…ame schedule

git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/branches/continuum-1.0.x@388290 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Emmanuel Venisse committed Mar 23, 2006
1 parent 2a522c3 commit 6f2017e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 34 deletions.
Expand Up @@ -101,7 +101,7 @@ Schedule storeSchedule( Schedule schedule )
Project getProject( int projectId )
throws ContinuumStoreException, ContinuumObjectNotFoundException;

Map getProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
Map getProjectIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
throws ContinuumStoreException;

void updateProject( Project project )
Expand Down
Expand Up @@ -395,7 +395,7 @@ public void buildProjects( Schedule schedule )

try
{
projectsMap = store.getProjectIdsAndBuildDefinitionIdsBySchedule( schedule.getId() );
projectsMap = store.getProjectIdsAndBuildDefinitionsIdsBySchedule( schedule.getId() );

if ( projectsMap == null )
{
Expand All @@ -420,12 +420,17 @@ public void buildProjects( Schedule schedule )
{
Project project = (Project) projectIterator.next();

Integer buildDefId = ( (Integer) projectsMap.get( new Integer( project.getId() ) ) );
List buildDefIds = (List) projectsMap.get( new Integer( project.getId() ) );

if ( buildDefId != null && !isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
!isInCheckoutQueue( project.getId() ) )
for ( Iterator buildDefinitionIterator = buildDefIds.iterator(); buildDefinitionIterator.hasNext(); )
{
buildProject( project, buildDefId.intValue(), ContinuumProjectState.TRIGGER_SCHEDULED, false );
Integer buildDefId = (Integer) buildDefinitionIterator.next();

if ( buildDefId != null && !isInBuildingQueue( project.getId(), buildDefId.intValue() ) &&
!isInCheckoutQueue( project.getId() ) )
{
buildProject( project, buildDefId.intValue(), ContinuumProjectState.TRIGGER_SCHEDULED, false );
}
}
}
}
Expand Down
Expand Up @@ -62,6 +62,7 @@ public List evaluate( List tasks )
BuildProjectTask task = (BuildProjectTask) it.next();

Integer key = new Integer( task.getProjectId() );

List projectTasks = (List) projects.get( key );

if ( projectTasks == null )
Expand Down Expand Up @@ -90,39 +91,42 @@ public List evaluate( List tasks )

private List checkTasks( List list )
{
BuildProjectTask okTask = null;

List toBeRemoved = new ArrayList();

for ( Iterator it = list.iterator(); it.hasNext(); )
{
BuildProjectTask buildProjectTask = (BuildProjectTask) it.next();

if ( okTask == null )
{
okTask = buildProjectTask;

continue;
}

// ----------------------------------------------------------------------
// If this build is forces, don't remove it
// ----------------------------------------------------------------------

if ( buildProjectTask.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
{
continue;
}

// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

long interval = buildProjectTask.getTimestamp() - okTask.getTimestamp();

if ( interval < requiredBuildInterval )
for ( Iterator it2 = list.iterator(); it2.hasNext(); )
{
toBeRemoved.add( buildProjectTask );
BuildProjectTask task = (BuildProjectTask) it2.next();

// check if it's the same task
if ( buildProjectTask == task ||
buildProjectTask.getBuildDefinitionId() != task.getBuildDefinitionId() )
{
continue;
}

// ----------------------------------------------------------------------
// If this build is forces, don't remove it
// ----------------------------------------------------------------------

if ( task.getTrigger() == ContinuumProjectState.TRIGGER_FORCED )
{
continue;
}

// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

long interval = task.getTimestamp() - buildProjectTask.getTimestamp();

if ( interval < requiredBuildInterval )
{
toBeRemoved.add( buildProjectTask );
}
}
}

Expand Down
Expand Up @@ -41,6 +41,7 @@
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -139,7 +140,7 @@ public Project getProjectByName( String name )
}
}

public Map getProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
public Map getProjectIdsAndBuildDefinitionsIdsBySchedule( int scheduleId )
throws ContinuumStoreException
{
PersistenceManager pm = getPersistenceManager();
Expand Down Expand Up @@ -175,7 +176,20 @@ public Map getProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
{
Object[] obj = (Object[]) i.next();

projects.put( (Integer) obj[0], (Integer) obj[1] );
List buildDefinitions;

if ( projects.get( obj[0] ) != null )
{
buildDefinitions = (List) projects.get( obj[0] );
}
else
{
buildDefinitions = new ArrayList();
}

buildDefinitions.add( obj[1] );

projects.put( obj[0], buildDefinitions );
}

return projects;
Expand Down

0 comments on commit 6f2017e

Please sign in to comment.