io.netty.resolver.dns.DnsServerAddressStreamProviders Java Examples
The following examples show how to use
io.netty.resolver.dns.DnsServerAddressStreamProviders.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisClient.java From redisson with Apache License 2.0 | 5 votes |
private RedisClient(RedisClientConfig config) { RedisClientConfig copy = new RedisClientConfig(config); if (copy.getTimer() == null) { copy.setTimer(new HashedWheelTimer()); hasOwnTimer = true; } if (copy.getGroup() == null) { copy.setGroup(new NioEventLoopGroup()); hasOwnGroup = true; } if (copy.getExecutor() == null) { copy.setExecutor(Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2)); hasOwnExecutor = true; } if (copy.getResolverGroup() == null) { if (config.getSocketChannelClass() == EpollSocketChannel.class) { copy.setResolverGroup(new DnsAddressResolverGroup(EpollDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault())); } else { copy.setResolverGroup(new DnsAddressResolverGroup(NioDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault())); } hasOwnResolver = true; } this.config = copy; this.executor = copy.getExecutor(); this.timer = copy.getTimer(); uri = copy.getAddress(); resolvedAddr = copy.getAddr(); if (resolvedAddr != null) { resolvedAddrFuture.set(RedissonPromise.newSucceededFuture(resolvedAddr)); } channels = new DefaultChannelGroup(copy.getGroup().next()); bootstrap = createBootstrap(copy, Type.PLAIN); pubSubBootstrap = createBootstrap(copy, Type.PUBSUB); this.commandTimeout = copy.getCommandTimeout(); }
Example #2
Source File: ClientBuilderFactory.java From curiostack with MIT License | 4 votes |
@Inject public ClientBuilderFactory( MeterRegistry meterRegistry, Tracing tracing, Function<HttpClient, LoggingClient> loggingClient, Optional<SelfSignedCertificate> selfSignedCertificate, Optional<TrustManagerFactory> caTrustManager, ServerConfig serverConfig) { this.tracing = tracing; this.meterRegistry = meterRegistry; this.loggingClient = loggingClient; final TrustManagerFactory trustManagerFactory; if (serverConfig.isDisableClientCertificateVerification()) { logger.warn("Disabling client SSL verification. This should only happen on local!"); trustManagerFactory = InsecureTrustManagerFactory.INSTANCE; } else if (caTrustManager.isPresent()) { trustManagerFactory = caTrustManager.get(); } else { trustManagerFactory = null; } final Consumer<SslContextBuilder> clientCertificateCustomizer; if (selfSignedCertificate.isPresent()) { SelfSignedCertificate certificate = selfSignedCertificate.get(); clientCertificateCustomizer = sslContext -> sslContext.keyManager(certificate.certificate(), certificate.privateKey()); } else if (serverConfig.getTlsCertificatePath().isEmpty() || serverConfig.getTlsPrivateKeyPath().isEmpty()) { throw new IllegalStateException( "No TLS configuration provided, Curiostack does not support clients without TLS " + "certificates. Use gradle-curio-cluster-plugin to set up a namespace and TLS."); } else { String certPath = !serverConfig.getClientTlsCertificatePath().isEmpty() ? serverConfig.getClientTlsCertificatePath() : serverConfig.getTlsCertificatePath(); String keyPath = !serverConfig.getClientTlsPrivateKeyPath().isEmpty() ? serverConfig.getClientTlsPrivateKeyPath() : serverConfig.getTlsPrivateKeyPath(); clientCertificateCustomizer = sslContext -> SslContextKeyConverter.execute( ResourceUtil.openStream(certPath), ResourceUtil.openStream(keyPath), sslContext::keyManager); } final Consumer<SslContextBuilder> clientTlsCustomizer; if (trustManagerFactory != null) { clientTlsCustomizer = sslContext -> { clientCertificateCustomizer.accept(sslContext); sslContext.trustManager(trustManagerFactory); }; } else { clientTlsCustomizer = clientCertificateCustomizer; } ClientFactoryBuilder factoryBuilder = ClientFactory.builder().tlsCustomizer(clientTlsCustomizer).meterRegistry(meterRegistry); if (serverConfig.getDisableEdns()) { factoryBuilder.addressResolverGroupFactory( eventLoopGroup -> new DnsAddressResolverGroup( new DnsNameResolverBuilder() .channelType(EventLoopGroups.datagramChannelType(eventLoopGroup)) .nameServerProvider(DnsServerAddressStreamProviders.platformDefault()) .optResourceEnabled(false))); } clientFactory = factoryBuilder.build(); }
Example #3
Source File: MasterSlaveConnectionManager.java From redisson with Apache License 2.0 | 4 votes |
protected MasterSlaveConnectionManager(Config cfg, UUID id) { this.id = id.toString(); Version.logVersion(); if (cfg.getTransportMode() == TransportMode.EPOLL) { if (cfg.getEventLoopGroup() == null) { this.group = new EpollEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = EpollSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(EpollDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } else if (cfg.getTransportMode() == TransportMode.KQUEUE) { if (cfg.getEventLoopGroup() == null) { this.group = new KQueueEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = KQueueSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(KQueueDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } else { if (cfg.getEventLoopGroup() == null) { this.group = new NioEventLoopGroup(cfg.getNettyThreads(), new DefaultThreadFactory("redisson-netty")); } else { this.group = cfg.getEventLoopGroup(); } this.socketChannelClass = NioSocketChannel.class; if (PlatformDependent.isAndroid()) { this.resolverGroup = DefaultAddressResolverGroup.INSTANCE; } else { this.resolverGroup = cfg.getAddressResolverGroupFactory().create(NioDatagramChannel.class, DnsServerAddressStreamProviders.platformDefault()); } } if (cfg.getExecutor() == null) { int threads = Runtime.getRuntime().availableProcessors() * 2; if (cfg.getThreads() != 0) { threads = cfg.getThreads(); } executor = Executors.newFixedThreadPool(threads, new DefaultThreadFactory("redisson")); } else { executor = cfg.getExecutor(); } this.cfg = cfg; this.codec = cfg.getCodec(); this.commandExecutor = new CommandSyncService(this); }