类 WindowManager<T>
java.lang.Object
org.apache.pulsar.functions.windowing.WindowManager<T>
- 类型参数:
T- the type of event in the window.
- 所有已实现的接口:
TriggerHandler
Tracks a window of events and fires
WindowLifecycleListener callbacks
on expiry of events or activation of the window due to TriggerPolicy.-
字段概要
字段修饰符和类型字段说明protected EvictionPolicy<T,?> protected static final intExpire old events every EXPIRE_EVENTS_THRESHOLD to keep the window size in check.protected final Collection<Event<T>>protected TriggerPolicy<T,?> protected final WindowLifecycleListener<Event<T>> -
构造器概要
构造器构造器说明WindowManager(WindowLifecycleListener<Event<T>> lifecycleListener, Collection<Event<T>> queue) Constructs aWindowManager -
方法概要
修饰符和类型方法说明voidTracks a window eventvoidAdd an event into the window, with the given ts as the tracking ts.protected voidexpires events that fall out of the window every EXPIRE_EVENTS_THRESHOLD so that the window does not grow too big.longgetEarliestEventTs(long startTs, long endTs) Scans the event queue and returns the next earliest event ts between the startTs and endTs.intgetEventCount(long referenceTime) Scans the event queue and returns number of events having timestamp less than or equal to the reference time.getSlidingCountTimestamps(long startTs, long endTs, int slidingCount) Scans the event queue and returns the list of event ts falling between startTs (exclusive) and endTs (inclusive) at each sliding interval counts.booleanThe callback invoked by the trigger policy.voidsetEvictionPolicy(EvictionPolicy<T, ?> evictionPolicy) voidsetTriggerPolicy(TriggerPolicy<T, ?> triggerPolicy) voidshutdown()toString()
-
字段详细资料
-
EXPIRE_EVENTS_THRESHOLD
protected static final int EXPIRE_EVENTS_THRESHOLDExpire old events every EXPIRE_EVENTS_THRESHOLD to keep the window size in check.Note that if the eviction policy is based on watermarks, events will not be evicted until a new watermark would cause them to be considered expired anyway, regardless of this limit
- 另请参阅:
-
queue
-
evictionPolicy
-
triggerPolicy
-
windowLifecycleListener
-
-
构造器详细资料
-
WindowManager
public WindowManager(WindowLifecycleListener<Event<T>> lifecycleListener, Collection<Event<T>> queue) Constructs aWindowManager- 参数:
lifecycleListener- theWindowLifecycleListenerqueue- a collection where the events in the window can be enqueued.
Note: This collection has to be thread safe.
-
-
方法详细资料
-
setEvictionPolicy
-
setTriggerPolicy
-
add
Add an event into the window, with the given ts as the tracking ts.- 参数:
event- the event to trackts- the timestamp
-
add
Tracks a window event- 参数:
windowEvent- the window event to track
-
onTrigger
public boolean onTrigger()The callback invoked by the trigger policy.- 指定者:
onTrigger在接口中TriggerHandler- 返回:
- true if the window was evaluated with at least one event in the window, false otherwise
-
shutdown
public void shutdown() -
compactWindow
protected void compactWindow()expires events that fall out of the window every EXPIRE_EVENTS_THRESHOLD so that the window does not grow too big. -
getEarliestEventTs
public long getEarliestEventTs(long startTs, long endTs) Scans the event queue and returns the next earliest event ts between the startTs and endTs.- 参数:
startTs- the start ts (exclusive)endTs- the end ts (inclusive)- 返回:
- the earliest event ts between startTs and endTs
-
getEventCount
public int getEventCount(long referenceTime) Scans the event queue and returns number of events having timestamp less than or equal to the reference time.- 参数:
referenceTime- the reference timestamp in millis- 返回:
- the count of events with timestamp less than or equal to referenceTime
-
getSlidingCountTimestamps
Scans the event queue and returns the list of event ts falling between startTs (exclusive) and endTs (inclusive) at each sliding interval counts.- 参数:
startTs- the start timestamp (exclusive)endTs- the end timestamp (inclusive)slidingCount- the sliding interval count- 返回:
- the list of event ts
-
toString
-