Skip to content

Commit

Permalink
Shutdown the client if it the enabled fp is set to false.
Browse files Browse the repository at this point in the history
also consolidated all shutdown under one method
  • Loading branch information
smadappa authored and sumanth-pasupuleti committed Nov 22, 2020
1 parent 2f689e3 commit 822cd49
Showing 1 changed file with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,15 @@ private synchronized void refresh(boolean force) throws IOException {
return;
}

for(ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
if(!instances.containsKey(serverGroup)) {
if (log.isDebugEnabled()) log.debug("\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup
+ " does not exist or is not enabled or is out of service. We will shutdown this client and remove it.");
serverGroupDisabled(serverGroup);
}
}


boolean updateAllEVCacheWriteClients = false;
for (Entry<ServerGroup, EVCacheServerGroupConfig> serverGroupEntry : instances.entrySet()) {
final ServerGroup serverGroup = serverGroupEntry.getKey();
Expand All @@ -1022,16 +1031,7 @@ private synchronized void refresh(boolean force) throws IOException {
if (discoveredHostsInServerGroup.size() == 0 && memcachedInstancesByServerGroup.containsKey(serverGroup)) {
if (log.isDebugEnabled()) log.debug("\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup
+ " has no active servers. Cleaning up this ServerGroup.");
final List<EVCacheClient> clients = memcachedInstancesByServerGroup.remove(serverGroup);
memcachedReadInstancesByServerGroup.remove(serverGroup);
memcachedWriteInstancesByServerGroup.remove(serverGroup);
setupAllEVCacheWriteClientsArray();
for (EVCacheClient client : clients) {
if (log.isDebugEnabled()) log.debug("\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup
+ "\n\tClient : " + client + " will be shutdown in 30 seconds.");
client.shutdown(30, TimeUnit.SECONDS);
client.getConnectionObserver().shutdown();
}
serverGroupDisabled(serverGroup);
continue;
}

Expand Down Expand Up @@ -1220,11 +1220,10 @@ public void run() {
void shutdown() {
if (log.isDebugEnabled()) log.debug("EVCacheClientPool for App : " + _appName + " and Zone : " + _zone + " is being shutdown.");
_shutdown = true;
for (List<EVCacheClient> instancesInAZone : memcachedInstancesByServerGroup.values()) {
for (EVCacheClient client : instancesInAZone) {
client.shutdown(30, TimeUnit.SECONDS);
client.getConnectionObserver().shutdown();
}

for(ServerGroup serverGroup : memcachedInstancesByServerGroup.keySet()) {
if (log.isDebugEnabled()) log.debug("\nSHUTDOWN\n\tApp : " + _appName + "\n\tServerGroup : " + serverGroup);
serverGroupDisabled(serverGroup);
}
setupMonitoring();
}
Expand Down

0 comments on commit 822cd49

Please sign in to comment.