Refactor peer pruning to be more retry-friendly.

This commit is contained in:
Jon Chambers 2020-09-04 17:34:56 -04:00 committed by Jon Chambers
parent e83b41dc01
commit a7266364d1
1 changed files with 9 additions and 11 deletions

View File

@ -221,18 +221,16 @@ public class ClientPresenceManager extends RedisClusterPubSubAdapter<String, Str
final String connectedClientsKey = getConnectedClientSetKey(peerId);
String presenceKey;
while ((presenceKey = presenceCluster.withCluster(connection -> connection.sync().spop(connectedClientsKey))) != null) {
clearPresenceScript.execute(List.of(presenceKey), List.of(peerId));
pruneClientMeter.mark();
}
presenceCluster.useCluster(connection -> {
final RedisAdvancedClusterCommands<String, String> commands = connection.sync();
String presenceKey;
while ((presenceKey = commands.spop(connectedClientsKey)) != null) {
clearPresenceScript.execute(List.of(presenceKey), List.of(peerId));
pruneClientMeter.mark();
}
commands.del(connectedClientsKey);
commands.srem(MANAGER_SET_KEY, peerId);
connection.sync().del(connectedClientsKey);
connection.sync().srem(MANAGER_SET_KEY, peerId);
});
}
}