Examples of ThreadSafeClientConnManager


Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

        HttpParams params = defaultParams.copy();
        ConnManagerParams.setMaxTotalConnections
            (params, 1);
        ConnManagerParams.setMaxConnectionsPerRoute
            (params, new ConnPerRouteBean(1));
        ThreadSafeClientConnManager mgr = createTSCCM(params, null);

        // Zero connections in the pool
        assertEquals(0, mgr.getConnectionsInPool());
       
        DefaultHttpClient client = new DefaultHttpClient(mgr, params);

        // Get some random data
        HttpGet httpget = new HttpGet("/dropdead");
        HttpHost target = getServerHttp();
       
        HttpResponse response = client.execute(target, httpget);

        ClientConnectionRequest connreq = mgr.requestConnection(new HttpRoute(target), null);
        try {
            connreq.getConnection(250, TimeUnit.MILLISECONDS);
            fail("ConnectionPoolTimeoutException should have been thrown");
        } catch (ConnectionPoolTimeoutException expected) {
        }
       
        HttpEntity e = response.getEntity();
        assertNotNull(e);
        // Read the content
        try {
            EntityUtils.toByteArray(e);
            fail("MalformedChunkCodingException should have been thrown");
        } catch (MalformedChunkCodingException expected) {
           
        }
       
        // Expect zero connections in the pool
        assertEquals(0, mgr.getConnectionsInPool());

        // Make sure one connection is available
        connreq = mgr.requestConnection(new HttpRoute(target), null);
        ManagedClientConnection conn = connreq.getConnection(250, TimeUnit.MILLISECONDS);
       
        mgr.releaseConnection(conn, -1, null);
       
        mgr.shutdown();
    }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

  /** Called from {@link #init(javax.servlet.ServletConfig)}. HttpClient offers many opportunities for customization.
* @param hcParams*/
  @SuppressWarnings("deprecation")
protected HttpClient createHttpClient(HttpParams hcParams) {
    return new DefaultHttpClient(new ThreadSafeClientConnManager(),hcParams);
  }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

    else
      httpsScheme = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(httpsScheme);
    HttpParams params = getHttpParams(connectionTimeout, soTimeout);
    ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry);
    return new DefaultHttpClient(cm, params);
  }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

    else
      httpsScheme = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(httpsScheme);
    HttpParams params = getHttpParams(connectionTimeout, soTimeout);
    ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry);
    return new DefaultHttpClient(cm, params);
  }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

    else
      httpsScheme = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(httpsScheme);
    HttpParams params = getHttpParams(connectionTimeout, soTimeout);
    ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry);
    return new DefaultHttpClient(cm, params);
  }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

    else
      httpsScheme = new Scheme("http", 80, PlainSocketFactory.getSocketFactory());
    SchemeRegistry schemeRegistry = new SchemeRegistry();
    schemeRegistry.register(httpsScheme);
    HttpParams params = getHttpParams(connectionTimeout, soTimeout);
    ClientConnectionManager cm = new ThreadSafeClientConnManager(schemeRegistry);
    return new DefaultHttpClient(cm, params);
  }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

                                                 "users",
                                                 RequestFormatType.VOLDEMORT_V1,
                                                 node.getHttpPort());
        server = context.getServer();

        ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                                        5000,
                                                                                        TimeUnit.MILLISECONDS);
        httpClient = new DefaultHttpClient(connectionManager);
        httpStore = ServerTestUtils.getHttpStore("users",
                                                 RequestFormatType.VOLDEMORT_V1,
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

        VoldemortIOUtils.closeQuietly(client);
        System.exit(1);
    }

    private static HttpClient createClient() {
        ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                                        DEFAULT_CONNECTION_MANAGER_TIMEOUT,
                                                                                        TimeUnit.MILLISECONDS);

        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);

        HttpParams clientParams = httpClient.getParams();

        HttpConnectionParams.setSocketBufferSize(clientParams, 60000);
        HttpConnectionParams.setTcpNoDelay(clientParams, false);
        HttpProtocolParams.setUserAgent(clientParams, VOLDEMORT_USER_AGENT);
        HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);
        // HostConfiguration hostConfig = new HostConfiguration();
        // hostConfig.setHost("localhost");

        HttpConnectionParams.setConnectionTimeout(clientParams, DEFAULT_CONNECTION_MANAGER_TIMEOUT);
        HttpConnectionParams.setSoTimeout(clientParams, 500);
        httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
        HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);

        connectionManager.setMaxTotal(DEFAULT_MAX_CONNECTIONS);
        connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_HOST_CONNECTIONS);
        HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

        return httpClient;
    }
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

                                                  RequestFormatType.VOLDEMORT_V0,
                                                  numThreads,
                                                  8080);
        httpService.start();

        ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager(SchemeRegistryFactory.createDefault(),
                                                                                        10000,
                                                                                        TimeUnit.MILLISECONDS);

        DefaultHttpClient httpClient = new DefaultHttpClient(connectionManager);

        HttpParams clientParams = httpClient.getParams();
        httpClient.setHttpRequestRetryHandler(new DefaultHttpRequestRetryHandler(0, false));
        HttpClientParams.setCookiePolicy(clientParams, CookiePolicy.IGNORE_COOKIES);
        HttpProtocolParams.setUserAgent(clientParams, "test-agent");
        HttpProtocolParams.setVersion(clientParams, HttpVersion.HTTP_1_1);

        HttpConnectionParams.setConnectionTimeout(clientParams, 10000);

        connectionManager.setMaxTotal(numThreads);
        connectionManager.setDefaultMaxPerRoute(numThreads);
        HttpConnectionParams.setStaleCheckingEnabled(clientParams, false);

        final HttpStore httpStore = new HttpStore("test",
                                                  "localhost",
                                                  8080,
View Full Code Here

Examples of org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager

    public void testHttpStoreSwapper() throws Exception {
        ExecutorService executor = Executors.newCachedThreadPool();
        DefaultHttpClient client = null;
        try {
            // Use the http store swapper
            ThreadSafeClientConnManager connectionManager = new ThreadSafeClientConnManager();

            connectionManager.setMaxTotal(10);
            connectionManager.setDefaultMaxPerRoute(10);

            client = new DefaultHttpClient(connectionManager);

            StoreSwapper swapper = new HttpStoreSwapper(cluster,
                                                        executor,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.