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 #918
  • Loading branch information
mp911de committed Nov 12, 2018
1 parent 4454f22 commit e1585f3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/lambdaworks/redis/AbstractRedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ public CompletableFuture<Void> shutdownAsync(long quietPeriod, long timeout, Tim

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

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

while (!closeableResources.isEmpty()) {
Closeable closeableResource = closeableResources.iterator().next();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,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<>(GlobalEventExecutor.INSTANCE);
DefaultPromise<Boolean> lastRelease = new DefaultPromise<>(GlobalEventExecutor.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,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 @@ -134,6 +136,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 @@ -156,6 +160,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 @@ -193,6 +199,9 @@ 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);
Expand Down

0 comments on commit e1585f3

Please sign in to comment.