continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r935792 - /continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Date Tue, 20 Apr 2010 02:40:36 GMT
Author: ctan
Date: Tue Apr 20 02:40:36 2010
New Revision: 935792

URL: http://svn.apache.org/viewvc?rev=935792&view=rev
Log:
move call to reload() to minimize if statement

Modified:
    continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java?rev=935792&r1=935791&r2=935792&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java
Tue Apr 20 02:40:36 2010
@@ -272,6 +272,9 @@ public class DefaultDistributedBuildMana
 
             throw new NoBuildAgentException( "No build agent configured" );
         }
+
+        // call in case we disabled a build agent
+        reload();
     }
 
     public void removeDistributedBuildQueueOfAgent( String buildAgentUrl )
@@ -1075,7 +1078,6 @@ public class DefaultDistributedBuildMana
     private OverallDistributedBuildQueue getOverallDistributedBuildQueueByScmRoot( ProjectScmRoot
scmRoot, int projectGroupId )
         throws ContinuumException
     {
-        OverallDistributedBuildQueue overallDistributedBuildQueue = null;
         int scmRootId = scmRoot.getId();
 
         synchronized( overallDistributedBuildQueues )
@@ -1090,48 +1092,36 @@ public class DefaultDistributedBuildMana
                     {
                         if ( task.getProjectScmRootId() == scmRootId )
                         {
-                            overallDistributedBuildQueue = distributedBuildQueue;
-                            break;
+                            return distributedBuildQueue;
                         }
                     }
 
-                    if ( overallDistributedBuildQueue == null )
+                    Task task = distributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask();
+                    if ( task != null && ( (PrepareBuildProjectsTask) task ).getProjectScmRootId()
== scmRootId )
                     {
-                        Task task = distributedBuildQueue.getDistributedBuildTaskQueueExecutor().getCurrentTask();
-                        if ( task != null && ( (PrepareBuildProjectsTask) task ).getProjectScmRootId()
== scmRootId )
-                        {
-                            overallDistributedBuildQueue = distributedBuildQueue;
-                        }
+                        return distributedBuildQueue;
                     }
 
-                    if ( overallDistributedBuildQueue == null )
+                    if ( isAgentAvailable( buildAgentUrl ) )
                     {
-                        if ( isAgentAvailable( buildAgentUrl ) )
+                        List<Project> projects = projectDao.getProjectsInGroup( projectGroupId
);
+                        List<Integer> pIds = new ArrayList<Integer>();
+
+                        for ( Project project : projects )
                         {
-                            List<Project> projects = projectDao.getProjectsInGroup(
projectGroupId );
-                            List<Integer> pIds = new ArrayList<Integer>();
-                            
-                            for ( Project project : projects )
+                            if ( project.getScmUrl().startsWith( scmRoot.getScmRootAddress()
) )
                             {
-                                if ( project.getScmUrl().startsWith( scmRoot.getScmRootAddress()
) )
-                                {
-                                    pIds.add( project.getId() );
-                                }
+                                pIds.add( project.getId() );
                             }
+                        }
 
-                            SlaveBuildAgentTransportService client = createSlaveBuildAgentTransportClientConnection(
buildAgentUrl );
+                        SlaveBuildAgentTransportService client = createSlaveBuildAgentTransportClientConnection(
buildAgentUrl );
 
-                            if ( client.isProjectScmRootInQueue( scmRootId, pIds ) )
-                            {
-                                overallDistributedBuildQueue = distributedBuildQueue;
-                            }
+                        if ( client.isProjectScmRootInQueue( scmRootId, pIds ) )
+                        {
+                            return distributedBuildQueue;
                         }
                     }
-
-                    if ( overallDistributedBuildQueue != null )
-                    {
-                        break;
-                    }
                 }
                 catch ( TaskQueueException e )
                 {
@@ -1153,10 +1143,7 @@ public class DefaultDistributedBuildMana
             }
         }
 
-        // call reload in case we disable a build agent
-        reload();
-
-        return overallDistributedBuildQueue;
+        return null;
     }
 
     private OverallDistributedBuildQueue getOverallDistributedBuildQueueByGroup( int projectGroupId,
List<ProjectScmRoot> scmRoots, int scmRootId )
@@ -1276,11 +1263,9 @@ public class DefaultDistributedBuildMana
                         }
                     }
                 }
-
-                // call reload in case we disable a build agent
-                reload();
             }
         }
+
         return whereToBeQueued;
     }
 
@@ -1340,9 +1325,6 @@ public class DefaultDistributedBuildMana
             }
         }
 
-        // call reload in case we disable a build agent
-        reload();
-
         return whereToBeQueued;
     }
 



Mime
View raw message