public class TimeEvictionPolicy<T> extends Object implements EvictionPolicy<T>
Eviction policy that evicts events based on time duration.
EvictionPolicy.Action
Modifier and Type | Field and Description |
---|---|
protected EvictionContext |
evictionContext |
protected Long |
referenceTime
The reference time in millis for window calculations and expiring events.
|
Constructor and Description |
---|
TimeEvictionPolicy(int windowLength)
Constructs a TimeEvictionPolicy that evicts events older than the given window length in millis
|
Modifier and Type | Method and Description |
---|---|
EvictionPolicy.Action |
evict(org.apache.storm.windowing.Event<T> event)
Decides if an event should be expired from the window, processed in the current window or kept for later processing.
|
void |
setContext(EvictionContext context)
Sets a context in the eviction policy that can be used while evicting the events.
|
String |
toString() |
void |
track(org.apache.storm.windowing.Event<T> event)
Tracks the event to later decide whether
EvictionPolicy.evict(Event) should evict it or not. |
protected Long referenceTime
The reference time in millis for window calculations and expiring events. If not set it will default to System.currentTimeMillis()
protected EvictionContext evictionContext
public TimeEvictionPolicy(int windowLength)
Constructs a TimeEvictionPolicy that evicts events older than the given window length in millis
windowLength
- the duration in millisecondspublic EvictionPolicy.Action evict(org.apache.storm.windowing.Event<T> event)
Decides if an event should be expired from the window, processed in the current window or kept for later processing.
evict
in interface EvictionPolicy<T>
event
- the input eventEvictionPolicy.Action
to be taken based on the input eventpublic void track(org.apache.storm.windowing.Event<T> event)
EvictionPolicy
Tracks the event to later decide whether EvictionPolicy.evict(Event)
should evict it or not.
track
in interface EvictionPolicy<T>
event
- the input event to be trackedpublic void setContext(EvictionContext context)
EvictionPolicy
Sets a context in the eviction policy that can be used while evicting the events. E.g. For TimeEvictionPolicy, this could be used to set the reference timestamp.
setContext
in interface EvictionPolicy<T>
Copyright © 2022 The Apache Software Foundation. All Rights Reserved.