use of com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor in project jmxtrans by jmxtrans.
the class JmxTransformer method doMain.
/**
* The real main method.
*/
private void doMain() throws Exception {
MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
ManagedJmxTransformerProcess mbean = new ManagedJmxTransformerProcess(this, configuration);
platformMBeanServer.registerMBean(mbean, mbean.getObjectName());
ManagedThreadPoolExecutor queryExecutorMBean = new ManagedThreadPoolExecutor(queryProcessorExecutor, "queryProcessorExecutor");
platformMBeanServer.registerMBean(queryExecutorMBean, queryExecutorMBean.getObjectName());
ManagedThreadPoolExecutor resultExecutorMBean = new ManagedThreadPoolExecutor(resultProcessorExecutor, "resultProcessorExecutor");
platformMBeanServer.registerMBean(resultExecutorMBean, resultExecutorMBean.getObjectName());
// Start the process
this.start();
while (true) {
// TODO : Make something here, maybe watch for files?
try {
Thread.sleep(5);
} catch (Exception e) {
log.info("shutting down", e);
break;
}
}
platformMBeanServer.unregisterMBean(mbean.getObjectName());
platformMBeanServer.unregisterMBean(queryExecutorMBean.getObjectName());
platformMBeanServer.unregisterMBean(resultExecutorMBean.getObjectName());
}
use of com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor in project jmxtrans by jmxtrans.
the class JmxTransformer method registerExecutors.
private ImmutableList<ManagedThreadPoolExecutor> registerExecutors(ExecutorRepository executorRepository) throws Exception {
ImmutableList.Builder<ManagedThreadPoolExecutor> executorMBeansBuilder = ImmutableList.builder();
for (ManagedThreadPoolExecutor executorMBean : executorRepository.getMBeans()) {
platformMBeanServer.registerMBean(executorMBean, executorMBean.getObjectName());
executorMBeansBuilder.add(executorMBean);
}
return executorMBeansBuilder.build();
}
use of com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor in project jmxtrans by jmxtrans.
the class ExecutorFactory method create.
public ManagedThreadPoolExecutor create(String aliasSuffix) throws MalformedObjectNameException {
final String serverAlias = aliasSuffix == null ? executorAlias : String.format("%s-%s", executorAlias, aliasSuffix);
ThreadFactory threadFactory = threadFactory(serverAlias);
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>(defaultWorkQueueCapacity);
// each server can have different settings in separate thread pool strategy
// this logic can be implemented in json/yaml configs if it will be needed
final ThreadPoolExecutor executor = new ThreadPoolExecutor(defaultPoolSize, defaultPoolSize, 0L, MILLISECONDS, workQueue, threadFactory);
ManagedThreadPoolExecutor executorMBean = new ManagedThreadPoolExecutor(executor, serverAlias);
return executorMBean;
}
use of com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor in project jmxtrans by jmxtrans.
the class SeparateExecutorRepository method put.
@Override
public void put(Server server) throws MalformedObjectNameException {
final ManagedThreadPoolExecutor managedThreadPoolExecutor = executorFactory.create(server.getId());
repository.put(server, managedThreadPoolExecutor.getExecutor());
mBeans.put(server, managedThreadPoolExecutor);
}
Aggregations