code cleanup
This commit is contained in:
@@ -116,21 +116,6 @@ public class ShardedJedisPoolTest extends Assert {
|
|||||||
assertNotSame(j1.getShard("foo"), j2.getShard("foo"));
|
assertNotSame(j1.getShard("foo"), j2.getShard("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkConnectionsWithNoServers() {
|
|
||||||
shards = new ArrayList<JedisShardInfo>();
|
|
||||||
shards.add(new JedisShardInfo("localhost", 6379, "ssa"));
|
|
||||||
shards.add(new JedisShardInfo("localhost", 6380, "ssa"));
|
|
||||||
Config redisConfig = new Config();
|
|
||||||
redisConfig.testOnBorrow = false; // deactivated for now
|
|
||||||
redisConfig.testOnReturn = true;
|
|
||||||
redisConfig.maxActive = 200; // nro threads + margen de seguridad?
|
|
||||||
redisConfig.minIdle = 200;
|
|
||||||
ShardedJedisPool pool = new ShardedJedisPool(redisConfig, shards);
|
|
||||||
ShardedJedis jedis = pool.getResource();
|
|
||||||
pool.returnResource(jedis);
|
|
||||||
pool.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkFailedJedisServer() {
|
public void checkFailedJedisServer() {
|
||||||
ShardedJedisPool pool = new ShardedJedisPool(new Config(), shards);
|
ShardedJedisPool pool = new ShardedJedisPool(new Config(), shards);
|
||||||
@@ -182,5 +167,4 @@ public class ShardedJedisPoolTest extends Assert {
|
|||||||
assertEquals(actual, c1);
|
assertEquals(actual, c1);
|
||||||
assertEquals(fails, c2);
|
assertEquals(fails, c2);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -23,10 +23,10 @@ public class ShardedJedisTest extends Assert {
|
|||||||
.get(1);
|
.get(1);
|
||||||
|
|
||||||
private List<String> getKeysDifferentShard(ShardedJedis jedis) {
|
private List<String> getKeysDifferentShard(ShardedJedis jedis) {
|
||||||
List<String> ret = new ArrayList<String> ();
|
List<String> ret = new ArrayList<String>();
|
||||||
JedisShardInfo first = jedis.getShardInfo("a0");
|
JedisShardInfo first = jedis.getShardInfo("a0");
|
||||||
ret.add("a0");
|
ret.add("a0");
|
||||||
for (int i =1; i < 100; ++i) {
|
for (int i = 1; i < 100; ++i) {
|
||||||
JedisShardInfo actual = jedis.getShardInfo("a" + i);
|
JedisShardInfo actual = jedis.getShardInfo("a" + i);
|
||||||
if (actual != first) {
|
if (actual != first) {
|
||||||
ret.add("a" + i);
|
ret.add("a" + i);
|
||||||
@@ -135,8 +135,8 @@ public class ShardedJedisTest extends Assert {
|
|||||||
assertEquals(jedis2.getKeyTag("foo"), "foo");
|
assertEquals(jedis2.getKeyTag("foo"), "foo");
|
||||||
assertNotSame(jedis2.getKeyTag("foo{bar}"), "bar");
|
assertNotSame(jedis2.getKeyTag("foo{bar}"), "bar");
|
||||||
|
|
||||||
JedisShardInfo s5 = jedis2.getShardInfo(keys.get(0)+"{bar}");
|
JedisShardInfo s5 = jedis2.getShardInfo(keys.get(0) + "{bar}");
|
||||||
JedisShardInfo s6 = jedis2.getShardInfo(keys.get(1)+"{bar}");
|
JedisShardInfo s6 = jedis2.getShardInfo(keys.get(1) + "{bar}");
|
||||||
assertNotSame(s5, s6);
|
assertNotSame(s5, s6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,22 +264,27 @@ public class ShardedJedisTest extends Assert {
|
|||||||
.toString(i));
|
.toString(i));
|
||||||
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
|
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
|
||||||
.toString(i));
|
.toString(i));
|
||||||
assertEquals(shards.indexOf(jedisShardInfo),
|
assertEquals(shards.indexOf(jedisShardInfo), otherShards
|
||||||
otherShards.indexOf(jedisShardInfo2));
|
.indexOf(jedisShardInfo2));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMasterSlaveShardingConsistencyWithShardNaming() {
|
public void testMasterSlaveShardingConsistencyWithShardNaming() {
|
||||||
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
|
List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(3);
|
||||||
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT, "HOST1:1234"));
|
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT,
|
||||||
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1,"HOST2:1234"));
|
"HOST1:1234"));
|
||||||
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2, "HOST3:1234"));
|
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 1,
|
||||||
|
"HOST2:1234"));
|
||||||
|
shards.add(new JedisShardInfo("localhost", Protocol.DEFAULT_PORT + 2,
|
||||||
|
"HOST3:1234"));
|
||||||
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(
|
Sharded<Jedis, JedisShardInfo> sharded = new Sharded<Jedis, JedisShardInfo>(
|
||||||
shards, Hashing.MURMUR_HASH);
|
shards, Hashing.MURMUR_HASH);
|
||||||
|
|
||||||
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
|
List<JedisShardInfo> otherShards = new ArrayList<JedisShardInfo>(3);
|
||||||
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT, "HOST2:1234"));
|
otherShards.add(new JedisShardInfo("otherhost", Protocol.DEFAULT_PORT,
|
||||||
|
"HOST2:1234"));
|
||||||
otherShards.add(new JedisShardInfo("otherhost",
|
otherShards.add(new JedisShardInfo("otherhost",
|
||||||
Protocol.DEFAULT_PORT + 1, "HOST3:1234"));
|
Protocol.DEFAULT_PORT + 1, "HOST3:1234"));
|
||||||
otherShards.add(new JedisShardInfo("otherhost",
|
otherShards.add(new JedisShardInfo("otherhost",
|
||||||
@@ -292,11 +297,7 @@ public class ShardedJedisTest extends Assert {
|
|||||||
.toString(i));
|
.toString(i));
|
||||||
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
|
JedisShardInfo jedisShardInfo2 = sharded2.getShardInfo(Integer
|
||||||
.toString(i));
|
.toString(i));
|
||||||
assertEquals(jedisShardInfo.getName(),
|
assertEquals(jedisShardInfo.getName(), jedisShardInfo2.getName());
|
||||||
jedisShardInfo2.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user