Package org.apache.storm.windowing

# Class TimeEvictionPolicy<T>

java.lang.Object
org.apache.storm.windowing.TimeEvictionPolicy<T>

All Implemented Interfaces:
  `EvictionPolicy<T,EvictionContext>`

Direct Known Subclasses:
  `WatermarkTimeEvictionPolicy`

public class TimeEvictionPolicy<T> extends Object implements EvictionPolicy<T,EvictionContext>
Eviction policy that evicts events based on time duration.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface org.apache.storm.windowing.EvictionPolicy

  `EvictionPolicy.Action`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected EvictionContext`
  `evictionContext`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TimeEvictionPolicy(int windowLength)`
  Constructs a TimeEvictionPolicy that evicts events older than the given window length in millis.

- ## Method Summary

  Modifier and Type
  Method
  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.
  `EvictionContext`
  `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(EvictionContext 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.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### evictionContext

    protected volatile EvictionContext evictionContext

- ## Constructor Details

  - ### TimeEvictionPolicy

    public TimeEvictionPolicy(int windowLength)
    Constructs a TimeEvictionPolicy that evicts events older than the given window length in millis.
    Parameters:
      `windowLength` - the duration in milliseconds

- ## Method Details

  - ### evict

    public 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.
    Specified by:
      `evict` in interface `EvictionPolicy<T,EvictionContext>`
    Parameters:
      `event` - the input event
    Returns:
      the `EvictionPolicy.Action` to be taken based on the input event

  - ### track

    public void track(Event<T> event)
    Description copied from interface: `EvictionPolicy`
    Tracks the event to later decide whether `EvictionPolicy.evict(Event)` should evict it or not.
    Specified by:
      `track` in interface `EvictionPolicy<T,EvictionContext>`
    Parameters:
      `event` - the input event to be tracked

  - ### getContext

    public EvictionContext getContext()
    Description copied from interface: `EvictionPolicy`
    Returns the current context that is part of this eviction policy.
    Specified by:
      `getContext` in interface `EvictionPolicy<T,EvictionContext>`
    Returns:
      the eviction context

  - ### setContext

    public void setContext(EvictionContext context)
    Description copied from interface: `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.
    Specified by:
      `setContext` in interface `EvictionPolicy<T,EvictionContext>`
    Parameters:
      `context` - the eviction context

  - ### reset

    public void reset()
    Description copied from interface: `EvictionPolicy`
    Resets the eviction policy.
    Specified by:
      `reset` in interface `EvictionPolicy<T,EvictionContext>`

  - ### getState

    public EvictionContext getState()
    Description copied from interface: `EvictionPolicy`
    Return runtime state to be checkpointed by the framework for restoring the eviction policy in case of failures.
    Specified by:
      `getState` in interface `EvictionPolicy<T,EvictionContext>`
    Returns:
      the state

  - ### restoreState

    public void restoreState(EvictionContext state)
    Description copied from interface: `EvictionPolicy`
    Restore the eviction policy from the state that was earlier checkpointed by the framework.
    Specified by:
      `restoreState` in interface `EvictionPolicy<T,EvictionContext>`
    Parameters:
      `state` - the state

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`