assertEquals(maxThreads, pool.getPoolSize()); ExecutorStatus status = executor.getStatus(); assertTrue(status.queuedEvents.isEmpty()); assertEquals(5, status.running.size());
/** * Start an executor service with a given name. If there was a service already * started with the same name, this throws a RuntimeException. * @param name Name of the service to start. */ @VisibleForTesting public void startExecutorService(String name, int maxThreads) { if (this.executorMap.get(name) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running!"); } Executor hbes = new Executor(name, maxThreads); if (this.executorMap.putIfAbsent(name, hbes) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running (2)!"); } LOG.debug("Starting executor service name=" + name + ", corePoolSize=" + hbes.threadPoolExecutor.getCorePoolSize() + ", maxPoolSize=" + hbes.threadPoolExecutor.getMaximumPoolSize()); }
public void submit(final EventHandler eh) { Executor executor = getExecutor(eh.getEventType().getExecutorServiceType()); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
assertEquals(maxThreads, pool.getPoolSize()); ExecutorStatus status = executor.getStatus(); assertTrue(status.queuedEvents.isEmpty()); assertEquals(5, status.running.size());
/** * Start an executor service with a given name. If there was a service already * started with the same name, this throws a RuntimeException. * @param name Name of the service to start. */ void startExecutorService(String name, int maxThreads) { if (this.executorMap.get(name) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running!"); } Executor hbes = new Executor(name, maxThreads, this.eventHandlerListeners); if (this.executorMap.putIfAbsent(name, hbes) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running (2)!"); } LOG.debug("Starting executor service name=" + name + ", corePoolSize=" + hbes.threadPoolExecutor.getCorePoolSize() + ", maxPoolSize=" + hbes.threadPoolExecutor.getMaximumPoolSize()); }
/** * Start an executor service with a given name. If there was a service already * started with the same name, this throws a RuntimeException. * @param name Name of the service to start. */ void startExecutorService(String name, int maxThreads) { if (this.executorMap.get(name) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running!"); } Executor hbes = new Executor(name, maxThreads, this.eventHandlerListeners); if (this.executorMap.putIfAbsent(name, hbes) != null) { throw new RuntimeException("An executor service with the name " + name + " is already running (2)!"); } LOG.debug("Starting executor service name=" + name + ", corePoolSize=" + hbes.threadPoolExecutor.getCorePoolSize() + ", maxPoolSize=" + hbes.threadPoolExecutor.getMaximumPoolSize()); }
public Map<String, ExecutorStatus> getAllExecutorStatuses() { Map<String, ExecutorStatus> ret = Maps.newHashMap(); for (Map.Entry<String, Executor> e : executorMap.entrySet()) { ret.put(e.getKey(), e.getValue().getStatus()); } return ret; }
public void submit(final EventHandler eh) { Executor executor = getExecutor(getExecutorServiceType(eh.getEventType())); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
public Map<String, ExecutorStatus> getAllExecutorStatuses() { Map<String, ExecutorStatus> ret = Maps.newHashMap(); for (Map.Entry<String, Executor> e : executorMap.entrySet()) { ret.put(e.getKey(), e.getValue().getStatus()); } return ret; }
public void submit(final EventHandler eh) { Executor executor = getExecutor(eh.getEventType().getExecutorServiceType()); if (executor == null) { // This happens only when events are submitted after shutdown() was // called, so dropping them should be "ok" since it means we're // shutting down. LOG.error("Cannot submit [" + eh + "] because the executor is missing." + " Is this process shutting down?"); } else { executor.submit(eh); } }
@VisibleForTesting public ThreadPoolExecutor getExecutorThreadPool(final ExecutorType type) { return getExecutor(type).getThreadPoolExecutor(); }
public Map<String, ExecutorStatus> getAllExecutorStatuses() { Map<String, ExecutorStatus> ret = Maps.newHashMap(); for (Map.Entry<String, Executor> e : executorMap.entrySet()) { ret.put(e.getKey(), e.getValue().getStatus()); } return ret; }