Class WatermarkCountEvictionPolicy<T>
- java.lang.Object
-
- org.apache.pulsar.functions.windowing.evictors.WatermarkCountEvictionPolicy<T>
-
- Type Parameters:
T- the type of event tracked by this policy.
- All Implemented Interfaces:
EvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>
public class WatermarkCountEvictionPolicy<T> extends java.lang.Object implements EvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>
An eviction policy that tracks count based on watermark ts and evicts events up to the watermark based on a threshold count.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.pulsar.functions.windowing.EvictionPolicy
EvictionPolicy.Action
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicLongcurrentCountprotected intthreshold
-
Constructor Summary
Constructors Constructor Description WatermarkCountEvictionPolicy(int count)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvictionPolicy.Actionevict(Event<T> event)Decides if an event should be expired from the window, processed in the current window or kept for later processing.EvictionContextgetContext()Returns the current context that is part of this eviction policy.org.apache.commons.lang3.tuple.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.voidreset()Resets the eviction policy.voidrestoreState(org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long> state)Restore the eviction policy from the state that was earlier checkpointed by the framework.voidsetContext(EvictionContext context)Sets a context in the eviction policy that can be used while evicting the events.java.lang.StringtoString()voidtrack(Event<T> event)Tracks the event to later decide whetherEvictionPolicy.evict(Event)should evict it or not.
-
-
-
Method Detail
-
evict
public EvictionPolicy.Action evict(Event<T> event)
Description copied from interface:EvictionPolicyDecides if an event should be expired from the window, processed in the current window or kept for later processing.- Specified by:
evictin interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Parameters:
event- the input event- Returns:
- the
EvictionPolicy.Actionto be taken based on the input event
-
track
public void track(Event<T> event)
Description copied from interface:EvictionPolicyTracks the event to later decide whetherEvictionPolicy.evict(Event)should evict it or not.- Specified by:
trackin interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Parameters:
event- the input event to be tracked
-
getContext
public EvictionContext getContext()
Description copied from interface:EvictionPolicyReturns the current context that is part of this eviction policy.- Specified by:
getContextin interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Returns:
- the eviction context
-
setContext
public void setContext(EvictionContext context)
Description copied from interface: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.- Specified by:
setContextin interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Parameters:
context- the eviction context
-
reset
public void reset()
Description copied from interface:EvictionPolicyResets the eviction policy.- Specified by:
resetin interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>
-
getState
public org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long> getState()
Description copied from interface:EvictionPolicyReturn runtime state to be checkpointed by the framework for restoring the eviction policy in case of failures.- Specified by:
getStatein interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Returns:
- the state
-
restoreState
public void restoreState(org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long> state)
Description copied from interface:EvictionPolicyRestore the eviction policy from the state that was earlier checkpointed by the framework.- Specified by:
restoreStatein interfaceEvictionPolicy<T,org.apache.commons.lang3.tuple.Pair<java.lang.Long,java.lang.Long>>- Parameters:
state- the state
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-