/** * Returns whether the specified {@link EventLoop} supports any {@link TransportType}. */ public static boolean isSupported(EventLoop eventLoop) { final EventLoopGroup parent = eventLoop.parent(); if (parent == null) { return false; } return isSupported(parent); }
@Override public EventLoopGroup parent() { return delegate().parent(); }
DnsEndpointGroup(EventLoop eventLoop, int minTtl, int maxTtl, DnsServerAddressStreamProvider serverAddressStreamProvider, Backoff backoff, Iterable<DnsQuestion> questions, Consumer<DnsNameResolverBuilder> resolverConfigurator) { this.eventLoop = eventLoop; this.minTtl = minTtl; this.maxTtl = maxTtl; this.backoff = backoff; this.questions = ImmutableList.copyOf(questions); assert !this.questions.isEmpty(); logger = LoggerFactory.getLogger(getClass()); logPrefix = this.questions.stream() .map(DnsQuestion::name) .distinct() .collect(Collectors.joining(", ", "[", "]")); final DnsNameResolverBuilder resolverBuilder = new DnsNameResolverBuilder(eventLoop) .channelType(TransportType.datagramChannelType(eventLoop.parent())) .ttl(minTtl, maxTtl) .nameServerProvider(serverAddressStreamProvider); resolverConfigurator.accept(resolverBuilder); resolver = resolverBuilder.build(); }
final EventLoopGroup bossGroup = ch.eventLoop().parent(); bossGroup.shutdownGracefully(); bossGroup.terminationFuture().addListener(unused6 -> {
@Override public EventLoopGroup parent() { return getDelegate().parent(); }
@Override protected boolean isCompatible(EventLoop loop) { if (!(loop instanceof XnioEventLoop)) { return false; } ServerSocketChannel parent = parent(); if (parent != null) { // if this channel has a parent we need to ensure that both EventLoopGroups are the same for XNIO // to be sure it uses a Thread from the correct Worker. if (parent.eventLoop().parent() != loop.parent()) { return false; } } return true; }
public static ChannelConfiguration clientConfig(EventLoopGroup workerGroup) { EventLoopGroup parent = workerGroup; if (parent instanceof EventLoop) { parent = ((EventLoop) workerGroup).parent(); } Class<? extends Channel> channelClass; if (parent instanceof EpollEventLoopGroup) { channelClass = EpollSocketChannel.class; } else if (parent instanceof NioEventLoopGroup) { channelClass = NioSocketChannel.class; } else { throw new RuntimeException("Unsupported EventLoopGroup " + workerGroup.getClass()); } return new ChannelConfiguration(workerGroup, channelClass); } }
/** * This method will configure a worker EventLoopGroup and a Channel for use by a client. It will * try to use the correct SocketChannel for the provided workerGroup. * * @param workerGroup uses EventLoopGroup in the ClientChannelConfiguration * @return ClientChannelConfiguration */ public static ClientChannelConfiguration clientConfig(EventLoopGroup workerGroup) { EventLoopGroup parent = workerGroup; if (parent instanceof EventLoop) { parent = ((EventLoop) workerGroup).parent(); } Class<? extends Channel> channelClass; if (parent instanceof EpollEventLoopGroup) { channelClass = EpollSocketChannel.class; } else if (parent instanceof NioEventLoopGroup) { channelClass = NioSocketChannel.class; } else { throw new RuntimeException("Unsupported EventLoopGroup " + workerGroup.getClass()); } return new ClientChannelConfiguration(workerGroup, channelClass); }