continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r721372 - in /continuum/branches/continuum-distributed-builds: continuum-core/src/main/java/org/apache/continuum/distributed/manager/ continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/
Date Fri, 28 Nov 2008 07:52:28 GMT
Author: ctan
Date: Thu Nov 27 23:52:28 2008
New Revision: 721372

URL: http://svn.apache.org/viewvc?rev=721372&view=rev
Log:
- more fix in distributed build manager
- added buildagentaction

Added:
    continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildAgentAction.java
Modified:
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/AbstractDistributedBuildManager.java
    continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/DefaultDistributedBuildManager.java

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/AbstractDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/AbstractDistributedBuildManager.java?rev=721372&r1=721371&r2=721372&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/AbstractDistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/AbstractDistributedBuildManager.java
Thu Nov 27 23:52:28 2008
@@ -70,8 +70,6 @@
 
     public static final String KEY_PREPARE_BUILD_FINISHED = "prepare-build-finished";
 
-    public static final String KEY_AGENT_URL = "agent-url";
-
     public static int getProjectId( Map context )
     {
         return getInteger( context, KEY_PROJECT_ID );
@@ -137,11 +135,6 @@
         return getBoolean( context, KEY_PREPARE_BUILD_FINISHED );
     }
 
-    public static String getAgentUrl( Map context )
-    {
-        return getString( context, KEY_AGENT_URL );
-    }
-
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------

Modified: continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/DefaultDistributedBuildManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/DefaultDistributedBuildManager.java?rev=721372&r1=721371&r2=721372&view=diff
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/DefaultDistributedBuildManager.java
(original)
+++ continuum/branches/continuum-distributed-builds/continuum-core/src/main/java/org/apache/continuum/distributed/manager/DefaultDistributedBuildManager.java
Thu Nov 27 23:52:28 2008
@@ -49,7 +49,6 @@
 
 /**
  * @author Maria Catherine Tan
- * @plexus.component role="org.apache.continuum.distributed.DistributedBuildManager"
  */
 public class DefaultDistributedBuildManager
     extends AbstractDistributedBuildManager
@@ -94,32 +93,85 @@
             buildAgents = new ArrayList<BuildAgent>();
         }
         
-        for ( BuildAgentConfiguration agent : agents )
+        if ( agents != null )
         {
-            if ( agent.isEnabled() )
-            { 
-                boolean found = false;
-
-                for ( BuildAgent buildAgent : buildAgents )
-                {
-                    if ( buildAgent.getUrl().equals( agent.getUrl() ) )
+            for ( BuildAgentConfiguration agent : agents )
+            {
+                if ( agent.isEnabled() )
+                { 
+                    boolean found = false;
+    
+                    for ( BuildAgent buildAgent : buildAgents )
                     {
-                        found = true;
-                        break;
+                        if ( buildAgent.getUrl().equals( agent.getUrl() ) )
+                        {
+                            found = true;
+                            break;
+                        }
+                    }
+    
+                    if ( !found )
+                    {
+                        BuildAgent buildAgent = new BuildAgent();
+                        buildAgent.setUrl( agent.getUrl() );
+                        buildAgent.setBusy( false );
+                        buildAgents.add( buildAgent );
                     }
-                }
-
-                if ( !found )
-                {
-                    BuildAgent buildAgent = new BuildAgent();
-                    buildAgent.setUrl( agent.getUrl() );
-                    buildAgent.setBusy( false );
-                    buildAgents.add( buildAgent );
                 }
             }
         }
     }
 
+    public ConfigurationService getConfigurationService()
+    {
+        return configurationService;
+    }
+
+    public void setConfigurationService( ConfigurationService configurationService )
+    {
+        this.configurationService = configurationService;
+    }
+
+    public ProjectDao getProjectDao()
+    {
+        return projectDao;
+    }
+
+    public void setProjectDao( ProjectDao projectDao )
+    {
+        this.projectDao = projectDao;
+    }
+
+    public BuildDefinitionDao getBuildDefinitionDao()
+    {
+        return buildDefinitionDao;
+    }
+
+    public void setBuildDefinitionDao( BuildDefinitionDao buildDefinitionDao )
+    {
+        this.buildDefinitionDao = buildDefinitionDao;
+    }
+
+    public BuildResultDao getBuildResultDao()
+    {
+        return buildResultDao;
+    }
+
+    public void setBuildResultDao( BuildResultDao buildResultDao )
+    {
+        this.buildResultDao = buildResultDao;
+    }
+
+    public ProjectScmRootDao getProjectScmRootDao()
+    {
+        return projectScmRootDao;
+    }
+
+    public void setProjectScmRootDao( ProjectScmRootDao projectScmRootDao )
+    {
+        this.projectScmRootDao = projectScmRootDao;
+    }
+
     public void buildProjects( Map<Integer, Integer> projectsAndBuildDefinitionsMap,
int trigger )
         throws ContinuumException
     {
@@ -471,24 +523,21 @@
     {
         for ( BuildAgent buildAgent : buildAgents )
         {
-            if ( buildAgent.getUrl().equals( getAgentUrl( context ) ) )
+            for ( Project project : buildAgent.getProjects() )
             {
-                for ( Project project : buildAgent.getProjects() )
+                if ( project.getId() == getProjectId( context ) )
                 {
-                    if ( project.getId() == getProjectId( context ) )
+                    buildAgent.getProjects().remove( project );
+                    
+                    if ( buildAgent.isBusy() && ( buildAgent.getProjects() == null
|| buildAgent.getProjects().size() == 0 ) )
                     {
-                        buildAgent.getProjects().remove( project );
-                        break;
+                        buildAgent.setBusy( false );
                     }
-                }
 
-                if ( buildAgent.getProjects() == null || buildAgent.getProjects().size()
== 0 )
-                {
-                    buildAgent.setBusy( false );
                     buildProjectsInQueue();
+                    return;
                 }
             }
         }
     }
-
 }

Added: continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildAgentAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildAgentAction.java?rev=721372&view=auto
==============================================================================
--- continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildAgentAction.java
(added)
+++ continuum/branches/continuum-distributed-builds/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/BuildAgentAction.java
Thu Nov 27 23:52:28 2008
@@ -0,0 +1,140 @@
+package org.apache.maven.continuum.web.action.admin;
+
+import org.apache.continuum.configuration.BuildAgentConfiguration;
+import org.apache.maven.continuum.configuration.ConfigurationService;
+import org.apache.maven.continuum.model.system.Installation;
+import org.apache.maven.continuum.security.ContinuumRoleConstants;
+import org.apache.maven.continuum.web.action.ContinuumActionSupport;
+import org.codehaus.plexus.redback.rbac.Resource;
+import org.codehaus.redback.integration.interceptor.SecureAction;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
+import org.codehaus.redback.integration.interceptor.SecureActionException;
+
+import java.util.List;
+
+public class BuildAgentAction
+    extends ContinuumActionSupport
+    implements SecureAction
+{
+    private List<BuildAgentConfiguration> buildAgents;
+
+    private BuildAgentConfiguration buildAgent;
+
+    private String buildAgentUrl;
+
+    private List<Installation> installations;
+
+    public String list()
+        throws Exception
+    {
+        this.buildAgents = getContinuum().getConfiguration().getBuildAgents();
+        return SUCCESS;
+    }
+
+    public String view()
+        throws Exception
+    {
+        ConfigurationService configuration = getContinuum().getConfiguration();
+
+        for ( BuildAgentConfiguration agent : configuration.getBuildAgents() )
+        {
+            if ( agent.getUrl().equals( buildAgentUrl ) )
+            {
+                buildAgent = agent;
+                
+                // connect to BuildAgentXMLRPCCLIENT
+                // installations = client.getAvailableInstallations();
+                break;
+            }
+        }
+
+        return SUCCESS;
+    }
+
+    public String save()
+        throws Exception
+    {
+        ConfigurationService configuration = getContinuum().getConfiguration();
+
+        for ( BuildAgentConfiguration agent : configuration.getBuildAgents() )
+        {
+            if ( buildAgent.getUrl().equals( agent.getUrl() ) )
+            {
+                addActionError( "buildAgent.error.exist" );
+                return ERROR;
+            }
+        }
+
+        configuration.addBuildAgent( buildAgent );
+
+        return SUCCESS;
+    }
+
+    public String delete()
+        throws Exception
+    {
+        ConfigurationService configuration = getContinuum().getConfiguration();
+
+        for ( BuildAgentConfiguration agent : configuration.getBuildAgents() )
+        {
+            if ( buildAgent.getUrl().equals( agent.getUrl() ) )
+            {
+                configuration.removeBuildAgent( buildAgent );
+                return SUCCESS;
+            }
+        }
+
+        addActionError( "buildAgent.error.notfound" );
+        return ERROR;
+    }
+
+    public SecureActionBundle getSecureActionBundle()
+        throws SecureActionException
+    {
+        SecureActionBundle bundle = new SecureActionBundle();
+        bundle.setRequiresAuthentication( true );
+        bundle.addRequiredAuthorization( ContinuumRoleConstants.SYSTEM_ADMINISTRATOR_ROLE,
Resource.GLOBAL );
+
+        return bundle;
+    }
+
+    public List<BuildAgentConfiguration> getBuildAgents()
+    {
+        return buildAgents;
+    }
+
+    public void setBuildAgents( List<BuildAgentConfiguration> buildAgents )
+    {
+        this.buildAgents = buildAgents;
+    }
+
+    public BuildAgentConfiguration getBuildAgent()
+    {
+        return buildAgent;
+    }
+
+    public void setBuildAgent( BuildAgentConfiguration buildAgent )
+    {
+        this.buildAgent = buildAgent;
+    }
+
+    public String getBuildAgentUrl()
+    {
+        return buildAgentUrl;
+    }
+
+    public void setBuildAgentUrl( String buildAgentUrl )
+    {
+        this.buildAgentUrl = buildAgentUrl;
+    }
+
+    public List<Installation> getInstallations()
+    {
+        return installations;
+    }
+
+    public void setInstallations( List<Installation> installations )
+    {
+        this.installations = installations;
+    }
+}



Mime
View raw message