public static synchronized SharedEventLoopGroup getInstance(Function<ThreadFactory, EventLoopGroup> eventLoopGroupSupplier) { if (instance != null) { ScheduledFuture<?> f = instance.shutdown.getAndSet(null); if (f != null) { f.cancel(false); } } else { instance = new SharedEventLoopGroup(eventLoopGroupSupplier.apply(AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { @Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-netty-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } }))); } instance.channelFactoryCount.incrementAndGet(); return instance; }
public static synchronized void forceShutdown() { if (instance != null) { instance.forEach(executor -> executor.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS)); instance.channelFactoryCount.set(0); instance = null; } }
public static void clearThreadPools() { SharedEventLoopGroup.forceShutdown(); }
@Override public Future<?> shutdownGracefully() { return shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS); }
@Override public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) { if (channelFactoryCount.decrementAndGet() == 0) { shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() { @Override public void run() { synchronized (SharedEventLoopGroup.class) { if (shutdown.get() != null) { Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit); future.addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception { if (future.isSuccess()) { terminationPromise.setSuccess(null); } else { terminationPromise.setFailure(future.cause()); } } }); instance = null; } } } }, 10, 10, TimeUnit.SECONDS)); } return terminationPromise; } }
group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory))); } else { group = new EpollEventLoopGroup(remotingThreads); } else if (useKQueue && KQueue.isAvailable()) { if (useGlobalWorkerPool) { group = SharedEventLoopGroup.getInstance((threadFactory -> new KQueueEventLoopGroup(remotingThreads, threadFactory))); } else { group = new KQueueEventLoopGroup(remotingThreads); if (useGlobalWorkerPool) { channelClazz = NioSocketChannel.class; group = SharedEventLoopGroup.getInstance((threadFactory -> new NioEventLoopGroup(remotingThreads, threadFactory))); } else { channelClazz = NioSocketChannel.class;
@Override public Future<?> shutdownGracefully() { return shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS); }
@Override public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) { if (channelFactoryCount.decrementAndGet() == 0) { shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() { @Override public void run() { synchronized (SharedEventLoopGroup.class) { if (shutdown.get() != null) { Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit); future.addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception { if (future.isSuccess()) { terminationPromise.setSuccess(null); } else { terminationPromise.setFailure(future.cause()); } } }); instance = null; } } } }, 10, 10, TimeUnit.SECONDS)); } return terminationPromise; } }
group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory))); } else { group = new EpollEventLoopGroup(remotingThreads); } else if (useKQueue && KQueue.isAvailable()) { if (useGlobalWorkerPool) { group = SharedEventLoopGroup.getInstance((threadFactory -> new KQueueEventLoopGroup(remotingThreads, threadFactory))); } else { group = new KQueueEventLoopGroup(remotingThreads); if (useGlobalWorkerPool) { channelClazz = NioSocketChannel.class; group = SharedEventLoopGroup.getInstance((threadFactory -> new NioEventLoopGroup(remotingThreads, threadFactory))); } else { channelClazz = NioSocketChannel.class;
public static synchronized void forceShutdown() { if (instance != null) { instance.forEach(executor -> executor.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS)); instance.channelFactoryCount.set(0); instance = null; } }
@Override public Future<?> shutdownGracefully() { return shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS); }
public static void clearThreadPools() { SharedEventLoopGroup.forceShutdown(); }
public static synchronized SharedEventLoopGroup getInstance(Function<ThreadFactory, EventLoopGroup> eventLoopGroupSupplier) { if (instance != null) { ScheduledFuture<?> f = instance.shutdown.getAndSet(null); if (f != null) { f.cancel(false); } } else { instance = new SharedEventLoopGroup(eventLoopGroupSupplier.apply(AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { @Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-netty-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } }))); } instance.channelFactoryCount.incrementAndGet(); return instance; }
@Override public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) { if (channelFactoryCount.decrementAndGet() == 0) { shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() { @Override public void run() { synchronized (SharedEventLoopGroup.class) { if (shutdown.get() != null) { Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit); future.addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception { if (future.isSuccess()) { terminationPromise.setSuccess(null); } else { terminationPromise.setFailure(future.cause()); } } }); instance = null; } } } }, 10, 10, TimeUnit.SECONDS)); } return terminationPromise; } }
group = SharedEventLoopGroup.getInstance((threadFactory -> new EpollEventLoopGroup(remotingThreads, threadFactory))); } else { group = new EpollEventLoopGroup(remotingThreads); } else if (useKQueue && KQueue.isAvailable()) { if (useGlobalWorkerPool) { group = SharedEventLoopGroup.getInstance((threadFactory -> new KQueueEventLoopGroup(remotingThreads, threadFactory))); } else { group = new KQueueEventLoopGroup(remotingThreads); if (useGlobalWorkerPool) { channelClazz = NioSocketChannel.class; group = SharedEventLoopGroup.getInstance((threadFactory -> new NioEventLoopGroup(remotingThreads, threadFactory))); } else { channelClazz = NioSocketChannel.class;
public static synchronized void forceShutdown() { if (instance != null) { instance.forEach(executor -> executor.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS)); instance.channelFactoryCount.set(0); instance = null; } }
@Override public Future<?> shutdownGracefully() { return shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS); }
public static void clearThreadPools() { SharedEventLoopGroup.forceShutdown(); }
public static synchronized SharedEventLoopGroup getInstance(Function<ThreadFactory, EventLoopGroup> eventLoopGroupSupplier) { if (instance != null) { ScheduledFuture<?> f = instance.shutdown.getAndSet(null); if (f != null) { f.cancel(false); } } else { instance = new SharedEventLoopGroup(eventLoopGroupSupplier.apply(AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() { @Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-netty-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } }))); } instance.channelFactoryCount.incrementAndGet(); return instance; }
@Override public Future<?> shutdownGracefully(final long l, final long l2, final TimeUnit timeUnit) { if (channelFactoryCount.decrementAndGet() == 0) { shutdown.compareAndSet(null, next().scheduleAtFixedRate(new Runnable() { @Override public void run() { synchronized (SharedEventLoopGroup.class) { if (shutdown.get() != null) { Future<?> future = SharedEventLoopGroup.super.shutdownGracefully(l, l2, timeUnit); future.addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception { if (future.isSuccess()) { terminationPromise.setSuccess(null); } else { terminationPromise.setFailure(future.cause()); } } }); instance = null; } } } }, 10, 10, TimeUnit.SECONDS)); } return terminationPromise; } }