@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
private static boolean isEventLoopGroupActive(EventExecutorGroup executorService) { return !(executorService.isShuttingDown()); }
private boolean processingAllowed(String channel, String message) { if (eventExecutors.isShuttingDown()) { return false; } if (!filter.test(channel, message)) { return false; } return true; } }
private static boolean isShuttingDown( ChannelHandlerContext ctx ) { EventExecutorGroup eventLoopGroup = ctx.executor().parent(); return eventLoopGroup != null && eventLoopGroup.isShuttingDown(); } }
/** * Shutdown executor in order. * * @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); }); } } }
/** * Check if the {@link EventExecutorGroup} is active * * @return false if the worker pool is terminating, shutdown or terminated */ private boolean isEventLoopActive() { EventExecutorGroup eventExecutors = clientResources.eventExecutorGroup(); if (eventExecutors.isShuttingDown() || eventExecutors.isShutdown() || eventExecutors.isTerminated()) { return false; } return true; }
@Override public Promise<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) { logger.debug("Release executor {}", eventLoopGroup); 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); }
/** * Connect and initialize a channel from {@link ConnectionBuilder}. * * @param connectionBuilder must not be {@literal null}. * @return the {@link ConnectionFuture} to synchronize the connection process. * @since 4.4 */ @SuppressWarnings("unchecked") protected <K, V, T extends RedisChannelHandler<K, V>> ConnectionFuture<T> initializeChannelAsync( ConnectionBuilder connectionBuilder) { Mono<SocketAddress> socketAddressSupplier = connectionBuilder.socketAddress(); if (clientResources.eventExecutorGroup().isShuttingDown()) { throw new IllegalStateException("Cannot connect, Event executor group is terminated."); } CompletableFuture<SocketAddress> socketAddressFuture = new CompletableFuture<>(); CompletableFuture<Channel> channelReadyFuture = new CompletableFuture<>(); socketAddressSupplier.doOnError(socketAddressFuture::completeExceptionally).doOnNext(socketAddressFuture::complete) .subscribe(redisAddress -> { if (channelReadyFuture.isCancelled()) { return; } initializeChannelAsync0(connectionBuilder, channelReadyFuture, redisAddress); }, channelReadyFuture::completeExceptionally); return new DefaultConnectionFuture<>(socketAddressFuture, channelReadyFuture.thenApply(channel -> (T) connectionBuilder .connection())); }
static void pingBeforeActivate(AsyncCommand<?, ?, ?> cmd, CompletableFuture<Boolean> initializedFuture, ChannelHandlerContext ctx, ClientResources clientResources, Duration timeout) throws Exception { ctx.fireUserEventTriggered(new PingBeforeActivate(cmd)); Runnable timeoutGuard = () -> { if (cmd.isDone() || initializedFuture.isDone()) { return; } initializedFuture.completeExceptionally(ExceptionFactory.createTimeoutException( "Cannot initialize channel (PING before activate)", timeout)); }; Timeout timeoutHandle = clientResources.timer().newTimeout(t -> { if (clientResources.eventExecutorGroup().isShuttingDown()) { timeoutGuard.run(); return; } clientResources.eventExecutorGroup().submit(timeoutGuard); }, timeout.toNanos(), TimeUnit.NANOSECONDS); cmd.whenComplete((o, throwable) -> { timeoutHandle.cancel(); if (throwable == null) { ctx.fireChannelActive(); initializedFuture.complete(true); } else { initializedFuture.completeExceptionally(throwable); } }); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
@Override public boolean isShuttingDown() { return group.isShuttingDown(); }
private static boolean isEventLoopGroupActive(EventExecutorGroup executorService) { return !(executorService.isShuttingDown()); }
private boolean processingAllowed(String channel, String message) { if (eventExecutors.isShuttingDown()) { return false; } if (!filter.test(channel, message)) { return false; } return true; } }
private static boolean isShuttingDown( ChannelHandlerContext ctx ) { EventExecutorGroup eventLoopGroup = ctx.executor().parent(); return eventLoopGroup != null && eventLoopGroup.isShuttingDown(); } }
/** * Check if the {@link EventExecutorGroup} is active * * @return false if the worker pool is terminating, shutdown or terminated */ protected boolean isEventLoopActive() { EventExecutorGroup eventExecutors = clientResources.eventExecutorGroup(); if (eventExecutors.isShuttingDown() || eventExecutors.isShutdown() || eventExecutors.isTerminated()) { return false; } return true; }