public class RingbufferConfig extends Object implements SplitBrainMergeTypeProvider, IdentifiedDataSerializable, Versioned, NamedConfig
Ringbuffer
.
The RingBuffer is a replicated but not partitioned 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 in-memory format.
|
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()
Returns the in-memory format.
|
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 in-memory format.
|
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 which is the maximum number of seconds
for each item to stay in the ringbuffer before being removed.
|
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)
setName
in interface NamedConfig
name
- the name of the ringbufferRingbufferConfig
IllegalArgumentException
- if name is null
or an empty stringpublic String getName()
getName
in interface NamedConfig
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 overwritten by the newest items.
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)
Entries that are older than timeToLiveSeconds
are removed from the
ringbuffer on the next ringbuffer operation (read or write).
Time to live can be disabled by setting timeToLiveSeconds
to 0.
It means that items won't get removed because they expire. They may only
be overwritten.
When timeToLiveSeconds
is disabled and after the tail does a full
loop in the ring, the ringbuffer size will always be equal to the capacity.
The timeToLiveSeconds
can be any integer between 0 and
Integer.MAX_VALUE
. 0 means infinite. The default is 0.
timeToLiveSeconds
- the time to live period in secondsIllegalArgumentException
- if timeToLiveSeconds smaller than 0public InMemoryFormat getInMemoryFormat()
The in-memory format controls the format of the stored item in the ringbuffer:
InMemoryFormat.OBJECT
: the item is stored in deserialized
format (a regular object)InMemoryFormat.BINARY
: the item is stored in serialized format
(a binary blob) The default is binary. The object InMemoryFormat is useful when:
public RingbufferConfig setInMemoryFormat(InMemoryFormat inMemoryFormat)
The in-memory format controls the format of the stored item in the ringbuffer:
InMemoryFormat.OBJECT
: the item is stored in deserialized
format (a regular object)InMemoryFormat.BINARY
: the item is stored in serialized format
(a 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 © 2020 Hazelcast, Inc.. All Rights Reserved.