@Beta public class RingbufferConfig extends Object implements SplitBrainMergeTypeProvider, IdentifiedDataSerializable, Versioned
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.
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
RingbufferConfig() |
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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
RingbufferConfig |
getAsReadOnly()
Deprecated.
this method will be removed in 4.0; it is meant for internal usage only
|
int |
getAsyncBackupCount()
Gets the number of asynchronous backups.
|
int |
getBackupCount()
Gets the number of synchronous backups.
|
int |
getCapacity()
Gets the capacity of the ringbuffer.
|
int |
getFactoryId()
Returns DataSerializableFactory factory ID for this class.
|
int |
getId()
Returns type identifier for this class.
|
InMemoryFormat |
getInMemoryFormat()
Gets the InMemoryFormat.
|
MergePolicyConfig |
getMergePolicyConfig()
Gets the
MergePolicyConfig for this ringbuffer. |
String |
getName()
Returns the name of the ringbuffer.
|
Class |
getProvidedMergeTypes() |
String |
getQuorumName()
Returns the quorum name for operations.
|
RingbufferStoreConfig |
getRingbufferStoreConfig()
Get the RingbufferStore (load and store ringbuffer items from/to a database) configuration.
|
int |
getTimeToLiveSeconds()
Gets the time to live in seconds.
|
int |
getTotalBackupCount()
Returns the total number of backups: backupCount plus asyncBackupCount.
|
int |
hashCode() |
void |
readData(ObjectDataInput in)
Reads fields from the input stream
|
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 |
setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
Sets the
MergePolicyConfig for this ringbuffer. |
RingbufferConfig |
setName(String name)
Sets the name of the ringbuffer.
|
RingbufferConfig |
setQuorumName(String quorumName)
Sets the quorum name for operations.
|
RingbufferConfig |
setRingbufferStoreConfig(RingbufferStoreConfig ringbufferStoreConfig)
Set the RingbufferStore (load and store ringbuffer items from/to a database) configuration.
|
RingbufferConfig |
setTimeToLiveSeconds(int timeToLiveSeconds)
Sets the time to live in seconds.
|
String |
toString() |
void |
writeData(ObjectDataOutput out)
Writes object fields to output stream
|
public static final int DEFAULT_CAPACITY
public static final int DEFAULT_SYNC_BACKUP_COUNT
public static final int DEFAULT_ASYNC_BACKUP_COUNT
public static final int DEFAULT_TTL_SECONDS
public static final InMemoryFormat DEFAULT_IN_MEMORY_FORMAT
public RingbufferConfig()
public RingbufferConfig(String name)
name
- the nameNullPointerException
- if name is null
public RingbufferConfig(RingbufferConfig config)
config
- the ringbuffer config to cloneNullPointerException
- if config is null
public RingbufferConfig(String name, RingbufferConfig config)
name
- the new nameconfig
- the configNullPointerException
- if name or config is null
public RingbufferConfig setName(String name)
name
- the name of the ringbufferRingbufferConfig
IllegalArgumentException
- if name is null
or an empty stringpublic String getName()
public int getCapacity()
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.
public RingbufferConfig setCapacity(int capacity)
capacity
- the capacityIllegalArgumentException
- if capacity smaller than 1getCapacity()
public int getBackupCount()
public RingbufferConfig setBackupCount(int backupCount)
backupCount
- the number of synchronous backups to setIllegalArgumentException
- 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 backupssetAsyncBackupCount(int)
,
getBackupCount()
public int getAsyncBackupCount()
public RingbufferConfig setAsyncBackupCount(int asyncBackupCount)
asyncBackupCount
- the number of asynchronous synchronous backups to setIllegalArgumentException
- 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 backupssetBackupCount(int)
,
getAsyncBackupCount()
public int getTotalBackupCount()
public int getTimeToLiveSeconds()
public RingbufferConfig setTimeToLiveSeconds(int timeToLiveSeconds)
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.
timeToLiveSeconds
- the time to live period in secondsIllegalArgumentException
- if timeToLiveSeconds smaller than 0public InMemoryFormat getInMemoryFormat()
public RingbufferConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)
Setting the InMemoryFormat controls format of storing an item in the ringbuffer:
InMemoryFormat.OBJECT
: the item is stored in deserialized format (so a regular object)InMemoryFormat.BINARY
: the item is stored in serialized format (so a is binary blob) The default is binary. The object InMemoryFormat is useful when:
inMemoryFormat
- the new in memory formatNullPointerException
- if inMemoryFormat is null
IllegalArgumentException
- if InMemoryFormat.NATIVE
in memory format is selectedpublic RingbufferStoreConfig getRingbufferStoreConfig()
public RingbufferConfig setRingbufferStoreConfig(RingbufferStoreConfig ringbufferStoreConfig)
ringbufferStoreConfig
- set the RingbufferStore configuration to this configurationpublic String getQuorumName()
public RingbufferConfig setQuorumName(String quorumName)
quorumName
- the quorum namepublic MergePolicyConfig getMergePolicyConfig()
MergePolicyConfig
for this ringbuffer.MergePolicyConfig
for this ringbufferpublic RingbufferConfig setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
MergePolicyConfig
for this ringbuffer.public Class getProvidedMergeTypes()
getProvidedMergeTypes
in interface SplitBrainMergeTypeProvider
public int getFactoryId()
IdentifiedDataSerializable
getFactoryId
in interface IdentifiedDataSerializable
public int getId()
IdentifiedDataSerializable
getId
in interface IdentifiedDataSerializable
public void writeData(ObjectDataOutput out) throws IOException
DataSerializable
writeData
in interface DataSerializable
out
- outputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
output stream has been closed.public void readData(ObjectDataInput in) throws IOException
DataSerializable
readData
in interface DataSerializable
in
- inputIOException
- if an I/O error occurs. In particular,
an IOException
may be thrown if the
input stream has been closed.public RingbufferConfig getAsReadOnly()
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.