Skip to content

Commit

Permalink
Add shutdown logging to client, ClientResources, and EventLoopGroupPr…
Browse files Browse the repository at this point in the history
…ovider redis#918
  • Loading branch information
mp911de committed Nov 12, 2018
1 parent d0398cc commit ce632ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/lettuce/core/AbstractRedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,8 @@ public CompletableFuture<Void> shutdownAsync(long quietPeriod, long timeout, Tim

if (shutdown.compareAndSet(false, true)) {

logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit);

List<CompletableFuture<Void>> closeFutures = new ArrayList<>();

while (!closeableResources.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ public Future<Boolean> shutdown() {
@SuppressWarnings("unchecked")
public Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) {

logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit);

shutdownCalled = true;
DefaultPromise<Boolean> overall = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE);
DefaultPromise<Boolean> lastRelease = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public DefaultEventLoopGroupProvider(int numberOfThreads) {

@Override
public <T extends EventLoopGroup> T allocate(Class<T> type) {

synchronized (this) {
logger.debug("Allocating executor {}", type.getName());
return addReference(getOrCreate(type));
}
}
Expand Down Expand Up @@ -133,6 +135,8 @@ private <T extends EventLoopGroup> T getOrCreate(Class<T> type) {
*/
public static <T extends EventExecutorGroup> EventExecutorGroup createEventLoopGroup(Class<T> type, int numberOfThreads) {

logger.debug("Creating executor {}", type.getName());

if (DefaultEventExecutorGroup.class.equals(type)) {
return new DefaultEventExecutorGroup(numberOfThreads, new DefaultThreadFactory("lettuce-eventExecutorLoop", true));
}
Expand All @@ -155,6 +159,8 @@ public static <T extends EventExecutorGroup> EventExecutorGroup createEventLoopG
@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)) {
Expand Down Expand Up @@ -192,13 +198,16 @@ public int threadPoolSize() {
@Override
@SuppressWarnings("unchecked")
public Future<Boolean> shutdown(long quietPeriod, long timeout, TimeUnit timeUnit) {

logger.debug("Initiate shutdown ({}, {}, {})", quietPeriod, timeout, timeUnit);

shutdownCalled = true;

Map<Class<? extends EventExecutorGroup>, EventExecutorGroup> copy = new HashMap<>(eventLoopGroups);

DefaultPromise<Boolean> overall = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE);
DefaultPromise<Boolean> lastRelease = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE);
Futures.PromiseAggregator<Boolean, Promise<Boolean>> aggregator = new Futures.PromiseAggregator<Boolean, Promise<Boolean>>(overall);
DefaultPromise<Boolean> overall = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
DefaultPromise<Boolean> lastRelease = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
Futures.PromiseAggregator<Boolean, Promise<Boolean>> aggregator = new Futures.PromiseAggregator<>(overall);

aggregator.expectMore(1 + copy.size());

Expand Down

0 comments on commit ce632ff

Please sign in to comment.