Search in sources :

Example 1 with NHttpClientConnectionManager

use of org.apache.http.nio.conn.NHttpClientConnectionManager in project incubator-gobblin by apache.

the class ApacheHttpAsyncClient method getNHttpConnManager.

private NHttpClientConnectionManager getNHttpConnManager(Config config) throws IOException {
    NHttpClientConnectionManager httpConnManager;
    String connMgrStr = config.getString(HTTP_CONN_MANAGER);
    switch(ApacheHttpClient.ConnManager.valueOf(connMgrStr.toUpperCase())) {
        case POOLING:
            ConnectingIOReactor ioReactor = new DefaultConnectingIOReactor();
            PoolingNHttpClientConnectionManager poolingConnMgr = new PoolingNHttpClientConnectionManager(ioReactor);
            poolingConnMgr.setMaxTotal(config.getInt(POOLING_CONN_MANAGER_MAX_TOTAL_CONN));
            poolingConnMgr.setDefaultMaxPerRoute(config.getInt(POOLING_CONN_MANAGER_MAX_PER_CONN));
            httpConnManager = poolingConnMgr;
            break;
        default:
            throw new IllegalArgumentException(connMgrStr + " is not supported");
    }
    LOG.info("Using " + httpConnManager.getClass().getSimpleName());
    return httpConnManager;
}
Also used : ConnectingIOReactor(org.apache.http.nio.reactor.ConnectingIOReactor) DefaultConnectingIOReactor(org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor) DefaultConnectingIOReactor(org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor) PoolingNHttpClientConnectionManager(org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager) NHttpClientConnectionManager(org.apache.http.nio.conn.NHttpClientConnectionManager) PoolingNHttpClientConnectionManager(org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager)

Aggregations

PoolingNHttpClientConnectionManager (org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager)1 DefaultConnectingIOReactor (org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor)1 NHttpClientConnectionManager (org.apache.http.nio.conn.NHttpClientConnectionManager)1 ConnectingIOReactor (org.apache.http.nio.reactor.ConnectingIOReactor)1