Search in sources :

Example 6 with LoopResources

use of reactor.ipc.netty.resources.LoopResources in project reactor-netty by reactor.

the class ServerOptions method groupAndChannel.

final void groupAndChannel(ServerBootstrap bootstrap) {
    LoopResources loops = Objects.requireNonNull(getLoopResources(), "loopResources");
    boolean useNative = preferNative() && !(sslContext() instanceof JdkSslContext);
    final EventLoopGroup selectorGroup = loops.onServerSelect(useNative);
    final EventLoopGroup elg = loops.onServer(useNative);
    bootstrap.group(selectorGroup, elg).channel(loops.onServerChannel(elg));
}
Also used : JdkSslContext(io.netty.handler.ssl.JdkSslContext) EventLoopGroup(io.netty.channel.EventLoopGroup) LoopResources(reactor.ipc.netty.resources.LoopResources)

Example 7 with LoopResources

use of reactor.ipc.netty.resources.LoopResources 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

LoopResources (reactor.ipc.netty.resources.LoopResources)7 EventLoopGroup (io.netty.channel.EventLoopGroup)4 Duration (java.time.Duration)4 Test (org.junit.Test)4 Mono (reactor.core.publisher.Mono)4 CountDownLatch (java.util.concurrent.CountDownLatch)3 TimeUnit (java.util.concurrent.TimeUnit)3 Supplier (java.util.function.Supplier)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 Before (org.junit.Before)3 NettyContext (reactor.ipc.netty.NettyContext)3 PoolResources (reactor.ipc.netty.resources.PoolResources)3 Bootstrap (io.netty.bootstrap.Bootstrap)2 Channel (io.netty.channel.Channel)2 ChannelPool (io.netty.channel.pool.ChannelPool)2 JdkSslContext (io.netty.handler.ssl.JdkSslContext)2 NON_NULL (com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL)1 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)1 FAIL_ON_UNKNOWN_PROPERTIES (com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1