Skip to content

Commit 14e19f0

Browse files
shy-1234Shih-Hao Yeh
andauthored
client shutdown without wait time when bean is destroyed (#166)
* no need to wait during shutting down * use fp to control the timeout --------- Co-authored-by: Shih-Hao Yeh <[email protected]>
1 parent a196528 commit 14e19f0

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

evcache-core/src/main/java/com/netflix/evcache/pool/EVCacheClientPool.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ public class EVCacheClientPool implements Runnable, EVCacheClientPoolMBean {
8686

8787
private final Property<Boolean> _pingServers;
8888

89+
private final Property<Integer> _sgDisabledTimeoutOnShutdown;
90+
8991
private final Property<Boolean> refreshConnectionOnReadQueueFull;
9092
private final Property<Integer> refreshConnectionOnReadQueueFullSize;
9193

@@ -149,6 +151,7 @@ public Property<Boolean> get(Object _serverGroup) {
149151
this._bulkReadTimeout = config.getPropertyRepository().get(appName + ".EVCacheClientPool.bulkReadTimeout", Integer.class).orElse(_readTimeout.get());
150152
this._bulkReadTimeout.subscribe(callback);
151153

154+
this._sgDisabledTimeoutOnShutdown = config.getPropertyRepository().get(appName + ".EVCacheClientPool.sgDisabled.timeoutOnShutdown", Integer.class).orElseGet("EVCacheClientPool.sgDisabled.timeoutOnShutdown").orElse(30);
152155
this.refreshConnectionOnReadQueueFull = config.getPropertyRepository().get(appName + ".EVCacheClientPool.refresh.connection.on.readQueueFull", Boolean.class).orElseGet("EVCacheClientPool.refresh.connection.on.readQueueFull").orElse(false);
153156
this.refreshConnectionOnReadQueueFullSize = config.getPropertyRepository().get(appName + ".EVCacheClientPool.refresh.connection.on.readQueueFull.size", Integer.class).orElseGet("EVCacheClientPool.refresh.connection.on.readQueueFull.size").orElse(100);
154157

@@ -1253,6 +1256,10 @@ public void pingServers(Boolean bootTimeCheck) {
12531256
}
12541257

12551258
public void serverGroupDisabled(final ServerGroup serverGroup) {
1259+
serverGroupDisabled(serverGroup, 30);
1260+
}
1261+
1262+
public void serverGroupDisabled(final ServerGroup serverGroup, final long timeoutSeconds) {
12561263
if (memcachedInstancesByServerGroup.containsKey(serverGroup)) {
12571264
if (log.isDebugEnabled()) log.debug("\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup
12581265
+ " has no active servers. Cleaning up this ServerGroup.");
@@ -1262,13 +1269,13 @@ public void serverGroupDisabled(final ServerGroup serverGroup) {
12621269
setupAllEVCacheWriteClientsArray();
12631270
for (EVCacheClient client : clients) {
12641271
if (log.isDebugEnabled()) log.debug("\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup
1265-
+ "\n\tClient : " + client + " will be shutdown in 30 seconds.");
1266-
client.shutdown(30, TimeUnit.SECONDS);
1272+
+ "\n\tClient : " + client + " will be shutdown in " + timeoutSeconds + " seconds.");
1273+
client.shutdown(timeoutSeconds, TimeUnit.SECONDS);
12671274
client.getConnectionObserver().shutdown();
12681275
}
12691276
}
12701277
if (duetClientPool != null)
1271-
duetClientPool.serverGroupDisabled(serverGroup);
1278+
duetClientPool.serverGroupDisabled(serverGroup, timeoutSeconds);
12721279
}
12731280

12741281
public void refreshAsync(MemcachedNode node) {
@@ -1300,7 +1307,7 @@ void shutdown() {
13001307

13011308
for(ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
13021309
if (log.isDebugEnabled()) log.debug("\nSHUTDOWN\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup);
1303-
serverGroupDisabled(serverGroup);
1310+
serverGroupDisabled(serverGroup, _sgDisabledTimeoutOnShutdown.get());
13041311
}
13051312
setupMonitoring();
13061313
}

0 commit comments

Comments
 (0)