public class WatermarkCountEvictionPolicy<T> extends Object implements EvictionPolicy<T,Pair<Long,Long>>
An eviction policy that tracks count based on watermark ts and evicts events up to the watermark based on a threshold count.
EvictionPolicy.Action| Modifier and Type | Field and Description |
|---|---|
protected 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<Long,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<Long,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.
|
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 AtomicLong currentCount
public EvictionPolicy.Action evict(Event<T> event)
EvictionPolicyDecides if an event should be expired from the window, processed in the current window or kept for later processing.
evict in interface EvictionPolicy<T,Pair<Long,Long>>event - the input eventEvictionPolicy.Action to be taken based on the input eventpublic void track(Event<T> event)
EvictionPolicyTracks the event to later decide whether EvictionPolicy.evict(Event) should evict it or not.
public EvictionContext getContext()
EvictionPolicyReturns the current context that is part of this eviction policy.
getContext in interface EvictionPolicy<T,Pair<Long,Long>>public void setContext(EvictionContext context)
EvictionPolicySets 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,Pair<Long,Long>>context - the eviction contextpublic void reset()
EvictionPolicyResets the eviction policy.
public Pair<Long,Long> getState()
EvictionPolicyReturn runtime state to be checkpointed by the framework for restoring the eviction policy in case of failures.
public void restoreState(Pair<Long,Long> state)
EvictionPolicyRestore the eviction policy from the state that was earlier checkpointed by the framework.
restoreState in interface EvictionPolicy<T,Pair<Long,Long>>state - the stateCopyright © 2022 The Apache Software Foundation. All rights reserved.