Package com.hazelcast.ringbuffer
Enum Class OverflowPolicy
- All Implemented Interfaces:
Serializable
,Comparable<OverflowPolicy>
,Constable
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.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic OverflowPolicy
getById
(int id) Returns the OverflowPolicy for the given ID.int
getId()
Gets the ID for the given OverflowPolicy.static OverflowPolicy
Returns the enum constant of this class with the specified name.static OverflowPolicy[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
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
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 Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException
- 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
Returns the OverflowPolicy for the given ID.- Returns:
- the OverflowPolicy found or null if not found
-