List of usage examples for io.netty.util ThreadDeathWatcher awaitInactivity
public static boolean awaitInactivity(long timeout, TimeUnit unit) throws InterruptedException
From source file:com.couchbase.client.core.env.resources.NettyShutdownHook.java
License:Apache License
@Override public Observable<Boolean> shutdown() { return Observable.create(new Observable.OnSubscribe<Boolean>() { @Override/* w w w .j a v a2s. c om*/ public void call(final Subscriber<? super Boolean> subscriber) { new Thread(new Runnable() { @Override public void run() { try { isReallyShutdown = ThreadDeathWatcher.awaitInactivity(3, TimeUnit.SECONDS); if (!subscriber.isUnsubscribed()) { subscriber.onNext(isReallyShutdown); subscriber.onCompleted(); } } catch (Throwable e) { if (!subscriber.isUnsubscribed()) { subscriber.onError(e); } } } }).start(); } }); }
From source file:com.datastax.driver.examples.osgi.impl.MailboxActivator.java
License:Apache License
@Override public void stop(BundleContext context) throws Exception { LOGGER.info("Stopping bundle {}", context.getBundle().getSymbolicName()); if (cluster != null) { cluster.close();//from w w w . j a va2 s . com // Await for Netty threads to stop gracefully ThreadDeathWatcher.awaitInactivity(10, TimeUnit.SECONDS); } LOGGER.info("Bundle {} successfully stopped", context.getBundle().getSymbolicName()); }
From source file:com.eluup.flume.sink.elasticsearch.client.PreBuiltTransportClient.java
License:Apache License
@Override public void close() { super.close(); if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings) == false || NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(Netty4Plugin.NETTY_TRANSPORT_NAME)) { try {/* w w w .ja v a 2 s .c o m*/ GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } try { ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
From source file:io.crate.http.HttpTestServer.java
License:Apache License
public void shutDown() { channel.close().awaitUninterruptibly(); if (group != null) { group.shutdownGracefully().awaitUninterruptibly(); group.terminationFuture().awaitUninterruptibly(); group = null;//from w w w .ja v a2 s . c o m } try { ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { // ignore } }
From source file:org.elasticsearch.xpack.client.PreBuiltXPackTransportClient.java
License:Open Source License
@Override public void close() { super.close(); if (NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(SecurityField.NAME4)) { try {//from w ww. j a va 2 s .c o m GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } try { ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
From source file:org.elasticsearch.xpack.core.TestXPackTransportClient.java
License:Open Source License
@Override public void close() { super.close(); if (NetworkModule.TRANSPORT_TYPE_SETTING.exists(settings) == false || NetworkModule.TRANSPORT_TYPE_SETTING.get(settings).equals(SecurityField.NAME4)) { try {//from w ww.j av a 2 s . c o m GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } try { ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } }
From source file:org.restcomm.imscf.common.lwcomm.service.impl.LwCommServiceImpl.java
License:Open Source License
@Override public void shutdown() { try {/*from ww w . ja v a2s . c o m*/ LOGGER.info("LwComm shutting down..."); initShutdownLock.writeLock().lock(); if (!inited) { LOGGER.info("LwComm service is not initialized, no shutdown needed."); } // Unregister statistics MBean try { LOGGER.info("Unregistering MBean {} ...", statisticsMBeanName); ObjectName on = new ObjectName(statisticsMBeanName); ManagementFactory.getPlatformMBeanServer().unregisterMBean(on); } catch (Exception ex) { LOGGER.warn("Error unregistering statistics MBean", ex); } listener.shutdown(); heartbeatService.shutdown(); nettyUtil.shutdown(); try { sendAndHeartbeatEventLoopGroup.shutdownGracefully().await(); } catch (InterruptedException e) { LOGGER.warn("Error shutting down event loop group for sending messages and heartbeats.", e); } try { receiveTransportEventLoopGroup.shutdownGracefully().await(); } catch (InterruptedException e) { LOGGER.warn("Error shutting down event loop group for receive transport event loop.", e); } LOGGER.info( "Shutting down GlobalEventExecutor and calling ThreadDeathWatcher.awaitInactivity(). This can take at most 10 seconds..."); try { GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); } catch (InterruptedException e) { LOGGER.error("Exception while waiting for inactivity...", e); } LOGGER.info("LwComm service shut down."); } finally { inited = false; service = null; initShutdownLock.writeLock().unlock(); } }