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:
Dmytro
2011-03-25 11:19:17 +00:00
parent cb0d76051d
commit 604615d228
4 changed files with 128 additions and 158 deletions

View File

@@ -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;
}
}
}