Tweaks, more pipelining.

This commit is contained in:
Tux 2014-06-17 15:47:52 -04:00
parent 511202044c
commit 688246b8fe
1 changed files with 41 additions and 41 deletions

View File

@ -332,8 +332,10 @@ public final class RedisBungee extends Plugin {
public void run() {
Jedis rsc = pool.getResource();
try {
rsc.hset("playerCounts", serverId, String.valueOf(getProxy().getOnlineCount()));
rsc.hset("heartbeats", serverId, String.valueOf(System.currentTimeMillis()));
Pipeline pipeline = rsc.pipelined();
pipeline.hset("playerCounts", serverId, String.valueOf(getProxy().getOnlineCount()));
pipeline.hset("heartbeats", serverId, String.valueOf(System.currentTimeMillis()));
pipeline.sync();
} catch (JedisConnectionException e) {
// Redis server has disappeared!
getLogger().log(Level.SEVERE, "Unable to update proxy counts - did your Redis server go away?", e);
@ -405,6 +407,7 @@ public final class RedisBungee extends Plugin {
Jedis tmpRsc = pool.getResource();
try {
tmpRsc.hdel("playerCounts", serverId);
tmpRsc.hdel("heartbeats", serverId);
if (tmpRsc.scard("server:" + serverId + ":usersOnline") > 0) {
Set<String> players = tmpRsc.smembers("server:" + serverId + ":usersOnline");
Pipeline pipeline = tmpRsc.pipelined();
@ -413,7 +416,6 @@ public final class RedisBungee extends Plugin {
pipeline.sync();
}
tmpRsc.hdel("heartbeats", serverId);
} finally {
pool.returnResource(tmpRsc);
}
@ -443,17 +445,16 @@ public final class RedisBungee extends Plugin {
String redisPassword = configuration.getString("redis-password");
serverId = configuration.getString("server-id");
if (redisPassword != null && (redisPassword.equals("") || redisPassword.equals("none"))) {
if (redisPassword != null && (redisPassword.isEmpty() || redisPassword.equals("none"))) {
redisPassword = null;
}
// Configuration sanity checks.
if (serverId == null || serverId.equals("")) {
if (serverId == null || serverId.isEmpty()) {
throw new RuntimeException("server-id is not specified in the configuration or is empty");
}
if (redisServer != null) {
if (!redisServer.equals("")) {
if (redisServer != null && !redisServer.isEmpty()) {
JedisPoolConfig config = new JedisPoolConfig();
config.setMaxTotal(configuration.getInt("max-redis-connections", -1));
pool = new JedisPool(config, redisServer, redisPort, 0, redisPassword);
@ -491,7 +492,6 @@ public final class RedisBungee extends Plugin {
pool.returnResource(rsc);
}
}
}
} else {
throw new RuntimeException("No redis server specified!");
}