You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2009/05/17 18:14:24 UTC
svn commit: r775693 [3/5] - in /continuum/branches/continuum-1.3.x:
continuum-api/src/main/java/org/apache/continuum/builder/distributed/
continuum-api/src/main/java/org/apache/continuum/builder/distributed/manager/
continuum-api/src/main/java/org/apac...
Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=775693&r1=775692&r2=775693&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java (original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java Sun May 17 16:14:22 2009
@@ -19,49 +19,35 @@
* under the License.
*/
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.continuum.builder.distributed.executor.DistributedBuildTaskQueueExecutor;
import org.apache.continuum.builder.distributed.executor.ThreadedDistributedBuildTaskQueueExecutor;
+import org.apache.continuum.builder.distributed.util.DistributedBuildUtil;
import org.apache.continuum.builder.utils.ContinuumBuildConstant;
import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.continuum.configuration.BuildAgentGroupConfiguration;
import org.apache.continuum.dao.BuildDefinitionDao;
import org.apache.continuum.dao.BuildResultDao;
import org.apache.continuum.dao.ProjectDao;
-import org.apache.continuum.dao.ProjectScmRootDao;
import org.apache.continuum.distributed.transport.slave.SlaveBuildAgentTransportClient;
-import org.apache.continuum.model.project.ProjectScmRoot;
+import org.apache.continuum.taskqueue.BuildProjectTask;
+import org.apache.continuum.taskqueue.OverallDistributedBuildQueue;
import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
import org.apache.continuum.utils.ContinuumUtils;
+import org.apache.continuum.utils.ProjectSorter;
import org.apache.maven.continuum.ContinuumException;
-import org.apache.maven.continuum.configuration.ConfigurationException;
import org.apache.maven.continuum.configuration.ConfigurationService;
-import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
-import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.BuildResult;
import org.apache.maven.continuum.model.project.Project;
-import org.apache.maven.continuum.model.project.ProjectDependency;
-import org.apache.maven.continuum.model.project.ProjectDeveloper;
-import org.apache.maven.continuum.model.project.ProjectNotifier;
-import org.apache.maven.continuum.model.scm.ChangeFile;
-import org.apache.maven.continuum.model.scm.ChangeSet;
-import org.apache.maven.continuum.model.scm.ScmResult;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
-import org.apache.maven.continuum.notification.ContinuumNotificationDispatcher;
-import org.apache.maven.continuum.project.ContinuumProjectState;
import org.apache.maven.continuum.store.ContinuumStoreException;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
@@ -73,6 +59,8 @@
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -86,15 +74,13 @@
{
private static final Logger log = LoggerFactory.getLogger( DefaultDistributedBuildManager.class );
- /**
- * @plexus.requirement
- */
- private ConfigurationService configurationService;
+ private Map<String, OverallDistributedBuildQueue> overallDistributedBuildQueues =
+ Collections.synchronizedMap( new HashMap<String, OverallDistributedBuildQueue>() );
/**
* @plexus.requirement
*/
- private InstallationService installationService;
+ private ConfigurationService configurationService;
/**
* @plexus.requirement
@@ -109,22 +95,15 @@
/**
* @plexus.requirement
*/
- private ProjectScmRootDao projectScmRootDao;
-
- /**
- * @plexus.requirement
- */
private BuildResultDao buildResultDao;
/**
* @plexus.requirement
*/
- private ContinuumNotificationDispatcher notifierDispatcher;
+ private DistributedBuildUtil distributedBuildUtil;
private PlexusContainer container;
- private Map<String, DistributedBuildTaskQueueExecutor> taskQueueExecutors;
-
// --------------------------------
// Plexus Lifecycle
// --------------------------------
@@ -137,26 +116,74 @@
public void initialize()
throws InitializationException
{
- taskQueueExecutors = new HashMap<String, DistributedBuildTaskQueueExecutor>();
-
List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
if ( agents != null )
{
+ synchronized( overallDistributedBuildQueues )
+ {
+ for ( BuildAgentConfiguration agent : agents )
+ {
+ if ( agent.isEnabled() )
+ {
+ try
+ {
+ SlaveBuildAgentTransportClient client =
+ new SlaveBuildAgentTransportClient( new URL( agent.getUrl() ) );
+
+ if ( client.ping() )
+ {
+ log.info(
+ "agent is enabled, create distributed build queue for build agent '" + agent.getUrl() + "'" );
+ createDistributedBuildQueueForAgent( agent.getUrl() );
+ }
+ else
+ {
+ log.info( "unable to ping build agent '" + agent.getUrl() + "'" );
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ // do not throw exception, just log it
+ log.info( "Invalid build agent URL " + agent.getUrl() + ", not creating distributed build queue" );
+ }
+ catch ( ContinuumException e )
+ {
+ throw new InitializationException(
+ "Error while initializing distributed build queues", e );
+ }
+ catch ( Exception e )
+ {
+ agent.setEnabled( false );
+ log.info( "unable to ping build agent '" + agent.getUrl() + "': " +
+ ContinuumUtils.throwableToString( e ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void reload()
+ throws ContinuumException
+ {
+ List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
+
+ synchronized( overallDistributedBuildQueues )
+ {
for ( BuildAgentConfiguration agent : agents )
{
- if ( agent.isEnabled() )
+ if ( agent.isEnabled() && !overallDistributedBuildQueues.containsKey( agent.getUrl() ) )
{
try
{
SlaveBuildAgentTransportClient client =
new SlaveBuildAgentTransportClient( new URL( agent.getUrl() ) );
-
+
if ( client.ping() )
{
- log.info(
- "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
- addTaskQueueExecutor( agent.getUrl() );
+ log.info( "agent is enabled, create distributed build queue for build agent '" + agent.getUrl() + "'" );
+ createDistributedBuildQueueForAgent( agent.getUrl() );
}
else
{
@@ -166,12 +193,7 @@
catch ( MalformedURLException e )
{
// do not throw exception, just log it
- log.info( "Invalid build agent URL " + agent.getUrl() + ", not creating task queue executor" );
- }
- catch ( ContinuumException e )
- {
- throw new InitializationException(
- "Error while initializing distributed build task queue executors", e );
+ log.info( "Invalid build agent URL " + agent.getUrl() + ", not creating distributed build queue" );
}
catch ( Exception e )
{
@@ -180,133 +202,317 @@
ContinuumUtils.throwableToString( e ) );
}
}
+ else if ( !agent.isEnabled() && overallDistributedBuildQueues.containsKey( agent.getUrl() ) )
+ {
+ log.info( "agent is disabled, remove distributed build queue for build agent '" + agent.getUrl() + "'" );
+ removeDistributedBuildQueueOfAgent( agent.getUrl() );
+ }
}
}
}
- public void reload()
+ public void prepareBuildProjects( Map<Integer, Integer>projectsBuildDefinitionsMap, int trigger, int projectGroupId,
+ String projectGroupName, String scmRootAddress, int scmRootId )
throws ContinuumException
{
- List<BuildAgentConfiguration> agents = configurationService.getBuildAgents();
+ PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger,
+ projectGroupId, projectGroupName,
+ scmRootAddress, scmRootId );
+
+ OverallDistributedBuildQueue overallDistributedBuildQueue = getOverallDistributedBuildQueueByGroup( projectGroupId );
+
+ if ( overallDistributedBuildQueue == null )
+ {
+ // get overall distributed build queue from build agent group
+ overallDistributedBuildQueue = getOverallDistributedBuildQueueByAgentGroup( projectsBuildDefinitionsMap );
+ }
+
+ if ( overallDistributedBuildQueue == null )
+ {
+ overallDistributedBuildQueue = getOverallDistributedBuildQueue();
+ }
+
+ if ( overallDistributedBuildQueue != null )
+ {
+ try
+ {
+ overallDistributedBuildQueue.addToDistributedBuildQueue( task );
+ }
+ catch ( TaskQueueException e )
+ {
+ log.error( "Error while enqueuing prepare build task", e );
+ throw new ContinuumException( "Error occurred while enqueuing prepare build task", e );
+ }
+ }
+ }
- for ( BuildAgentConfiguration agent : agents )
+ public void removeDistributedBuildQueueOfAgent( String buildAgentUrl )
+ throws ContinuumException
+ {
+ if ( overallDistributedBuildQueues.containsKey( buildAgentUrl ) )
{
- if ( agent.isEnabled() && !taskQueueExecutors.containsKey( agent.getUrl() ) )
+ List<PrepareBuildProjectsTask> tasks = null;
+
+ synchronized( overallDistributedBuildQueues )
{
+ OverallDistributedBuildQueue overallDistributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
+
try
{
- SlaveBuildAgentTransportClient client =
- new SlaveBuildAgentTransportClient( new URL( agent.getUrl() ) );
-
- if ( client.ping() )
+ if ( overallDistributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask() != null )
{
- log.info( "agent is enabled, add TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
- addTaskQueueExecutor( agent.getUrl() );
+ log.error( "Unable to remove build agent because it is currently being used" );
+ throw new ContinuumException( "Unable to remove build agent because it is currently being used" );
}
- else
+
+ tasks = overallDistributedBuildQueue.getProjectsInQueue();
+
+ overallDistributedBuildQueue.getDistributedBuildQueue().removeAll( tasks );
+
+ ( (ThreadedDistributedBuildTaskQueueExecutor) overallDistributedBuildQueue.getDistributedBuildTaskQueueExecutor() ).stop();
+
+ container.release( overallDistributedBuildQueue );
+
+ log.info( "remove distributed build queue for build agent '" + buildAgentUrl + "'" );
+ }
+ catch ( TaskQueueException e )
+ {
+ log.error( "Error occurred while removing build agent " + buildAgentUrl, e );
+ throw new ContinuumException( "Error occurred while removing build agent " + buildAgentUrl, e );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ log.error( "Error occurred while removing build agent " + buildAgentUrl, e );
+ throw new ContinuumException( "Error occurred while removing build agent " + buildAgentUrl, e );
+ }
+ catch ( StoppingException e )
+ {
+ log.error( "Error occurred while removing build agent " + buildAgentUrl, e );
+ throw new ContinuumException( "Error occurred while removing build agent " + buildAgentUrl, e );
+ }
+ }
+ }
+ }
+
+ public Map<String, List<PrepareBuildProjectsTask>> getProjectsInPrepareBuildQueue()
+ throws ContinuumException
+ {
+ Map<String, List<PrepareBuildProjectsTask>> map = new HashMap<String, List<PrepareBuildProjectsTask>>();
+
+ synchronized( overallDistributedBuildQueues )
+ {
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ List<PrepareBuildProjectsTask> tasks = new ArrayList<PrepareBuildProjectsTask>();
+
+ try
+ {
+ SlaveBuildAgentTransportClient client =
+ new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ List<Map<String, Object>> projects = client.getProjectsInPrepareBuildQueue();
+
+ for ( Map<String, Object> context : projects )
{
- log.info( "unable to ping build agent '" + agent.getUrl() + "'" );
+ tasks.add( getPrepareBuildProjectsTask( context ) );
}
+
+ map.put( buildAgentUrl, tasks );
}
catch ( MalformedURLException e )
{
- // do not throw exception, just log it
- log.info( "Invalid build agent URL " + agent.getUrl() + ", not creating task queue executor" );
+ throw new ContinuumException( "Invalid build agent url: " + buildAgentUrl );
}
catch ( Exception e )
{
- agent.setEnabled( false );
- log.info( "unable to ping build agent '" + agent.getUrl() + "': " +
- ContinuumUtils.throwableToString( e ) );
+ throw new ContinuumException( "Error while retrieving projects in prepare build queue", e );
}
}
- else if ( !agent.isEnabled() && taskQueueExecutors.containsKey( agent.getUrl() ) )
- {
- log.info( "agent is disabled, remove TaskQueueExecutor for build agent '" + agent.getUrl() + "'" );
- removeAgentFromTaskQueueExecutor( agent.getUrl() );
- }
}
+
+ return map;
}
- public void removeAgentFromTaskQueueExecutor( String buildAgentUrl )
+ public Map<String, PrepareBuildProjectsTask> getProjectsCurrentlyPreparingBuild()
throws ContinuumException
{
- log.info( "remove TaskQueueExecutor for build agent '" + buildAgentUrl + "'" );
- ThreadedDistributedBuildTaskQueueExecutor executor =
- (ThreadedDistributedBuildTaskQueueExecutor) taskQueueExecutors.get( buildAgentUrl );
+ Map<String, PrepareBuildProjectsTask> map = new HashMap<String, PrepareBuildProjectsTask>();
- if ( executor == null )
+ synchronized( overallDistributedBuildQueues )
{
- return;
- }
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ try
+ {
+ SlaveBuildAgentTransportClient client =
+ new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ Map<String, Object> project = client.getProjectCurrentlyPreparingBuild();
- try
- {
- executor.stop();
- container.release( executor );
- }
- catch ( StoppingException e )
- {
- throw new ContinuumException( "Error while stopping task queue executor", e );
+ if ( !project.isEmpty() )
+ {
+ map.put( buildAgentUrl, getPrepareBuildProjectsTask( project ) );
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new ContinuumException( "Invalid build agent url: " + buildAgentUrl );
+ }
+ catch ( Exception e )
+ {
+ throw new ContinuumException( "Error retrieving projects currently preparing build in " + buildAgentUrl, e );
+ }
+ }
}
- catch ( ComponentLifecycleException e )
+ return map;
+ }
+
+ public Map<String, BuildProjectTask> getProjectsCurrentlyBuilding()
+ throws ContinuumException
+ {
+ Map<String, BuildProjectTask> map = new HashMap<String, BuildProjectTask>();
+
+ synchronized( overallDistributedBuildQueues )
{
- throw new ContinuumException( "Error while releasing task queue executor from container", e );
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ try
+ {
+ SlaveBuildAgentTransportClient client =
+ new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ Map<String, Object> project = client.getProjectCurrentlyBuilding();
+
+ if ( !project.isEmpty() )
+ {
+ map.put( buildAgentUrl, getBuildProjectTask( project ) );
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new ContinuumException( "Invalid build agent url: " + buildAgentUrl );
+ }
+ catch ( Exception e )
+ {
+ throw new ContinuumException( "Error retrieving projects currently building in " + buildAgentUrl, e );
+ }
+ }
}
- taskQueueExecutors.remove( buildAgentUrl );
+ return map;
}
- public boolean isBuildAgentBusy( String buildAgentUrl )
+ public Map<String, List<BuildProjectTask>> getProjectsInBuildQueue()
+ throws ContinuumException
{
- DistributedBuildTaskQueueExecutor executor = taskQueueExecutors.get( buildAgentUrl );
+ Map<String, List<BuildProjectTask>> map = new HashMap<String, List<BuildProjectTask>>();
- if ( executor != null && executor.getCurrentTask() != null )
+ synchronized( overallDistributedBuildQueues )
{
- log.info( "build agent '" + buildAgentUrl + "' is busy" );
- return true;
- }
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ List<BuildProjectTask> tasks = new ArrayList<BuildProjectTask>();
+
+ try
+ {
+ SlaveBuildAgentTransportClient client =
+ new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ List<Map<String, Object>> projects = client.getProjectsInBuildQueue();
+
+ for ( Map<String, Object> context : projects )
+ {
+ tasks.add( getBuildProjectTask( context ) );
+ }
- log.info( "build agent '" + buildAgentUrl + "' is not busy" );
- return false;
+ map.put( buildAgentUrl, tasks );
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new ContinuumException( "Invalid build agent url: " + buildAgentUrl );
+ }
+ catch ( Exception e )
+ {
+ throw new ContinuumException( "Error while retrieving projects in build queue", e );
+ }
+ }
+ }
+ return map;
}
- private void addTaskQueueExecutor( String url )
+ public void removeFromDistributedBuildQueue( int projectGroupId, int scmRootId )
throws ContinuumException
{
try
{
- DistributedBuildTaskQueueExecutor taskQueueExecutor = (DistributedBuildTaskQueueExecutor) container.
- lookup( DistributedBuildTaskQueueExecutor.class, "distributed-build-project" );
- taskQueueExecutor.setBuildAgentUrl( url );
- taskQueueExecutors.put( url, taskQueueExecutor );
+ OverallDistributedBuildQueue distributedBuildQueue = getOverallDistributedBuildQueueByGroupAndScmRoot( projectGroupId, scmRootId );
+
+ if ( distributedBuildQueue != null )
+ {
+ distributedBuildQueue.removeFromDistributedBuildQueue( projectGroupId, scmRootId );
+ }
}
- catch ( ComponentLookupException e )
+ catch ( TaskQueueException e )
{
- throw new ContinuumException( "Unable to lookup TaskQueueExecutor for distributed-build-project", e );
+ log.error( "Error occurred while removing projectGroupId=" + projectGroupId +
+ " scmRootId=" + scmRootId + " from distributed build queue", e );
+ throw new ContinuumException( "Error occurred while removing projectGroupId=" + projectGroupId +
+ " scmRootId=" + scmRootId + " from distributed build queue", e );
}
}
- public void cancelDistributedBuild( String buildAgentUrl, int projectGroupId, String scmRootAddress )
+ public void removeFromDistributedBuildQueue( int[] hashCodes )
throws ContinuumException
{
- DistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( buildAgentUrl );
+ for ( int i = 0; i < hashCodes.length; i++ )
+ {
+ try
+ {
+ OverallDistributedBuildQueue distributedBuildQueue = getOverallDistributedBuildQueueByHashCode( hashCodes[i] );
+
+ distributedBuildQueue.removeFromDistributedBuildQueueByHashCode( hashCodes[i] );
+ }
+ catch ( TaskQueueException e )
+ {
+ log.error( "Error occurred while removing projects from distributed build queue", e );
+ throw new ContinuumException( "Error occcurred while removing projects from distributed build queue", e );
+ }
+ }
+ }
+
+ public boolean isBuildAgentBusy( String buildAgentUrl )
+ {
+ synchronized ( overallDistributedBuildQueues )
+ {
+ OverallDistributedBuildQueue overallDistributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
+
+ if ( overallDistributedBuildQueue != null &&
+ overallDistributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask() != null )
+ {
+ log.info( "build agent '" + buildAgentUrl + "' is busy" );
+ return true;
+ }
+
+ log.info( "build agent '" + buildAgentUrl + "' is not busy" );
+ return false;
+ }
+ }
- if ( taskQueueExecutor != null )
+ public void cancelDistributedBuild( String buildAgentUrl, int projectGroupId, int scmRootId )
+ throws ContinuumException
+ {
+ synchronized ( overallDistributedBuildQueues )
{
- if ( taskQueueExecutor.getCurrentTask() != null )
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
+
+ if ( distributedBuildQueue != null )
{
- if ( taskQueueExecutor.getCurrentTask() instanceof PrepareBuildProjectsTask )
+ if ( distributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask() != null )
{
- PrepareBuildProjectsTask currentTask = (PrepareBuildProjectsTask) taskQueueExecutor.getCurrentTask()
- ;
+ PrepareBuildProjectsTask task = (PrepareBuildProjectsTask)
+ distributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask();
- if ( currentTask.getProjectGroupId() == projectGroupId &&
- currentTask.getScmRootAddress().equals( scmRootAddress ) )
+ if ( task.getProjectGroupId() == projectGroupId &&
+ task.getProjectScmRootId() == scmRootId )
{
- log.info( "cancelling task for project group " + projectGroupId + " with scm root address " +
- scmRootAddress );
- taskQueueExecutor.cancelTask( currentTask );
+ log.info( "Cancelling task for projectGroupId=" + projectGroupId + " scmRootId=" + scmRootId );
+ distributedBuildQueue.getDistributedBuildTaskQueueExecutor().cancelTask( task );
try
{
@@ -323,182 +529,85 @@
}
else
{
- log.info( "current task not for project group " + projectGroupId + " with scm root address " +
- scmRootAddress );
+ log.info( "current task not for project group " + projectGroupId + " with scm root id " + scmRootId );
}
}
else
{
- log.info( "current task not a prepare build projects task, not cancelling" );
+ log.info( "no current task in build agent '" + buildAgentUrl + "'" );
}
}
else
{
- log.info( "no current task in build agent '" + buildAgentUrl + "'" );
+ log.info( "no distributed build queue for build agent '" + buildAgentUrl + "'" );
}
}
- else
- {
- log.info( "no task queue executor defined for build agent '" + buildAgentUrl + "'" );
- }
}
- public void updateBuildResult( Map<String, Object> context )
+ public Map<String, Object> getBuildResult( int projectId )
throws ContinuumException
{
+ Map<String, Object> map = new HashMap<String, Object>();
+
+ String buildAgentUrl = getBuildAgent( projectId );
+
+ if ( buildAgentUrl == null )
+ {
+ return null;
+ }
+
try
{
- int projectId = ContinuumBuildConstant.getProjectId( context );
- int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( context );
-
- log.info( "update build result of project '" + projectId + "'" );
-
- Project project = projectDao.getProjectWithAllDetails( projectId );
- BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
-
- BuildResult oldBuildResult =
- buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
-
- int buildNumber;
-
- if ( ContinuumBuildConstant.getBuildState( context ) == ContinuumProjectState.OK )
- {
- buildNumber = project.getBuildNumber() + 1;
- }
- else
- {
- buildNumber = project.getBuildNumber();
- }
-
- // ----------------------------------------------------------------------
- // Make the buildResult
- // ----------------------------------------------------------------------
-
- BuildResult buildResult = convertMapToBuildResult( context );
-
- if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
+ SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+
+ Map<String, Object> result = client.getBuildResult( projectId );
+
+ if ( result != null )
{
+ int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( result );
+
+ Project project = projectDao.getProjectWithAllDetails( projectId );
+ BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
+
+ BuildResult oldBuildResult =
+ buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
+
+ BuildResult buildResult = distributedBuildUtil.convertMapToBuildResult( result );
buildResult.setBuildDefinition( buildDefinition );
- buildResult.setBuildNumber( buildNumber );
- buildResult.setModifiedDependencies( getModifiedDependencies( oldBuildResult, context ) );
- buildResult.setScmResult( getScmResult( context ) );
-
- Date date = ContinuumBuildConstant.getLatestUpdateDate( context );
- if ( date != null )
- {
- buildResult.setLastChangedDate( date.getTime() );
- }
- else if ( oldBuildResult != null )
- {
- buildResult.setLastChangedDate( oldBuildResult.getLastChangedDate() );
- }
-
- buildResultDao.addBuildResult( project, buildResult );
-
- project.setOldState( project.getState() );
- project.setState( ContinuumBuildConstant.getBuildState( context ) );
- project.setBuildNumber( buildNumber );
- project.setLatestBuildId( buildResult.getId() );
- }
- else
- {
- project.setState( project.getOldState() );
- project.setOldState( 0 );
- }
-
- projectDao.updateProject( project );
-
- File buildOutputFile = configurationService.getBuildOutputFile( buildResult.getId(), project.getId() );
-
- FileWriter fstream = new FileWriter( buildOutputFile );
- BufferedWriter out = new BufferedWriter( fstream );
- out.write( ContinuumBuildConstant.getBuildOutput( context ) == null ? ""
- : ContinuumBuildConstant.getBuildOutput( context ) );
- out.close();
-
- if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
- {
- notifierDispatcher.buildComplete( project, buildDefinition, buildResult );
+ buildResult.setBuildNumber( project.getBuildNumber() + 1 );
+ buildResult.setModifiedDependencies( distributedBuildUtil.getModifiedDependencies( oldBuildResult, result ) );
+ buildResult.setScmResult( distributedBuildUtil.getScmResult( result ) );
+
+ String buildOutput = ContinuumBuildConstant.getBuildOutput( result );
+
+ map.put( ContinuumBuildConstant.KEY_BUILD_RESULT, buildResult );
+ map.put( ContinuumBuildConstant.KEY_BUILD_OUTPUT, buildOutput );
}
}
- catch ( ContinuumStoreException e )
- {
- throw new ContinuumException( "Error while updating build result for project", e );
- }
- catch ( ConfigurationException e )
+ catch ( MalformedURLException e )
{
- throw new ContinuumException( "Error retrieving build output file", e );
+ throw new ContinuumException( "Invalid build agent URL '" + buildAgentUrl + "'" );
}
- catch ( IOException e )
+ catch ( Exception e )
{
- throw new ContinuumException( "Error while writing build output to file", e );
+ throw new ContinuumException( "Error while retrieving build result for project" + projectId, e );
}
+
+ return map;
}
- public void prepareBuildFinished( Map<String, Object> context )
+ public List<Installation> getAvailableInstallations( String buildAgentUrl )
throws ContinuumException
{
- int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
- String scmRootAddress = ContinuumBuildConstant.getScmRootAddress( context );
-
+ List<Installation> installations = new ArrayList<Installation>();
+
try
{
- ProjectScmRoot scmRoot =
- projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroupId, scmRootAddress );
-
- String error = ContinuumBuildConstant.getScmError( context );
-
- if ( StringUtils.isEmpty( error ) )
- {
- scmRoot.setState( ContinuumProjectState.UPDATED );
- }
- else
- {
- scmRoot.setState( ContinuumProjectState.ERROR );
- scmRoot.setError( error );
- }
-
- projectScmRootDao.updateProjectScmRoot( scmRoot );
-
- notifierDispatcher.prepareBuildComplete( scmRoot );
- }
- catch ( ContinuumStoreException e )
- {
- throw new ContinuumException( "Error while updating project scm root '" + scmRootAddress + "'", e );
- }
- }
-
- public Map<String, PrepareBuildProjectsTask> getDistributedBuildProjects()
- {
- Map<String, PrepareBuildProjectsTask> map = new HashMap<String, PrepareBuildProjectsTask>();
-
- for ( String url : taskQueueExecutors.keySet() )
- {
- DistributedBuildTaskQueueExecutor taskQueueExecutor = taskQueueExecutors.get( url );
-
- if ( taskQueueExecutor.getCurrentTask() != null )
- {
- PrepareBuildProjectsTask task = (PrepareBuildProjectsTask) taskQueueExecutor.getCurrentTask();
-
- map.put( url, task );
- }
- }
-
- return map;
- }
-
- public List<Installation> getAvailableInstallations( String buildAgentUrl )
- throws ContinuumException
- {
- List<Installation> installations = new ArrayList<Installation>();
-
- try
- {
- SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
-
- List<Map<String, String>> installationsList = client.getAvailableInstallations();
-
- for ( Map context : installationsList )
+ SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+
+ List<Map<String, String>> installationsList = client.getAvailableInstallations();
+
+ for ( Map context : installationsList )
{
Installation installation = new Installation();
installation.setName( ContinuumBuildConstant.getInstallationName( context ) );
@@ -507,7 +616,7 @@
installation.setVarValue( ContinuumBuildConstant.getInstallationVarValue( context ) );
installations.add( installation );
}
-
+
return installations;
}
catch ( Exception e )
@@ -516,202 +625,27 @@
}
}
- public void startProjectBuild( int projectId )
- throws ContinuumException
- {
- try
- {
- Project project = projectDao.getProject( projectId );
- project.setState( ContinuumProjectState.BUILDING );
- projectDao.updateProject( project );
- }
- catch ( ContinuumStoreException e )
- {
- log.error( "Error while updating project's state", e );
- throw new ContinuumException( "Error while updating project's state", e );
- }
- }
-
- public void startPrepareBuild( Map<String, Object> context )
- throws ContinuumException
- {
- try
- {
- int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
- String scmRootAddress = ContinuumBuildConstant.getScmRootAddress( context );
-
- ProjectScmRoot scmRoot =
- projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroupId, scmRootAddress );
- scmRoot.setOldState( scmRoot.getState() );
- scmRoot.setState( ContinuumProjectState.UPDATING );
- projectScmRootDao.updateProjectScmRoot( scmRoot );
- }
- catch ( ContinuumStoreException e )
- {
- log.error( "Error while updating project scm root's state", e );
- throw new ContinuumException( "Error while updating project scm root's state", e );
- }
- }
-
- public Map<String, Object> getBuildResult( int projectId )
- throws ContinuumException
- {
- Map<String, Object> map = new HashMap<String, Object>();
-
- String buildAgentUrl = getBuildAgent( projectId );
-
- if ( buildAgentUrl == null )
- {
- return null;
- }
-
- try
- {
- SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
-
- Map<String, Object> result = client.getBuildResult( projectId );
-
- if ( result != null )
- {
- int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( result );
-
- Project project = projectDao.getProjectWithAllDetails( projectId );
- BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
-
- BuildResult oldBuildResult =
- buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
-
- BuildResult buildResult = convertMapToBuildResult( result );
- buildResult.setBuildDefinition( buildDefinition );
- buildResult.setBuildNumber( project.getBuildNumber() + 1 );
- buildResult.setModifiedDependencies( getModifiedDependencies( oldBuildResult, result ) );
- buildResult.setScmResult( getScmResult( result ) );
-
- String buildOutput = ContinuumBuildConstant.getBuildOutput( result );
-
- map.put( ContinuumBuildConstant.KEY_BUILD_RESULT, buildResult );
- map.put( ContinuumBuildConstant.KEY_BUILD_OUTPUT, buildOutput );
- }
- }
- catch ( MalformedURLException e )
- {
- throw new ContinuumException( "Invalid build agent URL '" + buildAgentUrl + "'" );
- }
- catch ( Exception e )
- {
- throw new ContinuumException( "Error while retrieving build result for project" + projectId, e );
- }
-
- return map;
- }
-
- public Map<String, String> getEnvironments( int buildDefinitionId, String installationType )
- throws ContinuumException
- {
- BuildDefinition buildDefinition;
-
- try
- {
- buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
- }
- catch ( ContinuumStoreException e )
- {
- throw new ContinuumException( "Failed to retrieve build definition: " + buildDefinitionId, e );
- }
-
- Profile profile = buildDefinition.getProfile();
- if ( profile == null )
- {
- return Collections.EMPTY_MAP;
- }
- Map<String, String> envVars = new HashMap<String, String>();
- String javaHome = getJavaHomeValue( buildDefinition );
- if ( !StringUtils.isEmpty( javaHome ) )
- {
- envVars.put( installationService.getEnvVar( InstallationService.JDK_TYPE ), javaHome );
- }
- Installation builder = profile.getBuilder();
- if ( builder != null )
- {
- envVars.put( installationService.getEnvVar( installationType ), builder.getVarValue() );
- }
- envVars.putAll( getEnvironmentVariables( buildDefinition ) );
- return envVars;
- }
-
- public void updateProject( Map<String, Object> context )
- throws ContinuumException
- {
- try
- {
- Project project = projectDao.getProject( ContinuumBuildConstant.getProjectId( context ) );
-
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getGroupId( context ) ) )
- {
- project.setGroupId( ContinuumBuildConstant.getGroupId( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getArtifactId( context ) ) )
- {
- project.setArtifactId( ContinuumBuildConstant.getArtifactId( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getVersion( context ) ) )
- {
- project.setVersion( ContinuumBuildConstant.getVersion( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectName( context ) ) )
- {
- project.setName( ContinuumBuildConstant.getProjectName( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectDescription( context ) ) )
- {
- project.setDescription( ContinuumBuildConstant.getProjectDescription( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getProjectUrl( context ) ) )
- {
- project.setUrl( ContinuumBuildConstant.getProjectUrl( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getScmUrl( context ) ) )
- {
- project.setScmUrl( ContinuumBuildConstant.getScmUrl( context ) );
- }
- if ( StringUtils.isNotBlank( ContinuumBuildConstant.getScmTag( context ) ) )
- {
- project.setScmTag( ContinuumBuildConstant.getScmTag( context ) );
- }
- project.setParent( getProjectParent( context ) );
- project.setDependencies( getProjectDependencies( context ) );
- project.setDevelopers( getProjectDevelopers( context ) );
- project.setNotifiers( getProjectNotifiers( context ) );
-
- projectDao.updateProject( project );
- }
- catch ( ContinuumStoreException e )
- {
- throw new ContinuumException( "Unable to update project from working copy", e );
- }
- }
-
public String generateWorkingCopyContent( int projectId, String directory, String baseUrl, String imageBaseUrl )
throws ContinuumException
{
BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId );
-
+
if ( buildResult != null )
{
String buildAgentUrl = buildResult.getBuildUrl();
-
+
if ( buildAgentUrl == null )
{
return "";
}
-
+
try
{
if ( directory == null )
{
directory = "";
}
-
+
SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
return client.generateWorkingCopyContent( projectId, directory, baseUrl, imageBaseUrl );
}
@@ -726,21 +660,21 @@
}
return "";
}
-
+
public String getFileContent( int projectId, String directory, String filename )
throws ContinuumException
{
BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId );
-
+
if ( buildResult != null )
{
String buildAgentUrl = buildResult.getBuildUrl();
-
+
if ( buildAgentUrl == null )
{
return "";
}
-
+
try
{
SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
@@ -758,329 +692,159 @@
return "";
}
- public boolean shouldBuild( Map<String, Object> context )
+ private String getBuildAgent( int projectId )
+ throws ContinuumException
{
- try
+ synchronized( overallDistributedBuildQueues )
{
- int projectId = ContinuumBuildConstant.getProjectId( context );
-
- int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( context );
-
- int trigger = ContinuumBuildConstant.getTrigger( context );
-
- Project project = projectDao.getProjectWithAllDetails( projectId );
-
- BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
-
- BuildResult oldBuildResult =
- buildResultDao.getLatestBuildResultForBuildDefinition( projectId, buildDefinitionId );
-
- List<ProjectDependency> modifiedDependencies = getModifiedDependencies( oldBuildResult, context );
-
- List<ChangeSet> changes = getScmChanges( context );
-
- if ( buildDefinition.isBuildFresh() )
- {
- log.info( "FreshBuild configured, building" );
- return true;
- }
- if ( buildDefinition.isAlwaysBuild() )
- {
- log.info( "AlwaysBuild configured, building" );
- return true;
- }
- if ( oldBuildResult == null )
- {
- log.info( "The project was never be built with the current build definition, building" );
- return true;
- }
-
- //CONTINUUM-1428
- if ( project.getOldState() == ContinuumProjectState.ERROR ||
- oldBuildResult.getState() == ContinuumProjectState.ERROR )
- {
- log.info( "Latest state was 'ERROR', building" );
- return true;
- }
-
- if ( trigger == ContinuumProjectState.TRIGGER_FORCED )
- {
- log.info( "The project build is forced, building" );
- return true;
- }
-
- Date date = ContinuumBuildConstant.getLatestUpdateDate( context );
- if ( date != null && oldBuildResult.getLastChangedDate() >= date.getTime() )
- {
- log.info( "No changes found,not building" );
- return false;
- }
- else if ( date != null && changes.isEmpty() )
- {
- // fresh checkout from build agent that's why changes is empty
- log.info( "Changes found in the current project, building" );
- return true;
- }
-
- boolean shouldBuild = false;
-
- boolean allChangesUnknown = true;
-
- if ( project.getOldState() != ContinuumProjectState.NEW &&
- project.getOldState() != ContinuumProjectState.CHECKEDOUT &&
- project.getState() != ContinuumProjectState.NEW &&
- project.getState() != ContinuumProjectState.CHECKEDOUT )
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
{
- // Check SCM changes
- allChangesUnknown = checkAllChangesUnknown( changes );
-
- if ( allChangesUnknown )
+ OverallDistributedBuildQueue overallDistributedBuildQueue =
+ overallDistributedBuildQueues.get( buildAgentUrl );
+
+ if ( overallDistributedBuildQueue != null )
{
- if ( !changes.isEmpty() )
+ PrepareBuildProjectsTask task =
+ (PrepareBuildProjectsTask) overallDistributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask();
+
+ for ( Integer id : task.getProjectsBuildDefinitionsMap().keySet() )
{
- log.info(
- "The project was not built because all changes are unknown (maybe local modifications or ignored files not defined in your SCM tool." );
- }
- else
- {
- log.info(
- "The project was not built because no changes were detected in sources since the last build." );
+ if ( projectId == id )
+ {
+ return buildAgentUrl;
+ }
}
}
-
- // Check dependencies changes
- if ( modifiedDependencies != null && !modifiedDependencies.isEmpty() )
- {
- log.info( "Found dependencies changes, building" );
- shouldBuild = true;
- }
- }
-
- // Check changes
- if ( !shouldBuild && ( ( !allChangesUnknown && !changes.isEmpty() ) ||
- project.getExecutorId().equals( ContinuumBuildExecutorConstants.MAVEN_TWO_BUILD_EXECUTOR ) ) )
- {
- shouldBuild = shouldBuild( changes, buildDefinition, project, getMavenProjectVersion( context ),
- getMavenProjectModules( context ) );
- }
-
- if ( shouldBuild )
- {
- log.info( "Changes found in the current project, building" );
}
- else
- {
- log.info( "No changes in the current project, not building" );
- }
-
- return shouldBuild;
- }
- catch ( ContinuumStoreException e )
- {
- log.error( "Failed to determine if project should build", e );
- }
- catch ( ContinuumException e )
- {
- log.error( "Failed to determine if project should build", e );
}
-
- return false;
+
+ return null;
}
- private boolean shouldBuild( List<ChangeSet> changes, BuildDefinition buildDefinition, Project project,
- String mavenProjectVersion, List<String> mavenProjectModules )
+ private void createDistributedBuildQueueForAgent( String buildAgentUrl )
+ throws ComponentLookupException
{
- //Check if it's a recursive build
- boolean isRecursive = false;
- if ( StringUtils.isNotEmpty( buildDefinition.getArguments() ) )
+ if ( !overallDistributedBuildQueues.containsKey( buildAgentUrl ) )
{
- isRecursive = buildDefinition.getArguments().indexOf( "-N" ) < 0 &&
- buildDefinition.getArguments().indexOf( "--non-recursive" ) < 0;
- }
+ OverallDistributedBuildQueue overallDistributedBuildQueue =
+ (OverallDistributedBuildQueue) container.lookup( OverallDistributedBuildQueue.class );
+ overallDistributedBuildQueue.setBuildAgentUrl( buildAgentUrl );
+ overallDistributedBuildQueue.getDistributedBuildTaskQueueExecutor().setBuildAgentUrl( buildAgentUrl );
- if ( isRecursive && changes != null && !changes.isEmpty() )
- {
- if ( log.isInfoEnabled() )
- {
- log.info( "recursive build and changes found --> building" );
- }
- return true;
- }
-
- if ( !project.getVersion().equals( mavenProjectVersion ) )
- {
- log.info( "Found changes in project's version ( maybe project was recently released ), building" );
- return true;
+ overallDistributedBuildQueues.put( buildAgentUrl, overallDistributedBuildQueue );
}
+ }
- if ( changes == null || changes.isEmpty() )
+ private OverallDistributedBuildQueue getOverallDistributedBuildQueueByGroupAndScmRoot( int projectGroupId, int scmRootId )
+ throws ContinuumException
+ {
+ synchronized( overallDistributedBuildQueues )
{
- if ( log.isInfoEnabled() )
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
{
- log.info( "Found no changes, not building" );
- }
- return false;
- }
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
- //check if changes are only in sub-modules or not
- List<ChangeFile> files = new ArrayList<ChangeFile>();
- for ( ChangeSet changeSet : changes )
- {
- files.addAll( changeSet.getFiles() );
- }
-
- int i = 0;
- while ( i <= files.size() - 1 )
- {
- ChangeFile file = files.get( i );
- if ( log.isDebugEnabled() )
- {
- log.debug( "changeFile.name " + file.getName() );
- log.debug( "check in modules " + mavenProjectModules );
- }
- boolean found = false;
- if ( mavenProjectModules != null )
- {
- for ( String module : mavenProjectModules )
+ try
{
- if ( file.getName().indexOf( module ) >= 0 )
+ for ( PrepareBuildProjectsTask task : distributedBuildQueue.getProjectsInQueue() )
{
- if ( log.isDebugEnabled() )
+ if ( task.getProjectGroupId() == projectGroupId && task.getProjectScmRootId() == scmRootId )
{
- log.debug( "changeFile.name " + file.getName() + " removed because in a module" );
+ return distributedBuildQueue;
}
- files.remove( file );
- found = true;
- break;
- }
- if ( log.isDebugEnabled() )
- {
- log.debug( "not removing file " + file.getName() + " not in module " + module );
}
}
- }
- if ( !found )
- {
- i++;
- }
- }
-
- boolean shouldBuild = !files.isEmpty();
-
- if ( !shouldBuild )
- {
- log.info( "Changes are only in sub-modules." );
- }
-
- if ( log.isDebugEnabled() )
- {
- log.debug( "shoulbuild = " + shouldBuild );
- }
-
- return shouldBuild;
- }
-
- private boolean checkAllChangesUnknown( List<ChangeSet> changes )
- {
- for ( ChangeSet changeSet : changes )
- {
- List<ChangeFile> changeFiles = changeSet.getFiles();
-
- for ( ChangeFile changeFile : changeFiles )
- {
- if ( !"unknown".equalsIgnoreCase( changeFile.getStatus() ) )
+ catch ( TaskQueueException e )
{
- return false;
+ log.error( "Error occurred while retrieving distributed build queue of projectGroupId=" + projectGroupId + " scmRootId=" + scmRootId, e );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue of group", e );
}
}
}
- return true;
+ return null;
}
- private List<ProjectDependency> getModifiedDependencies( BuildResult oldBuildResult, Map<String, Object> context )
+ private OverallDistributedBuildQueue getOverallDistributedBuildQueueByGroup( int projectGroupId )
throws ContinuumException
{
- if ( oldBuildResult == null )
- {
- return null;
- }
-
- try
+ synchronized( overallDistributedBuildQueues )
{
- Project project = projectDao.getProjectWithAllDetails( ContinuumBuildConstant.getProjectId( context ) );
- List<ProjectDependency> dependencies = project.getDependencies();
-
- if ( dependencies == null )
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
{
- dependencies = new ArrayList<ProjectDependency>();
- }
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
- if ( project.getParent() != null )
- {
- dependencies.add( project.getParent() );
- }
-
- if ( dependencies.isEmpty() )
- {
- return null;
- }
-
- List<ProjectDependency> modifiedDependencies = new ArrayList<ProjectDependency>();
-
- for ( ProjectDependency dep : dependencies )
- {
- Project dependencyProject =
- projectDao.getProject( dep.getGroupId(), dep.getArtifactId(), dep.getVersion() );
-
- if ( dependencyProject != null )
+ try
{
- List<BuildResult> buildResults =
- buildResultDao.getBuildResultsInSuccessForProject( dependencyProject.getId(),
- oldBuildResult.getEndTime() );
- if ( buildResults != null && !buildResults.isEmpty() )
+
+ for ( PrepareBuildProjectsTask task : distributedBuildQueue.getProjectsInQueue() )
{
- log.debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
- dep.getVersion() );
- modifiedDependencies.add( dep );
+ if ( task.getProjectGroupId() == projectGroupId )
+ {
+ return distributedBuildQueue;
+ }
}
- else
+
+ Task task = distributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask();
+ if ( task != null && ( (PrepareBuildProjectsTask) task ).getProjectGroupId() == projectGroupId )
{
- log.debug( "Dependency not changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
- dep.getVersion() );
+ return distributedBuildQueue;
+ }
+
+ SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+
+ if ( client.isProjectGroupInQueue( projectGroupId ) )
+ {
+ return distributedBuildQueue;
}
}
- else
+ catch ( TaskQueueException e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue of projectGroupId=" + projectGroupId, e );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue of group", e );
+ }
+ catch ( MalformedURLException e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue of projectGroupId=" + projectGroupId +
+ ": Invalid build agent url " + buildAgentUrl );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue of projectGroupId=" + projectGroupId +
+ ": Invalid build agent url " + buildAgentUrl );
+ }
+ catch ( Exception e )
{
- log.debug( "Skip non Continuum project: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
- dep.getVersion() );
+ log.error( "Error occurred while retrieving distributed build queue of projectGroupId=" + projectGroupId, e );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue of group", e );
}
}
-
- return modifiedDependencies;
- }
- catch ( ContinuumStoreException e )
- {
- log.warn( "Can't get the project dependencies", e );
}
return null;
}
- private String getBuildAgent( int projectId )
+ // need to change this
+ private OverallDistributedBuildQueue getOverallDistributedBuildQueueByHashCode( int hashCode )
throws ContinuumException
{
- Map<String, PrepareBuildProjectsTask> map = getDistributedBuildProjects();
-
- for ( String url : map.keySet() )
+ synchronized( overallDistributedBuildQueues )
{
- PrepareBuildProjectsTask task = map.get( url );
-
- for ( Integer id : task.getProjectsBuildDefinitionsMap().keySet() )
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
{
- if ( projectId == id )
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
+
+ try
{
- return url;
+ for ( PrepareBuildProjectsTask task : distributedBuildQueue.getProjectsInQueue() )
+ {
+ if ( task.getHashCode() == hashCode )
+ {
+ return distributedBuildQueue;
+ }
+ }
+ }
+ catch ( TaskQueueException e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue", e );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue", e );
}
}
}
@@ -1088,228 +852,195 @@
return null;
}
- private BuildResult convertMapToBuildResult( Map<String, Object> context )
+ private OverallDistributedBuildQueue getOverallDistributedBuildQueueByAgentGroup( Map<Integer, Integer> projectsAndBuildDefinitionsMap )
+ throws ContinuumException
{
- BuildResult buildResult = new BuildResult();
-
- buildResult.setStartTime( ContinuumBuildConstant.getStartTime( context ) );
- buildResult.setEndTime( ContinuumBuildConstant.getEndTime( context ) );
- buildResult.setError( ContinuumBuildConstant.getBuildError( context ) );
- buildResult.setExitCode( ContinuumBuildConstant.getBuildExitCode( context ) );
- buildResult.setState( ContinuumBuildConstant.getBuildState( context ) );
- buildResult.setTrigger( ContinuumBuildConstant.getTrigger( context ) );
- buildResult.setBuildUrl( ContinuumBuildConstant.getBuildAgentUrl( context ) );
+ OverallDistributedBuildQueue whereToBeQueued = null;
- return buildResult;
- }
+ BuildAgentGroupConfiguration buildAgentGroup = getBuildAgentGroup( projectsAndBuildDefinitionsMap );
- private String getJavaHomeValue( BuildDefinition buildDefinition )
- {
- Profile profile = buildDefinition.getProfile();
- if ( profile == null )
- {
- return null;
- }
- Installation jdk = profile.getJdk();
- if ( jdk == null )
+ if ( buildAgentGroup != null )
{
- return null;
- }
- return jdk.getVarValue();
- }
+ List<BuildAgentConfiguration> buildAgents = buildAgentGroup.getBuildAgents();
- private Map<String, String> getEnvironmentVariables( BuildDefinition buildDefinition )
- {
- Profile profile = buildDefinition.getProfile();
- Map<String, String> envVars = new HashMap<String, String>();
- if ( profile == null )
- {
- return envVars;
- }
- List<Installation> environmentVariables = profile.getEnvironmentVariables();
- if ( environmentVariables.isEmpty() )
- {
- return envVars;
- }
- for ( Installation installation : environmentVariables )
- {
- envVars.put( installation.getVarName(), installation.getVarValue() );
- }
- return envVars;
- }
+ if ( buildAgents != null && buildAgents.size() > 0 )
+ {
+ List<String> buildAgentUrls = new ArrayList<String>();
+
+ for ( BuildAgentConfiguration buildAgent : buildAgents )
+ {
+ buildAgentUrls.add( buildAgent.getUrl() );
+ }
- private List<ChangeSet> getScmChanges( Map<String, Object> context )
- {
- List<ChangeSet> changes = new ArrayList<ChangeSet>();
- List<Map<String, Object>> scmChanges = ContinuumBuildConstant.getScmChanges( context );
+ synchronized( overallDistributedBuildQueues )
+ {
+ int idx = 0;
+ int size = 0;
+
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ if ( ( !buildAgentUrls.isEmpty() && buildAgentUrls.contains( buildAgentUrl ) ) || buildAgentUrls.isEmpty() )
+ {
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
- if ( scmChanges != null )
- {
- for ( Map<String, Object> map : scmChanges )
- {
- ChangeSet changeSet = new ChangeSet();
- changeSet.setAuthor( ContinuumBuildConstant.getChangeSetAuthor( map ) );
- changeSet.setComment( ContinuumBuildConstant.getChangeSetComment( map ) );
- changeSet.setDate( ContinuumBuildConstant.getChangeSetDate( map ) );
- setChangeFiles( changeSet, map );
- changes.add( changeSet );
+ if ( distributedBuildQueue != null )
+ {
+ try
+ {
+ SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ int agentBuildSize = client.getBuildSizeOfAgent();
+
+ if ( idx == 0 )
+ {
+ whereToBeQueued = distributedBuildQueue;
+ size = agentBuildSize;
+
+
+ }
+
+ if ( agentBuildSize < size )
+ {
+ whereToBeQueued = distributedBuildQueue;
+ size = agentBuildSize;
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue: Invalid build agent url " + buildAgentUrl );
+ }
+ catch ( Exception e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue ", e );
+ }
+ }
+ }
+ }
+ }
}
}
-
- return changes;
+ return whereToBeQueued;
}
- private void setChangeFiles( ChangeSet changeSet, Map<String, Object> context )
+ private OverallDistributedBuildQueue getOverallDistributedBuildQueue()
+ throws ContinuumException
{
- List<Map<String, Object>> changeFiles = ContinuumBuildConstant.getChangeSetFiles( context );
+ OverallDistributedBuildQueue whereToBeQueued = null;
- if ( changeFiles != null )
+ synchronized ( overallDistributedBuildQueues )
{
- for ( Map<String, Object> map : changeFiles )
+ if ( overallDistributedBuildQueues.isEmpty() )
{
- ChangeFile changeFile = new ChangeFile();
- changeFile.setName( ContinuumBuildConstant.getChangeFileName( map ) );
- changeFile.setRevision( ContinuumBuildConstant.getChangeFileRevision( map ) );
- changeFile.setStatus( ContinuumBuildConstant.getChangeFileStatus( map ) );
-
- changeSet.addFile( changeFile );
+ log.info( "No distributed build queues are configured for build agents" );
+ return null;
}
- }
- }
-
- private ProjectDependency getProjectParent( Map<String, Object> context )
- {
- Map<String, Object> map = ContinuumBuildConstant.getProjectParent( context );
- if ( map != null && map.size() > 0 )
- {
- ProjectDependency parent = new ProjectDependency();
- parent.setGroupId( ContinuumBuildConstant.getGroupId( map ) );
- parent.setArtifactId( ContinuumBuildConstant.getArtifactId( map ) );
- parent.setVersion( ContinuumBuildConstant.getVersion( map ) );
+ int idx = 0;
+ int size = 0;
- return parent;
- }
-
- return null;
- }
+ for ( String buildAgentUrl : overallDistributedBuildQueues.keySet() )
+ {
+ OverallDistributedBuildQueue distributedBuildQueue = overallDistributedBuildQueues.get( buildAgentUrl );
- private List<ProjectDependency> getProjectDependencies( Map<String, Object> context )
- {
- List<ProjectDependency> projectDependencies = new ArrayList<ProjectDependency>();
+ if ( distributedBuildQueue != null )
+ {
+ try
+ {
+ SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
+ int agentBuildSize = client.getBuildSizeOfAgent();
- List<Map<String, Object>> dependencies = ContinuumBuildConstant.getProjectDependencies( context );
+ if ( idx == 0 )
+ {
+ whereToBeQueued = distributedBuildQueue;
+ size = agentBuildSize;
+ }
- if ( dependencies != null )
- {
- for ( Map<String, Object> map : dependencies )
- {
- ProjectDependency dependency = new ProjectDependency();
- dependency.setGroupId( ContinuumBuildConstant.getGroupId( map ) );
- dependency.setArtifactId( ContinuumBuildConstant.getArtifactId( map ) );
- dependency.setVersion( ContinuumBuildConstant.getVersion( map ) );
+ if ( agentBuildSize < size )
+ {
+ whereToBeQueued = distributedBuildQueue;
+ size = agentBuildSize;
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue: invalid build agent url " + buildAgentUrl );
+ }
+ catch ( Exception e )
+ {
+ log.error( "Error occurred while retrieving distributed build queue", e );
+ throw new ContinuumException( "Error occurred while retrieving distributed build queue", e );
+ }
+ }
- projectDependencies.add( dependency );
+ idx++;
}
}
- return projectDependencies;
+
+ return whereToBeQueued;
}
- private List<ProjectDeveloper> getProjectDevelopers( Map<String, Object> context )
+ private BuildAgentGroupConfiguration getBuildAgentGroup( Map<Integer, Integer> projectsAndBuildDefinitions )
+ throws ContinuumException
{
- List<ProjectDeveloper> projectDevelopers = new ArrayList<ProjectDeveloper>();
-
- List<Map<String, Object>> developers = ContinuumBuildConstant.getProjectDevelopers( context );
- if ( developers != null )
+ if ( projectsAndBuildDefinitions == null )
{
- for ( Map<String, Object> map : developers )
- {
- ProjectDeveloper developer = new ProjectDeveloper();
- developer.setName( ContinuumBuildConstant.getDeveloperName( map ) );
- developer.setEmail( ContinuumBuildConstant.getDeveloperEmail( map ) );
- developer.setScmId( ContinuumBuildConstant.getDeveloperScmId( map ) );
-
- projectDevelopers.add( developer );
- }
+ return null;
}
- return projectDevelopers;
- }
-
- private List<ProjectNotifier> getProjectNotifiers( Map<String, Object> context )
- {
- List<ProjectNotifier> projectNotifiers = new ArrayList<ProjectNotifier>();
-
- List<Map<String, Object>> notifiers = ContinuumBuildConstant.getProjectNotifiers( context );
- if ( notifiers != null )
+ try
{
- for ( Map<String, Object> map : notifiers )
- {
- ProjectNotifier notifier = new ProjectNotifier();
- notifier.setConfiguration( ContinuumBuildConstant.getNotifierConfiguration( map ) );
- notifier.setEnabled( ContinuumBuildConstant.isNotifierEnabled( map ) );
- notifier.setFrom( ContinuumBuildConstant.getNotifierFrom( map ) );
- notifier.setRecipientType( ContinuumBuildConstant.getNotifierRecipientType( map ) );
- notifier.setSendOnError( ContinuumBuildConstant.isNotifierSendOnError( map ) );
- notifier.setSendOnFailure( ContinuumBuildConstant.isNotifierSendOnFailure( map ) );
- notifier.setSendOnScmFailure( ContinuumBuildConstant.isNotifierSendOnScmFailure( map ) );
- notifier.setSendOnSuccess( ContinuumBuildConstant.isNotifierSendOnSuccess( map ) );
- notifier.setSendOnWarning( ContinuumBuildConstant.isNotifierSendOnWarning( map ) );
- notifier.setType( ContinuumBuildConstant.getNotifierType( map ) );
+ List<Project> projects = new ArrayList<Project>();
- projectNotifiers.add( notifier );
+ for ( Integer projectId : projectsAndBuildDefinitions.keySet() )
+ {
+ projects.add( projectDao.getProjectWithDependencies( projectId ) );
}
- }
- return projectNotifiers;
- }
- private ScmResult getScmResult( Map<String, Object> context )
- {
- Map<String, Object> map = ContinuumBuildConstant.getScmResult( context );
+ projects = ProjectSorter.getSortedProjects( projects, null );
- if ( !map.isEmpty() )
- {
- ScmResult scmResult = new ScmResult();
- scmResult.setCommandLine( ContinuumBuildConstant.getScmCommandLine( map ) );
- scmResult.setCommandOutput( ContinuumBuildConstant.getScmCommandOutput( map ) );
- scmResult.setException( ContinuumBuildConstant.getScmException( map ) );
- scmResult.setProviderMessage( ContinuumBuildConstant.getScmProviderMessage( map ) );
- scmResult.setSuccess( ContinuumBuildConstant.isScmSuccess( map ) );
- scmResult.setChanges( getScmChanges( map ) );
+ int buildDefinitionId = projectsAndBuildDefinitions.get( projects.get( 0 ).getId() );
+ BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( buildDefinitionId );
- return scmResult;
- }
+ Profile profile = buildDefinition.getProfile();
- return null;
- }
+ if ( profile != null && !StringUtils.isEmpty( profile.getBuildAgentGroup() ) )
+ {
+ String groupName = profile.getBuildAgentGroup();
- private String getMavenProjectVersion( Map<String, Object> context )
- {
- Map<String, Object> map = ContinuumBuildConstant.getMavenProject( context );
+ BuildAgentGroupConfiguration buildAgentGroup = configurationService.getBuildAgentGroup( groupName );
- if ( !map.isEmpty() )
+ return buildAgentGroup;
+ }
+ }
+ catch ( ContinuumStoreException e )
{
- return ContinuumBuildConstant.getVersion( map );
+ log.error( "Error while getting build agent group", e );
+ throw new ContinuumException( "Error while getting build agent group", e );
}
+ log.info( "profile build agent group is null" );
+
return null;
}
-
- private List<String> getMavenProjectModules( Map<String, Object> context )
+
+ private PrepareBuildProjectsTask getPrepareBuildProjectsTask( Map context )
{
- Map<String, Object> map = ContinuumBuildConstant.getMavenProject( context );
-
- if ( !map.isEmpty() )
- {
- return ContinuumBuildConstant.getProjectModules( map );
- }
+ int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
+ int scmRootId = ContinuumBuildConstant.getScmRootId( context );
+ String scmRootAddress = ContinuumBuildConstant.getScmRootAddress( context );
+ int trigger = ContinuumBuildConstant.getTrigger( context );
- return null;
+ return new PrepareBuildProjectsTask( null, trigger, projectGroupId, null, scmRootAddress, scmRootId );
}
- public Map<String, DistributedBuildTaskQueueExecutor> getTaskQueueExecutors()
+ private BuildProjectTask getBuildProjectTask( Map context )
{
- return taskQueueExecutors;
+ int projectId = ContinuumBuildConstant.getProjectId( context );
+ int buildDefinitionId = ContinuumBuildConstant.getBuildDefinitionId( context );
+ int trigger = ContinuumBuildConstant.getTrigger( context );
+ int projectGroupId = ContinuumBuildConstant.getProjectGroupId( context );
+ String buildDefinitionLabel = ContinuumBuildConstant.getBuildDefinitionLabel( context );
+
+ return new BuildProjectTask( projectId, buildDefinitionId, trigger, null, buildDefinitionLabel, null, projectGroupId );
}
-}
+}
\ No newline at end of file
Added: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java?rev=775693&view=auto
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java (added)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java Sun May 17 16:14:22 2009
@@ -0,0 +1,180 @@
+package org.apache.continuum.builder.distributed.util;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.continuum.builder.utils.ContinuumBuildConstant;
+import org.apache.continuum.dao.BuildResultDao;
+import org.apache.continuum.dao.ProjectDao;
+import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.model.project.BuildResult;
+import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.apache.maven.continuum.model.scm.ChangeFile;
+import org.apache.maven.continuum.model.scm.ChangeSet;
+import org.apache.maven.continuum.model.scm.ScmResult;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @plexus.component role="org.apache.continuum.builder.distributed.util.DistributedBuildUtil"
+ */
+public class DistributedBuildUtil
+{
+ private Logger log = LoggerFactory.getLogger( DistributedBuildUtil.class );
+
+ /**
+ * @plexus.requirement
+ */
+ private ProjectDao projectDao;
+
+ /**
+ * @plexus.requirement
+ */
+ private BuildResultDao buildResultDao;
+
+ public BuildResult convertMapToBuildResult( Map<String, Object> context )
+ {
+ BuildResult buildResult = new BuildResult();
+
+ buildResult.setStartTime( ContinuumBuildConstant.getStartTime( context ) );
+ buildResult.setEndTime( ContinuumBuildConstant.getEndTime( context ) );
+ buildResult.setError( ContinuumBuildConstant.getBuildError( context ) );
+ buildResult.setExitCode( ContinuumBuildConstant.getBuildExitCode( context ) );
+ buildResult.setState( ContinuumBuildConstant.getBuildState( context ) );
+ buildResult.setTrigger( ContinuumBuildConstant.getTrigger( context ) );
+ buildResult.setBuildUrl( ContinuumBuildConstant.getBuildAgentUrl( context ) );
+
+ return buildResult;
+ }
+
+ public List<ProjectDependency> getModifiedDependencies( BuildResult oldBuildResult, Map<String, Object> context )
+ throws ContinuumException
+ {
+ if ( oldBuildResult == null )
+ {
+ return null;
+ }
+
+ try
+ {
+ Project project = projectDao.getProjectWithAllDetails( ContinuumBuildConstant.getProjectId( context ) );
+ List<ProjectDependency> dependencies = project.getDependencies();
+
+ if ( dependencies == null )
+ {
+ dependencies = new ArrayList<ProjectDependency>();
+ }
+
+ if ( project.getParent() != null )
+ {
+ dependencies.add( project.getParent() );
+ }
+
+ if ( dependencies.isEmpty() )
+ {
+ return null;
+ }
+
+ List<ProjectDependency> modifiedDependencies = new ArrayList<ProjectDependency>();
+
+ for ( ProjectDependency dep : dependencies )
+ {
+ Project dependencyProject =
+ projectDao.getProject( dep.getGroupId(), dep.getArtifactId(), dep.getVersion() );
+
+ if ( dependencyProject != null )
+ {
+ List<BuildResult> buildResults =
+ buildResultDao.getBuildResultsInSuccessForProject( dependencyProject.getId(),
+ oldBuildResult.getEndTime() );
+ if ( buildResults != null && !buildResults.isEmpty() )
+ {
+ log.debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
+ dep.getVersion() );
+ modifiedDependencies.add( dep );
+ }
+ else
+ {
+ log.debug( "Dependency not changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
+ dep.getVersion() );
+ }
+ }
+ else
+ {
+ log.debug( "Skip non Continuum project: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
+ dep.getVersion() );
+ }
+ }
+
+ return modifiedDependencies;
+ }
+ catch ( ContinuumStoreException e )
+ {
+ log.warn( "Can't get the project dependencies", e );
+ }
+
+ return null;
+ }
+
+ public ScmResult getScmResult( Map<String, Object> context )
+ {
+ Map<String, Object> map = ContinuumBuildConstant.getScmResult( context );
+
+ if ( !map.isEmpty() )
+ {
+ ScmResult scmResult = new ScmResult();
+ scmResult.setCommandLine( ContinuumBuildConstant.getScmCommandLine( map ) );
+ scmResult.setCommandOutput( ContinuumBuildConstant.getScmCommandOutput( map ) );
+ scmResult.setException( ContinuumBuildConstant.getScmException( map ) );
+ scmResult.setProviderMessage( ContinuumBuildConstant.getScmProviderMessage( map ) );
+ scmResult.setSuccess( ContinuumBuildConstant.isScmSuccess( map ) );
+ scmResult.setChanges( getScmChanges( map ) );
+
+ return scmResult;
+ }
+
+ return null;
+ }
+
+ public List<ChangeSet> getScmChanges( Map<String, Object> context )
+ {
+ List<ChangeSet> changes = new ArrayList<ChangeSet>();
+ List<Map<String, Object>> scmChanges = ContinuumBuildConstant.getScmChanges( context );
+
+ if ( scmChanges != null )
+ {
+ for ( Map<String, Object> map : scmChanges )
+ {
+ ChangeSet changeSet = new ChangeSet();
+ changeSet.setAuthor( ContinuumBuildConstant.getChangeSetAuthor( map ) );
+ changeSet.setComment( ContinuumBuildConstant.getChangeSetComment( map ) );
+ changeSet.setDate( ContinuumBuildConstant.getChangeSetDate( map ) );
+ setChangeFiles( changeSet, map );
+ changes.add( changeSet );
+ }
+ }
+
+ return changes;
+ }
+
+ private void setChangeFiles( ChangeSet changeSet, Map<String, Object> context )
+ {
+ List<Map<String, Object>> changeFiles = ContinuumBuildConstant.getChangeSetFiles( context );
+
+ if ( changeFiles != null )
+ {
+ for ( Map<String, Object> map : changeFiles )
+ {
+ ChangeFile changeFile = new ChangeFile();
+ changeFile.setName( ContinuumBuildConstant.getChangeFileName( map ) );
+ changeFile.setRevision( ContinuumBuildConstant.getChangeFileRevision( map ) );
+ changeFile.setStatus( ContinuumBuildConstant.getChangeFileStatus( map ) );
+
+ changeSet.addFile( changeFile );
+ }
+ }
+ }
+}
Propchange: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision