List of usage examples for io.netty.util.concurrent EventExecutorGroup isShuttingDown
boolean isShuttingDown();
From source file:com.lambdaworks.redis.cluster.ClusterTopologyRefreshScheduler.java
License:Apache License
/** * Check if the {@link EventExecutorGroup} is active * * @return false if the worker pool is terminating, shutdown or terminated *///from w w w .j a v a 2 s . c om protected boolean isEventLoopActive() { EventExecutorGroup eventExecutors = clientResources.eventExecutorGroup(); if (eventExecutors.isShuttingDown() || eventExecutors.isShutdown() || eventExecutors.isTerminated()) { return false; } return true; }
From source file:com.lambdaworks.redis.RedisClientTest.java
License:Apache License
@Test public void reuseClientConnections() throws Exception { // given/* ww w .ja va 2 s . co m*/ DefaultClientResources clientResources = DefaultClientResources.create(); Map<Class<? extends EventExecutorGroup>, EventExecutorGroup> eventLoopGroups = getExecutors( clientResources); RedisClient redisClient1 = newClient(clientResources); RedisClient redisClient2 = newClient(clientResources); connectAndClose(redisClient1); connectAndClose(redisClient2); // when EventExecutorGroup executor = eventLoopGroups.values().iterator().next(); redisClient1.shutdown(0, 0, TimeUnit.MILLISECONDS); // then connectAndClose(redisClient2); clientResources.shutdown(0, 0, TimeUnit.MILLISECONDS).get(); assertThat(eventLoopGroups).isEmpty(); assertThat(executor.isShuttingDown()).isTrue(); assertThat(clientResources.eventExecutorGroup().isShuttingDown()).isTrue(); }
From source file:com.lambdaworks.redis.RedisClientTest.java
License:Apache License
@Test public void managedClientResources() throws Exception { // given/*from w w w . j av a 2 s.c o m*/ RedisClient redisClient1 = RedisClient.create(RedisURI.create(TestSettings.host(), TestSettings.port())); ClientResources clientResources = redisClient1.getResources(); Map<Class<? extends EventExecutorGroup>, EventExecutorGroup> eventLoopGroups = getExecutors( clientResources); connectAndClose(redisClient1); // when EventExecutorGroup executor = eventLoopGroups.values().iterator().next(); redisClient1.shutdown(0, 0, TimeUnit.MILLISECONDS); // then assertThat(eventLoopGroups).isEmpty(); assertThat(executor.isShuttingDown()).isTrue(); assertThat(clientResources.eventExecutorGroup().isShuttingDown()).isTrue(); }
From source file:com.lambdaworks.redis.resource.DefaultEventLoopGroupProvider.java
License:Apache License
@Override public Promise<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {//from ww w. ja va 2 s .c om Class<?> key = getKey(release(eventLoopGroup)); if ((key == null && eventLoopGroup.isShuttingDown()) || refCounter.containsKey(eventLoopGroup)) { DefaultPromise<Boolean> promise = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); promise.setSuccess(true); return promise; } if (key != null) { eventLoopGroups.remove(key); } Future<?> shutdownFuture = eventLoopGroup.shutdownGracefully(quietPeriod, timeout, unit); return toBooleanPromise(shutdownFuture); }
From source file:io.lettuce.core.protocol.ConnectionWatchdog.java
License:Apache License
private static boolean isEventLoopGroupActive(EventExecutorGroup executorService) { return !(executorService.isShuttingDown()); }
From source file:io.lettuce.core.resource.DefaultEventLoopGroupProvider.java
License:Apache License
@Override public Promise<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {// ww w .j av a 2 s .c o m Class<?> key = getKey(release(eventLoopGroup)); if ((key == null && eventLoopGroup.isShuttingDown()) || refCounter.containsKey(eventLoopGroup)) { DefaultPromise<Boolean> promise = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE); promise.setSuccess(true); return promise; } if (key != null) { eventLoopGroups.remove(key); } Future<?> shutdownFuture = eventLoopGroup.shutdownGracefully(quietPeriod, timeout, unit); return toBooleanPromise(shutdownFuture); }
From source file:org.jooby.internal.netty.NettyServer.java
License:Apache License
/** * Shutdown executor in order.//from w w w. ja va 2 s .c o m * * @param iterator Executors to shutdown. */ private void shutdownGracefully(final Iterator<EventExecutorGroup> iterator) { if (iterator.hasNext()) { EventExecutorGroup group = iterator.next(); if (!group.isShuttingDown()) { group.shutdownGracefully().addListener(future -> { if (!future.isSuccess()) { log.debug("shutdown of {} resulted in exception", group, future.cause()); } shutdownGracefully(iterator); }); } } }