@Stateless public class ManagedThread { @Resource ManagedExecutorService executor; public void executeManagedThread(){ Runnable task = () -> { try { // some long running task Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } }; executor.execute(task); } }
public ManagedExecutorDTO(ManagedExecutorService executorService) { this.name = executorService.getName(); this.queueSize = executorService.getQueueSize(); this.poolSize = executorService.getPoolSize(); this.remainingQueueCapacity = executorService.getRemainingQueueCapacity(); this.maximumPoolSize = executorService.getMaximumPoolSize(); this.isTerminated = executorService.isTerminated(); this.completedTaskCount = executorService.getCompletedTaskCount(); }
@Override public Future<?> submit(String name, Runnable task) { return getExecutor(name).submit(task); }
public void stopPopulation() { ExecutionService svc = nodeEngine.getExecutionService(); ManagedExecutorService mes = svc.getExecutor(MAP_LOADER_EXECUTOR); if (mes != null) { logger.info("stopPopulation; stopping.. completed load tasks: {}; remaining load tasks: {}", mes.getCompletedTaskCount(), mes.getQueueSize()); } allowPopulation = false; stopTime.set(nodeEngine.getClusterService().getClusterTime()); }
@ManagedAnnotation("queueSize") @ManagedDescription("The work queue size") public int queueSize() { return managedObject.getQueueSize(); }
@ManagedAnnotation("completedTaskCount") @ManagedDescription("The number of tasks this ManagedExecutor has executed") public long getExecutedCount() { return managedObject.getCompletedTaskCount(); } }
@ManagedAnnotation("name") @ManagedDescription("The name of the ManagedExecutor") public String getName() { return managedObject.getName(); }
@ManagedAnnotation("poolSize") @ManagedDescription("The current number of thread in the threadpool") public int poolSize() { return managedObject.getPoolSize(); }
@ManagedAnnotation("remainingQueueCapacity") @ManagedDescription("The remaining capacity on the work queue") public int queueRemainingCapacity() { return managedObject.getRemainingQueueCapacity(); }
@ManagedAnnotation("isShutdown") @ManagedDescription("If the ManagedExecutor is shutdown") public boolean isShutdown() { return managedObject.isShutdown(); }
@ManagedAnnotation("maximumPoolSize") @ManagedDescription("The maximum number of thread in the threadpool") public int maxPoolSize() { return managedObject.getMaximumPoolSize(); }
@ManagedAnnotation("isTerminated") @ManagedDescription("If the ManagedExecutor is terminated") public boolean isTerminated() { return managedObject.isTerminated(); }
@ManagedAnnotation("queueSize") @ManagedDescription("The work queue size") public int queueSize() { return managedObject.getQueueSize(); }
@ManagedAnnotation("completedTaskCount") @ManagedDescription("The number of tasks this ManagedExecutor has executed") public long getExecutedCount() { return managedObject.getCompletedTaskCount(); } }
@ManagedAnnotation("name") @ManagedDescription("The name of the ManagedExecutor") public String getName() { return managedObject.getName(); }
@ManagedAnnotation("poolSize") @ManagedDescription("The current number of thread in the threadpool") public int poolSize() { return managedObject.getPoolSize(); }
@ManagedAnnotation("remainingQueueCapacity") @ManagedDescription("The remaining capacity on the work queue") public int queueRemainingCapacity() { return managedObject.getRemainingQueueCapacity(); }
@ManagedAnnotation("isShutdown") @ManagedDescription("If the ManagedExecutor is shutdown") public boolean isShutdown() { return managedObject.isShutdown(); }
@ManagedAnnotation("maximumPoolSize") @ManagedDescription("The maximum number of thread in the threadpool") public int maxPoolSize() { return managedObject.getMaximumPoolSize(); }
@ManagedAnnotation("isTerminated") @ManagedDescription("If the ManagedExecutor is terminated") public boolean isTerminated() { return managedObject.isTerminated(); }