continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r731555 - in /continuum/branches/continuum-distributed-builds: continuum-api/src/main/java/org/apache/continuum/taskqueue/ continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/ continuum-api/src/main/java/org/apache/maven/cont...
Date Mon, 05 Jan 2009 13:15:35 GMT
Author: ctan
Date: Mon Jan  5 05:15:34 2009
New Revision: 731555

URL: http://svn.apache.org/viewvc?rev=731555&view=rev
Log:
- added remove distributed build task
- added check to see if agent should build the project
- fixed cancel build

Modified:
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/PrepareBuildProjectsTask.java
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
    continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ExecuteBuilderAction.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java
    continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/PrepareBuildProjectsTask.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/PrepareBuildProjectsTask.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/PrepareBuildProjectsTask.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/PrepareBuildProjectsTask.java Mon Jan  5 05:15:34 2009
@@ -17,14 +17,18 @@
 
     private String scmRootAddress;
 
+    private int projectScmRootId;
+
     public PrepareBuildProjectsTask( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger,
-                                     int projectGroupId, String projectGroupName, String scmRootAddress )
+                                     int projectGroupId, String projectGroupName, String scmRootAddress,
+                                     int projectScmRootId )
     {
         this.projectsBuildDefinitionsMap = projectsBuildDefinitionsMap;
         this.trigger = trigger;
         this.projectGroupId = projectGroupId;
         this.projectGroupName = projectGroupName;
         this.scmRootAddress = scmRootAddress;
+        this.projectScmRootId = projectScmRootId;
     }
     
     public long getMaxExecutionTime()
@@ -87,4 +91,9 @@
     {
         this.scmRootAddress = scmRootAddress;
     }
+
+    public int hashCode()
+    {
+        return this.projectGroupId + this.projectScmRootId + this.trigger;
+    }
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/continuum/taskqueue/manager/TaskQueueManager.java Mon Jan  5 05:15:34 2009
@@ -101,6 +101,9 @@
     boolean removeFromBuildingQueue( int projectId, int buildDefinitionId, int trigger, String projectName )
         throws TaskQueueManagerException;
 
+    boolean removeFromDistributedBuildQueue( int projectGroupId, String scmRootAddress )
+        throws TaskQueueManagerException;
+
     boolean removeFromPrepareBuildQueue( int projectGroupId, String scmRootAddress )
         throws TaskQueueManagerException;
 
@@ -158,4 +161,7 @@
      */
     void removeTasksFromCheckoutQueueWithHashCodes( int[] hashCodes )
         throws TaskQueueManagerException;
+
+    void removeTasksFromDistributedBuildQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException;
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Mon Jan  5 05:15:34 2009
@@ -623,6 +623,9 @@
     ProjectScmRoot getProjectScmRootByProject( int projectId )
         throws ContinuumException;
 
+    ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
+        throws ContinuumException;
+
     // ----------------------------------------------------------------------
     // Task Queue Manager
     // ----------------------------------------------------------------------

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java Mon Jan  5 05:15:34 2009
@@ -141,6 +141,7 @@
                 context.put( ContinuumBuildConstant.KEY_PROJECT_NAME, project.getName() );
                 context.put( ContinuumBuildConstant.KEY_EXECUTOR_ID, project.getExecutorId() );
                 context.put( ContinuumBuildConstant.KEY_SCM_URL, project.getScmUrl() );
+                context.put( ContinuumBuildConstant.KEY_PROJECT_STATE, new Integer( project.getState() ) );
 
                 if ( project.getScmUsername() == null )
                 {

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java Mon Jan  5 05:15:34 2009
@@ -347,16 +347,25 @@
             // ----------------------------------------------------------------------
 
             BuildResult buildResult = convertMapToBuildResult( context );
-            buildResult.setBuildDefinition( buildDefinition );
-            buildResult.setBuildNumber( buildNumber );
-            buildResult.setModifiedDependencies( getModifiedDependencies( oldBuildResult, context ) );
             
-            buildResultDao.addBuildResult( project, buildResult );
+            if ( buildResult.getState() != ContinuumProjectState.CANCELLED )
+            {
+                buildResult.setBuildDefinition( buildDefinition );
+                buildResult.setBuildNumber( buildNumber );
+                buildResult.setModifiedDependencies( getModifiedDependencies( oldBuildResult, context ) );
+                
+                buildResultDao.addBuildResult( project, buildResult );
             
-            project.setBuildNumber( buildNumber );
-            project.setLatestBuildId( buildResult.getId() );
-            project.setOldState( project.getState() );
-            project.setState( ContinuumBuildConstant.getBuildState( context ) );
+                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 );
 

Modified: continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java Mon Jan  5 05:15:34 2009
@@ -60,6 +60,8 @@
 
     public static final String KEY_BUILD_RESULT = "build-result";
 
+    public static final String KEY_PROJECT_STATE = "project-state";
+
     public static int getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/taskqueue/manager/DefaultTaskQueueManager.java Mon Jan  5 05:15:34 2009
@@ -527,6 +527,21 @@
         return this.buildQueue.remove( buildProjectTask );
     }
 
+    public boolean removeFromDistributedBuildQueue( int projectGroupId, String scmRootAddress )
+        throws TaskQueueManagerException
+    {
+        List<PrepareBuildProjectsTask> queue = getDistributedBuildProjectsInQueue();
+
+        for ( PrepareBuildProjectsTask task : queue )
+        {
+            if ( task != null && task.getProjectGroupId() == projectGroupId && task.getScmRootAddress().equals( scmRootAddress ) )
+            {
+                return distributedBuildQueue.remove( task );
+            }
+        }
+        return false;
+    }
+
     public boolean removeFromPurgeQueue( int purgeConfigId )
         throws TaskQueueManagerException
     {
@@ -775,4 +790,18 @@
             throw new TaskQueueManagerException( "Unable to lookup current task", e );
         }
     }
+
+    public void removeTasksFromDistributedBuildQueueWithHashCodes( int[] hashCodes )
+        throws TaskQueueManagerException
+    {
+        List<PrepareBuildProjectsTask> queue = getDistributedBuildProjectsInQueue();
+        
+        for ( PrepareBuildProjectsTask task : queue )
+        {
+            if ( ArrayUtils.contains( hashCodes, task.hashCode() ) )
+            {
+                distributedBuildQueue.remove( task );
+            }
+        }
+    }
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java Mon Jan  5 05:15:34 2009
@@ -963,7 +963,8 @@
         projectsBuildDefinitionsMap.put( projectId, buildDef.getId() );
         
         ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
-        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(), scmRoot.getProjectGroup().getId() );
+        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(), 
+                              scmRoot.getProjectGroup().getId(), scmRoot.getId() );
     }
 
     public void buildProject( int projectId, int buildDefinitionId, int trigger )
@@ -987,7 +988,8 @@
         projectsBuildDefinitionsMap.put( projectId, buildDefinitionId );
 
         ProjectScmRoot scmRoot = getProjectScmRootByProject( projectId );
-        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(), scmRoot.getProjectGroup().getId() );
+        prepareBuildProjects( projectsBuildDefinitionsMap, trigger, scmRoot.getScmRootAddress(), 
+                              scmRoot.getProjectGroup().getId(), scmRoot.getId() );
     }
 
     public BuildResult getBuildResult( int buildId )
@@ -1578,7 +1580,7 @@
 
             String url = (String) context.get( CreateProjectsFromMetadataAction.KEY_URL );
             
-            projectScmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
+            projectScmRoot = getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
             
             if ( projectScmRoot == null )
             {
@@ -3195,6 +3197,19 @@
         return null;
     }
 
+    public ProjectScmRoot getProjectScmRootByProjectGroupAndScmRootAddress( int projectGroupId, String scmRootAddress )
+        throws ContinuumException
+    {
+        try
+        {
+            return projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroupId, scmRootAddress );
+        }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Error while retrieving project scm root for " + projectGroupId, e );
+        }
+    }
+
     private void prepareBuildProjects( Collection<Project> projects, List<BuildDefinition> bds,
                                       boolean checkDefaultBuildDefinitionForProject, int trigger )
         throws ContinuumException
@@ -3335,17 +3350,19 @@
     {
         for ( ProjectScmRoot scmRoot : map.keySet() )
         {
-            prepareBuildProjects( map.get( scmRoot ), trigger, scmRoot.getScmRootAddress(), scmRoot.getProjectGroup().getId() );
+            prepareBuildProjects( map.get( scmRoot ), trigger, scmRoot.getScmRootAddress(), 
+                                  scmRoot.getProjectGroup().getId(), scmRoot.getId() );
         }
     }
 
     private void prepareBuildProjects( Map<Integer, Integer> projectsBuildDefinitionsMap, int trigger, 
-                                       String scmRootAddress, int projectGroupId )
+                                       String scmRootAddress, int projectGroupId, int scmRootId )
         throws ContinuumException
     {
         ProjectGroup group = getProjectGroup( projectGroupId );
         PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( projectsBuildDefinitionsMap, trigger,
-                                                                      projectGroupId, group.getName(), scmRootAddress );
+                                                                      projectGroupId, group.getName(), 
+                                                                      scmRootAddress, scmRootId );
 
         try
         {
@@ -3404,7 +3421,7 @@
     {
         try
         {
-            ProjectScmRoot scmRoot = projectScmRootDao.getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
+            ProjectScmRoot scmRoot = getProjectScmRootByProjectGroupAndScmRootAddress( projectGroup.getId(), url );
 
             if ( scmRoot != null )
             {

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java Mon Jan  5 05:15:34 2009
@@ -179,7 +179,9 @@
             context.setProjectGroupId( ContinuumBuildAgentUtil.getProjectGroupId( map ) );
             context.setScmRootAddress( ContinuumBuildAgentUtil.getScmRootAddress( map ) );
             context.setProjectName( ContinuumBuildAgentUtil.getProjectName( map ) );
-            
+            context.setProjectState( ContinuumBuildAgentUtil.getProjectState( map ) );
+            context.setTrigger( ContinuumBuildAgentUtil.getTrigger( map ) );
+
             buildContext.add( context );
         }
 

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ExecuteBuilderAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ExecuteBuilderAction.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ExecuteBuilderAction.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/ExecuteBuilderAction.java Mon Jan  5 05:15:34 2009
@@ -93,7 +93,8 @@
 
             if ( buildResult.getState() != ContinuumProjectState.OK &&
                  buildResult.getState() != ContinuumProjectState.FAILED &&
-                 buildResult.getState() != ContinuumProjectState.ERROR )
+                 buildResult.getState() != ContinuumProjectState.ERROR &&
+                 buildResult.getState() != ContinuumProjectState.CANCELLED )
             {
                 buildResult.setState( ContinuumProjectState.ERROR );
             }

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java Mon Jan  5 05:15:34 2009
@@ -11,6 +11,8 @@
 
     private String projectName;
 
+    private int projectState;
+
     private int buildDefinitionId;
 
     private String buildFile;
@@ -83,6 +85,16 @@
         this.projectName = projectName;
     }
 
+    public int getProjectState()
+    {
+        return projectState;
+    }
+
+    public void setProjectState( int projectState )
+    {
+        this.projectState = projectState;
+    }
+
     public int getBuildDefinitionId()
     {
         return buildDefinitionId;

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java Mon Jan  5 05:15:34 2009
@@ -439,19 +439,24 @@
     {
         for ( BuildContext buildContext : buildContexts )
         {
-            BuildProjectTask buildProjectTask = new BuildProjectTask( buildContext.getProjectId(),
-                                                                      buildContext.getBuildDefinitionId(),
-                                                                      buildContext.getTrigger(),
-                                                                      buildContext.getProjectName(),
-                                                                      "" );
-            try
+            // only build if it's forced build or project state is not OK
+            if ( buildContext.getTrigger() == ContinuumProjectState.TRIGGER_FORCED || 
+                 buildContext.getProjectState() != ContinuumProjectState.OK )
             {
-                buildAgentTaskQueueManager.getBuildQueue().put( buildProjectTask );
-            }
-            catch ( TaskQueueException e )
-            {
-                log.error( "Error while enqueing build task for project " + buildContext.getProjectId(), e );
-                throw new ContinuumException( "Error while enqueuing build task for project " + buildContext.getProjectId(), e );
+                BuildProjectTask buildProjectTask = new BuildProjectTask( buildContext.getProjectId(),
+                                                                          buildContext.getBuildDefinitionId(),
+                                                                          buildContext.getTrigger(),
+                                                                          buildContext.getProjectName(),
+                                                                          "" );
+                try
+                {
+                    buildAgentTaskQueueManager.getBuildQueue().put( buildProjectTask );
+                }
+                catch ( TaskQueueException e )
+                {
+                    log.error( "Error while enqueing build task for project " + buildContext.getProjectId(), e );
+                    throw new ContinuumException( "Error while enqueuing build task for project " + buildContext.getProjectId(), e );
+                }
             }
         }
 

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/BuildContextToProject.java Mon Jan  5 05:15:34 2009
@@ -23,9 +23,8 @@
         project.setScmPassword( buildContext.getScmPassword() );
 
         project.setExecutorId( buildContext.getExecutorId() );
-        
-        //rename ?
-        project.setName( "distributed-build-[projectId="+buildContext.getProjectId()+"]" );
+
+        project.setState( buildContext.getProjectState() );
         
         return project;
     }

Modified: continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-distributed-build/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java Mon Jan  5 05:15:34 2009
@@ -85,6 +85,8 @@
 
     public static final String KEY_BUILD_OUTPUT = "build-output";
 
+    public static final String KEY_PROJECT_STATE = "project-state";
+
     public static Integer getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );
@@ -95,6 +97,11 @@
         return getString( context, KEY_PROJECT_NAME );
     }
 
+    public static Integer getProjectState( Map context )
+    {
+        return getInteger( context, KEY_PROJECT_STATE );
+    }
+
     public static Integer getBuildDefinitionId( Map context )
     {
         return getInteger( context, KEY_BUILD_DEFINITION_ID );

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/QueuesAction.java Mon Jan  5 05:15:34 2009
@@ -25,6 +25,7 @@
 
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.continuum.builder.distributed.manager.DistributedBuildManager;
+import org.apache.continuum.model.project.ProjectScmRoot;
 import org.apache.continuum.taskqueue.BuildProjectTask;
 import org.apache.continuum.taskqueue.CheckOutTask;
 import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
@@ -32,6 +33,7 @@
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectGroup;
+import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
 import org.apache.maven.continuum.web.action.ContinuumActionSupport;
 import org.apache.maven.continuum.web.exception.AuthenticationRequiredException;
@@ -106,6 +108,8 @@
 
     private String scmRootAddress;
 
+    private List<String> selectedDistributedBuildTaskHashCodes;
+
     // -----------------------------------------------------
     //  webwork
     // -----------------------------------------------------     
@@ -219,6 +223,17 @@
                summary.setProjectGroupId( task.getProjectGroupId() );
                summary.setProjectGroupName( projectGroup.getName() );
                summary.setScmRootAddress( task.getScmRootAddress() );
+               
+               ProjectScmRoot scmRoot = continuum.getProjectScmRootByProjectGroupAndScmRootAddress( task.getProjectGroupId(), 
+                                                                                                    task.getScmRootAddress() );
+               if ( scmRoot.getState() == ContinuumProjectState.UPDATING )
+               {
+                   summary.setCancelEnabled( false );
+               }
+               else
+               {
+                   summary.setCancelEnabled( true );
+               }
 
                distributedBuildSummary.add( summary );
             }
@@ -331,6 +346,53 @@
         return SUCCESS;
     }
 
+    public String removeDistributedBuildEntry()
+        throws Exception
+    {
+        try 
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        taskQueueManager.removeFromDistributedBuildQueue( projectGroupId, scmRootAddress );
+
+        return SUCCESS;
+    }
+
+    public String removeDistributedBuildEntries()
+        throws Exception
+    {
+        try 
+        {
+            checkManageQueuesAuthorization();
+        }
+        catch( AuthorizationRequiredException authzE )
+        {
+            addActionError( authzE.getMessage() );
+            return REQUIRES_AUTHORIZATION;
+        }
+        catch ( AuthenticationRequiredException e )
+        {
+            addActionError( e.getMessage() );
+            return REQUIRES_AUTHENTICATION;
+        }
+
+        taskQueueManager
+            .removeTasksFromDistributedBuildQueueWithHashCodes( listToIntArray( this.getSelectedDistributedBuildTaskHashCodes() ) );
+
+        return SUCCESS;
+    }
+
     private int[] listToIntArray( List<String> strings )
     {
         if ( strings == null || strings.isEmpty() )
@@ -510,4 +572,14 @@
     {
         this.distributedBuildQueues = distributedBuildQueues;
     }
+
+    public List<String> getSelectedDistributedBuildTaskHashCodes()
+    {
+        return selectedDistributedBuildTaskHashCodes;
+    }
+
+    public void setSelectedDistributedBuildTaskHashCodes( List<String> selectedDistributedBuildTaskHashCodes )
+    {
+        this.selectedDistributedBuildTaskHashCodes = selectedDistributedBuildTaskHashCodes;
+    }
 }

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/mdo/view-models.mdo Mon Jan  5 05:15:34 2009
@@ -507,6 +507,13 @@
           <description>Scm root address of projects</description>
           <type>String</type>
         </field>
+        <field>
+          <name>cancelEnabled</name>
+          <version>1.0.0</version>
+          <required>true</required>
+          <description>Determines if the cancel button is enabled</description>
+          <type>boolean</type>
+        </field>
       </fields>
     </class>
   </classes>

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/localization/Continuum.properties Mon Jan  5 05:15:34 2009
@@ -994,4 +994,5 @@
 distributedBuild.table.projectGroupName = Project Group Name
 distributedBuild.table.scmRootAddress = Scm Root Address
 distributedBuild.table.agentUrl = Build Agent URL
-distributedBuilds.empty = No Distributed Builds
\ No newline at end of file
+distributedBuilds.empty = No Distributed Builds
+distributedBuilds.removeEntries = Cancel Entries
\ No newline at end of file

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/resources/struts.xml Mon Jan  5 05:15:34 2009
@@ -798,6 +798,18 @@
         <param name="actionName">displayQueues</param>
       </result>
     </action>
+
+    <action name="removeDistributedBuildEntries" class="queues" method="removeDistributedBuildEntries">
+      <result name="success" type="redirect-action">
+        <param name="actionName">displayQueues</param>
+      </result>
+    </action>
+    
+    <action name="removeDistributedBuildEntry" class="queues" method="removeDistributedBuildEntry">
+      <result name="success" type="redirect-action">
+        <param name="actionName">displayQueues</param>
+      </result>
+    </action>
     
     <!--
     * Local Repository actions

Modified: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp?rev=731555&r1=731554&r2=731555&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp (original)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/webapp/WEB-INF/jsp/admin/viewDistributedBuilds.jsp Mon Jan  5 05:15:34 2009
@@ -28,69 +28,107 @@
       <title><s:text name="distributedBuilds.page.title"/></title>
     </head>
     <body>
-      <div id="h3">
-        <h3><s:text name="distributedBuilds.section.title"/></h3>
-        <c:if test="${!empty actionErrors}">
-          <div class="errormessage">
-            <s:iterator value="actionErrors">
-              <p><s:text name="<s:property/>" /></p>
-            </s:iterator>
-          </div>
-        </c:if>
-        <c:if test="${not empty distributedBuildSummary}">
-          <s:set name="distributedBuildSummary" value="distributedBuildSummary" scope="request"/>
-          <ec:table items="distributedBuildSummary"
-                    var="distributedBuild"
-                    showExports="false"
-                    showPagination="false"
-                    showStatusBar="false"
-                    sortable="false"
-                    filterable="false">
-            <ec:row>
-              <ec:column property="projectGroupName" title="distributedBuild.table.projectGroupName"/>
-              <ec:column property="scmRootAddress" title="distributedBuild.table.scmRootAddress"/>
-              <ec:column property="url" title="distributedBuild.table.agentUrl"/>
-              <ec:column property="cancelEntry" title="&nbsp;" width="1%">
-                <s:url id="cancelUrl" action="cancelDistributedBuild" method="cancelDistributedBuild" namespace="/">
-                  <s:param name="projectGroupId">${pageScope.distributedBuild.projectGroupId}</s:param>
-                  <s:param name="scmRootAddress">${pageScope.distributedBuild.scmRootAddress}</s:param>
-                  <s:param name="buildAgentUrl">${pageScope.distributedBuild.url}</s:param>
-                </s:url>
-                <s:a href="%{cancelUrl}"><img src="<s:url value='/images/cancelbuild.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0"></s:a>
-              </ec:column>
-            </ec:row>
-          </ec:table>
-        </c:if>
-        <c:if test="${empty distributedBuildSummary}">
-          <s:text name="distributedBuilds.empty"/>
-        </c:if>
-      </div>
-      <div id="h3">
-        <h3>
+      <s:form id="removeForm" action="none" method="post">
+        <div id="h3">
+          <h3><s:text name="distributedBuilds.section.title"/></h3>
+          <c:if test="${!empty actionErrors}">
+            <div class="errormessage">
+              <s:iterator value="actionErrors">
+                <p><s:text name="<s:property/>" /></p>
+              </s:iterator>
+            </div>
+          </c:if>
+          <c:if test="${not empty distributedBuildSummary}">
+            <s:set name="distributedBuildSummary" value="distributedBuildSummary" scope="request"/>
+            <ec:table items="distributedBuildSummary"
+                      var="distributedBuild"
+                      showExports="false"
+                      showPagination="false"
+                      showStatusBar="false"
+                      sortable="false"
+                      filterable="false">
+              <ec:row>
+                <ec:column property="projectGroupName" title="distributedBuild.table.projectGroupName"/>
+                <ec:column property="scmRootAddress" title="distributedBuild.table.scmRootAddress"/>
+                <ec:column property="url" title="distributedBuild.table.agentUrl"/>
+                <ec:column property="cancelEntry" title="&nbsp;" width="1%">
+                  <c:choose>
+                    <c:when test="${pageScope.distributedBuild.cancelEnabled}">
+                      <s:url id="cancelUrl" action="cancelDistributedBuild" method="cancelDistributedBuild" namespace="/">
+                        <s:param name="projectGroupId">${pageScope.distributedBuild.projectGroupId}</s:param>
+                        <s:param name="scmRootAddress">${pageScope.distributedBuild.scmRootAddress}</s:param>
+                        <s:param name="buildAgentUrl">${pageScope.distributedBuild.url}</s:param>
+                      </s:url>
+                      <redback:ifAuthorized permission="continuum-manage-queues">
+                        <s:a href="%{cancelUrl}"><img src="<s:url value='/images/cancelbuild.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0"></s:a>
+                      </redback:ifAuthorized>
+                      <redback:elseAuthorized>
+                        <img src="<s:url value='/images/cancelbuild_disabled.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0">
+                      </redback:elseAuthorized>
+                    </c:when>
+                    <c:otherwise>
+                      <img src="<s:url value='/images/cancelbuild_disabled.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0">
+                    </c:otherwise>
+                  </c:choose>
+                </ec:column>
+              </ec:row>
+            </ec:table>
+          </c:if>
+          <c:if test="${empty distributedBuildSummary}">
+            <s:text name="distributedBuilds.empty"/>
+          </c:if>
+        </div>
+        <div id="h3">
+          <h3>
             <s:text name="distributedBuilds.buildQueue.section.title"/>
           </h3>
+          <c:if test="${not empty distributedBuildQueues}">
+            <ec:table items="distributedBuildQueues"
+                      var="distributedBuildQueue"
+                      showExports="false"
+                      showPagination="false"
+                      showStatusBar="false"
+                      sortable="false"
+                      filterable="false">
+              <ec:row>
+                <redback:ifAuthorized permission="continuum-manage-queues">
+                  <ec:column alias="selectedDistributedBuildTaskHashCodes" title="&nbsp;" style="width:5px" filterable="false" sortable="false" width="1%" headerCell="selectAll">
+                    <input type="checkbox" name="selectedDistributedBuildTaskHashCodes" value="${pageScope.distributedBuildQueue.hashCode}" />
+                  </ec:column>              
+                </redback:ifAuthorized>
+                <ec:column property="projectGroupName" title="distributedBuild.table.projectGroupName"/>
+                <ec:column property="scmRootAddress" title="distributedBuild.table.scmRootAddress"/>
+                <ec:column property="cancelEntry" title="&nbsp;" width="1%">
+                  <redback:ifAuthorized permission="continuum-manage-queues">
+                    <s:url id="cancelUrl" action="removeDistributedBuildEntry" method="removeDistributedBuildEntry" namespace="/">
+                      <s:param name="projectGroupId">${pageScope.distributedBuildQueue.projectGroupId}</s:param>
+                      <s:param name="scmRootAddress">${pageScope.distributedBuildQueue.scmRootAddress}</s:param>
+                    </s:url>
+                    <s:a href="%{cancelUrl}"><img src="<s:url value='/images/cancelbuild.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0"></s:a>
+                  </redback:ifAuthorized>
+                  <redback:elseAuthorized>
+                    <img src="<s:url value='/images/cancelbuild_disabled.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0">
+                  </redback:elseAuthorized>
+                </ec:column>
+              </ec:row>
+            </ec:table>
+          </c:if>
+        </div>
         <c:if test="${not empty distributedBuildQueues}">
-          <ec:table items="distributedBuildQueues"
-                    var="distributedBuildQueue"
-                    showExports="false"
-                    showPagination="false"
-                    showStatusBar="false"
-                    sortable="false"
-                    filterable="false">
-            <ec:row>
-              <ec:column property="projectGroupName" title="distributedBuild.table.projectGroupName"/>
-              <ec:column property="scmRootAddress" title="distributedBuild.table.scmRootAddress"/>
-              <ec:column property="cancelEntry" title="&nbsp;" width="1%">
-                <s:url id="cancelUrl" action="removeDistributedBuild" method="removeDistributedBuild" namespace="/">
-                  <s:param name="projectGroupId">${pageScope.distributedBuild.projectGroupId}</s:param>
-                  <s:param name="scmRootAddress">${pageScope.distributedBuild.scmRootAddress}</s:param>
-                </s:url>
-                <s:a href="%{cancelUrl}"><img src="<s:url value='/images/cancelbuild.gif' includeParams="none"/>" alt="<s:text name='cancel'/>" title="<s:text name='cancel'/>" border="0"></s:a>
-              </ec:column>
-            </ec:row>
-          </ec:table>
+          <div class="functnbar3">
+            <table>
+              <tbody>
+                <tr>
+                  <td>
+                    <input type="submit" value="<s:text name="distributedBuilds.removeEntries"/>"
+                           onclick="$('removeForm').action='removeDistributedBuildEntries!removeDistributedBuildEntries.action';$('removeForm').submit();" /> 
+                  </td>
+                </tr>
+              </tbody>
+            </table>
+          </div>
         </c:if>
-      </div>
+      </s:form>
     </body>
   </s:i18n>
 </html>
\ No newline at end of file



Mime
View raw message