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

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

Introduction

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

Prototype

public int getDefaultMaxConnectionsPerHost() 

Source Link

Usage

From source file:com.zimbra.common.util.ZimbraHttpConnectionManager.java

private static String dumpParams(String notes, HttpConnectionManagerParams connMgrParams,
        HttpClientParams clientParams) {
    // dump httpclient package defaults if params is null
    if (connMgrParams == null)
        connMgrParams = new HttpConnectionManagerParams();
    if (clientParams == null)
        clientParams = new HttpClientParams();

    StringBuilder sb = new StringBuilder();

    sb.append("======== " + notes + "========\n");

    sb.append("HttpConnectionManagerParams DefaultMaxConnectionsPerHost  : "
            + connMgrParams.getDefaultMaxConnectionsPerHost() + "\n");
    sb.append("HttpConnectionManagerParams MaxTotalConnections           : "
            + connMgrParams.getMaxTotalConnections() + "\n");

    sb.append("HttpConnectionParams ConnectionTimeout                    : "
            + connMgrParams.getConnectionTimeout() + "\n");
    sb.append(/*w  ww .  ja  v a  2  s.c o  m*/
            "HttpConnectionParams Linger                               : " + connMgrParams.getLinger() + "\n");
    sb.append("HttpConnectionParams ReceiveBufferSize                    : "
            + connMgrParams.getReceiveBufferSize() + "\n");
    sb.append("HttpConnectionParams SendBufferSize                       : " + connMgrParams.getSendBufferSize()
            + "\n");
    sb.append("HttpConnectionParams SoTimeout                            : " + connMgrParams.getSoTimeout()
            + "\n");
    sb.append("HttpConnectionParams TcpNoDelay                           : " + connMgrParams.getTcpNoDelay()
            + "\n");
    sb.append("HttpConnectionParams isStaleCheckingEnabled               : "
            + connMgrParams.isStaleCheckingEnabled() + "\n");

    // sb.append("HttpClientParams ALLOW_CIRCULAR_REDIRECTS            (no corresponding method?)
    sb.append("HttpClientParams ConnectionManagerClass               : "
            + clientParams.getConnectionManagerClass().getName() + "\n");
    sb.append("HttpClientParams ConnectionManagerTimeout             : "
            + clientParams.getConnectionManagerTimeout() + "\n");
    // sb.append("HttpClientParams MAX_REDIRECTS                       (no corresponding method?)
    sb.append("HttpClientParams isAuthenticationPreemptive()         : "
            + clientParams.isAuthenticationPreemptive() + "\n");
    // sb.append("HttpClientParams REJECT_RELATIVE_REDIRECT            (no corresponding method?)

    return sb.toString();
}

From source file:org.bibsonomy.recommender.tags.WebserviceTagRecommender.java

/**
 * inits the recommender//from   ww w  .  j  a  va  2  s  .  c om
 */
public WebserviceTagRecommender() {
    // Create an instance of HttpClient.
    connectionManager = new IdleClosingConnectionManager();// MultiThreadedHttpConnectionManager();
    client = new HttpClient(connectionManager);

    // set default timeouts
    final HttpConnectionManagerParams connectionParams = connectionManager.getParams();
    connectionParams.setSoTimeout(SOCKET_TIMEOUT_MS);
    connectionParams.setConnectionTimeout(HTTP_CONNECTION_TIMEOUT_MS);
    connectionManager.setParams(connectionParams);
    log.debug("MAXCONNECTIONS: " + connectionParams.getMaxTotalConnections());
    log.debug("MAXCONNECTIONSPERHOST: " + connectionParams.getDefaultMaxConnectionsPerHost());

    // handle idle connections
    connectionManager.closeIdleConnections(IDLE_TIMEOUT_MS);
    idleConnectionHandler = new IdleConnectionTimeoutThread();
    idleConnectionHandler.addConnectionManager(connectionManager);
    idleConnectionHandler.start();

    this.renderer = new RendererFactory(new UrlRenderer("/api/")).getRenderer(RenderingFormat.XML);
}

From source file:org.mule.transport.http.HttpConnectorTestCase.java

@Test
public void testProperties() throws Exception {
    HttpConnector c = (HttpConnector) getConnector();

    c.setSendBufferSize(1024);//from  w  ww .  j av a 2s.c o m
    assertEquals(1024, c.getSendBufferSize());
    c.setSendBufferSize(0);
    assertEquals(TcpConnector.DEFAULT_BUFFER_SIZE, c.getSendBufferSize());

    int maxDispatchers = c.getMaxTotalDispatchers();
    HttpConnectionManagerParams params = c.getClientConnectionManager().getParams();
    assertEquals(maxDispatchers, params.getDefaultMaxConnectionsPerHost());
    assertEquals(maxDispatchers, params.getMaxTotalConnections());

    // all kinds of timeouts are now being tested in TcpConnectorTestCase
}