Package org.apache.commons.httpclient.params

Examples of org.apache.commons.httpclient.params.HttpConnectionManagerParams


  private void initialize(Cluster cluster, boolean sslEnabled) {
    this.cluster = cluster;
    this.sslEnabled = sslEnabled;
    MultiThreadedHttpConnectionManager manager =
      new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams managerParams = manager.getParams();
    managerParams.setConnectionTimeout(2000); // 2 s
    managerParams.setDefaultMaxConnectionsPerHost(10);
    managerParams.setMaxTotalConnections(100);
    extraHeaders = new ConcurrentHashMap<String, String>();
    this.httpClient = new HttpClient(manager);
    HttpClientParams clientParams = httpClient.getParams();
    clientParams.setVersion(HttpVersion.HTTP_1_1);
View Full Code Here


   * client.
   */
  public synchronized HttpClient getHttpClient() {
    //see http://hc.apache.org/httpclient-3.x/threading.html
    MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams connectionManagerParams = connectionManager.getParams();
    connectionManagerParams.setConnectionTimeout(30000);
    connectionManager.setParams(connectionManagerParams);

    HttpClientParams clientParams = new HttpClientParams();
    clientParams.setConnectionManagerTimeout(300000); // 5 minutes

View Full Code Here

  public SemanticWebClient(CacheController cacheController, SpongerProvider spongerProvider, Collection<DataProvider> dataProviders) {
    this.cacheController = cacheController;
    this.dataProviders = dataProviders;

    /* Set connection parameters */
    HttpConnectionManagerParams httpManagerParams = new HttpConnectionManagerParams();
    httpManagerParams.setConnectionTimeout(CONNECTION_TIMEOUT * 1000);
    httpManagerParams.setTcpNoDelay(true);
    httpManagerParams.setStaleCheckingEnabled(true);

    MultiThreadedHttpConnectionManager httpManager = new MultiThreadedHttpConnectionManager();
    httpManager.setParams(httpManagerParams);

    httpClient = new HttpClient(httpManager);
View Full Code Here

    // Use MultiThreadedHttpConnectionManager to allow concurrent access on
    // HttpClient
    HttpConnectionManager manager = new MultiThreadedHttpConnectionManager();

    // Allow 20 concurrent connections to the same host (default is 2)
    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
    params.setDefaultMaxConnectionsPerHost(20);
    manager.setParams(params);

    httpClient = new HttpClient(manager);
  }
View Full Code Here

        /* Set host configuration */
        HostConfiguration hostConfiguration = new HostConfiguration();

        /* Set connection manager parameters */
        HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
        connectionManagerParams.setConnectionTimeout(config.getConnectionTimeout());
        connectionManagerParams.setSoTimeout(config.getSocketTimeout());
        connectionManagerParams.setStaleCheckingEnabled(true);
        connectionManagerParams.setTcpNoDelay(true);
        connectionManagerParams.setMaxTotalConnections(config.getMaxConnections());
        connectionManagerParams.setMaxConnectionsPerHost(hostConfiguration, config.getMaxConnections());

        int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0];
        if (socketSendBufferSizeHint > 0) {
            connectionManagerParams.setSendBufferSize(socketSendBufferSizeHint);
        }

        int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1];
        if (socketReceiveBufferSizeHint > 0) {
            connectionManagerParams.setReceiveBufferSize(socketReceiveBufferSizeHint);
        }

        /* Set connection manager */
        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.setParams(connectionManagerParams);
View Full Code Here

            throw new RepositoryException(e);
        }

        connectionManager = new MultiThreadedHttpConnectionManager();
        if (maximumHttpConnections > 0) {
            HttpConnectionManagerParams connectionParams = connectionManager.getParams();
            connectionParams.setDefaultMaxConnectionsPerHost(maximumHttpConnections);
        }

        // This configuration of the clients cache assumes that the level of
        // concurrency on this map will be equal to the default number of maximum
        // connections allowed on the httpClient level.
View Full Code Here

    // Set up an HTTPS socket factory that accepts self-signed certs.
    ProtocolSocketFactory factory = new SSLProtocolSocketFactory();
    Protocol https = new Protocol("https", factory, 443);
    Protocol.registerProtocol("https", https);

    HttpConnectionManagerParams params = connectionManager.getParams();
    params.setConnectionTimeout(timeout);
    params.setSoTimeout(timeout);
    params.setSendBufferSize(BUFFER_SIZE);
    params.setReceiveBufferSize(BUFFER_SIZE);
    params.setMaxTotalConnections(maxThreadsTotal);

    // executeMethod(HttpMethod) seems to ignore the connection timeout on the connection manager.
    // set it explicitly on the HttpClient.
    client.getParams().setConnectionManagerTimeout(timeout);
View Full Code Here

        /* Set host configuration */
        HostConfiguration hostConfiguration = new HostConfiguration();

        /* Set connection manager parameters */
        HttpConnectionManagerParams connectionManagerParams = new HttpConnectionManagerParams();
        connectionManagerParams.setConnectionTimeout(config.getConnectionTimeout());
        connectionManagerParams.setSoTimeout(config.getSocketTimeout());
        connectionManagerParams.setStaleCheckingEnabled(true);
        connectionManagerParams.setTcpNoDelay(true);
        connectionManagerParams.setMaxTotalConnections(config.getMaxConnections());
        connectionManagerParams.setMaxConnectionsPerHost(hostConfiguration, config.getMaxConnections());

        int socketSendBufferSizeHint = config.getSocketBufferSizeHints()[0];
        if (socketSendBufferSizeHint > 0) {
            connectionManagerParams.setSendBufferSize(socketSendBufferSizeHint);
        }

        int socketReceiveBufferSizeHint = config.getSocketBufferSizeHints()[1];
        if (socketReceiveBufferSizeHint > 0) {
            connectionManagerParams.setReceiveBufferSize(socketReceiveBufferSizeHint);
        }

        /* Set connection manager */
        MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
        connectionManager.setParams(connectionManagerParams);
View Full Code Here

    // Set up an HTTPS socket factory that accepts self-signed certs.
    Protocol dummyhttps = new Protocol("https", new DummySSLProtocolSocketFactory(), 443);
    Protocol.registerProtocol("https", dummyhttps);
   
    HttpConnectionManagerParams params = connectionManager.getParams();
    params.setConnectionTimeout(timeout);
    params.setSoTimeout(timeout);
    params.setSendBufferSize(BUFFER_SIZE);
    params.setReceiveBufferSize(BUFFER_SIZE);
    params.setMaxTotalConnections(maxThreadsTotal);
    if (maxThreadsTotal > maxThreadsPerHost) {
      params.setDefaultMaxConnectionsPerHost(maxThreadsPerHost);
    } else {
      params.setDefaultMaxConnectionsPerHost(maxThreadsTotal);
    }

    HostConfiguration hostConf = client.getHostConfiguration();
    ArrayList headers = new ArrayList();
    // prefer English
View Full Code Here

    private void ensureClientInitialized() {
        if(configuration == null) throw new IllegalStateException("client must be initialized first.");
        if (client != null) return;
        client = new HttpClient(manager);
        HttpConnectionManager connectionManager = client.getHttpConnectionManager();
        HttpConnectionManagerParams params = connectionManager.getParams();
        params.setConnectionTimeout(configuration.getDefaultTimeout());
        params.setSoTimeout(configuration.getDefaultTimeout());
        params.setMaxTotalConnections(configuration.getMaxConnections());

        HostConfiguration hostConf = client.getHostConfiguration();
        List<Header> headers = new ArrayList<Header>();
        headers.add(new Header("User-Agent", configuration.getUserAgent()));
        if (configuration.getAcceptHeader() != null) {
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.params.HttpConnectionManagerParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.