public class EPEventServiceImpl extends Object implements EPEventServiceSPI, com.espertech.esper.common.internal.context.util.InternalEventRouteDest, TimerCallback, com.espertech.esper.common.internal.event.util.EPRuntimeEventProcessWrapped
Modifier and Type | Field and Description |
---|---|
protected boolean |
isPrioritized |
protected static org.slf4j.Logger |
log |
protected ThreadLocal<com.espertech.esper.common.internal.collection.ArrayBackedCollection<com.espertech.esper.common.internal.filtersvc.FilterHandle>> |
matchesArrayThreadLocal |
protected EPServicesContext |
services |
protected UnmatchedListener |
unmatchedListener |
Constructor and Description |
---|
EPEventServiceImpl(EPServicesContext services)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
advanceTime(long time)
Advance time by jumping to the given time in milliseconds (or nanoseconds if so configured).
|
void |
advanceTimeSpan(long targetTime)
Advance time by continually-sliding to the given time in milliseconds (or nanoseconds if so configured) at the smallest resolution (non-hopping).
|
void |
advanceTimeSpan(long targetTime,
long resolution)
Advance time by continually-sliding to the given time in milliseconds (or nanoseconds if so configured) at the provided resolution (hopping).
|
void |
clearCaches() |
void |
clockExternal()
Switches off the internal timer which tracks system time.
|
void |
clockInternal()
Switches on the internal timer which tracks system time.
|
void |
destroy()
Destroy for destroying an runtime instance: sets references to null and clears thread-locals
|
void |
dispatch()
Dispatch events.
|
long |
getCurrentTime()
Returns current engine time.
|
com.espertech.esper.common.client.EventSender |
getEventSender(String eventTypeName)
Returns a facility to process event objects that are of a known type.
|
Long |
getNextScheduledTime()
Returns the time at which the next schedule execution is expected, returns null if no schedule execution is
outstanding.
|
long |
getNumEventsEvaluated()
Number of events evaluated over the lifetime of the event stream processing runtime,
or since the last resetStats() call.
|
long |
getRoutedExternal() |
long |
getRoutedInternal() |
String |
getRuntimeURI() |
EPServicesContext |
getServices() |
Map<com.espertech.esper.common.internal.util.DeploymentIdNamePair,Long> |
getStatementNearestSchedules() |
protected void |
handleFilterFault(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle faultingHandle,
com.espertech.esper.common.client.EventBean theEvent,
int filterFaultCount) |
void |
initialize() |
boolean |
isExternalClockingEnabled()
Returns true for external clocking, false for internal clocking.
|
protected void |
processMatches(com.espertech.esper.common.client.EventBean theEvent) |
void |
processScheduleHandles(com.espertech.esper.common.internal.collection.ArrayBackedCollection<com.espertech.esper.common.internal.schedule.ScheduleHandle> handles) |
void |
processStatementFilterMultiple(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle,
Object callbackList,
com.espertech.esper.common.client.EventBean theEvent,
long version,
int filterFaultCount)
Processing multiple filter matches for a statement.
|
void |
processStatementFilterSingle(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle,
com.espertech.esper.common.internal.context.util.EPStatementHandleCallbackFilter handleCallback,
com.espertech.esper.common.client.EventBean theEvent,
long version,
int filterFaultCount)
Process a single match.
|
static void |
processStatementScheduleMultiple(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle,
Object callbackObject,
EPServicesContext services)
Processing multiple schedule matches for a statement.
|
static void |
processStatementScheduleSingle(com.espertech.esper.common.internal.context.util.EPStatementHandleCallbackSchedule handle,
EPServicesContext services)
Processing single schedule matche for a statement.
|
void |
processThreadWorkQueue()
Works off the thread's work queue.
|
void |
processWrappedEvent(com.espertech.esper.common.client.EventBean eventBean) |
void |
resetStats()
Reset the count of the number of events received and emitted
|
void |
route(com.espertech.esper.common.client.EventBean theEvent,
com.espertech.esper.common.internal.context.util.EPStatementHandle epStatementHandle,
boolean addToFront) |
void |
routeEventAvro(Object avroGenericDataDotRecord,
String eventTypeName)
Route the event object back to the runtime for internal dispatching,
to avoid the possibility of a stack overflow due to nested calls to sendEvent.
|
void |
routeEventBean(com.espertech.esper.common.client.EventBean theEvent) |
void |
routeEventBean(Object event,
String eventTypeName)
Route the event object back to the runtime for internal dispatching,
to avoid the possibility of a stack overflow due to nested calls to sendEvent.
|
void |
routeEventMap(Map<String,Object> map,
String eventTypeName)
Route the event object back to the runtime for internal dispatching,
to avoid the possibility of a stack overflow due to nested calls to sendEvent.
|
void |
routeEventObjectArray(Object[] event,
String eventTypeName)
Route the event object back to the runtime for internal dispatching,
to avoid the possibility of a stack overflow due to nested calls to sendEvent.
|
void |
routeEventXMLDOM(Node event,
String eventTypeName)
Route the event object back to the runtime for internal dispatching,
to avoid the possibility of a stack overflow due to nested calls to sendEvent.
|
void |
sendEventAvro(Object avroGenericDataDotRecord,
String avroEventTypeName)
Send an event represented by a Avro GenericData.Record to the runtime.
|
void |
sendEventBean(Object theEvent,
String eventTypeName)
Send an event represented by an object to the runtime.
|
void |
sendEventMap(Map<String,Object> map,
String mapEventTypeName)
Send a map containing event property values to the runtime.
|
void |
sendEventObjectArray(Object[] propertyValues,
String eventTypeName)
Send an object array containing event property values to the runtime.
|
void |
sendEventXMLDOM(Node node,
String eventTypeName)
Send an event represented by a DOM node to the runtime.
|
void |
setInternalEventRouter(com.espertech.esper.common.internal.context.util.InternalEventRouter internalEventRouter)
Sets the route for events to use
|
void |
setUnmatchedListener(UnmatchedListener listener)
Sets a listener to receive events that are unmatched by any statement.
|
void |
timerCallback()
Invoked by the internal clocking service at regular intervals.
|
protected static final org.slf4j.Logger log
protected EPServicesContext services
protected boolean isPrioritized
protected volatile UnmatchedListener unmatchedListener
protected ThreadLocal<com.espertech.esper.common.internal.collection.ArrayBackedCollection<com.espertech.esper.common.internal.filtersvc.FilterHandle>> matchesArrayThreadLocal
public EPEventServiceImpl(EPServicesContext services)
services
- - references to servicespublic EPServicesContext getServices()
public void setInternalEventRouter(com.espertech.esper.common.internal.context.util.InternalEventRouter internalEventRouter)
setInternalEventRouter
in interface com.espertech.esper.common.internal.context.util.InternalEventRouteDest
internalEventRouter
- routerpublic long getRoutedInternal()
getRoutedInternal
in interface EPEventServiceSPI
public long getRoutedExternal()
getRoutedExternal
in interface EPEventServiceSPI
public void timerCallback()
TimerCallback
timerCallback
in interface TimerCallback
public void sendEventAvro(Object avroGenericDataDotRecord, String avroEventTypeName)
EPEventServiceSendEvent
Use the route method for sending events into the runtime from within UpdateListener code,
to avoid the possibility of a stack overflow due to nested calls to sendEvent
(except with the outbound-threading configuration), see EPEventServiceRouteEvent.routeEventAvro(Object, String)
}).
sendEventAvro
in interface com.espertech.esper.common.internal.event.core.EventServiceSendEventCommon
sendEventAvro
in interface EPEventServiceSendEvent
avroGenericDataDotRecord
- is the event to sent to the runtimeavroEventTypeName
- event type namepublic void sendEventBean(Object theEvent, String eventTypeName)
EPEventServiceSendEvent
Use the route method for sending events into the runtime from within UpdateListener code,
to avoid the possibility of a stack overflow due to nested calls to sendEvent
(except with the outbound-threading configuration), see EPEventServiceRouteEvent.routeEventBean(Object, String)
.
sendEventBean
in interface com.espertech.esper.common.internal.event.core.EventServiceSendEventCommon
sendEventBean
in interface EPEventServiceSendEvent
theEvent
- is the event to sent to the runtimeeventTypeName
- event type namepublic void advanceTime(long time)
EPEventServiceTimeControl
For externally controlling the time within a runtime.
External clocking must be first be enabled by configuration ConfigurationRuntimeThreading.setInternalTimerEnabled(boolean)
passing false
or by calling EPEventServiceTimeControl.clockExternal()
.
Time should never move backwards (unless for testing purposes where previous results can be thrown away)
advanceTime
in interface EPEventServiceTimeControl
time
- timepublic void advanceTimeSpan(long targetTime)
EPEventServiceTimeControl
For externally controlling the time within a runtime.
External clocking must be first be enabled by configuration ConfigurationRuntimeThreading.setInternalTimerEnabled(boolean)
passing false
or by calling EPEventServiceTimeControl.clockExternal()
.
Time should never move backwards (unless for testing purposes where previous results can be thrown away)
advanceTimeSpan
in interface EPEventServiceTimeControl
targetTime
- timepublic void advanceTimeSpan(long targetTime, long resolution)
EPEventServiceTimeControl
For externally controlling the time within a runtime.
External clocking must be first be enabled by configuration ConfigurationRuntimeThreading.setInternalTimerEnabled(boolean)
passing false
or by calling EPEventServiceTimeControl.clockExternal()
.
Time should never move backwards (unless for testing purposes where previous results can be thrown away)
advanceTimeSpan
in interface EPEventServiceTimeControl
targetTime
- timeresolution
- the resolution to usepublic Long getNextScheduledTime()
EPEventServiceTimeControl
getNextScheduledTime
in interface EPEventServiceTimeControl
public void sendEventXMLDOM(Node node, String eventTypeName)
EPEventServiceSendEvent
Use the route method for sending events into the runtime from within UpdateListener code.
to avoid the possibility of a stack overflow due to nested calls to sendEvent
(except with the outbound-threading configuration), see EPEventServiceRouteEvent.routeEventXMLDOM(Node, String)
.
sendEventXMLDOM
in interface com.espertech.esper.common.internal.event.core.EventServiceSendEventCommon
sendEventXMLDOM
in interface EPEventServiceSendEvent
node
- is the DOM node as an eventeventTypeName
- event type namepublic void sendEventObjectArray(Object[] propertyValues, String eventTypeName) throws com.espertech.esper.common.client.EPException
EPEventServiceSendEvent
Use the route method for sending events into the runtime from within UpdateListener code.
to avoid the possibility of a stack overflow due to nested calls to sendEvent
(except with the outbound-threading configuration), see EPEventServiceRouteEvent.routeEventObjectArray(Object[], String)
.
sendEventObjectArray
in interface com.espertech.esper.common.internal.event.core.EventServiceSendEventCommon
sendEventObjectArray
in interface EPEventServiceSendEvent
propertyValues
- - array that contains event property values. Your application must ensure that property values
match the exact same order that the property names and types have been declared, and that the array length matches the number of properties declared.eventTypeName
- - event type namecom.espertech.esper.common.client.EPException
- - when the processing of the event leads to an errorpublic void sendEventMap(Map<String,Object> map, String mapEventTypeName) throws com.espertech.esper.common.client.EPException
EPEventServiceSendEvent
Use the route method for sending events into the runtime from within UpdateListener code.
to avoid the possibility of a stack overflow due to nested calls to sendEvent
(except with the outbound-threading configuration), see EPEventServiceRouteEvent.routeEventMap(java.util.Map, String)
).
sendEventMap
in interface com.espertech.esper.common.internal.event.core.EventServiceSendEventCommon
sendEventMap
in interface EPEventServiceSendEvent
map
- - map that contains event property values. Keys are expected to be of type String while values
can be of any type. Keys and values should match those declared via Configuration for the given eventTypeName.mapEventTypeName
- - event type namecom.espertech.esper.common.client.EPException
- - when the processing of the event leads to an errorpublic void routeEventBean(com.espertech.esper.common.client.EventBean theEvent)
routeEventBean
in interface com.espertech.esper.common.internal.event.util.EPRuntimeEventProcessWrapped
public void route(com.espertech.esper.common.client.EventBean theEvent, com.espertech.esper.common.internal.context.util.EPStatementHandle epStatementHandle, boolean addToFront)
route
in interface com.espertech.esper.common.internal.context.util.InternalEventRouteDest
public void processWrappedEvent(com.espertech.esper.common.client.EventBean eventBean)
processWrappedEvent
in interface com.espertech.esper.common.internal.event.util.EPRuntimeEventProcessWrapped
public void processThreadWorkQueue()
processThreadWorkQueue
in interface com.espertech.esper.common.internal.context.util.InternalEventRouteDest
protected void processMatches(com.espertech.esper.common.client.EventBean theEvent)
public static void processStatementScheduleMultiple(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle, Object callbackObject, EPServicesContext services)
handle
- statement handlecallbackObject
- object containing matchesservices
- runtime servicespublic void processStatementFilterMultiple(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle, Object callbackList, com.espertech.esper.common.client.EventBean theEvent, long version, int filterFaultCount)
handle
- statement handlecallbackList
- object containing callbackstheEvent
- to processversion
- filter versionfilterFaultCount
- filter fault countpublic void processStatementFilterSingle(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle handle, com.espertech.esper.common.internal.context.util.EPStatementHandleCallbackFilter handleCallback, com.espertech.esper.common.client.EventBean theEvent, long version, int filterFaultCount)
handle
- statementhandleCallback
- callbacktheEvent
- event to indicateversion
- filter versionfilterFaultCount
- filter fault countprotected void handleFilterFault(com.espertech.esper.common.internal.context.util.EPStatementAgentInstanceHandle faultingHandle, com.espertech.esper.common.client.EventBean theEvent, int filterFaultCount)
public void dispatch()
dispatch
in interface com.espertech.esper.common.internal.context.util.InternalEventRouteDest
public boolean isExternalClockingEnabled()
EPEventServiceTimeControl
isExternalClockingEnabled
in interface EPEventServiceTimeControl
public void destroy()
destroy
in interface EPEventServiceSPI
public void initialize()
initialize
in interface EPEventServiceSPI
public void clearCaches()
clearCaches
in interface EPEventServiceSPI
public void setUnmatchedListener(UnmatchedListener listener)
EPEventService
Events that can be unmatched are all events that are send into a runtime via one of the sendEvent methods, or that have been generated via insert-into clause.
For an event to be unmatched by any statement, the event must not match any statement's event stream filter criteria (a where-clause is NOT a filter criteria for a stream, as below).
Note: In the following statement a MyEvent event does always match this statement's event stream filter criteria, regardless of the value of the 'quantity' property.
select * from MyEvent where quantity > 5
select * from MyEvent(quantity > 5)
For patterns, if no pattern sub-expression is active for such event, the event is also unmatched.
setUnmatchedListener
in interface EPEventService
listener
- is the listener to receive notification of unmatched events, or null to unregister a
previously registered listenerpublic long getCurrentTime()
EPEventServiceTimeControl
If time is provided externally via timer events, the function returns current time as externally provided.
getCurrentTime
in interface EPEventServiceTimeControl
public String getRuntimeURI()
getRuntimeURI
in interface com.espertech.esper.common.internal.context.util.InternalEventRouteDest
public void processScheduleHandles(com.espertech.esper.common.internal.collection.ArrayBackedCollection<com.espertech.esper.common.internal.schedule.ScheduleHandle> handles)
public static void processStatementScheduleSingle(com.espertech.esper.common.internal.context.util.EPStatementHandleCallbackSchedule handle, EPServicesContext services)
handle
- statement handleservices
- runtime servicespublic void routeEventMap(Map<String,Object> map, String eventTypeName)
EPEventServiceRouteEvent
Note: when outbound-threading is enabled, the thread delivering to listeners is not the thread processing the original event. Therefore with outbound-threading enabled the sendEvent method should be used by listeners instead.
routeEventMap
in interface EPEventServiceRouteEvent
map
- to route internally for processing by the runtimeeventTypeName
- event type namepublic void routeEventBean(Object event, String eventTypeName)
EPEventServiceRouteEvent
Note: when outbound-threading is enabled, the thread delivering to listeners is not the thread processing the original event. Therefore with outbound-threading enabled the sendEvent method should be used by listeners instead.
routeEventBean
in interface EPEventServiceRouteEvent
event
- to route internally for processing by the runtimeeventTypeName
- event type namepublic void routeEventObjectArray(Object[] event, String eventTypeName)
EPEventServiceRouteEvent
Note: when outbound-threading is enabled, the thread delivering to listeners is not the thread processing the original event. Therefore with outbound-threading enabled the sendEvent method should be used by listeners instead.
routeEventObjectArray
in interface EPEventServiceRouteEvent
event
- to route internally for processing by the runtimeeventTypeName
- event type namepublic void routeEventXMLDOM(Node event, String eventTypeName)
EPEventServiceRouteEvent
Note: when outbound-threading is enabled, the thread delivering to listeners is not the thread processing the original event. Therefore with outbound-threading enabled the sendEvent method should be used by listeners instead.
routeEventXMLDOM
in interface EPEventServiceRouteEvent
event
- to route internally for processing by the runtimeeventTypeName
- event type namepublic void routeEventAvro(Object avroGenericDataDotRecord, String eventTypeName)
EPEventServiceRouteEvent
Note: when outbound-threading is enabled, the thread delivering to listeners is not the thread processing the original event. Therefore with outbound-threading enabled the sendEvent method should be used by listeners instead.
routeEventAvro
in interface EPEventServiceRouteEvent
avroGenericDataDotRecord
- to route internally for processing by the runtimeeventTypeName
- event type namepublic com.espertech.esper.common.client.EventSender getEventSender(String eventTypeName) throws com.espertech.esper.common.client.EventTypeException
EPEventService
Given an event type name this method returns a sender that allows to send in event objects of that type. The event objects send in via the event sender are expected to match the event type, thus the event sender does not inspect the event object other then perform basic checking.
For events backed by a Java class (JavaBean events), the sender ensures that the object send in matches in class, or implements or extends the class underlying the event type for the given event type name. Note that event type identity for Java class events is the Java class. When assigning two different event type names to the same Java class the names are an alias for the same event type i.e. there is always a single event type to represent a given Java class.
For events backed by a Object[] (Object-array events), the sender does not perform any checking other then checking that the event object indeed is an array of object.
For events backed by a java.util.Map (Map events), the sender does not perform any checking other then checking that the event object indeed implements Map.
For events backed by a org.w3c.Node (XML DOM events), the sender checks that the root element name indeed does match the root element name for the event type name.
getEventSender
in interface EPEventService
eventTypeName
- is the name of the event typecom.espertech.esper.common.client.EventTypeException
- thrown to indicate that the name does not existpublic Map<com.espertech.esper.common.internal.util.DeploymentIdNamePair,Long> getStatementNearestSchedules()
getStatementNearestSchedules
in interface EPEventServiceSPI
public void clockInternal()
EPEventServiceTimeControl
Your application may not want to use EPEventServiceTimeControl.advanceTime(long)
, EPEventServiceTimeControl.advanceTimeSpan(long)
or EPEventServiceTimeControl.advanceTimeSpan(long, long)
after calling this method, since time advances according to JVM time.
clockInternal
in interface EPEventServiceTimeControl
public void clockExternal()
EPEventServiceTimeControl
Your application may want to use EPEventServiceTimeControl.advanceTime(long)
, EPEventServiceTimeControl.advanceTimeSpan(long)
or EPEventServiceTimeControl.advanceTimeSpan(long, long)
after calling this method to set or advance time.
Its generally preferable to turn off internal clocking (and thus turn on external clocking) by configuration ConfigurationRuntimeThreading.setInternalTimerEnabled(boolean)
passing false.
clockExternal
in interface EPEventServiceTimeControl
public long getNumEventsEvaluated()
EPEventService
getNumEventsEvaluated
in interface EPEventService
public void resetStats()
EPEventService
resetStats
in interface EPEventService
Copyright © 2005–2018. All rights reserved.