use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project cachecloud by sohutv.
the class JedisSentinelPoolTest method checkResourceIsCloseable.
@Test
public void checkResourceIsCloseable() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000, "foobared", 2);
Jedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
} finally {
jedis.close();
}
Jedis jedis2 = pool.getResource();
try {
assertEquals(jedis, jedis2);
} finally {
jedis2.close();
}
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project cachecloud by sohutv.
the class JedisSentinelPoolTest method ensureSafeTwiceFailover.
@Test
public void ensureSafeTwiceFailover() throws InterruptedException {
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, new GenericObjectPoolConfig(), 1000, "foobared", 2);
forceFailover(pool);
// after failover sentinel needs a bit of time to stabilize before a new
// failover
Thread.sleep(100);
forceFailover(pool);
// you can test failover as much as possible
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project cachecloud by sohutv.
the class PipelineClusterTest method before.
@Before
public void before() {
GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
poolConfig.setMaxWaitMillis(2 * 1000L);
Set<HostAndPort> nodes = new HashSet<HostAndPort>();
//test mHgetAll
nodes.add(new HostAndPort("127.0.0.1", 6386));
nodes.add(new HostAndPort("127.0.0.1", 6386));
nodes.add(new HostAndPort("127.0.0.1", 7642));
nodes.add(new HostAndPort("127.0.0.1", 7643));
nodes.add(new HostAndPort("127.0.0.1", 7644));
nodes.add(new HostAndPort("127.0.0.1", 6392));
pipelineCluster = new PipelineCluster(poolConfig, nodes);
for (int i = 1; i < 10; i++) {
String key = "key:" + i;
keys.add(key);
}
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project cachecloud by sohutv.
the class JedisClusterTest method testIfPoolConfigAppliesToClusterPools.
@Test(expected = JedisConnectionException.class)
public void testIfPoolConfigAppliesToClusterPools() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(0);
config.setMaxWaitMillis(2000);
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
JedisCluster jc = new JedisCluster(jedisClusterNode, config);
jc.set("52", "poolTestValue");
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project cachecloud by sohutv.
the class ShardedJedisPoolTest method checkConnections.
@Test
public void checkConnections() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
}
Aggregations