maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r746179 - in /maven/components/branches/maven-2.1.x: maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Date Fri, 20 Feb 2009 08:16:51 GMT
Author: brett
Date: Fri Feb 20 08:16:51 2009
New Revision: 746179

URL: http://svn.apache.org/viewvc?rev=746179&view=rev
Log:
[MNG-3379] add a configuration option for the number of threads. We need to use a system property
so it can be set constantly (via MAVEN_OPTS), but cannot modify the settings file

Modified:
    maven/components/branches/maven-2.1.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
    maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java

Modified: maven/components/branches/maven-2.1.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java?rev=746179&r1=746178&r2=746179&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
(original)
+++ maven/components/branches/maven-2.1.x/maven-artifact-manager/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactResolver.java
Fri Feb 20 08:16:51 2009
@@ -29,7 +29,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.Executors;
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.factory.ArtifactFactory;
@@ -463,4 +462,9 @@
         }
     }
 
+    public synchronized void configureNumberOfThreads( int threads )
+    {
+        resolveArtifactPool.setCorePoolSize( threads );
+        resolveArtifactPool.setMaximumPoolSize( threads );
+    }
 }

Modified: maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=746179&r1=746178&r2=746179&view=diff
==============================================================================
--- maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
(original)
+++ maven/components/branches/maven-2.1.x/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
Fri Feb 20 08:16:51 2009
@@ -36,6 +36,8 @@
 import org.apache.maven.artifact.manager.WagonManager;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import org.apache.maven.execution.BuildFailure;
@@ -269,7 +271,7 @@
 
         try
         {
-            resolveParameters( request.getSettings() );
+            resolveParameters( request.getSettings(), request.getExecutionProperties() );
         }
         catch ( ComponentLookupException e )
         {
@@ -609,7 +611,7 @@
      * @todo [JC] we should at least provide a mapping of protocol-to-proxy for
      * the wagons, shouldn't we?
      */
-    private void resolveParameters( Settings settings )
+    private void resolveParameters( Settings settings, Properties executionProperties )
         throws ComponentLookupException, ComponentLifecycleException, SettingsConfigurationException
     {
         // TODO: remove when components.xml can be used to configure this instead
@@ -754,6 +756,40 @@
         {
             container.release( wagonManager );
         }
+        
+        // Would be better in settings.xml, but it is not extensible yet
+        String numThreads = System.getProperty( "maven.artifact.threads" );
+        if ( numThreads != null )
+        {
+            int threads = 0;
+            try
+            {
+                threads = Integer.valueOf( numThreads ).intValue();
+
+                if ( threads < 1 )
+                {
+                    getLogger().warn( "Invalid number of threads '" + threads + "' will be
ignored" );
+                }
+            }
+            catch ( NumberFormatException e )
+            {
+                getLogger().warn( "Invalid number of threads '" + numThreads + "' will be
ignored: " + e.getMessage() );
+            }
+            
+            if ( threads > 0 )
+            {
+                DefaultArtifactResolver artifactResolver = (DefaultArtifactResolver) container.lookup(
ArtifactResolver.ROLE );
+                try
+                {
+                    artifactResolver.configureNumberOfThreads( threads );
+                    getLogger().debug( "Resolution thread pool size set to: " + threads );
+                }
+                finally
+                {
+                    container.release( artifactResolver );
+                }
+            }
+        }
     }
 
     // ----------------------------------------------------------------------



Mime
View raw message