com.hazelcast.config
Class RingbufferConfig

java.lang.Object
  extended by com.hazelcast.config.RingbufferConfig

@Beta
public class RingbufferConfig
extends Object

Contains the configuration for the Ringbuffer.

The RingBuffer is currently not a distributed data-structure, so its content will be fully stored on a single member in the cluster and its backup in another member in the cluster.


Field Summary
static int DEFAULT_ASYNC_BACKUP_COUNT
          Default value of asynchronous backup count
static int DEFAULT_CAPACITY
          Default value of capacity of the RingBuffer.
static InMemoryFormat DEFAULT_IN_MEMORY_FORMAT
          Default value for the InMemoryFormat.
static int DEFAULT_SYNC_BACKUP_COUNT
          Default value of synchronous backup count
static int DEFAULT_TTL_SECONDS
          Default value for the time to live property.
 
Constructor Summary
RingbufferConfig(RingbufferConfig config)
          Clones a RingbufferConfig
RingbufferConfig(String name)
          Creates a RingbufferConfig with the provided name.
RingbufferConfig(String name, RingbufferConfig config)
          Creates a new RingbufferConfig by cloning an existing config and overriding the name.
 
Method Summary
 RingbufferConfig getAsReadOnly()
          Creates a readonly copy of this RingbufferConfig.
 int getAsyncBackupCount()
          Gets the number of asynchronous backups.
 int getBackupCount()
          Gets the number of synchronous backups.
 int getCapacity()
          Gets the capacity of the ringbuffer.
 InMemoryFormat getInMemoryFormat()
          Gets the InMemoryFormat.
 String getName()
          Returns the name of the ringbuffer.
 int getTimeToLiveSeconds()
          Gets the time to live in seconds.
 int getTotalBackupCount()
          Returns the total number of backups: backupCount plus asyncBackupCount.
 RingbufferConfig setAsyncBackupCount(int asyncBackupCount)
          Sets the number of asynchronous backups.
 RingbufferConfig setBackupCount(int backupCount)
          Sets the number of synchronous backups.
 RingbufferConfig setCapacity(int capacity)
          Sets the capacity of the ringbuffer.
 RingbufferConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)
          Sets the InMemoryFormat.
 RingbufferConfig setTimeToLiveSeconds(int timeToLiveSeconds)
          Sets the time to live in seconds.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CAPACITY

public static final int DEFAULT_CAPACITY
Default value of capacity of the RingBuffer.

See Also:
Constant Field Values

DEFAULT_SYNC_BACKUP_COUNT

public static final int DEFAULT_SYNC_BACKUP_COUNT
Default value of synchronous backup count

See Also:
Constant Field Values

DEFAULT_ASYNC_BACKUP_COUNT

public static final int DEFAULT_ASYNC_BACKUP_COUNT
Default value of asynchronous backup count

See Also:
Constant Field Values

DEFAULT_TTL_SECONDS

public static final int DEFAULT_TTL_SECONDS
Default value for the time to live property.

See Also:
Constant Field Values

DEFAULT_IN_MEMORY_FORMAT

public static final InMemoryFormat DEFAULT_IN_MEMORY_FORMAT
Default value for the InMemoryFormat.

Constructor Detail

RingbufferConfig

public RingbufferConfig(String name)
Creates a RingbufferConfig with the provided name.

Parameters:
name - the name
Throws:
NullPointerException - if name is null

RingbufferConfig

public RingbufferConfig(RingbufferConfig config)
Clones a RingbufferConfig

Parameters:
config - the ringbuffer config to clone
Throws:
NullPointerException - if config is null

RingbufferConfig

public RingbufferConfig(String name,
                        RingbufferConfig config)
Creates a new RingbufferConfig by cloning an existing config and overriding the name.

Parameters:
name - the new name
config - the config.
Throws:
NullPointerException - if name or config is null.
Method Detail

getName

public String getName()
Returns the name of the ringbuffer.

Returns:
the name of the ringbuffer.

getCapacity

public int getCapacity()
Gets the capacity of the ringbuffer.

The capacity is the total number of items in the ringbuffer. The items will remain in the ringbuffer, but the oldest items will eventually be be overwritten by the newest items.

In the future we'll add more advanced policies e.g. based on memory usage or lifespan.

Returns:
the capacity.

setCapacity

public RingbufferConfig setCapacity(int capacity)
Sets the capacity of the ringbuffer.

Parameters:
capacity - the capacity.
Returns:
the updated Config.
Throws:
IllegalArgumentException - if capacity smaller than 1.
See Also:
getCapacity()

getBackupCount

public int getBackupCount()
Gets the number of synchronous backups.

Returns:
number of synchronous backups.

setBackupCount

public RingbufferConfig setBackupCount(int backupCount)
Sets the number of synchronous backups.

Parameters:
backupCount - the number of synchronous backups to set
Returns:
the updated SemaphoreConfig
Throws:
IllegalArgumentException - if backupCount smaller than 0, or larger than the maximum number of backup or the sum of the backups and async backups is larger than the maximum number of backups
See Also:
setAsyncBackupCount(int), getBackupCount()

getAsyncBackupCount

public int getAsyncBackupCount()
Gets the number of asynchronous backups.

Returns:
the number of asynchronous backups.

setAsyncBackupCount

public RingbufferConfig setAsyncBackupCount(int asyncBackupCount)
Sets the number of asynchronous backups. 0 means no backups

Parameters:
asyncBackupCount - the number of asynchronous synchronous backups to set
Returns:
the updated SemaphoreConfig
Throws:
IllegalArgumentException - if asyncBackupCount smaller than 0, or larger than the maximum number of backup or the sum of the backups and async backups is larger than the maximum number of backups
See Also:
setBackupCount(int), getAsyncBackupCount()

getTotalBackupCount

public int getTotalBackupCount()
Returns the total number of backups: backupCount plus asyncBackupCount.

Returns:
the total number of backups: backupCount plus asyncBackupCount

getAsReadOnly

public RingbufferConfig getAsReadOnly()
Creates a readonly copy of this RingbufferConfig.

Returns:
the readonly copy.

getTimeToLiveSeconds

public int getTimeToLiveSeconds()
Gets the time to live in seconds.

Returns:
the time to live in seconds. Returns 0 the time to live if the items don't expire.

setTimeToLiveSeconds

public RingbufferConfig setTimeToLiveSeconds(int timeToLiveSeconds)
Sets the time to live in seconds. Time to live is the time the ringbuffer is going to retain items before deleting them. Time to live can be disabled by setting timeToLiveSeconds to 0. It means that items won't get removed because they retire. They will only overwrite. This means that when timeToLiveSeconds is disabled, that after tail did a full loop in the ring that the size will always be equal to the capacity.

Parameters:
timeToLiveSeconds - the time to live period in seconds
Returns:
the updated RingbufferConfig
Throws:
IllegalArgumentException - if timeToLiveSeconds smaller than 0.

getInMemoryFormat

public InMemoryFormat getInMemoryFormat()
Gets the InMemoryFormat.

Returns:
the InMemoryFormat.

setInMemoryFormat

public RingbufferConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)
Sets the InMemoryFormat. Setting the InMemoryFormat controls format of storing an item in the ringbuffer:
  1. InMemoryFormat.OBJECT: the item is stored in deserialized format (so a regular object)
  2. InMemoryFormat.BINARY: the item is stored in serialized format (so a is binary blob)
The default is binary. The object InMemoryFormat is useful when:
  1. of the object stored in object format has a smaller footprint than in binary format
  2. if there are readers using a filter. Since for every filter invocation, the object needs to be available in object format.

Parameters:
inMemoryFormat - the new in memory format.
Returns:
the updated Config.
Throws:
NullPointerException - if inMemoryFormat is null.
IllegalArgumentException - if InMemoryFormat.NATIVE in memory format is selected.

toString

public String toString()
Overrides:
toString in class Object


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