use of com.googlecode.jmxtrans.monitoring.ManagedGenericKeyedObjectPool in project jmxtrans by jmxtrans.
the class JmxTransModule method getObjectPool.
private <K, V> GenericKeyedObjectPool<K, V> getObjectPool(KeyedPoolableObjectFactory<K, V> factory, String poolName) {
GenericKeyedObjectPool<K, V> pool = new GenericKeyedObjectPool<>(factory);
pool.setTestOnBorrow(true);
pool.setMaxActive(-1);
pool.setMaxIdle(-1);
pool.setTimeBetweenEvictionRunsMillis(MILLISECONDS.convert(5, MINUTES));
pool.setMinEvictableIdleTimeMillis(MILLISECONDS.convert(5, MINUTES));
try {
ManagedGenericKeyedObjectPool mbean = new ManagedGenericKeyedObjectPool(pool, poolName);
ManagementFactory.getPlatformMBeanServer().registerMBean(mbean, mbean.getObjectName());
} catch (Exception e) {
log.error("Could not register mbean for pool [{}]", poolName, e);
}
return pool;
}
use of com.googlecode.jmxtrans.monitoring.ManagedGenericKeyedObjectPool in project jmxtrans by jmxtrans.
the class StatsDWriter method start.
@Override
public void start() throws LifecycleException {
try {
pool = new GenericKeyedObjectPool<>(new DatagramSocketFactory());
pool.setTestOnBorrow(true);
pool.setMaxActive(-1);
pool.setMaxIdle(-1);
pool.setTimeBetweenEvictionRunsMillis(MILLISECONDS.convert(5, MINUTES));
pool.setMinEvictableIdleTimeMillis(MILLISECONDS.convert(5, MINUTES));
this.mbean = new ManagedGenericKeyedObjectPool((GenericKeyedObjectPool) pool, "StatsdConnectionPool");
ManagementFactory.getPlatformMBeanServer().registerMBean(this.mbean, this.mbean.getObjectName());
} catch (Exception e) {
throw new LifecycleException(e);
}
}
Aggregations