io.netty.channel.EventLoop Java Examples
The following examples show how to use
io.netty.channel.EventLoop.
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: NettyChannel.java From Jupiter with Apache License 2.0 | 6 votes |
@Override public void addTask(Runnable task) { EventLoop eventLoop = channel.eventLoop(); while (!taskQueue.offer(task)) { if (eventLoop.inEventLoop()) { runAllTasks.run(); } else { // TODO await? eventLoop.execute(runAllTasks); } } if (!taskQueue.isEmpty()) { eventLoop.execute(runAllTasks); } }
Example #2
Source File: AbstractEpollStreamChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
@Override public ChannelFuture shutdownInput(final ChannelPromise promise) { Executor closeExecutor = ((EpollStreamUnsafe) unsafe()).prepareToClose(); if (closeExecutor != null) { closeExecutor.execute(new Runnable() { @Override public void run() { shutdownInput0(promise); } }); } else { EventLoop loop = eventLoop(); if (loop.inEventLoop()) { shutdownInput0(promise); } else { loop.execute(new Runnable() { @Override public void run() { shutdownInput0(promise); } }); } } return promise; }
Example #3
Source File: RefreshingAddressResolverTest.java From armeria with Apache License 2.0 | 6 votes |
@Test void cacheClearWhenClosed() throws Exception { try (TestDnsServer server = new TestDnsServer(ImmutableMap.of( new DefaultDnsQuestion("foo.com.", A), new DefaultDnsResponse(0).addRecord(ANSWER, newAddressRecord("foo.com.", "1.1.1.1")))) ) { final EventLoop eventLoop = eventLoopExtension.get(); final RefreshingAddressResolverGroup group = builder(server).build(eventLoop); final AddressResolver<InetSocketAddress> resolver = group.getResolver(eventLoop); final Future<InetSocketAddress> foo = resolver.resolve( InetSocketAddress.createUnresolved("foo.com", 36462)); await().untilAsserted(() -> assertThat(foo.isSuccess()).isTrue()); assertThat(foo.getNow().getAddress().getHostAddress()).isEqualTo("1.1.1.1"); final ConcurrentMap<String, CompletableFuture<CacheEntry>> cache = group.cache(); assertThat(cache.size()).isEqualTo(1); final CacheEntry cacheEntry = cache.get("foo.com").join(); group.close(); await().until(() -> { final ScheduledFuture<?> future = cacheEntry.refreshFuture; return future != null && future.isCancelled(); }); assertThat(cache).isEmpty(); } }
Example #4
Source File: PerServerConnectionPool.java From zuul with Apache License 2.0 | 6 votes |
public PooledConnection tryGettingFromConnectionPool(EventLoop eventLoop) { PooledConnection conn; Deque<PooledConnection> connections = getPoolForEventLoop(eventLoop); while ((conn = connections.poll()) != null) { conn.setInPool(false); /* Check that the connection is still open. */ if (isValidFromPool(conn)) { reuseConnCounter.increment(); connsInUse.incrementAndGet(); connsInPool.decrementAndGet(); return conn; } else { connTakenFromPoolIsNotOpen.increment(); connsInPool.decrementAndGet(); conn.close(); } } return null; }
Example #5
Source File: DefaultEventLoopSchedulerTest.java From armeria with Apache License 2.0 | 6 votes |
/** * Similar to {@link #acquireAndRelease()}, but with a {@code null} {@link Endpoint}. */ @Test void acquireAndReleaseWithNullEndpoint() { final DefaultEventLoopScheduler s = defaultEventLoopScheduler(); final AbstractEventLoopEntry e0 = acquireEntry(s, null); final EventLoop loop = e0.get(); assertThat(e0.id()).isZero(); assertThat(e0.activeRequests()).isEqualTo(1); e0.release(); assertThat(e0.activeRequests()).isZero(); for (int i = 0; i < 2; i++) { final AbstractEventLoopEntry e0again = acquireEntry(s, null); assertThat(e0again).isSameAs(e0); assertThat(e0again.id()).isZero(); assertThat(e0again.activeRequests()).isEqualTo(1); assertThat(e0again.get()).isSameAs(loop); e0again.release(); } }
Example #6
Source File: NettyHandlerTestBase.java From grpc-java with Apache License 2.0 | 6 votes |
void createEventLoop() { EventLoop realEventLoop = super.eventLoop(); if (realEventLoop == null) { return; } eventLoop = mock(EventLoop.class, delegatesTo(realEventLoop)); doAnswer( new Answer<ScheduledFuture<Void>>() { @Override public ScheduledFuture<Void> answer(InvocationOnMock invocation) throws Throwable { Runnable command = (Runnable) invocation.getArguments()[0]; Long delay = (Long) invocation.getArguments()[1]; TimeUnit timeUnit = (TimeUnit) invocation.getArguments()[2]; return new FakeClockScheduledNettyFuture(eventLoop, command, delay, timeUnit); } }).when(eventLoop).schedule(any(Runnable.class), anyLong(), any(TimeUnit.class)); }
Example #7
Source File: TabViewManager.java From BungeeTabListPlus with GNU General Public License v3.0 | 6 votes |
private PlayerTabView createTabView(ProxiedPlayer player) { try { TabOverlayHandler tabOverlayHandler; PacketHandler packetHandler; Logger logger = new ChildLogger(btlp.getLogger(), player.getName()); EventLoop eventLoop = ReflectionUtil.getChannelWrapper(player).getHandle().eventLoop(); if (protocolVersionProvider.has18OrLater(player)) { LowMemoryTabOverlayHandlerImpl tabOverlayHandlerImpl = new LowMemoryTabOverlayHandlerImpl(logger, eventLoop, player.getUniqueId(), player, protocolVersionProvider.is18(player), protocolVersionProvider.has113OrLater(player)); tabOverlayHandler = tabOverlayHandlerImpl; packetHandler = new RewriteLogic(new GetGamemodeLogic(tabOverlayHandlerImpl, ((UserConnection) player))); } else { LegacyTabOverlayHandlerImpl legacyTabOverlayHandler = new LegacyTabOverlayHandlerImpl(logger, player.getPendingConnection().getListener().getTabListSize(), eventLoop, player, protocolVersionProvider.has113OrLater(player)); tabOverlayHandler = legacyTabOverlayHandler; packetHandler = legacyTabOverlayHandler; } return new PlayerTabView(tabOverlayHandler, logger, btlp.getAsyncExecutor(), packetHandler); } catch (NoSuchFieldException | IllegalAccessException e) { throw new AssertionError("Failed to create tab view", e); } }
Example #8
Source File: Http2MultiplexedChannelPool.java From ambry with Apache License 2.0 | 6 votes |
private Future<?> doClose() { EventLoop closeEventLoop = eventLoopGroup.next(); Promise<?> closeFinishedPromise = closeEventLoop.newPromise(); NettyUtils.doInEventLoop(closeEventLoop, () -> { Promise<Void> releaseAllChannelsPromise = closeEventLoop.newPromise(); PromiseCombiner promiseCombiner = new PromiseCombiner(closeEventLoop); // Create a copy of the connections to remove while we close them, in case closing updates the original list. List<MultiplexedChannelRecord> channelsToRemove = new ArrayList<>(parentConnections); for (MultiplexedChannelRecord channel : channelsToRemove) { promiseCombiner.add(closeAndReleaseParent(channel.getParentChannel())); } promiseCombiner.finish(releaseAllChannelsPromise); releaseAllChannelsPromise.addListener(f -> { parentConnectionPool.close(); closeFinishedPromise.setSuccess(null); }); }); return closeFinishedPromise; }
Example #9
Source File: RefreshingAddressResolverTest.java From armeria with Apache License 2.0 | 6 votes |
@Test void removedWhenNoCacheHit() throws Exception { try (TestDnsServer server = new TestDnsServer(ImmutableMap.of( new DefaultDnsQuestion("foo.com.", A), new DefaultDnsResponse(0).addRecord(ANSWER, newAddressRecord("foo.com.", "1.1.1.1", 1)))) ) { final EventLoop eventLoop = eventLoopExtension.get(); final DnsResolverGroupBuilder builder = builder(server); try (RefreshingAddressResolverGroup group = builder.build(eventLoop)) { final AddressResolver<InetSocketAddress> resolver = group.getResolver(eventLoop); final long start = System.nanoTime(); final Future<InetSocketAddress> foo = resolver.resolve( InetSocketAddress.createUnresolved("foo.com", 36462)); await().untilAsserted(() -> assertThat(foo.isSuccess()).isTrue()); assertThat(foo.getNow().getAddress().getHostAddress()).isEqualTo("1.1.1.1"); final ConcurrentMap<String, CompletableFuture<CacheEntry>> cache = group.cache(); await().until(cache::isEmpty); assertThat(System.nanoTime() - start).isGreaterThanOrEqualTo( (long) (TimeUnit.SECONDS.toNanos(1) * 0.9)); } } }
Example #10
Source File: BGPProtocolSessionPromise.java From bgpcep with Eclipse Public License 1.0 | 6 votes |
synchronized void reconnect() { if (this.retryTimer == 0) { LOG.debug("Retry timer value is 0. Reconnection will not be attempted"); this.setFailure(this.pending.cause()); return; } final EventLoop loop = this.pending.channel().eventLoop(); loop.schedule(() -> { synchronized (BGPProtocolSessionPromise.this) { if (BGPProtocolSessionPromise.this.peerSessionPresent) { LOG.debug("Connection to {} already exists", BGPProtocolSessionPromise.this.address); BGPProtocolSessionPromise.this.connectSkipped = true; return; } BGPProtocolSessionPromise.this.connectSkipped = false; LOG.debug("Attempting to connect to {}", BGPProtocolSessionPromise.this.address); final ChannelFuture reconnectFuture = BGPProtocolSessionPromise.this.bootstrap.connect(); reconnectFuture.addListener(new BootstrapConnectListener()); BGPProtocolSessionPromise.this.pending = reconnectFuture; } }, this.retryTimer, TimeUnit.SECONDS); LOG.debug("Next reconnection attempt in {}s", this.retryTimer); }
Example #11
Source File: ClientConnectionImpl.java From pravega with Apache License 2.0 | 6 votes |
private void write(WireCommand cmd) throws ConnectionFailedException { Channel channel = nettyHandler.getChannel(); EventLoop eventLoop = channel.eventLoop(); ChannelPromise promise = channel.newPromise(); promise.addListener(new ChannelFutureListener() { @Override public void operationComplete(ChannelFuture future) { nettyHandler.setRecentMessage(); if (!future.isSuccess()) { future.channel().pipeline().fireExceptionCaught(future.cause()); } } }); // Work around for https://github.com/netty/netty/issues/3246 eventLoop.execute(() -> { try { if (!closed.get()) { channel.write(cmd, promise); } } catch (Exception e) { channel.pipeline().fireExceptionCaught(e); } }); }
Example #12
Source File: AbstractNioChannel.java From netty-4.1.22 with Apache License 2.0 | 6 votes |
/** * Set read pending to {@code false}. */ protected final void clearReadPending() { // 如果渠道已经注册了 if (isRegistered()) { // 获取事件组 EventLoop eventLoop = eventLoop(); // 如果当前线程在事件组 if (eventLoop.inEventLoop()) { clearReadPending0(); } else { // 否则异步执行清除自动读 eventLoop.execute(clearReadPendingRunnable); } } else { // Best effort if we are not registered yet clear readPending. This happens during channel initialization. // NB: We only set the boolean field instead of calling clearReadPending0(), because the SelectionKey is // not set yet so it would produce an assertion failure. readPending = false; } }
Example #13
Source File: DefaultClientRequestContext.java From armeria with Apache License 2.0 | 6 votes |
private DefaultClientRequestContext( @Nullable EventLoop eventLoop, MeterRegistry meterRegistry, SessionProtocol sessionProtocol, RequestId id, HttpMethod method, String path, @Nullable String query, @Nullable String fragment, ClientOptions options, @Nullable HttpRequest req, @Nullable RpcRequest rpcReq, @Nullable ServiceRequestContext root, long requestStartTimeNanos, long requestStartTimeMicros) { super(meterRegistry, sessionProtocol, id, method, path, query, req, rpcReq, root); this.eventLoop = eventLoop; this.options = requireNonNull(options, "options"); this.fragment = fragment; this.root = root; log = RequestLog.builder(this); log.startRequest(requestStartTimeNanos, requestStartTimeMicros); timeoutScheduler = new TimeoutScheduler(options.responseTimeoutMillis()); writeTimeoutMillis = options.writeTimeoutMillis(); maxResponseLength = options.maxResponseLength(); additionalRequestHeaders = options.get(ClientOption.HTTP_HEADERS); customizers = copyThreadLocalCustomizers(); }
Example #14
Source File: NioSocketChannel.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Override public ChannelFuture shutdownOutput(final ChannelPromise promise) { final EventLoop loop = eventLoop(); if (loop.inEventLoop()) { ((AbstractUnsafe) unsafe()).shutdownOutput(promise); } else { loop.execute(new Runnable() { @Override public void run() { ((AbstractUnsafe) unsafe()).shutdownOutput(promise); } }); } return promise; }
Example #15
Source File: DnsAddressResolverGroup.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override protected final AddressResolver<InetSocketAddress> newResolver(EventExecutor executor) throws Exception { if (!(executor instanceof EventLoop)) { throw new IllegalStateException( "unsupported executor type: " + StringUtil.simpleClassName(executor) + " (expected: " + StringUtil.simpleClassName(EventLoop.class)); } return newResolver((EventLoop) executor, channelFactory, nameServerProvider); }
Example #16
Source File: XioConnectionPool.java From xio with Apache License 2.0 | 5 votes |
@Override public Future<Boolean> isHealthy(Channel channel) { EventLoop loop = channel.eventLoop(); if (channel.isActive()) { passedHealthCheckCount.incrementAndGet(); return loop.newSucceededFuture(Boolean.TRUE); } else { failedHealthCheckCount.incrementAndGet(); return loop.newSucceededFuture(Boolean.FALSE); } }
Example #17
Source File: DnsEndpointGroupBuilderTest.java From armeria with Apache License 2.0 | 5 votes |
@Test void eventLoop() { assertThat(builder().eventLoop()).isNotNull(); final EventLoop loop = new NioEventLoopGroup().next(); assertThat(builder().eventLoop(loop).eventLoop()).isSameAs(loop); assertThatThrownBy(() -> builder().eventLoop(new DefaultEventLoop())) .isInstanceOf(IllegalArgumentException.class).hasMessageContaining("unsupported"); }
Example #18
Source File: DnsAddressResolverGroup.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
/** * Creates a new {@link NameResolver}. Override this method to create an alternative {@link NameResolver} * implementation or override the default configuration. */ protected NameResolver<InetAddress> newNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsServerAddressStreamProvider nameServerProvider) throws Exception { return new DnsNameResolverBuilder(eventLoop) .channelFactory(channelFactory) .nameServerProvider(nameServerProvider) .build(); }
Example #19
Source File: PeerTest.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
private void mockSession() { final EventLoop eventLoop = mock(EventLoop.class); final Channel channel = mock(Channel.class); final ChannelPipeline pipeline = mock(ChannelPipeline.class); doReturn(null).when(eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class)); doReturn(eventLoop).when(channel).eventLoop(); doReturn(Boolean.TRUE).when(channel).isWritable(); doReturn(null).when(channel).close(); doReturn(pipeline).when(channel).pipeline(); doCallRealMethod().when(channel).toString(); doReturn(pipeline).when(pipeline).addLast(any(ChannelHandler.class)); doReturn(new DefaultChannelPromise(channel)).when(channel).writeAndFlush(any(Notification.class)); doReturn(new InetSocketAddress("localhost", 12345)).when(channel).remoteAddress(); doReturn(new InetSocketAddress("localhost", 12345)).when(channel).localAddress(); final List<BgpParameters> params = Lists.newArrayList(new BgpParametersBuilder() .setOptionalCapabilities(Lists.newArrayList(new OptionalCapabilitiesBuilder() .setCParameters(new CParametersBuilder() .addAugmentation(new CParameters1Builder() .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder() .setAfi(Ipv4AddressFamily.class) .setSafi(UnicastSubsequentAddressFamily.class) .build()) .build()) .build()) .build())) .build()); final Open openObj = new OpenBuilder() .setBgpIdentifier(new Ipv4AddressNoZone("1.1.1.1")) .setHoldTimer(Uint16.valueOf(50)) .setMyAsNumber(Uint16.valueOf(72)) .setBgpParameters(params).build(); this.session = new BGPSessionImpl(this.classic, channel, openObj, 30, null); this.session.setChannelExtMsgCoder(openObj); }
Example #20
Source File: DnsTextEndpointGroup.java From armeria with Apache License 2.0 | 5 votes |
DnsTextEndpointGroup(EndpointSelectionStrategy selectionStrategy, EventLoop eventLoop, int minTtl, int maxTtl, long queryTimeoutMillis, DnsServerAddressStreamProvider serverAddressStreamProvider, Backoff backoff, String hostname, Function<byte[], Endpoint> mapping) { super(selectionStrategy, eventLoop, minTtl, maxTtl, queryTimeoutMillis, serverAddressStreamProvider, backoff, ImmutableList.of(DnsQuestionWithoutTrailingDot.of(hostname, DnsRecordType.TXT)), unused -> {}); this.mapping = mapping; start(); }
Example #21
Source File: NettyHandlerTestBase.java From grpc-java with Apache License 2.0 | 5 votes |
protected final ChannelHandlerContext newMockContext() { ChannelHandlerContext ctx = mock(ChannelHandlerContext.class); when(ctx.alloc()).thenReturn(UnpooledByteBufAllocator.DEFAULT); EventLoop eventLoop = mock(EventLoop.class); when(ctx.executor()).thenReturn(eventLoop); when(ctx.channel()).thenReturn(channel); return ctx; }
Example #22
Source File: RequestResponseCloseHandlerTest.java From servicetalk with Apache License 2.0 | 5 votes |
private ServerSocketChannel startServer() { EventLoopAwareNettyIoExecutor eventLoopAwareNettyIoExecutor = toEventLoopAwareNettyIoExecutor(S_CTX.ioExecutor()); EventLoop loop = eventLoopAwareNettyIoExecutor.eventLoopGroup().next(); ServerBootstrap bs = new ServerBootstrap(); bs.group(loop); bs.channel(serverChannel(loop, InetSocketAddress.class)); bs.childHandler(new ChannelInitializer() { @Override protected void initChannel(final Channel ch) { sChannel = (SocketChannel) ch; ch.pipeline().addLast(new ChannelInboundHandlerAdapter() { @Override public void userEventTriggered(final ChannelHandlerContext ctx, final Object evt) { LOGGER.debug("Server Evt: {}", evt.getClass().getSimpleName()); if (evt == ChannelInputShutdownEvent.INSTANCE) { serverInputShutdownLatch.countDown(); } else if (evt == ChannelInputShutdownReadComplete.INSTANCE) { serverInputShutdownReadCompleteLatch.countDown(); } else if (evt == ChannelOutputShutdownEvent.INSTANCE) { serverOutputShutdownLatch.countDown(); } release(evt); } }); ch.eventLoop().execute(connectedLatch::countDown); } }); bs.childOption(AUTO_READ, true); bs.childOption(ALLOW_HALF_CLOSURE, true); bs.childOption(AUTO_CLOSE, false); return (ServerSocketChannel) bs.bind(localAddress(0)) .syncUninterruptibly().channel(); }
Example #23
Source File: BuilderUtils.java From servicetalk with Apache License 2.0 | 5 votes |
/** * Returns {@code true} if native kqueue transport should be used. * * @param group the used {@link EventLoopGroup} * @return {@code true} if native transport should be used */ public static boolean useKQueue(EventLoopGroup group) { // Check if we should use the kqueue transport. This is true if either the KQueueEventLoopGroup is used directly // or if the passed group is a EventLoop and it's parent is an KQueueEventLoopGroup. return group instanceof KQueueEventLoopGroup || (group instanceof EventLoop && ((EventLoop) group).parent() instanceof KQueueEventLoopGroup); }
Example #24
Source File: AbstractChannelPoolMapTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@Test(expected = ConnectException.class) public void testMap() throws Exception { EventLoopGroup group = new LocalEventLoopGroup(); LocalAddress addr = new LocalAddress(LOCAL_ADDR_ID); final Bootstrap cb = new Bootstrap(); cb.remoteAddress(addr); cb.group(group) .channel(LocalChannel.class); AbstractChannelPoolMap<EventLoop, SimpleChannelPool> poolMap = new AbstractChannelPoolMap<EventLoop, SimpleChannelPool>() { @Override protected SimpleChannelPool newPool(EventLoop key) { return new SimpleChannelPool(cb.clone(key), new TestChannelPoolHandler()); } }; EventLoop loop = group.next(); assertFalse(poolMap.iterator().hasNext()); assertEquals(0, poolMap.size()); SimpleChannelPool pool = poolMap.get(loop); assertEquals(1, poolMap.size()); assertTrue(poolMap.iterator().hasNext()); assertSame(pool, poolMap.get(loop)); assertTrue(poolMap.remove(loop)); assertFalse(poolMap.remove(loop)); assertFalse(poolMap.iterator().hasNext()); assertEquals(0, poolMap.size()); pool.acquire().syncUninterruptibly(); }
Example #25
Source File: PCCReconnectPromise.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
@Override public void operationComplete(final ChannelFuture cf) { synchronized (this.lock) { if (PCCReconnectPromise.this.isCancelled()) { if (cf.isSuccess()) { PCCReconnectPromise.LOG.debug("Closing channels for cancelled promise {}", PCCReconnectPromise.this); cf.channel().close(); } } else if (cf.isSuccess()) { PCCReconnectPromise.LOG.debug("Promise connection is successful."); } else { PCCReconnectPromise.LOG.debug("Attempt to connect to {} failed", PCCReconnectPromise.this.address, cf.cause()); if (PCCReconnectPromise.this.retryTimer == 0) { PCCReconnectPromise.LOG.debug("Retry timer value is 0. Reconnection will not be attempted"); PCCReconnectPromise.this.setFailure(cf.cause()); return; } final EventLoop loop = cf.channel().eventLoop(); loop.schedule(() -> { synchronized (PCCReconnectPromise.this) { PCCReconnectPromise.LOG.debug("Attempting to connect to {}", PCCReconnectPromise.this.address); final Future<Void> reconnectFuture = PCCReconnectPromise.this.bootstrap.connect(); reconnectFuture.addListener(this); PCCReconnectPromise.this.pending = reconnectFuture; } }, PCCReconnectPromise.this.retryTimer, TimeUnit.SECONDS); PCCReconnectPromise.LOG.debug("Next reconnection attempt in {}s", PCCReconnectPromise.this.retryTimer); } } }
Example #26
Source File: NettyClientServerCommunicationSystemClientSide.java From library with Apache License 2.0 | 5 votes |
private void scheduleReconnect(final ChannelHandlerContext ctx, int time) { if (closed) { closeChannelAndEventLoop(ctx.channel()); return; } final EventLoop loop = ctx.channel().eventLoop(); loop.schedule(new Runnable() { @Override public void run() { reconnect(ctx); } }, time, TimeUnit.SECONDS); }
Example #27
Source File: Dhcp6Server.java From dhcp4j with Apache License 2.0 | 5 votes |
@PreDestroy public void stop() throws IOException, InterruptedException { EventLoop loop = channel.eventLoop(); channel.close().sync(); channel = null; loop.shutdownGracefully(); }
Example #28
Source File: NettyUtils.java From ambry with Apache License 2.0 | 5 votes |
public static void warnIfNotInEventLoop(EventLoop loop) { assert loop.inEventLoop(); if (!loop.inEventLoop()) { Exception exception = new IllegalStateException( "Execution is not in the expected event loop. Please report this issue to the " + "AWS SDK for Java team on GitHub, because it could result in race conditions."); log.warn("Execution is happening outside of the expected event loop.", exception); } }
Example #29
Source File: ClientHandler.java From LuckyFrameClient with GNU Affero General Public License v3.0 | 5 votes |
@Override public void channelInactive(ChannelHandlerContext ctx) { log.info("�����ѶϿ������ڳ�������..."); //ʹ�ù����ж������� final EventLoop eventLoop = ctx.channel().eventLoop(); eventLoop.schedule(() -> { try { NettyClient.start(); } catch (Exception e) { log.error("���ӳ����쳣�����ڳ�������...",e); } }, 1, TimeUnit.SECONDS); ctx.fireChannelInactive(); }
Example #30
Source File: NettyClientStream.java From grpc-nebula-java with Apache License 2.0 | 5 votes |
public TransportState( NettyClientHandler handler, EventLoop eventLoop, int maxMessageSize, StatsTraceContext statsTraceCtx, TransportTracer transportTracer) { super(maxMessageSize, statsTraceCtx, transportTracer); this.handler = checkNotNull(handler, "handler"); this.eventLoop = checkNotNull(eventLoop, "eventLoop"); }