T - the type of event tracked by this policy.public class WatermarkCountEvictionPolicy<T> extends java.lang.Object implements EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>
EvictionPolicy.Action| Modifier and Type | Field and Description |
|---|---|
protected java.util.concurrent.atomic.AtomicLong |
currentCount |
protected int |
threshold |
| Constructor and Description |
|---|
WatermarkCountEvictionPolicy(int count) |
| Modifier and Type | Method and Description |
|---|---|
EvictionPolicy.Action |
evict(Event<T> event)
Decides if an event should be expired from the window, processed in the current
window or kept for later processing.
|
EvictionContext |
getContext()
Returns the current context that is part of this eviction policy.
|
Pair<java.lang.Long,java.lang.Long> |
getState()
Return runtime state to be checkpointed by the framework for restoring the eviction
policy in case of failures.
|
void |
reset()
Resets the eviction policy.
|
void |
restoreState(Pair<java.lang.Long,java.lang.Long> state)
Restore the eviction policy from the state that was earlier checkpointed by the framework.
|
void |
setContext(EvictionContext context)
Sets a context in the eviction policy that can be used while evicting the events.
|
java.lang.String |
toString() |
void |
track(Event<T> event)
Tracks the event to later decide whether
EvictionPolicy.evict(Event)
should evict it or not. |
protected final int threshold
protected final java.util.concurrent.atomic.AtomicLong currentCount
public EvictionPolicy.Action evict(Event<T> event)
EvictionPolicyevict in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>event - the input eventEvictionPolicy.Action to be taken
based on the input eventpublic void track(Event<T> event)
EvictionPolicyEvictionPolicy.evict(Event)
should evict it or not.track in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>event - the input event to be trackedpublic EvictionContext getContext()
EvictionPolicygetContext in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>public void setContext(EvictionContext context)
EvictionPolicysetContext in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>context - the eviction contextpublic void reset()
EvictionPolicyreset in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>public Pair<java.lang.Long,java.lang.Long> getState()
EvictionPolicygetState in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>public void restoreState(Pair<java.lang.Long,java.lang.Long> state)
EvictionPolicyrestoreState in interface EvictionPolicy<T,Pair<java.lang.Long,java.lang.Long>>state - the statepublic java.lang.String toString()
toString in class java.lang.Object