|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hammurapi.eventbus.AbstractEventBus<E,P,C,K,H,S>
E - Event type.P - Priority type.C - Context type.K - Handler registration key.public abstract class AbstractEventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>
Event bus dispatches events to event handlers.
| Nested Class Summary | |
|---|---|
protected class |
AbstractEventBus.CreateMasterHandleResult
|
static interface |
AbstractEventBus.DerivationEx<K>
Helper interface for snapshot taking. |
static interface |
AbstractEventBus.Handle<E,P extends Comparable<P>,C,K>
Event handle. |
static interface |
AbstractEventBus.Snapshot<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>
Interface to output bus structure for troubleshooting. |
static interface |
AbstractEventBus.StateSnapshot<E,P extends Comparable<P>,C,K,H extends EventBus.Handle<E,P,C>,S extends EventStore<E,P,C,H,S>>
This snapshot also outputs bus state. |
static interface |
AbstractEventBus.StoreEntry<E,P extends Comparable<P>,C,K>
Store entry complements store handle to provide functionality of event handle. |
| Field Summary | |
|---|---|
protected static Logger |
logger
|
| Constructor Summary | |
|---|---|
AbstractEventBus(Class<E> eventType,
S store,
InferencePolicy inferencePolicy,
InferenceFilter<E,P,C,K,H,S> inferenceFilter,
StatsCollector statsCollector,
TimeUnit statsTimeUnit,
Matcher<E,P,C,K,H,S> matcher)
|
|
| Method Summary | |
|---|---|
K |
addHandler(EventHandler<E,P,C,H,S> eventHandler)
Registers event handler with a predicate. |
protected abstract TrackingExecutorService |
createExecutorService(boolean oneOff,
String name)
Create a wrapper around the root executor service for task tracking purposes. |
protected abstract TrackingExecutorService |
createExecutorService(ExecutorService master,
boolean oneOff,
String name)
Creates a wrapper around the master executor service for task tracking purposes. |
protected abstract InferenceContext<E,P,C,K,H,S> |
createInferenceContext()
Creates inference context with zero chain length and no root handle. |
protected H |
createMasterHandle(PostCommand<E,P,C,K,H,S> postCommand)
Creates and returns new master handle. |
Collection<Derivation<E,P,C>> |
getDerivations(E event)
|
Class<E> |
getEventType()
|
ExceptionHandler |
getExceptionHandler()
|
protected abstract TrackingExecutorService |
getExecutorService()
Returns "root" executor service to submit predicate evaluation and handler execution tasks to. |
InferencePolicy |
getInferencePolicy()
|
protected abstract Lock |
getRtcLock()
|
S |
getStore()
|
void |
join()
|
boolean |
join(long timeout)
|
void |
manageHandlers(Matcher.HandlerManager<E,P,C,K,H,S> handlerManager)
This method is used for batch live updates of bus handlers. |
protected abstract H |
newMasterHandle(PostCommand<E,P,C,K,H,S> postCommand)
Instantiates master handle. |
protected abstract K |
nextId()
Generates handler ID. |
H |
post(E event,
Posts event to the bus. |
protected H |
processInferenceCommand(InferenceCommand<E,P,C,K,H,S> command)
|
protected abstract void |
processRemoveCommand(RemoveCommand<E,P,C,K,H,S> command)
|
void |
removeHandlers(Iterable<K> keys)
Removes registered handler(s). |
void |
removeHandlers(K... keys)
Removes registered handler(s). |
void |
reset()
Clears join collections and handle map. |
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
|
void |
takeSnapshot(AbstractEventBus.Snapshot<E,P,C,K,H,S> snapshot)
|
protected void |
workingMemorySnapshot(AbstractEventBus.StateSnapshot<E,P,C,K,H,S> snapshot)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.hammurapi.eventbus.EventBus |
|---|
remove |
| Field Detail |
|---|
protected static final Logger logger
| Constructor Detail |
|---|
public AbstractEventBus(Class<E> eventType,
S store,
InferencePolicy inferencePolicy,
InferenceFilter<E,P,C,K,H,S> inferenceFilter,
StatsCollector statsCollector,
TimeUnit statsTimeUnit,
Matcher<E,P,C,K,H,S> matcher)
| Method Detail |
|---|
public Class<E> getEventType()
getEventType in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public InferencePolicy getInferencePolicy()
getInferencePolicy in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>protected abstract H newMasterHandle(PostCommand<E,P,C,K,H,S> postCommand)
event -
protected abstract TrackingExecutorService getExecutorService()
protected abstract TrackingExecutorService createExecutorService(ExecutorService master,
boolean oneOff,
String name)
master - Master executor service
protected abstract TrackingExecutorService createExecutorService(boolean oneOff,
String name)
protected abstract K nextId()
protected void workingMemorySnapshot(AbstractEventBus.StateSnapshot<E,P,C,K,H,S> snapshot)
public void takeSnapshot(AbstractEventBus.Snapshot<E,P,C,K,H,S> snapshot)
public void setExceptionHandler(ExceptionHandler exceptionHandler)
setExceptionHandler in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public ExceptionHandler getExceptionHandler()
getExceptionHandler in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public K addHandler(EventHandler<E,P,C,H,S> eventHandler)
EventBus
addHandler in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>eventHandler - Event handler.
public void removeHandlers(Iterable<K> keys)
EventBus
removeHandlers in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public void removeHandlers(K... keys)
EventBus
removeHandlers in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>protected abstract Lock getRtcLock()
public H post(E event,
... validators)
EventBus
post in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>event - Event to dispatch to handlers.validators - Predicate(s) which are checked when object is retrieved from the event store.
If there is more than one predicate, predicates are connected with AND. If validator(s) evaluate to
false, the object handle is considered invalid, i.e. object is considered removed from the store.
Once validator(s) evaluate to false, they shall always evaluate to false. One of use of validators
can be to expire object in the store, i.e. after some time validator returns false and object is cleared
from the database. If validators evaluate to false at put time, object is not put to the store and
put() returns null. Validators evaluation result is not cached.
protected H processInferenceCommand(InferenceCommand<E,P,C,K,H,S> command)
command - command to be processedexecutorService - Executor service for asynchronous processinginferenceCommandsQueue - collector of inference commands for further processing.protected abstract void processRemoveCommand(RemoveCommand<E,P,C,K,H,S> command)
protected H createMasterHandle(PostCommand<E,P,C,K,H,S> postCommand)
event - Event to add to the store.joinDelegate - directPost - validators - derivation -
public void reset()
EventBus
reset in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public Collection<Derivation<E,P,C>> getDerivations(E event)
getDerivations in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>
public void join()
throws InterruptedException
InterruptedException
public boolean join(long timeout)
throws InterruptedException
InterruptedExceptionpublic S getStore()
getStore in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>public void manageHandlers(Matcher.HandlerManager<E,P,C,K,H,S> handlerManager)
EventBus
manageHandlers in interface EventBus<E,P extends Comparable<P>,C,K,H extends AbstractEventBus.Handle<E,P,C,K>,S extends EventStore<E,P,C,H,S>>protected abstract InferenceContext<E,P,C,K,H,S> createInferenceContext()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||