Package com.hazelcast.config
Class CacheConfig<K,V>
- java.lang.Object
-
- com.hazelcast.config.AbstractCacheConfig<K,V>
-
- com.hazelcast.config.CacheConfig<K,V>
-
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
CacheConfiguration<K,V>
,DataSerializable
,IdentifiedDataSerializable
,com.hazelcast.nio.serialization.impl.Versioned
,java.io.Serializable
,javax.cache.configuration.CompleteConfiguration<K,V>
,javax.cache.configuration.Configuration<K,V>
public class CacheConfig<K,V> extends AbstractCacheConfig<K,V> implements com.hazelcast.nio.serialization.impl.Versioned
Contains all the configuration for theICache
.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.hazelcast.config.AbstractCacheConfig
cacheLoaderFactory, cacheWriterFactory, classLoader, dataPersistenceConfig, eventJournalConfig, expiryPolicyFactory, hotRestartConfig, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, listenerConfigurations, serializationService
-
-
Constructor Summary
Constructors Constructor Description CacheConfig()
CacheConfig(CacheSimpleConfig simpleConfig)
CacheConfig(java.lang.String name)
CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends CacheConfig<K,V>>
Tcopy(T target, boolean resolved)
Copy this CacheConfig to giventarget
object whose type extends CacheConfig.boolean
equals(java.lang.Object o)
int
getAsyncBackupCount()
Gets the number of asynchronous backups for thisICache
.int
getBackupCount()
Gets the number of synchronous backups for thisICache
.int
getClassId()
Returns type identifier for this class.EvictionConfig
getEvictionConfig()
Gets theEvictionConfig
instance of the eviction configuration for thisICache
.InMemoryFormat
getInMemoryFormat()
Gets the data type that will be used to store records.java.lang.String
getManagerPrefix()
Gets the manager prefix of theICache
, such as "hz://".MergePolicyConfig
getMergePolicyConfig()
Gets theMergePolicyConfig
for this map.MerkleTreeConfig
getMerkleTreeConfig()
Gets theMerkleTreeConfig
for thisCacheConfig
java.lang.String
getName()
Gets the name of thisICache
.java.lang.String
getNameWithPrefix()
Gets the full name of theICache
, including the manager scope prefix.java.util.List<CachePartitionLostListenerConfig>
getPartitionLostListenerConfigs()
Gets the partition lost listener references added to cache configuration.java.lang.String
getSplitBrainProtectionName()
Gets the name of the associated split brain protection if any.int
getTotalBackupCount()
Gets the total backup count (backupCount + asyncBackupCount
) of the cache.java.lang.String
getUriString()
Gets the URI string which is the global identifier for thisICache
.WanReplicationRef
getWanReplicationRef()
int
hashCode()
boolean
isDisablePerEntryInvalidationEvents()
Returns invalidation events disabled status for per entry.void
readData(ObjectDataInput in)
Reads fields from the input streamprotected void
readFactories(ObjectDataInput in)
protected void
readKeyValueTypes(ObjectDataInput in)
protected void
readListenerConfigurations(ObjectDataInput in)
protected void
readTenant(ObjectDataInput in)
CacheConfig<K,V>
setAsyncBackupCount(int asyncBackupCount)
Sets the number of asynchronous backups for thisICache
.CacheConfig<K,V>
setBackupCount(int backupCount)
Sets the number of synchronous backups.CacheConfig<K,V>
setDisablePerEntryInvalidationEvents(boolean disablePerEntryInvalidationEvents)
Sets invalidation events disabled status for per entry.CacheConfig<K,V>
setEvictionConfig(EvictionConfig evictionConfig)
Sets theEvictionConfig
instance for eviction configuration for thisICache
.CacheConfig<K,V>
setInMemoryFormat(InMemoryFormat inMemoryFormat)
Data type that will be used to store records in thisICache
.CacheConfig<K,V>
setManagerPrefix(java.lang.String managerPrefix)
Sets the manager prefix of theICache
.CacheConfig<K,V>
setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
Sets theMergePolicyConfig
for this map.void
setMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig)
Sets theMerkleTreeConfig
for thisCacheConfig
CacheConfig<K,V>
setName(java.lang.String name)
Sets the name of thisICache
.CacheConfig<K,V>
setPartitionLostListenerConfigs(java.util.List<CachePartitionLostListenerConfig> partitionLostListenerConfigs)
Sets the WAN target replication reference.CacheConfig<K,V>
setSplitBrainProtectionName(java.lang.String splitBrainProtectionName)
Associates this cache configuration to a split brain protection.CacheConfig<K,V>
setUriString(java.lang.String uriString)
Sets the URI string, which is the global identifier of theICache
.CacheConfig<K,V>
setWanReplicationRef(WanReplicationRef wanReplicationRef)
java.lang.String
toString()
void
writeData(ObjectDataOutput out)
Writes object fields to output streamprotected void
writeFactories(ObjectDataOutput out)
protected void
writeKeyValueTypes(ObjectDataOutput out)
protected void
writeListenerConfigurations(ObjectDataOutput out)
protected void
writeTenant(ObjectDataOutput out)
-
Methods inherited from class com.hazelcast.config.AbstractCacheConfig
addCacheEntryListenerConfiguration, createConcurrentSet, getCacheEntryListenerConfigurations, getCacheLoaderFactory, getCacheWriterFactory, getDataPersistenceConfig, getEventJournalConfig, getExpiryPolicyFactory, getFactoryId, getHotRestartConfig, getKeyClassName, getKeyType, getListenerConfigurations, getValueClassName, getValueType, hasListenerConfiguration, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, keyValueTypesEqual, removeCacheEntryListenerConfiguration, setCacheLoaderFactory, setCacheWriterFactory, setClassLoader, setDataPersistenceConfig, setEventJournalConfig, setExpiryPolicyFactory, setHotRestartConfig, setKeyClassName, setKeyType, setListenerConfigurations, setListenerConfigurations, setManagementEnabled, setReadThrough, setStatisticsEnabled, setStoreByValue, setTypes, setValueClassName, setValueType, setWriteThrough
-
-
-
-
Constructor Detail
-
CacheConfig
public CacheConfig()
-
CacheConfig
public CacheConfig(java.lang.String name)
-
CacheConfig
public CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
-
CacheConfig
public CacheConfig(CacheSimpleConfig simpleConfig) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of thisICache
.- Returns:
- the name of this
ICache
-
setName
public CacheConfig<K,V> setName(java.lang.String name)
Sets the name of thisICache
.- Parameters:
name
- the name to set for thisICache
- Returns:
- the current cache config instance
-
getManagerPrefix
public java.lang.String getManagerPrefix()
Gets the manager prefix of theICache
, such as "hz://".- Returns:
- the manager prefix of this
ICache
-
setManagerPrefix
public CacheConfig<K,V> setManagerPrefix(java.lang.String managerPrefix)
Sets the manager prefix of theICache
.- Parameters:
managerPrefix
- the manager prefix to set for thisICache
- Returns:
- the current cache config instance
-
getUriString
public java.lang.String getUriString()
Gets the URI string which is the global identifier for thisICache
.- Returns:
- the URI string of this
ICache
-
setUriString
public CacheConfig<K,V> setUriString(java.lang.String uriString)
Sets the URI string, which is the global identifier of theICache
.- Parameters:
uriString
- the URI string to set for thisICache
- Returns:
- the current cache config instance
-
getNameWithPrefix
public java.lang.String getNameWithPrefix()
Gets the full name of theICache
, including the manager scope prefix.- Returns:
- the full name of the
ICache
, including the manager scope prefix
-
getBackupCount
public int getBackupCount()
Gets the number of synchronous backups for thisICache
.- Returns:
- the number of synchronous backups (backupCount) for this
ICache
- See Also:
getAsyncBackupCount()
-
setBackupCount
public CacheConfig<K,V> setBackupCount(int backupCount)
Sets the number of synchronous backups. For example, if 1 is set as the backup count, then all entries of the map will be copied to another JVM for fail-safety. 0 means no synchronous backup.- Parameters:
backupCount
- the number of synchronous backups to set for thisICache
- Returns:
- the current cache config instance
- Throws:
java.lang.IllegalArgumentException
- if backupCount smaller than 0, or larger than the maximum number of backup, or the sum of the synchronous and asynchronous backups is larger than the maximum number of backups- See Also:
setAsyncBackupCount(int)
-
getAsyncBackupCount
public int getAsyncBackupCount()
Gets the number of asynchronous backups for thisICache
.- Returns:
- the number of asynchronous backups for this
ICache
- See Also:
setBackupCount(int)
-
setAsyncBackupCount
public CacheConfig<K,V> setAsyncBackupCount(int asyncBackupCount)
Sets the number of asynchronous backups for thisICache
.- Parameters:
asyncBackupCount
- the number of asynchronous backups to set for thisICache
- Returns:
- the updated CacheConfig
- Throws:
java.lang.IllegalArgumentException
- if asyncBackupCount is smaller than 0, or larger than the maximum number of backups, or the sum of the synchronous and asynchronous backups is larger than the maximum number of backups- See Also:
setBackupCount(int)
,getAsyncBackupCount()
-
getTotalBackupCount
public int getTotalBackupCount()
Gets the total backup count (backupCount + asyncBackupCount
) of the cache.- Returns:
- the total backup count (
backupCount + asyncBackupCount
) of the cache
-
getEvictionConfig
public EvictionConfig getEvictionConfig()
Gets theEvictionConfig
instance of the eviction configuration for thisICache
.- Returns:
- the
EvictionConfig
instance of the eviction configuration
-
setEvictionConfig
public CacheConfig<K,V> setEvictionConfig(EvictionConfig evictionConfig)
Sets theEvictionConfig
instance for eviction configuration for thisICache
.- Parameters:
evictionConfig
- theEvictionConfig
instance to set for the eviction configuration- Returns:
- the current cache config instance
-
getWanReplicationRef
public WanReplicationRef getWanReplicationRef()
-
setWanReplicationRef
public CacheConfig<K,V> setWanReplicationRef(WanReplicationRef wanReplicationRef)
-
getPartitionLostListenerConfigs
public java.util.List<CachePartitionLostListenerConfig> getPartitionLostListenerConfigs()
Gets the partition lost listener references added to cache configuration.- Returns:
- List of CachePartitionLostListenerConfig
-
setPartitionLostListenerConfigs
public CacheConfig<K,V> setPartitionLostListenerConfigs(java.util.List<CachePartitionLostListenerConfig> partitionLostListenerConfigs)
Sets the WAN target replication reference.- Parameters:
partitionLostListenerConfigs
- CachePartitionLostListenerConfig list
-
getInMemoryFormat
public InMemoryFormat getInMemoryFormat()
Gets the data type that will be used to store records.- Returns:
- the data storage type of the cache config
-
setInMemoryFormat
public CacheConfig<K,V> setInMemoryFormat(InMemoryFormat inMemoryFormat)
Data type that will be used to store records in thisICache
. Possible values:- BINARY (default): keys and values will be stored as binary data
- OBJECT: values will be stored in their object forms
- NATIVE: values will be stored in non-heap region of JVM (Hazelcast Enterprise only)
- Parameters:
inMemoryFormat
- the record type to set- Returns:
- current cache config instance
- Throws:
java.lang.IllegalArgumentException
- if inMemoryFormat isnull
-
getSplitBrainProtectionName
public java.lang.String getSplitBrainProtectionName()
Gets the name of the associated split brain protection if any.- Returns:
- the name of the associated split brain protection if any
-
setSplitBrainProtectionName
public CacheConfig<K,V> setSplitBrainProtectionName(java.lang.String splitBrainProtectionName)
Associates this cache configuration to a split brain protection.- Parameters:
splitBrainProtectionName
- name of the desired split brain protection- Returns:
- the updated CacheConfig
-
getMergePolicyConfig
public MergePolicyConfig getMergePolicyConfig()
Gets theMergePolicyConfig
for this map.- Returns:
- the
MergePolicyConfig
for this map
-
setMergePolicyConfig
public CacheConfig<K,V> setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
Sets theMergePolicyConfig
for this map.- Returns:
- the updated map configuration
-
getMerkleTreeConfig
public MerkleTreeConfig getMerkleTreeConfig()
Gets theMerkleTreeConfig
for thisCacheConfig
- Returns:
- merkle tree config
-
setMerkleTreeConfig
public void setMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig)
Sets theMerkleTreeConfig
for thisCacheConfig
- Parameters:
merkleTreeConfig
- merkle tree config
-
isDisablePerEntryInvalidationEvents
public boolean isDisablePerEntryInvalidationEvents()
Returns invalidation events disabled status for per entry.- Returns:
true
if invalidation events are disabled for per entry,false
otherwise
-
setDisablePerEntryInvalidationEvents
public CacheConfig<K,V> setDisablePerEntryInvalidationEvents(boolean disablePerEntryInvalidationEvents)
Sets invalidation events disabled status for per entry.- Parameters:
disablePerEntryInvalidationEvents
- disables invalidation event sending behaviour if it istrue
, otherwise enables it- Returns:
- this configuration
-
writeData
public void writeData(ObjectDataOutput out) throws java.io.IOException
Description copied from interface:DataSerializable
Writes object fields to output stream- Specified by:
writeData
in interfaceDataSerializable
- Parameters:
out
- output- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the output stream has been closed.
-
getClassId
public int getClassId()
Description copied from interface:IdentifiedDataSerializable
Returns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassId
in interfaceIdentifiedDataSerializable
- Returns:
- type ID
-
readData
public void readData(ObjectDataInput in) throws java.io.IOException
Description copied from interface:DataSerializable
Reads fields from the input stream- Specified by:
readData
in interfaceDataSerializable
- Parameters:
in
- input- Throws:
java.io.IOException
- if an I/O error occurs. In particular, anIOException
may be thrown if the input stream has been closed.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractCacheConfig<K,V>
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classAbstractCacheConfig<K,V>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeTenant
protected void writeTenant(ObjectDataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
readTenant
protected void readTenant(ObjectDataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeKeyValueTypes
protected void writeKeyValueTypes(ObjectDataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
readKeyValueTypes
protected void readKeyValueTypes(ObjectDataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeFactories
protected void writeFactories(ObjectDataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
readFactories
protected void readFactories(ObjectDataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeListenerConfigurations
protected void writeListenerConfigurations(ObjectDataOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
readListenerConfigurations
protected void readListenerConfigurations(ObjectDataInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
copy
public <T extends CacheConfig<K,V>> T copy(T target, boolean resolved)
Copy this CacheConfig to giventarget
object whose type extends CacheConfig.- Type Parameters:
T
- the target object type- Parameters:
target
- the target object to which this configuration will be copiedresolved
- whentrue
, it is assumed that thiscacheConfig
's key-value types have already been or will be resolved to loaded classes and the actualkeyType
andvalueType
will be copied. Otherwise, this configuration'skeyClassName
andvalueClassName
will be copied to the target config, to be resolved at a later time.- Returns:
- the target config
-
-