Example usage for org.apache.http.conn.params ConnPerRouteBean ConnPerRouteBean

List of usage examples for org.apache.http.conn.params ConnPerRouteBean ConnPerRouteBean

Introduction

In this page you can find the example usage for org.apache.http.conn.params ConnPerRouteBean ConnPerRouteBean.

Prototype

public ConnPerRouteBean(final int defaultMax) 

Source Link

Usage

From source file:org.apache.camel.component.http4.HttpComponent.java

protected ClientConnectionManager createConnectionManager() {
    SchemeRegistry schemeRegistry = new SchemeRegistry();

    // configure additional configurations
    HttpParams params = new BasicHttpParams();
    ConnManagerParamBean param = new ConnManagerParamBean(params);
    if (getMaxTotalConnections() > 0) {
        param.setMaxTotalConnections(getMaxTotalConnections());
    }/*from ww w.  jav  a 2 s.c o  m*/
    if (getConnectionsPerRoute() > 0) {
        param.setConnectionsPerRoute(new ConnPerRouteBean(getConnectionsPerRoute()));
    }

    ThreadSafeClientConnManager answer = new ThreadSafeClientConnManager(params, schemeRegistry);
    LOG.info("Created ClientConnectionManager " + answer);

    return answer;
}

From source file:org.apache.http.impl.conn.ConnPoolBench.java

static void oldPool(int c, long reps) throws Exception {
    ClientConnectionOperator operator = new DefaultClientConnectionOperator(
            SchemeRegistryFactory.createDefault());
    ConnPerRoute connPerRoute = new ConnPerRouteBean(c);
    ConnPoolByRoute pool = new ConnPoolByRoute(operator, connPerRoute, c * 10);

    WorkerThread2[] workers = new WorkerThread2[c];
    for (int i = 0; i < workers.length; i++) {
        workers[i] = new WorkerThread2(pool, reps);
    }/*www  .j  a va  2 s.  c  o  m*/
    long start = System.currentTimeMillis();
    for (int i = 0; i < workers.length; i++) {
        workers[i].start();
    }
    for (int i = 0; i < workers.length; i++) {
        workers[i].join();
    }
    long finish = System.currentTimeMillis();
    float totalTimeSec = (float) (finish - start) / 1000;
    System.out.print("Concurrency level:\t");
    System.out.println(c);
    System.out.print("Total operations:\t");
    System.out.println(c * reps);
    System.out.print("Time taken for tests:\t");
    System.out.print(totalTimeSec);
    System.out.println(" seconds");
}