Java Code Examples for io.netty.util.concurrent.Future#await()
The following examples show how to use
io.netty.util.concurrent.Future#await() .
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: Http2MultiplexedChannelPool.java From aws-sdk-java-v2 with Apache License 2.0 | 6 votes |
@Override public void close() { if (closed.compareAndSet(false, true)) { Future<?> closeCompleteFuture = doClose(); try { if (!closeCompleteFuture.await(10, TimeUnit.SECONDS)) { throw new RuntimeException("Event loop didn't close after 10 seconds."); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } Throwable exception = closeCompleteFuture.cause(); if (exception != null) { throw new RuntimeException("Failed to close channel pool.", exception); } } }
Example 2
Source File: Http2MultiplexedChannelPool.java From ambry with Apache License 2.0 | 6 votes |
@Override public void close() { if (closed.compareAndSet(false, true)) { Future<?> closeCompleteFuture = doClose(); try { if (!closeCompleteFuture.await(10, TimeUnit.SECONDS)) { throw new RuntimeException("Event loop didn't close after 10 seconds."); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new RuntimeException(e); } Throwable exception = closeCompleteFuture.cause(); if (exception != null) { throw new RuntimeException("Failed to close channel pool.", exception); } } }
Example 3
Source File: NewNettyAcceptor.java From cassandana with Apache License 2.0 | 5 votes |
@SuppressWarnings("FutureReturnValueIgnored") public void close() { LOG.debug("Closing Netty acceptor..."); if (workerGroup == null || bossGroup == null) { LOG.error("Netty acceptor is not initialized"); throw new IllegalStateException("Invoked close on an Acceptor that wasn't initialized"); } Future<?> workerWaiter = workerGroup.shutdownGracefully(); Future<?> bossWaiter = bossGroup.shutdownGracefully(); /* * We shouldn't raise an IllegalStateException if we are interrupted. If we did so, the * broker is not shut down properly. */ LOG.info("Waiting for worker and boss event loop groups to terminate..."); try { workerWaiter.await(10, TimeUnit.SECONDS); bossWaiter.await(10, TimeUnit.SECONDS); } catch (InterruptedException iex) { LOG.warn("An InterruptedException was caught while waiting for event loops to terminate..."); } if (!workerGroup.isTerminated()) { LOG.warn("Forcing shutdown of worker event loop..."); workerGroup.shutdownGracefully(0L, 0L, TimeUnit.MILLISECONDS); } if (!bossGroup.isTerminated()) { LOG.warn("Forcing shutdown of boss event loop..."); bossGroup.shutdownGracefully(0L, 0L, TimeUnit.MILLISECONDS); } }
Example 4
Source File: LocalChannelTest.java From netty-4.1.22 with Apache License 2.0 | 5 votes |
@AfterClass public static void afterClass() throws InterruptedException { Future<?> group1Future = group1.shutdownGracefully(0, 0, SECONDS); Future<?> group2Future = group2.shutdownGracefully(0, 0, SECONDS); Future<?> sharedGroupFuture = sharedGroup.shutdownGracefully(0, 0, SECONDS); group1Future.await(); group2Future.await(); sharedGroupFuture.await(); }
Example 5
Source File: DriftNettyServerTransport.java From drift with Apache License 2.0 | 5 votes |
private static void await(Future<?> future) { try { future.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
Example 6
Source File: Server.java From jlogstash-input-plugin with Apache License 2.0 | 5 votes |
public void stop() throws InterruptedException { logger.debug("Requesting the server to stop."); Future<?> bossWait = bossGroup.shutdownGracefully(0, SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS); Future<?> workWait = workGroup.shutdownGracefully(0, SHUTDOWN_TIMEOUT_SECONDS, TimeUnit.SECONDS); bossWait.await(); workWait.await(); logger.debug("Server.stopped"); }
Example 7
Source File: DefaultChannelFactory.java From pinpoint with Apache License 2.0 | 5 votes |
@Override public void close() { final Future<?> future = eventLoopGroup.shutdownGracefully(); try { logger.debug("shutdown {}-eventLoopGroup", factoryName); future.await(1000 * 3); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } ExecutorUtils.shutdownExecutorService(factoryName + "-eventLoopExecutor", eventLoopExecutor); ExecutorUtils.shutdownExecutorService(factoryName + "-executorService", executorService); }