Package org.apache.http.impl.conn

Examples of org.apache.http.impl.conn.PoolingClientConnectionManager


            httpMethod.abort();
        }
    }

    protected HttpClient createHttpClient() {
        DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager());
        if (useCompression) {
            client.addRequestInterceptor( new HttpRequestInterceptor() {
                @Override
                public void process(HttpRequest request, HttpContext context) {
                    // We expect to received a compression response that we un-gzip
View Full Code Here


        ClientConfig clientConfig = new ClientConfig();
        clientConfig.property(ClientProperties.READ_TIMEOUT, configuration.getReadTimeout());
        clientConfig.property(ClientProperties.CONNECT_TIMEOUT, configuration.getConnectTimeout());
        clientConfig.property(ApacheClientProperties.DISABLE_COOKIES, true);

        PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager();
        poolingClientConnectionManager.setMaxTotal(configuration.getMaxTotalThread());
        poolingClientConnectionManager.setDefaultMaxPerRoute(configuration.getDefaultMaxPerRoute());

        clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, poolingClientConnectionManager);

        Client client = ClientBuilder.newBuilder()
                .register(JacksonFeature.class)
View Full Code Here

    public ApacheHttpClient(HttpClientConfig config, Set<? extends HttpRequestFilter> requestFilters)
    {
        Preconditions.checkNotNull(config, "config is null");
        Preconditions.checkNotNull(requestFilters, "requestFilters is null");

        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
        connectionManager.setMaxTotal(config.getMaxConnections());
        connectionManager.setDefaultMaxPerRoute(config.getMaxConnectionsPerServer());

        BasicHttpParams httpParams = new BasicHttpParams();
        httpParams.setParameter(CoreConnectionPNames.SO_TIMEOUT, Ints.checkedCast(config.getReadTimeout().toMillis()));
        httpParams.setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Ints.checkedCast(config.getConnectTimeout().toMillis()));
        httpParams.setParameter(CoreConnectionPNames.SO_LINGER, 0); // do we need this?
View Full Code Here

      url = new URL(restAPIUrlBase);
    } catch (MalformedURLException e) {
      throw new SettingsException("Parameter es_connection/urlBase is malformed: " + e.getMessage());
    }

    PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
    connectionManager.setDefaultMaxPerRoute(20);
    connectionManager.setMaxTotal(20);

    DefaultHttpClient dc = new DefaultHttpClient(connectionManager);
    httpclient = dc;
    HttpParams params = httpclient.getParams();
    params.setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");
View Full Code Here

  private static DefaultHttpClient createClient() throws GeneralSecurityException {
    SchemeRegistry registry = new SchemeRegistry();
    SSLSocketFactory socketFactory = new SSLSocketFactory( new TrustSelfSignedStrategy(), SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER );
    registry.register( new Scheme( "https", 443, socketFactory ) );
    registry.register( new Scheme( "http", 80, new PlainSocketFactory() ) );
    PoolingClientConnectionManager mgr = new PoolingClientConnectionManager( registry );
    DefaultHttpClient client = new DefaultHttpClient( mgr, new DefaultHttpClient().getParams() );
    return client;
  }
View Full Code Here

    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(new Scheme("http", config.url.getPort(), PlainSocketFactory.getSocketFactory()));
    schemeRegistry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

    PoolingClientConnectionManager cm = new PoolingClientConnectionManager(schemeRegistry);
    // Increase max total connection
    cm.setMaxTotal(1000);
    // Increase default max connection per route
    cm.setDefaultMaxPerRoute(1000);

    HttpClient httpClient = new DefaultHttpClient(cm);
    client = new ApacheHttpClient4(new ApacheHttpClient4Handler(httpClient, null, false), clientConfig);

    client.setReadTimeout(10000);
View Full Code Here

            HttpConnectionParams.setSocketBufferSize(httpClientParams,
                    Math.max(socketSendBufferSizeHint, socketReceiveBufferSizeHint));
        }

        /* Set connection manager */
        PoolingClientConnectionManager connectionManager = ConnectionManagerFactory.createPoolingClientConnManager(config, httpClientParams);
        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager, httpClientParams);
        httpClient.setRedirectStrategy(new LocationHeaderNotRequiredRedirectStrategy());

        try {
            Scheme http = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());

            SSLSocketFactory sf = new SSLSocketFactory(
                    SSLContext.getDefault(),
                    SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
            Scheme https = new Scheme("https", 443, sf);

            SchemeRegistry sr = connectionManager.getSchemeRegistry();
            sr.register(http);
            sr.register(https);
        } catch (NoSuchAlgorithmException e) {
            throw new AmazonClientException("Unable to access default SSL context", e);
        }
View Full Code Here

/** Responsible for creating and configuring instances of Apache HttpClient4's Connection Manager. */
class ConnectionManagerFactory {

    public static PoolingClientConnectionManager createPoolingClientConnManager( ClientConfiguration config, HttpParams httpClientParams ) {
        PoolingClientConnectionManager connectionManager = new PoolingClientConnectionManager();
        connectionManager.setDefaultMaxPerRoute(config.getMaxConnections());
        connectionManager.setMaxTotal(config.getMaxConnections());

        IdleConnectionReaper.registerConnectionManager(connectionManager);
        return connectionManager;
    }
View Full Code Here

                        schemeRegistry.register(
                                new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
                        schemeRegistry.register(
                                new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));

                        connManager = new PoolingClientConnectionManager(schemeRegistry);
                        ((PoolingClientConnectionManager)connManager).setMaxTotal(200);
                        ((PoolingClientConnectionManager)connManager).setDefaultMaxPerRoute(200);
                        configContext.setProperty(
                                HTTPConstants.MULTITHREAD_HTTP_CONNECTION_MANAGER, connManager);
                    }
View Full Code Here

            httpParams.setParameter(CoreProtocolPNames.USER_AGENT, "Stanbol Integration Test");
            httpParams.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS,true);
            httpParams.setIntParameter(ClientPNames.MAX_REDIRECTS,3);
            httpParams.setBooleanParameter(CoreConnectionPNames.SO_KEEPALIVE,true);
   
            connectionManager = new PoolingClientConnectionManager();
            connectionManager.setMaxTotal(20);
            connectionManager.setDefaultMaxPerRoute(20);
   
            pooledHttpClient = new DefaultHttpClient(connectionManager,httpParams);
        }
View Full Code Here

TOP

Related Classes of org.apache.http.impl.conn.PoolingClientConnectionManager

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.