Search in sources :

Example 21 with PoolResources

use of reactor.ipc.netty.resources.PoolResources in project cf-java-client by cloudfoundry.

the class _DefaultConnectionContext method getHttpClient.

@Override
@Value.Default
public HttpClient getHttpClient() {
    return HttpClient.create(options -> {
        options.compression(true).loopResources(getThreadPool()).option(SO_SNDBUF, SEND_BUFFER_SIZE).option(SO_RCVBUF, RECEIVE_BUFFER_SIZE).disablePool();
        options.sslSupport(ssl -> getSslCertificateTruster().ifPresent(trustManager -> ssl.trustManager(new StaticTrustManagerFactory(trustManager))));
        getConnectionPool().ifPresent(options::poolResources);
        getConnectTimeout().ifPresent(socketTimeout -> options.option(CONNECT_TIMEOUT_MILLIS, (int) socketTimeout.toMillis()));
        getKeepAlive().ifPresent(keepAlive -> options.option(SO_KEEPALIVE, keepAlive));
        getSslHandshakeTimeout().ifPresent(options::sslHandshakeTimeout);
        getSslCloseNotifyFlushTimeout().ifPresent(options::sslCloseNotifyFlushTimeout);
        getSslCloseNotifyReadTimeout().ifPresent(options::sslCloseNotifyReadTimeout);
        getProxyConfiguration().ifPresent(c -> c.configure(options));
    });
}
Also used : SO_SNDBUF(io.netty.channel.ChannelOption.SO_SNDBUF) LoggerFactory(org.slf4j.LoggerFactory) SO_RCVBUF(io.netty.channel.ChannelOption.SO_RCVBUF) DeserializationFeature(com.fasterxml.jackson.databind.DeserializationFeature) CONNECT_TIMEOUT_MILLIS(io.netty.channel.ChannelOption.CONNECT_TIMEOUT_MILLIS) PreDestroy(javax.annotation.PreDestroy) FAIL_ON_UNKNOWN_PROPERTIES(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) DeserializationProblemHandler(com.fasterxml.jackson.databind.deser.DeserializationProblemHandler) Value(org.immutables.value.Value) SslCertificateTruster(org.cloudfoundry.reactor.util.SslCertificateTruster) Duration(java.time.Duration) HttpClient(reactor.ipc.netty.http.client.HttpClient) LoopResources(reactor.ipc.netty.resources.LoopResources) ManagementFactory(java.lang.management.ManagementFactory) NON_NULL(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) ByteBufAllocatorMetricProviderWrapper(org.cloudfoundry.reactor.util.ByteBufAllocatorMetricProviderWrapper) Logger(org.slf4j.Logger) SO_KEEPALIVE(io.netty.channel.ChannelOption.SO_KEEPALIVE) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultSslCertificateTruster(org.cloudfoundry.reactor.util.DefaultSslCertificateTruster) Mono(reactor.core.publisher.Mono) ObjectName(javax.management.ObjectName) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) Nullable(org.cloudfoundry.Nullable) PoolResources(reactor.ipc.netty.resources.PoolResources) Jdk8Module(com.fasterxml.jackson.datatype.jdk8.Jdk8Module) StaticTrustManagerFactory(org.cloudfoundry.reactor.util.StaticTrustManagerFactory) MalformedObjectNameException(javax.management.MalformedObjectNameException) List(java.util.List) JMException(javax.management.JMException) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) StaticTrustManagerFactory(org.cloudfoundry.reactor.util.StaticTrustManagerFactory)

Aggregations

PoolResources (reactor.ipc.netty.resources.PoolResources)21 Test (org.junit.Test)18 Mono (reactor.core.publisher.Mono)17 Duration (java.time.Duration)16 Flux (reactor.core.publisher.Flux)15 NettyContext (reactor.ipc.netty.NettyContext)15 InetSocketAddress (java.net.InetSocketAddress)14 CountDownLatch (java.util.concurrent.CountDownLatch)14 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)12 StepVerifier (reactor.test.StepVerifier)12 SslContext (io.netty.handler.ssl.SslContext)11 HttpHeaderNames (io.netty.handler.codec.http.HttpHeaderNames)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)10 FutureMono (reactor.ipc.netty.FutureMono)10 HttpServer (reactor.ipc.netty.http.server.HttpServer)10 Unpooled (io.netty.buffer.Unpooled)9 HttpResponseStatus (io.netty.handler.codec.http.HttpResponseStatus)9 HttpVersion (io.netty.handler.codec.http.HttpVersion)9 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)9 InsecureTrustManagerFactory (io.netty.handler.ssl.util.InsecureTrustManagerFactory)9