mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
7d285b2179
commit
e42e26c8e1
|
@ -158,6 +158,17 @@
|
|||
The organisation info.
|
||||
</description>
|
||||
</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>
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -66,6 +66,26 @@
|
|||
</exclusion>
|
||||
</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>
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
//-------------------------
|
||||
//
|
||||
//-------------------------
|
||||
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
11
pom.xml
11
pom.xml
|
@ -1056,6 +1056,17 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.1.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-provider-api</artifactId>
|
||||
|
|
Loading…
Reference in New Issue