Enum OverflowPolicy

java.lang.Object
java.lang.Enum<OverflowPolicy>
com.hazelcast.ringbuffer.OverflowPolicy
All Implemented Interfaces:
Serializable, Comparable<OverflowPolicy>, java.lang.constant.Constable

public enum OverflowPolicy
extends Enum<OverflowPolicy>
Using this policy one can control the behavior what should to be done when an item is about to be added to the ringbuffer, but there is 0 remaining capacity. Overflowing happens when a time-to-live is set and the oldest item in the ringbuffer (the head) is not old enough to expire.
See Also:
Ringbuffer.addAsync(Object, OverflowPolicy), Ringbuffer.addAllAsync(java.util.Collection, OverflowPolicy), RingbufferConfig.setTimeToLiveSeconds(int)
  • Enum Constant Details

    • OVERWRITE

      public static final OverflowPolicy OVERWRITE
      Using this policy the oldest item is overwritten no matter it is not old enough to retire. Using this policy you are sacrificing the time-to-live in favor of being able to write. Example: if there is a time-to-live of 30 seconds, the buffer is full and the oldest item in the ring has been placed a second ago, then there are 29 seconds remaining for that item. Using this policy you are going to overwrite no matter what.
    • FAIL

      public static final OverflowPolicy FAIL
      Using this policy the call will fail immediately and the oldest item will not be overwritten before it is old enough to retire. So this policy sacrificing the ability to write in favor of time-to-live. The advantage of FAIL is that the caller can decide what to do since it doesn't trap the thread due to backoff. Example: if there is a time-to-live of 30 seconds, the buffer is full and the oldest item in the ring has been placed a second ago, then there are 29 seconds remaining for that item. Using this policy you are not going to overwrite that item for the next 29 seconds.
  • Method Details

    • values

      public static OverflowPolicy[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static OverflowPolicy valueOf​(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null
    • getId

      public int getId()
      Gets the ID for the given OverflowPolicy. The reason this ID is used instead of an the ordinal value is that the ordinal value is more prone to changes due to reordering.
      Returns:
      the ID
    • getById

      public static OverflowPolicy getById​(int id)
      Returns the OverflowPolicy for the given ID.
      Returns:
      the OverflowPolicy found or null if not found