Package com.hazelcast.ringbuffer
Enum OverflowPolicy
- java.lang.Object
-
- java.lang.Enum<OverflowPolicy>
-
- com.hazelcast.ringbuffer.OverflowPolicy
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<OverflowPolicy>
public enum OverflowPolicy extends java.lang.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 is0
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static OverflowPolicy
getById(int id)
Returns the OverflowPolicy for the given ID.int
getId()
Gets the ID for the given OverflowPolicy.static OverflowPolicy
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static OverflowPolicy[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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 ofFAIL
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 Detail
-
values
public static OverflowPolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (OverflowPolicy c : OverflowPolicy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static OverflowPolicy valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.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
-
-