public class TraceableDelegatingDispatcher extends java.lang.Object implements Dispatcher
Dispatcher that traces activity through it.| Constructor and Description |
|---|
TraceableDelegatingDispatcher(Dispatcher delegate) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
alive()
Determine whether this
Dispatcher can be used for dispatching. |
boolean |
awaitAndShutdown()
Block until all submitted tasks have completed, then do a normal
Dispatcher.shutdown(). |
boolean |
awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
Block until all submitted tasks have completed, then do a normal
Dispatcher.shutdown(). |
<E extends Event<?>> |
dispatch(E event,
EventRouter eventRouter,
Consumer<E> consumer,
Consumer<java.lang.Throwable> errorConsumer)
|
<E extends Event<?>> |
dispatch(java.lang.Object key,
E event,
Registry<Consumer<? extends Event<?>>> consumerRegistry,
Consumer<java.lang.Throwable> errorConsumer,
EventRouter eventRouter,
Consumer<E> completionConsumer)
Instruct the
Dispatcher to dispatch the event that has the given key. |
void |
execute(java.lang.Runnable command) |
void |
halt()
Shutdown this
Dispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected. |
void |
shutdown()
Shutdown this
Dispatcher such that it can no longer be used. |
public TraceableDelegatingDispatcher(Dispatcher delegate)
public boolean alive()
DispatcherDispatcher can be used for dispatching.alive in interface DispatcherDispatcher is alive and can be used, false otherwise.public boolean awaitAndShutdown()
DispatcherDispatcher.shutdown().awaitAndShutdown in interface Dispatcherpublic boolean awaitAndShutdown(long timeout,
java.util.concurrent.TimeUnit timeUnit)
DispatcherDispatcher.shutdown().awaitAndShutdown in interface Dispatcherpublic void shutdown()
DispatcherDispatcher such that it can no longer be used.shutdown in interface Dispatcherpublic void halt()
DispatcherDispatcher, forcibly halting any tasks currently executing and discarding any tasks that have
not yet been exected.halt in interface Dispatcherpublic <E extends Event<?>> void dispatch(java.lang.Object key, E event, Registry<Consumer<? extends Event<?>>> consumerRegistry, Consumer<java.lang.Throwable> errorConsumer, EventRouter eventRouter, Consumer<E> completionConsumer)
DispatcherDispatcher to dispatch the event that has the given key. The Consumers
that will receive the event are selected from the consumerRegistry, and the event is routed to them using
the eventRouter. In the event of an error during dispatching, the errorConsumer will be called. In
the event of successful dispatching, the completionConsumer will be called.dispatch in interface DispatcherE - type of the eventkey - The key associated with the eventevent - The eventconsumerRegistry - The registry from which consumer's are selectederrorConsumer - The consumer that is invoked if dispatch fails. May be nulleventRouter - Used to route the event to the selected consumerscompletionConsumer - The consumer that is driven if dispatch succeeds May be nullpublic <E extends Event<?>> void dispatch(E event, EventRouter eventRouter, Consumer<E> consumer, Consumer<java.lang.Throwable> errorConsumer)
DispatcherDispatcher to dispatch the given Event using the given Consumer. This optimized
route bypasses all selection and routing so provides a significant throughput boost. If an error occurs, the given
errorConsumer will be invoked.dispatch in interface DispatcherE - type of the eventevent - the eventeventRouter - invokes the Consumer in the correct threaderrorConsumer - consumer to invoke if dispatch fails (may be null)public void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executor