Example usage for org.apache.commons.httpclient.params HttpConnectionManagerParams setDefaultMaxConnectionsPerHost

List of usage examples for org.apache.commons.httpclient.params HttpConnectionManagerParams setDefaultMaxConnectionsPerHost

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.params HttpConnectionManagerParams setDefaultMaxConnectionsPerHost.

Prototype

public void setDefaultMaxConnectionsPerHost(int paramInt) 

Source Link

Usage

From source file:org.wso2.carbon.event.output.adapter.soap.SoapEventAdapter.java

private HttpClient createMultiThreadedHttpConnectionManager(int connectionTimeOut, int maxConnectionPerHost) {

    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(maxConnectionPerHost);
    params.setConnectionTimeout(connectionTimeOut);
    MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
    httpConnectionManager.setParams(params);
    return new HttpClient(httpConnectionManager);
}

From source file:org.wso2.carbon.mashup.javascript.hostobjects.pooledhttpclient.PooledHttpClientHostObject.java

public PooledHttpClientHostObject() {
    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = connectionManager.getParams();
    params.setDefaultMaxConnectionsPerHost(CONN_POOL_THREAD_MAX);
    params.setMaxTotalConnections(CONN_POOL_GLOBAL_MAX);

    this.httpClient = new HttpClient(connectionManager);
}

From source file:org.wso2.carbon.micro.integrator.core.internal.ServiceComponent.java

private ConfigurationContext getClientConfigurationContext() throws AxisFault {
    String clientRepositoryLocation = serverConfig.getFirstProperty(CLIENT_REPOSITORY_LOCATION);
    String clientAxis2XmlLocationn = serverConfig.getFirstProperty(CLIENT_AXIS2_XML_LOCATION);
    ConfigurationContext clientConfigContextToReturn = ConfigurationContextFactory
            .createConfigurationContextFromFileSystem(clientRepositoryLocation, clientAxis2XmlLocationn);
    MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();

    // Set the default max connections per host
    int defaultMaxConnPerHost = 500;
    Parameter defaultMaxConnPerHostParam = clientConfigContextToReturn.getAxisConfiguration()
            .getParameter("defaultMaxConnPerHost");
    if (defaultMaxConnPerHostParam != null) {
        defaultMaxConnPerHost = Integer.parseInt((String) defaultMaxConnPerHostParam.getValue());
    }/* w ww.j av a2  s.  c  o m*/
    params.setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost);

    // Set the max total connections
    int maxTotalConnections = 15000;
    Parameter maxTotalConnectionsParam = clientConfigContextToReturn.getAxisConfiguration()
            .getParameter("maxTotalConnections");
    if (maxTotalConnectionsParam != null) {
        maxTotalConnections = Integer.parseInt((String) maxTotalConnectionsParam.getValue());
    }
    params.setMaxTotalConnections(maxTotalConnections);

    params.setSoTimeout(600000);
    params.setConnectionTimeout(600000);

    httpConnectionManager.setParams(params);
    clientConfigContextToReturn.setProperty(HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER,
            httpConnectionManager);
    //        registerHouseKeepingTask(clientConfigContextToReturn);
    clientConfigContextToReturn.setProperty(ServerConstants.WORK_DIR, serverWorkDir);
    return clientConfigContextToReturn;
}

From source file:org.wso2.carbon.webapp.authenticator.framework.Utils.OAuthTokenValidationStubFactory.java

/**
 * Creates an instance of MultiThreadedHttpConnectionManager using HttpClient 3.x APIs
 *
 * @param properties Properties to configure MultiThreadedHttpConnectionManager
 * @return An instance of properly configured MultiThreadedHttpConnectionManager
 *//*from   w w  w . java2  s .  c o  m*/
private HttpConnectionManager createConnectionManager(Properties properties) {
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    if (properties == null || properties.isEmpty()) {
        throw new IllegalArgumentException("Parameters required to initialize HttpClient instances "
                + "associated with OAuth token validation service stub are not provided");
    }
    String maxConnectionsPerHostParam = properties.getProperty("MaxConnectionsPerHost");
    if (maxConnectionsPerHostParam == null || maxConnectionsPerHostParam.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("MaxConnectionsPerHost parameter is not explicitly defined. Therefore, the default, "
                    + "which is 2, will be used");
        }
    } else {
        params.setDefaultMaxConnectionsPerHost(Integer.parseInt(maxConnectionsPerHostParam));
    }

    String maxTotalConnectionsParam = properties.getProperty("MaxTotalConnections");
    if (maxTotalConnectionsParam == null || maxTotalConnectionsParam.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("MaxTotalConnections parameter is not explicitly defined. Therefore, the default, "
                    + "which is 10, will be used");
        }
    } else {
        params.setMaxTotalConnections(Integer.parseInt(maxTotalConnectionsParam));
    }
    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    connectionManager.setParams(params);
    return connectionManager;
}

From source file:org.wso2.esb.integration.common.utils.clients.axis2client.ConfigurationContextProvider.java

public ConfigurationContextProvider() {
    try {/* w  w  w  .ja v a2s .c  o m*/
        MultiThreadedHttpConnectionManager httpConnectionManager;
        HttpClient httpClient;
        HttpConnectionManagerParams params;
        configurationContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                TestConfigurationProvider.getResourceLocation() + File.separator + "client", null);

        httpConnectionManager = new MultiThreadedHttpConnectionManager();
        params = new HttpConnectionManagerParams();
        params.setDefaultMaxConnectionsPerHost(25);
        httpConnectionManager.setParams(params);
        httpClient = new HttpClient(httpConnectionManager);

        configurationContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        configurationContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE);

    } catch (AxisFault axisFault) {
        log.error(axisFault);
    }
}

From source file:org.zaizi.alfresco.redlink.service.search.solr.SensefySolrQueryHTTPClient.java

public void init() {
    PropertyCheck.mandatory(this, "NodeService", nodeService);
    PropertyCheck.mandatory(this, "PermissionService", permissionService);
    PropertyCheck.mandatory(this, "RepositoryState", repositoryState);

    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    httpClient = new HttpClient(connectionManager);
    HttpClientParams params = httpClient.getParams();
    params.setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true);
    params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, true);
    params.setSoTimeout(socketTimeout);//w w w .j a v a  2 s .  c  o  m
    HttpConnectionManagerParams connectionManagerParams = httpClient.getHttpConnectionManager().getParams();
    connectionManagerParams.setMaxTotalConnections(maxTotalConnections);
    connectionManagerParams.setDefaultMaxConnectionsPerHost(maxHostConnections);

    httpClient.getHostConfiguration().setHost(host, port);
}

From source file:terrastore.client.connection.resteasy.HTTPConnectionFactory.java

public HTTPConnectionFactory() {
    HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams();
    httpParams.setDefaultMaxConnectionsPerHost(Runtime.getRuntime().availableProcessors() * 10);
    httpParams.setMaxTotalConnections(Runtime.getRuntime().availableProcessors() * 10);
    HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager();
    httpManager.setParams(httpParams);/*from w w  w  .j  a  v  a 2  s .co  m*/
    this.client = new HttpClient(httpManager);
}

From source file:terrastore.integration.IntegrationTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ...");
    Thread.sleep(SETUP_TIME);/*from   w ww .j a v  a  2 s  . c o  m*/
    //
    HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams();
    httpParams.setDefaultMaxConnectionsPerHost(100);
    httpParams.setMaxTotalConnections(100);
    HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager();
    httpManager.setParams(httpParams);
    HTTP_CLIENT.setHttpConnectionManager(httpManager);
}

From source file:terrastore.metrics.PerformanceTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    HTTP_CLIENT.setHttpConnectionManager(new MultiThreadedHttpConnectionManager());
    System.err.println("Waiting " + SETUP_TIME + " millis for system to set up ...");
    Thread.sleep(SETUP_TIME);/*from  ww w . j av a  2  s  .c o m*/
    //
    HttpConnectionManagerParams httpParams = new HttpConnectionManagerParams();
    httpParams.setDefaultMaxConnectionsPerHost(100);
    httpParams.setMaxTotalConnections(100);
    HttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager();
    httpManager.setParams(httpParams);
    HTTP_CLIENT.setHttpConnectionManager(httpManager);
}