@Override public void close() { executor.shutdown(); }
public int getMaximumPoolSize() { return _messageExecutor.getMaximumPoolSize(); }
public int getMaximumQueueSize() { return _messageExecutor.getMaximumQueueSize(); }
void addToEventQueue(CellEvent ce) { try { _eventQueueSize.incrementAndGet(); _messageExecutor.execute(new CellEventTask(ce)); } catch (RejectedExecutionException e) { _eventQueueSize.decrementAndGet(); LOGGER.error("Dropping event: {}", e.getMessage()); } }
/** * Submits a task for execution on the message thread. */ <T> Future<T> invokeOnMessageThread(Callable<T> task) { return _messageExecutor.submit(wrapLoggingContext(task)); }
public void setMaximumQueueSize(int size) { _messageExecutor.setMaximumQueueSize(size); }
public void setMaximumPoolSize(int size) { _messageExecutor.setMaximumPoolSize(size); }
@Override public List<Runnable> shutdownNow() { List<Runnable> runnables = super.shutdownNow(); executor.shutdown(); return runnables; } }
_messageExecutor = (executor == null) ? new BoundedCachedExecutor(this, 1) : new BoundedExecutor(executor, 1);
@Override public Watcher load(Watcher watcher) throws Exception { CDC cdc = new CDC(); return event -> executor.execute(() -> { try (CDC ignore = cdc.restore()) { watcher.process(event); } }); } });
/** * Submits a task for execution on the message thread. */ Future<?> invokeOnMessageThread(Runnable task) { return _messageExecutor.submit(wrapLoggingContext(task)); }
@Override public void shutdown() { super.shutdown(); executor.shutdown(); }
@Override public CuratorWatcher load(CuratorWatcher watcher) throws Exception { CDC cdc = new CDC(); return event -> executor.execute(() -> { try (CDC ignore = cdc.restore()) { try { watcher.process(event); } catch (Exception e) { ThreadUtils.checkInterrupted(e); LOGGER.error("Watcher exception", e); } } }); } });
/** * Starts the cell asynchronously. * * Calls the startup callbacks of the cell, registers the cell with the cell glue and * initiates cell message delivery. If startup fails, the cell is torn down. * * Must only be called once. */ public ListenableFuture<Void> start() { _lifeCycleMonitor.enter(); try { checkState(_state == State.NEW); _state = State.PRE_STARTUP; _startup = _messageExecutor.submit(wrapLoggingContext(this::doStart)); } finally { _lifeCycleMonitor.leave(); } return Futures.nonCancellationPropagating(_startup); }
EventLogger.queueBegin(ce); _eventQueueSize.incrementAndGet(); _messageExecutor.execute(new DeliverMessageTask(ce)); } catch (RejectedExecutionException e) { EventLogger.queueEnd(ce);
Uninterruptibles.getUninterruptibly(_messageExecutor.submit(() -> { try { EventLogger.prepareRemovalBegin(_cell, event);