Example usage for org.apache.http.impl.nio.reactor IOReactorConfig.Builder setIoThreadCount

List of usage examples for org.apache.http.impl.nio.reactor IOReactorConfig.Builder setIoThreadCount

Introduction

In this page you can find the example usage for org.apache.http.impl.nio.reactor IOReactorConfig.Builder setIoThreadCount.

Prototype

@Deprecated
public void setIoThreadCount(final int ioThreadCount) 

Source Link

Usage

From source file:com.networknt.client.Client.java

private ConnectingIOReactor ioReactor() throws ClientException {
    Map<String, Object> asyncMap = (Map) config.get(ASYNC);
    Map<String, Object> reactorMap = (Map) asyncMap.get(REACTOR);
    Integer ioThreadCount = (Integer) reactorMap.get(REACTOR_IO_THREAD_COUNT);
    IOReactorConfig.Builder builder = IOReactorConfig.custom();
    builder.setIoThreadCount(
            ioThreadCount == null ? Runtime.getRuntime().availableProcessors() : ioThreadCount);
    Integer connectTimeout = (Integer) reactorMap.get(REACTOR_CONNECT_TIMEOUT);
    builder.setConnectTimeout(connectTimeout == null ? DEFAULT_REACTOR_CONNECT_TIMEOUT : connectTimeout);
    Integer soTimeout = (Integer) reactorMap.get(REACTOR_SO_TIMEOUT);
    builder.setSoTimeout(soTimeout == null ? DEFAULT_REACTOR_SO_TIMEOUT : soTimeout);
    ConnectingIOReactor reactor = null;//from w  w  w. j a va 2  s.co m
    try {
        reactor = new DefaultConnectingIOReactor(builder.build());
    } catch (IOReactorException e) {
        logger.error("IOReactorException: ", e);
        throw new ClientException("IOReactorException: ", e);
    }
    return reactor;
}