@AssistedInject public UdpTransport(@Assisted Configuration configuration, EventLoopGroupFactory eventLoopGroupFactory, NettyTransportConfiguration nettyTransportConfiguration, ThroughputCounter throughputCounter, LocalMetricRegistry localRegistry) { super(configuration, eventLoopGroupFactory, throughputCounter, localRegistry); this.nettyTransportConfiguration = nettyTransportConfiguration; this.channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); }
private SocketManager() { channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); appNames = new ConcurrentHashMap<>(); executorService = Executors.newSingleThreadScheduledExecutor(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { executorService.shutdown(); try { executorService.awaitTermination(10, TimeUnit.MINUTES); } catch (InterruptedException ignored) { } })); }
/** * Constructs a new channel pool that will create new channels with the given {@code channelFactory} and has the * given maximum channel {@code capacity}. * * @param channelFactory the factory to be used to create new channels * @param capacity the maximum number of channels that may be held in this pool * @param executor the executor on which listeners for acquisition/release promises will be called * @param metricsListener an optional listener for metrics describing the performance and behavior of the pool */ ApnsChannelPool(final PooledObjectFactory<Channel> channelFactory, final int capacity, final OrderedEventExecutor executor, final ApnsChannelPoolMetricsListener metricsListener) { this.channelFactory = channelFactory; this.capacity = capacity; this.executor = executor; this.metricsListener = metricsListener != null ? metricsListener : new NoopChannelPoolMetricsListener(); this.allChannels = new DefaultChannelGroup(this.executor, true); }
@PostConstruct public void init() throws Exception { ChannelConfig channelDeps = new ChannelConfig(); addChannelDependencies(channelDeps); ChannelGroup clientChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); clientConnectionsShutdown = new ClientConnectionsShutdown(clientChannels, GlobalEventExecutor.INSTANCE, discoveryClient); portsToChannelInitializers = choosePortsAndChannels(clientChannels, channelDeps); server = new Server(portsToChannelInitializers, serverStatusManager, clientConnectionsShutdown, eventLoopGroupMetrics); }
/** * A variant of {@link #ReactorNettyTcpClient(String, int, ReactorNettyCodec)} * that still manages the lifecycle of the {@link TcpClient} and underlying * resources, but allows for direct configuration of other properties of the * client through a {@code Function<TcpClient, TcpClient>}. * @param clientConfigurer the configurer function * @param codec for encoding and decoding the input/output byte streams * @since 5.1.3 * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ public ReactorNettyTcpClient(Function<TcpClient, TcpClient> clientConfigurer, ReactorNettyCodec<P> codec) { Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); this.codec = codec; this.tcpClient = clientConfigurer.apply(TcpClient .create(this.poolResources) .runOn(this.loopResources, false) .doOnConnected(conn -> this.channelGroup.add(conn.channel()))); }
/** * Simple constructor with the host and port to use to connect to. * <p>This constructor manages the lifecycle of the {@link TcpClient} and * underlying resources such as {@link ConnectionProvider}, * {@link LoopResources}, and {@link ChannelGroup}. * <p>For full control over the initialization and lifecycle of the * TcpClient, use {@link #ReactorNettyTcpClient(TcpClient, ReactorNettyCodec)}. * @param host the host to connect to * @param port the port to connect to * @param codec for encoding and decoding the input/output byte streams * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec) { Assert.notNull(host, "host is required"); Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); this.codec = codec; this.tcpClient = TcpClient.create(this.poolResources) .host(host).port(port) .runOn(this.loopResources, false) .doOnConnected(conn -> this.channelGroup.add(conn.channel())); }
public void close() { System.out.println("Closing all sockets..."); DefaultChannelGroup allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); userSession.forEach((userKey, session) -> { allChannels.addAll(session.appChannels); allChannels.addAll(session.hardwareChannels); }); allChannels.close().awaitUninterruptibly(); }
bootstrap.option(ChannelOption.SO_KEEPALIVE, true); bootstrap.option(ChannelOption.SO_REUSEADDR, true); channelGroup = new DefaultChannelGroup("activemq-connector", GlobalEventExecutor.INSTANCE);
this.nettyTransportConfiguration = nettyTransportConfiguration; this.channelReference = new AtomicReference<>(); this.childChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
this.allChannels = new DefaultChannelGroup(this.bootstrap.config().group().next());
/** * Create a new instance with client resources. * * @param clientResources the client resources. If {@literal null}, the client will create a new dedicated instance of * client resources and keep track of them. */ protected AbstractRedisClient(ClientResources clientResources) { if (clientResources == null) { sharedResources = false; this.clientResources = DefaultClientResources.create(); } else { sharedResources = true; this.clientResources = clientResources; } genericWorkerPool = this.clientResources.eventExecutorGroup(); channels = new DefaultChannelGroup(genericWorkerPool.next()); timer = (HashedWheelTimer) this.clientResources.timer(); }
@PostConstruct public void init() throws Exception { ChannelConfig channelDeps = new ChannelConfig(); addChannelDependencies(channelDeps); ChannelGroup clientChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); clientConnectionsShutdown = new ClientConnectionsShutdown(clientChannels, GlobalEventExecutor.INSTANCE, discoveryClient); portsToChannelInitializers = choosePortsAndChannels(clientChannels, channelDeps); server = new Server(portsToChannelInitializers, serverStatusManager, clientConnectionsShutdown, eventLoopGroupMetrics); }
HttpServerImpl shared = vertx.sharedHttpServers().get(id); if (shared == null || port == 0) { serverChannelGroup = new DefaultChannelGroup("vertx-acceptor-channels", GlobalEventExecutor.INSTANCE); ServerBootstrap bootstrap = new ServerBootstrap(); bootstrap.group(vertx.getAcceptorEventLoopGroup(), availableWorkers);
NetServerImpl shared = vertx.sharedNetServers().get(id); if (shared == null || actualPort == 0) { // Wildcard port will imply a new actual server each time serverChannelGroup = new DefaultChannelGroup("vertx-acceptor-channels", GlobalEventExecutor.INSTANCE);
channels = new DefaultChannelGroup(copy.getGroup().next()); bootstrap = createBootstrap(copy, Type.PLAIN); pubSubBootstrap = createBootstrap(copy, Type.PUBSUB);
channels = new DefaultChannelGroup(copy.getGroup().next()); bootstrap = createBootstrap(copy, Type.PLAIN); pubSubBootstrap = createBootstrap(copy, Type.PUBSUB);
openChannels = new DefaultChannelGroup("asyncHttpClient", GlobalEventExecutor.INSTANCE);
public WebImageViewer(InetSocketAddress address, Configuration conf) { this.address = address; this.bossGroup = new NioEventLoopGroup(); this.workerGroup = new NioEventLoopGroup(); this.allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE); this.bootstrap = new ServerBootstrap() .group(bossGroup, workerGroup) .channel(NioServerSocketChannel.class); this.conf = conf; UserGroupInformation.setConfiguration(conf); }
/** * A variant of {@link #ReactorNettyTcpClient(String, int, ReactorNettyCodec)} * that still manages the lifecycle of the {@link TcpClient} and underlying * resources, but allows for direct configuration of other properties of the * client through a {@code Function<TcpClient, TcpClient>}. * @param clientConfigurer the configurer function * @param codec for encoding and decoding the input/output byte streams * @since 5.1.3 * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ public ReactorNettyTcpClient(Function<TcpClient, TcpClient> clientConfigurer, ReactorNettyCodec<P> codec) { Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); this.codec = codec; this.tcpClient = clientConfigurer.apply(TcpClient .create(this.poolResources) .runOn(this.loopResources, false) .doOnConnected(conn -> this.channelGroup.add(conn.channel()))); }
/** * Simple constructor with the host and port to use to connect to. * <p>This constructor manages the lifecycle of the {@link TcpClient} and * underlying resources such as {@link ConnectionProvider}, * {@link LoopResources}, and {@link ChannelGroup}. * <p>For full control over the initialization and lifecycle of the * TcpClient, use {@link #ReactorNettyTcpClient(TcpClient, ReactorNettyCodec)}. * @param host the host to connect to * @param port the port to connect to * @param codec for encoding and decoding the input/output byte streams * @see org.springframework.messaging.simp.stomp.StompReactorNettyCodec */ public ReactorNettyTcpClient(String host, int port, ReactorNettyCodec<P> codec) { Assert.notNull(host, "host is required"); Assert.notNull(codec, "ReactorNettyCodec is required"); this.channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE); this.loopResources = LoopResources.create("tcp-client-loop"); this.poolResources = ConnectionProvider.elastic("tcp-client-pool"); this.codec = codec; this.tcpClient = TcpClient.create(this.poolResources) .host(host).port(port) .runOn(this.loopResources, false) .doOnConnected(conn -> this.channelGroup.add(conn.channel())); }