com.hazelcast.ringbuffer
Enum OverflowPolicy

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

@Beta
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)

Enum Constant Summary
FAIL
          Using this policy the call will fail immediately and the oldest item will not be overwritten before it is old enough to retire.
OVERWRITE
          Using this policy the oldest item is overwritten no matter it is not old enough to retire.
 
Method Summary
static OverflowPolicy getById(int id)
          Returns the OverflowPolicy for the given id.
 int getId()
          Gets the id for the given OverflowPolicy.
static OverflowPolicy valueOf(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.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

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 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 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(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. This 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


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.