use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method checkFailedJedisServer.
@Test
public void checkFailedJedisServer() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method shouldNotShareInstances.
@Test
public void shouldNotShareInstances() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(2);
ShardedJedisPool pool = new ShardedJedisPool(config, shards);
ShardedJedis j1 = pool.getResource();
ShardedJedis j2 = pool.getResource();
assertNotSame(j1.getShard("foo"), j2.getShard("foo"));
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
the class ShardedJedisPoolTest method checkJedisIsReusedWhenReturned.
@Test
public void checkJedisIsReusedWhenReturned() {
ShardedJedisPool pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
ShardedJedis jedis = pool.getResource();
jedis.set("foo", "0");
jedis.close();
jedis = pool.getResource();
jedis.incr("foo");
jedis.close();
pool.destroy();
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.
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();
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project bigbluebutton by bigbluebutton.
the class MessageSender method start.
public void start() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(32);
config.setMaxIdle(8);
config.setMinIdle(1);
config.setTestOnBorrow(true);
config.setTestOnReturn(true);
config.setTestWhileIdle(true);
config.setNumTestsPerEvictionRun(12);
config.setMaxWaitMillis(5000);
config.setTimeBetweenEvictionRunsMillis(60000);
config.setBlockWhenExhausted(true);
// Set the name of this client to be able to distinguish when doing
// CLIENT LIST on redis-cli
redisPool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE, "BbbRed5AppsPub");
log.info("Redis message publisher starting!");
try {
sendMessage = true;
Runnable messageSender = new Runnable() {
public void run() {
while (sendMessage) {
try {
MessageToSend msg = messages.take();
publish(msg.getChannel(), msg.getMessage());
} catch (InterruptedException e) {
log.warn("Failed to get message from queue.");
}
}
}
};
msgSenderExec.execute(messageSender);
} catch (Exception e) {
log.error("Error subscribing to channels: " + e.getMessage());
}
}
Aggregations