use of org.apache.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, "BbbWebPub");
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());
}
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.
the class DataSourceFactoryTest method testPoolConfigDefaultValues.
@Test
public void testPoolConfigDefaultValues() {
GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
assertNotNull(config);
assertEquals(config.getMaxTotal(), GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
assertEquals(config.getMaxIdle(), GenericObjectPoolConfig.DEFAULT_MAX_IDLE);
assertEquals(config.getMinIdle(), GenericObjectPoolConfig.DEFAULT_MIN_IDLE);
assertEquals(config.getMaxWaitMillis(), GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS);
assertEquals(config.getMinEvictableIdleTimeMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
assertEquals(config.getTimeBetweenEvictionRunsMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
assertTrue(config.getTestWhileIdle());
assertTrue(config.getTestOnBorrow());
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.
the class DataSourceFactoryTest method testPoolConfigInvalidValues.
@Test
public void testPoolConfigInvalidValues() {
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "a");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "b");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "c");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "d");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "e");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "f");
GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
assertNotNull(config);
assertEquals(config.getMaxTotal(), GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
assertEquals(config.getMaxIdle(), GenericObjectPoolConfig.DEFAULT_MAX_IDLE);
assertEquals(config.getMinIdle(), GenericObjectPoolConfig.DEFAULT_MIN_IDLE);
assertEquals(config.getMaxWaitMillis(), GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS);
assertEquals(config.getMinEvictableIdleTimeMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
assertEquals(config.getTimeBetweenEvictionRunsMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
assertTrue(config.getTestWhileIdle());
assertTrue(config.getTestOnBorrow());
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.
the class DataSourceFactoryTest method testPoolConfigZeroValues.
@Test
public void testPoolConfigZeroValues() {
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "0");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "0");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "0");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "0");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "0");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "0");
GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
assertNotNull(config);
// MaxTotal and MaxIdle are set to -1 if the value is 0
assertEquals(config.getMaxTotal(), -1);
assertEquals(config.getMaxIdle(), -1);
assertEquals(config.getMinIdle(), 0);
assertEquals(config.getMaxWaitMillis(), 0);
assertEquals(config.getMinEvictableIdleTimeMillis(), 0);
assertEquals(config.getTimeBetweenEvictionRunsMillis(), 0);
assertTrue(config.getTestWhileIdle());
assertTrue(config.getTestOnBorrow());
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
use of org.apache.commons.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.
the class DataSourceFactoryTest method testPoolConfigSpecifiedValues.
@Test
public void testPoolConfigSpecifiedValues() {
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "10");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "20");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "30");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "40");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "50");
System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "60");
GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
assertNotNull(config);
assertEquals(config.getMaxTotal(), 10);
assertEquals(config.getMaxIdle(), 20);
assertEquals(config.getMinIdle(), 30);
assertEquals(config.getMaxWaitMillis(), 40);
assertEquals(config.getMinEvictableIdleTimeMillis(), 50);
assertEquals(config.getTimeBetweenEvictionRunsMillis(), 60);
assertTrue(config.getTestWhileIdle());
assertTrue(config.getTestOnBorrow());
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
Aggregations