Example usage for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager

List of usage examples for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager

Introduction

In this page you can find the example usage for org.apache.commons.httpclient MultiThreadedHttpConnectionManager MultiThreadedHttpConnectionManager.

Prototype

public MultiThreadedHttpConnectionManager() 

Source Link

Usage

From source file:com.rometools.propono.atom.client.ClientCollection.java

ClientCollection(final String href, final AuthStrategy authStrategy) throws ProponoException {
    super("Standalone connection", "text", href);
    this.authStrategy = authStrategy;
    try {//www. j a  va 2s.co  m
        httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
        // TODO: make connection timeout configurable
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
    } catch (final Throwable t) {
        throw new ProponoException("ERROR creating HTTPClient", t);
    }
}

From source file:com.gisgraphy.rest.RestClient.java

/**
 * Default constructor 
 */
public RestClient() {
    this(new MultiThreadedHttpConnectionManager());
}

From source file:de.kp.ames.webdav.WebDAVClient.java

/**
 * Constructor/*from w  w  w .j  a va  2 s  .c  om*/
 * 
 * @param alias
 * @param keypass
 * @param uri
 */
public WebDAVClient(String alias, String keypass, String uri) {

    /*
     * Register request uri
     */
    this.uri = uri;

    /*
     * Setup HttpClient
     */
    HostConfiguration hostConfig = new HostConfiguration();
    hostConfig.setHost(uri);

    HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();

    int maxHostConnections = 200;
    params.setMaxConnectionsPerHost(hostConfig, maxHostConnections);

    connectionManager.setParams(params);

    client = new HttpClient(connectionManager);
    client.setHostConfiguration(hostConfig);

    Credentials creds = new UsernamePasswordCredentials(alias, keypass);
    client.getState().setCredentials(AuthScope.ANY, creds);

}

From source file:com.gisgraphy.domain.geoloc.service.fulltextsearch.SolrClientTest.java

@Test
public void testIsALive() throws Exception {
    IsolrClient clientAlive = new SolrClient("http://nowhere.tld/solr",
            new MultiThreadedHttpConnectionManager());
    assertFalse(clientAlive.isServerAlive());
    clientAlive.bindToUrl(AbstractIntegrationHttpSolrTestCase.fulltextSearchUrlBinded);
    assertTrue(clientAlive.isServerAlive());
}

From source file:net.sf.xmm.moviemanager.http.HttpUtil.java

public void setup() {
    client = new HttpClient(new MultiThreadedHttpConnectionManager());
    client.getHttpConnectionManager().getParams().setConnectionTimeout(7000);
    setUp = true;/*from w  w  w.j  a v a2  s  . c o  m*/
}

From source file:com.sun.syndication.propono.atom.client.ClientCollection.java

ClientCollection(String href, AuthStrategy authStrategy) throws ProponoException {
    super("Standalone connection", "text", href);
    this.authStrategy = authStrategy;
    try {/* w ww. j  a  v a 2 s  . c o  m*/
        httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
        // TODO: make connection timeout configurable
        httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(30000);
    } catch (Throwable t) {
        throw new ProponoException("ERROR creating HTTPClient", t);
    }
}

From source file:com.duowan.common.rpc.client.CommonsHttpInvokerRequestExecutor.java

/**
 * Create a new CommonsHttpInvokerRequestExecutor with a default
 * HttpClient that uses a default MultiThreadedHttpConnectionManager.
 * Sets the socket read timeout to {@link #DEFAULT_READ_TIMEOUT_MILLISECONDS}.
 * @see org.apache.commons.httpclient.HttpClient
 * @see org.apache.commons.httpclient.MultiThreadedHttpConnectionManager
 */// w w w  .j  a va  2 s .c  o m
public CommonsHttpInvokerRequestExecutor() {
    MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(300);
    params.setMaxTotalConnections(500);
    httpConnectionManager.setParams(params);

    this.httpClient = new HttpClient(httpConnectionManager);
    this.setReadTimeout(getReadTimeout());
    this.setConnectionTimeout(getConnectionTimeout());
}

From source file:com.boyuanitsm.pay.alipay.util.httpClient.HttpProtocolHandler.java

/**
 * ?//ww w. j  av  a  2s  .  c o  m
 */
private HttpProtocolHandler() {
    // HTTP
    connectionManager = new MultiThreadedHttpConnectionManager();
    connectionManager.getParams().setDefaultMaxConnectionsPerHost(defaultMaxConnPerHost);
    connectionManager.getParams().setMaxTotalConnections(defaultMaxTotalConn);

    IdleConnectionTimeoutThread ict = new IdleConnectionTimeoutThread();
    ict.addConnectionManager(connectionManager);
    ict.setConnectionTimeout(defaultIdleConnTimeout);

    ict.start();
}

From source file:net.mumie.cocoon.httpclient.SimpleHttpClientImpl.java

/**
 * Creates a new <code>SimpleHttpClientImpl</code>.
 *//*from w  w w .j  a  va 2  s .c  om*/

public SimpleHttpClientImpl() {
    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    this.httpClient = new HttpClient(connectionManager);
    this.instanceStatus = new ServiceInstanceStatus(serviceStatus);
    this.instanceStatus.notifyCreation();
}

From source file:edu.indiana.dlib.avalon.HydrantWorkflowListener.java

private void pingHydrant(String pid, long workflowId) {
    logger.trace("Starting to ping Hydrant: " + pid + " " + workflowId);
    try {/* w w  w.j a v  a  2  s  .  co  m*/
        String url = UrlSupport.concat(new String[] { hydrantUrl, "master_files", pid });
        MultiThreadedHttpConnectionManager mgr = new MultiThreadedHttpConnectionManager();
        HttpClient client = new HttpClient(mgr);

        PutMethod put = new PutMethod(url);

        Part[] parts = { new StringPart("workflow_id", String.valueOf(workflowId)), };
        put.setRequestEntity(new MultipartRequestEntity(parts, put.getParams()));
        logger.trace("About to ping Hydrant");
        int status = client.executeMethod(put);
        logger.debug("Got status: " + status);
        logger.trace("Got response body: " + put.getResponseBodyAsString());
    } catch (Exception e) {
        logger.debug("Exception pinging Hydrant: " + e.getCause(), e);
    }
}