Search in sources :

Example 1 with ManagedThreadPoolExecutor

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());
}
Also used : ManagedThreadPoolExecutor(com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor) ValidationException(com.googlecode.jmxtrans.model.ValidationException) SchedulerException(org.quartz.SchedulerException) ParseException(java.text.ParseException) LifecycleException(com.googlecode.jmxtrans.exceptions.LifecycleException) MBeanServer(javax.management.MBeanServer)

Example 2 with ManagedThreadPoolExecutor

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ManagedThreadPoolExecutor(com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor)

Example 3 with ManagedThreadPoolExecutor

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;
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ManagedThreadPoolExecutor(com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) ManagedThreadPoolExecutor(com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue)

Example 4 with ManagedThreadPoolExecutor

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);
}
Also used : ManagedThreadPoolExecutor(com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor)

Aggregations

ManagedThreadPoolExecutor (com.googlecode.jmxtrans.monitoring.ManagedThreadPoolExecutor)4 ImmutableList (com.google.common.collect.ImmutableList)1 LifecycleException (com.googlecode.jmxtrans.exceptions.LifecycleException)1 ValidationException (com.googlecode.jmxtrans.model.ValidationException)1 ParseException (java.text.ParseException)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 ThreadFactory (java.util.concurrent.ThreadFactory)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 MBeanServer (javax.management.MBeanServer)1 SchedulerException (org.quartz.SchedulerException)1