Skip to content

Commit

Permalink
Adding some logging for evictor thread
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-buttner committed Oct 11, 2023
1 parent 6f1911e commit b70f418
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.io.IOException;
import java.util.List;

import static org.elasticsearch.core.Strings.format;

public class HttpClientManager implements Closeable {
private static final Logger logger = LogManager.getLogger(HttpClientManager.class);
/**
Expand Down Expand Up @@ -143,6 +145,8 @@ boolean isEvictionThreadRunning() {

// default for testing
void setEvictionInterval(TimeValue evictionInterval) {
logger.debug(() -> format("Eviction thread's interval time updated to [%s]", evictionInterval));

evictorSettings = new EvictorSettings(evictionInterval, evictorSettings.evictionMaxIdle);

connectionEvictor.close();
Expand All @@ -151,6 +155,7 @@ void setEvictionInterval(TimeValue evictionInterval) {
}

void setEvictionMaxIdle(TimeValue evictionMaxIdle) {
logger.debug(() -> format("Eviction thread's max idle time updated to [%s]", evictionMaxIdle));
evictorSettings = new EvictorSettings(evictorSettings.evictionInterval, evictionMaxIdle);
connectionEvictor.setMaxIdleTime(evictionMaxIdle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.InferencePlugin.UTILITY_THREAD_POOL_NAME;

/**
Expand Down Expand Up @@ -63,6 +64,8 @@ public synchronized void start() {
}

private void startInternal() {
logger.debug(() -> format("Idle connection evictor started with wait time: [%s] max idle: [%s]", sleepTime, maxIdleTime));

Scheduler.Cancellable task = threadPool.scheduleWithFixedDelay(() -> {
try {
connectionManager.closeExpiredConnections();
Expand All @@ -80,6 +83,7 @@ private void startInternal() {
@Override
public void close() {
if (cancellableTask.get() != null) {
logger.debug("Idle connection evictor closing");
cancellableTask.get().cancel();
}
}
Expand Down

0 comments on commit b70f418

Please sign in to comment.