Search in sources :

Example 1 with DatagramSocketFactory

use of com.googlecode.jmxtrans.connections.DatagramSocketFactory 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);
    }
}
Also used : LifecycleException(com.googlecode.jmxtrans.exceptions.LifecycleException) ManagedGenericKeyedObjectPool(com.googlecode.jmxtrans.monitoring.ManagedGenericKeyedObjectPool) GenericKeyedObjectPool(org.apache.commons.pool.impl.GenericKeyedObjectPool) DatagramSocketFactory(com.googlecode.jmxtrans.connections.DatagramSocketFactory) ManagedGenericKeyedObjectPool(com.googlecode.jmxtrans.monitoring.ManagedGenericKeyedObjectPool) ValidationException(com.googlecode.jmxtrans.model.ValidationException) IOException(java.io.IOException) LifecycleException(com.googlecode.jmxtrans.exceptions.LifecycleException)

Aggregations

DatagramSocketFactory (com.googlecode.jmxtrans.connections.DatagramSocketFactory)1 LifecycleException (com.googlecode.jmxtrans.exceptions.LifecycleException)1 ValidationException (com.googlecode.jmxtrans.model.ValidationException)1 ManagedGenericKeyedObjectPool (com.googlecode.jmxtrans.monitoring.ManagedGenericKeyedObjectPool)1 IOException (java.io.IOException)1 GenericKeyedObjectPool (org.apache.commons.pool.impl.GenericKeyedObjectPool)1