|
|
|
@ -299,20 +299,16 @@ public class RedisManager extends JedisPubSub {
|
|
|
|
|
public void clearUsersCheckedOutOnServer() {
|
|
|
|
|
final String keyFormat = String.format("%s*", RedisKeyType.DATA_CHECKOUT.getKeyPrefix(clusterId));
|
|
|
|
|
try (Jedis jedis = jedisPool.getResource()) {
|
|
|
|
|
final Set<String> keys = Sets.newHashSet();
|
|
|
|
|
|
|
|
|
|
// Scan for keys
|
|
|
|
|
String nextCursor;
|
|
|
|
|
do {
|
|
|
|
|
final ScanResult<String> scanResult = jedis.scan(keyFormat, new ScanParams().match(keyFormat));
|
|
|
|
|
keys.addAll(scanResult.getResult());
|
|
|
|
|
nextCursor = scanResult.getCursor();
|
|
|
|
|
} while (!nextCursor.equals("0"));
|
|
|
|
|
|
|
|
|
|
// Delete matched keys
|
|
|
|
|
jedis.del(keys.stream()
|
|
|
|
|
.filter(k -> jedis.get(k).equals(plugin.getServerName()))
|
|
|
|
|
.toArray(String[]::new));
|
|
|
|
|
final Set<String> keys = jedis.keys(keyFormat);
|
|
|
|
|
if (keys == null) {
|
|
|
|
|
plugin.log(Level.WARNING, "Checkout key returned null from Redis during clearing");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (String key : keys) {
|
|
|
|
|
if (jedis.get(key).equals(plugin.getServerName())) {
|
|
|
|
|
jedis.del(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
plugin.log(Level.SEVERE, "An exception occurred clearing this server's checkout keys on Redis", e);
|
|
|
|
|
}
|
|
|
|
|