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

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

Introduction

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

Prototype

@Deprecated
public void setConnectTimeout(final int connectTimeout) 

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(/*from w  w w  . j  a  v  a 2 s .  c  om*/
            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;
    try {
        reactor = new DefaultConnectingIOReactor(builder.build());
    } catch (IOReactorException e) {
        logger.error("IOReactorException: ", e);
        throw new ClientException("IOReactorException: ", e);
    }
    return reactor;
}