aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-09-30 13:36:56 +0000
committerOlivier Lamy <olamy@apache.org>2011-09-30 13:36:56 +0000
commite42e26c8e11f682494aaa9a42a79813c9fc3934b (patch)
treeaa0cf44bf6b88c6dd3723eac50f97c58c1e1f301 /archiva-modules
parent7d285b2179cce87c467ef34385cf3cada04eafc2 (diff)
downloadarchiva-e42e26c8e11f682494aaa9a42a79813c9fc3934b.tar.gz
archiva-e42e26c8e11f682494aaa9a42a79813c9fc3934b.zip
[MRM-1526] configure http connection pool values for wagon http.
add basic services. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177654 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo44
-rw-r--r--archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java13
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/admin/ArchivaAdministration.java7
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/NetworkConfiguration.java97
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml20
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java47
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java13
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java16
-rw-r--r--archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java13
9 files changed, 266 insertions, 4 deletions
diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
index 763e5ee6f..b867ef7d8 100644
--- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
+++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
@@ -157,7 +157,18 @@
<description>
The organisation info.
</description>
- </field>
+ </field>
+ <field>
+ <name>networkConfiguration</name>
+ <version>1.4.0+</version>
+ <association>
+ <type>NetworkConfiguration</type>
+ <multiplicity>1</multiplicity>
+ </association>
+ <description>
+ The NetworkConfiguration .
+ </description>
+ </field>
</fields>
<codeSegments>
<codeSegment>
@@ -1277,6 +1288,37 @@
</fields>
</class>
+ <class>
+ <name>NetworkConfiguration</name>
+ <version>1.4.0+</version>
+ <description>
+ The network configuration for external http request to repositories.
+ </description>
+ <fields>
+ <field>
+ <name>maxTotal</name>
+ <description>maximum total external http connections.</description>
+ <version>1.4.0+</version>
+ <type>int</type>
+ <defaultValue>30</defaultValue>
+ </field>
+ <field>
+ <name>maxTotalPerHost</name>
+ <description>maximum total external http connections per host</description>
+ <version>1.4.0+</version>
+ <type>int</type>
+ <defaultValue>30</defaultValue>
+ </field>
+ <field>
+ <name>usePooling</name>
+ <description>use or not http connection pooling default true</description>
+ <version>1.4.0+</version>
+ <type>boolean</type>
+ <defaultValue>true</defaultValue>
+ </field>
+ </fields>
+ </class>
+
</classes>
</model>
diff --git a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java
index fa34784db..93e6c33ac 100644
--- a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java
+++ b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
@@ -160,4 +161,16 @@ public class MockArchivaAdministration
{
}
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/admin/ArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/admin/ArchivaAdministration.java
index bfd271ef4..975b045f3 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/admin/ArchivaAdministration.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/admin/ArchivaAdministration.java
@@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.AuditInformation;
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
@@ -97,4 +98,10 @@ public interface ArchivaAdministration
void updateUiConfiguration( UiConfiguration uiConfiguration )
throws RepositoryAdminException;
+ NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException;
+
+ void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException;
+
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/NetworkConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/NetworkConfiguration.java
new file mode 100644
index 000000000..26e732d73
--- /dev/null
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/NetworkConfiguration.java
@@ -0,0 +1,97 @@
+package org.apache.archiva.admin.model.beans;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@XmlRootElement( name = "networkConfiguration" )
+public class NetworkConfiguration
+ implements Serializable
+{
+ /**
+ * maximum total external http connections.
+ */
+ private int maxTotal = 30;
+
+ /**
+ * maximum total external http connections per host.
+ */
+ private int maxTotalPerHost = 30;
+
+ private boolean usePooling = true;
+
+ public NetworkConfiguration()
+ {
+ // no op
+ }
+
+ public NetworkConfiguration( int maxTotal, int maxTotalPerHost, boolean usePooling )
+ {
+ this.maxTotal = maxTotal;
+ this.maxTotalPerHost = maxTotalPerHost;
+ this.usePooling = usePooling;
+ }
+
+ public int getMaxTotal()
+ {
+ return maxTotal;
+ }
+
+ public void setMaxTotal( int maxTotal )
+ {
+ this.maxTotal = maxTotal;
+ }
+
+ public int getMaxTotalPerHost()
+ {
+ return maxTotalPerHost;
+ }
+
+ public void setMaxTotalPerHost( int maxTotalPerHost )
+ {
+ this.maxTotalPerHost = maxTotalPerHost;
+ }
+
+ public boolean isUsePooling()
+ {
+ return usePooling;
+ }
+
+ public void setUsePooling( boolean usePooling )
+ {
+ this.usePooling = usePooling;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "NetworkConfiguration" );
+ sb.append( "{maxTotal=" ).append( maxTotal );
+ sb.append( ", maxTotalPerHost=" ).append( maxTotalPerHost );
+ sb.append( ", usePooling=" ).append( usePooling );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml
index a2f4721da..232f246cd 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/pom.xml
@@ -67,6 +67,26 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java
index 8cb88007f..6a6999c8e 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java
@@ -24,6 +24,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
@@ -32,6 +33,8 @@ import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.UserInterfaceOptions;
import org.apache.archiva.configuration.WebappConfiguration;
import org.apache.commons.lang.StringUtils;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.maven.wagon.providers.http.HttpWagon;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
@@ -56,7 +59,6 @@ public class DefaultArchivaAdministration
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
}
return legacyArtifactPaths;
-
}
public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
@@ -323,7 +325,48 @@ public class DefaultArchivaAdministration
}
-//-------------------------
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ org.apache.archiva.configuration.NetworkConfiguration networkConfiguration =
+ getArchivaConfiguration().getConfiguration().getNetworkConfiguration();
+
+ if ( networkConfiguration == null )
+ {
+ return null;
+ }
+ return new BeanReplicator().replicateBean( networkConfiguration, NetworkConfiguration.class );
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( networkConfiguration == null )
+ {
+ configuration.setNetworkConfiguration( null );
+ // back to default values
+ HttpWagon.setUseClientManagerPooled( true );
+ ThreadSafeClientConnManager threadSafeClientConnManager = new ThreadSafeClientConnManager();
+ threadSafeClientConnManager.setDefaultMaxPerRoute( 30 );
+ threadSafeClientConnManager.setMaxTotal( 30 );
+ HttpWagon.setConnectionManagerPooled( threadSafeClientConnManager );
+
+ }
+ else
+ {
+ HttpWagon.setUseClientManagerPooled( networkConfiguration.isUsePooling() );
+ ThreadSafeClientConnManager threadSafeClientConnManager = new ThreadSafeClientConnManager();
+ threadSafeClientConnManager.setDefaultMaxPerRoute( networkConfiguration.getMaxTotalPerHost() );
+ threadSafeClientConnManager.setMaxTotal( networkConfiguration.getMaxTotal() );
+ HttpWagon.setConnectionManagerPooled( threadSafeClientConnManager );
+ configuration.setNetworkConfiguration( new BeanReplicator().replicateBean( networkConfiguration,
+ org.apache.archiva.configuration.NetworkConfiguration.class ) );
+ }
+ saveConfiguration( configuration );
+ }
+
+ //-------------------------
//
//-------------------------
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java
index 1a3e153fa..59165ba5c 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java
@@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
@@ -219,4 +220,16 @@ public class ArchivaAdministrationTest
assertFalse( ui.isAppletFindEnabled() );
assertFalse( ui.isShowFindArtifacts() );
}
+
+ @Test
+ public void networkConfiguration()
+ throws Exception
+ {
+ NetworkConfiguration networkConfiguration = archivaAdministration.getNetworkConfiguration();
+ assertNotNull( networkConfiguration );
+
+ assertTrue( networkConfiguration.isUsePooling() );
+ assertEquals( 30, networkConfiguration.getMaxTotal() );
+ assertEquals( 30, networkConfiguration.getMaxTotalPerHost() );
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java
index 671a48598..57041e32d 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/ArchivaAdministrationStub.java
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.configuration.ArchivaConfiguration;
@@ -174,6 +175,19 @@ public class ArchivaAdministrationStub
public void updateUiConfiguration( UiConfiguration uiConfiguration )
throws RepositoryAdminException
{
- //To change body of implemented methods use File | Settings | File Templates.
+
+ }
+
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
}
}
diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java
index f87f1b7f9..2cb62ef78 100644
--- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java
+++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java
@@ -23,6 +23,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.configuration.ArchivaConfiguration;
@@ -175,4 +176,16 @@ public class MockArchivaAdministration
{
}
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
+ }
}