diff --git a/src/main/java/io/lettuce/core/AbstractRedisClient.java b/src/main/java/io/lettuce/core/AbstractRedisClient.java index e871c291e9..c1ca9af793 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisClient.java +++ b/src/main/java/io/lettuce/core/AbstractRedisClient.java @@ -433,6 +433,8 @@ public CompletableFuture shutdownAsync(long quietPeriod, long timeout, Tim if (shutdown.compareAndSet(false, true)) { + logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit); + List> closeFutures = new ArrayList<>(); while (!closeableResources.isEmpty()) { diff --git a/src/main/java/io/lettuce/core/resource/DefaultClientResources.java b/src/main/java/io/lettuce/core/resource/DefaultClientResources.java index f7f487d086..0528188455 100644 --- a/src/main/java/io/lettuce/core/resource/DefaultClientResources.java +++ b/src/main/java/io/lettuce/core/resource/DefaultClientResources.java @@ -573,6 +573,8 @@ public Future shutdown() { @SuppressWarnings("unchecked") public Future shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) { + logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit); + shutdownCalled = true; DefaultPromise overall = new DefaultPromise(GlobalEventExecutor.INSTANCE); DefaultPromise lastRelease = new DefaultPromise(GlobalEventExecutor.INSTANCE); diff --git a/src/main/java/io/lettuce/core/resource/DefaultEventLoopGroupProvider.java b/src/main/java/io/lettuce/core/resource/DefaultEventLoopGroupProvider.java index 12f3d416a8..898781d81d 100644 --- a/src/main/java/io/lettuce/core/resource/DefaultEventLoopGroupProvider.java +++ b/src/main/java/io/lettuce/core/resource/DefaultEventLoopGroupProvider.java @@ -59,7 +59,9 @@ public DefaultEventLoopGroupProvider(int numberOfThreads) { @Override public T allocate(Class type) { + synchronized (this) { + logger.debug("Allocating executor {}", type.getName()); return addReference(getOrCreate(type)); } } @@ -133,6 +135,8 @@ private T getOrCreate(Class type) { */ public static EventExecutorGroup createEventLoopGroup(Class type, int numberOfThreads) { + logger.debug("Creating executor {}", type.getName()); + if (DefaultEventExecutorGroup.class.equals(type)) { return new DefaultEventExecutorGroup(numberOfThreads, new DefaultThreadFactory("lettuce-eventExecutorLoop", true)); } @@ -155,6 +159,8 @@ public static EventExecutorGroup createEventLoopG @Override public Promise 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)) { @@ -192,13 +198,16 @@ public int threadPoolSize() { @Override @SuppressWarnings("unchecked") public Future shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) { + + logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit); + shutdownCalled = true; Map, EventExecutorGroup> copy = new HashMap<>(eventLoopGroups); - DefaultPromise overall = new DefaultPromise(GlobalEventExecutor.INSTANCE); - DefaultPromise lastRelease = new DefaultPromise(GlobalEventExecutor.INSTANCE); - Futures.PromiseAggregator> aggregator = new Futures.PromiseAggregator>(overall); + DefaultPromise overall = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); + DefaultPromise lastRelease = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); + Futures.PromiseAggregator> aggregator = new Futures.PromiseAggregator<>(overall); aggregator.expectMore(1 + copy.size());