ISSUE 78: Removed logic that waits forever till all shards are connected in ShardedJedisPool
Ensuered that all commands connect at the beginning if necessary.
This commit is contained in:
@@ -47,22 +47,6 @@ public class ShardedJedisPool extends Pool<ShardedJedis> {
|
||||
|
||||
public Object makeObject() throws Exception {
|
||||
ShardedJedis jedis = new ShardedJedis(shards, algo, keyTagPattern);
|
||||
boolean done = false;
|
||||
while (!done) {
|
||||
try {
|
||||
for (Jedis shard : jedis.getAllShards()) {
|
||||
if (!shard.isConnected()) {
|
||||
shard.connect();
|
||||
}
|
||||
}
|
||||
done = true;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return jedis;
|
||||
}
|
||||
|
||||
@@ -77,17 +61,7 @@ public class ShardedJedisPool extends Pool<ShardedJedis> {
|
||||
}
|
||||
|
||||
public boolean validateObject(final Object obj) {
|
||||
try {
|
||||
ShardedJedis jedis = (ShardedJedis) obj;
|
||||
for (Jedis shard : jedis.getAllShards()) {
|
||||
if (!shard.isConnected() || !shard.ping().equals("PONG")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user