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
,Serializable
,javax.cache.configuration.CompleteConfiguration<K,V>
,javax.cache.configuration.Configuration<K,V>
public class CacheConfig<K,V> extends AbstractCacheConfig<K,V>
Contains all the configuration for the
ICache
.- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class com.hazelcast.config.AbstractCacheConfig
cacheLoaderFactory, cacheWriterFactory, classLoader, eventJournalConfig, expiryPolicyFactory, hotRestartConfig, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, listenerConfigurations, serializationService
-
Constructor Summary
Constructors Constructor Description CacheConfig()
CacheConfig(CacheSimpleConfig simpleConfig)
CacheConfig(String name)
CacheConfig(javax.cache.configuration.CompleteConfiguration<K,V> configuration)
-
Method Summary
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(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.String
getManagerPrefix()
Gets the manager prefix of theICache
, such as "hz://".MergePolicyConfig
getMergePolicyConfig()
Gets theMergePolicyConfig
for this map.String
getName()
Gets the name of thisICache
.String
getNameWithPrefix()
Gets the full name of theICache
, including the manager scope prefix.List<CachePartitionLostListenerConfig>
getPartitionLostListenerConfigs()
Gets the partition lost listener references added to cache configuration.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.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(String managerPrefix)
Sets the manager prefix of theICache
.CacheConfig<K,V>
setMergePolicyConfig(MergePolicyConfig mergePolicyConfig)
Sets theMergePolicyConfig
for this map.CacheConfig<K,V>
setName(String name)
Sets the name of thisICache
.CacheConfig<K,V>
setPartitionLostListenerConfigs(List<CachePartitionLostListenerConfig> partitionLostListenerConfigs)
Sets the WAN target replication reference.CacheConfig<K,V>
setSplitBrainProtectionName(String splitBrainProtectionName)
Associates this cache configuration to a split brain protection.CacheConfig<K,V>
setUriString(String uriString)
Sets the URI string, which is the global identifier of theICache
.CacheConfig<K,V>
setWanReplicationRef(WanReplicationRef wanReplicationRef)
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, getEventJournalConfig, getExpiryPolicyFactory, getFactoryId, getHotRestartConfig, getKeyClassName, getKeyType, getListenerConfigurations, getValueClassName, getValueType, hasListenerConfiguration, isManagementEnabled, isReadThrough, isStatisticsEnabled, isStoreByValue, isWriteThrough, keyValueTypesEqual, removeCacheEntryListenerConfiguration, setCacheLoaderFactory, setCacheWriterFactory, setClassLoader, setEventJournalConfig, setExpiryPolicyFactory, setHotRestartConfig, setKeyClassName, setKeyType, setListenerConfigurations, setListenerConfigurations, setManagementEnabled, setReadThrough, setStatisticsEnabled, setStoreByValue, setTypes, setValueClassName, setValueType, setWriteThrough
-
Constructor Details
-
CacheConfig
public CacheConfig() -
CacheConfig
-
CacheConfig
-
CacheConfig
- Throws:
Exception
-
-
Method Details
-
getName
Gets the name of thisICache
.- Returns:
- the name of this
ICache
-
setName
Sets the name of thisICache
.- Parameters:
name
- the name to set for thisICache
- Returns:
- the current cache config instance
-
getManagerPrefix
Gets the manager prefix of theICache
, such as "hz://".- Returns:
- the manager prefix of this
ICache
-
setManagerPrefix
Sets the manager prefix of theICache
.- Parameters:
managerPrefix
- the manager prefix to set for thisICache
- Returns:
- the current cache config instance
-
getUriString
Gets the URI string which is the global identifier for thisICache
.- Returns:
- the URI string of this
ICache
-
setUriString
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
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
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:
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
Sets the number of asynchronous backups for thisICache
.- Parameters:
asyncBackupCount
- the number of asynchronous backups to set for thisICache
- Returns:
- the updated CacheConfig
- Throws:
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
Gets theEvictionConfig
instance of the eviction configuration for thisICache
.- Returns:
- the
EvictionConfig
instance of the eviction configuration
-
setEvictionConfig
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
-
setWanReplicationRef
-
getPartitionLostListenerConfigs
Gets the partition lost listener references added to cache configuration.- Returns:
- List of CachePartitionLostListenerConfig
-
setPartitionLostListenerConfigs
public CacheConfig<K,V> setPartitionLostListenerConfigs(List<CachePartitionLostListenerConfig> partitionLostListenerConfigs)Sets the WAN target replication reference.- Parameters:
partitionLostListenerConfigs
- CachePartitionLostListenerConfig list
-
getInMemoryFormat
Gets the data type that will be used to store records.- Returns:
- the data storage type of the cache config
-
setInMemoryFormat
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:
IllegalArgumentException
- if inMemoryFormat isnull
-
getSplitBrainProtectionName
Gets the name of the associated split brain protection if any.- Returns:
- the name of the associated split brain protection if any
-
setSplitBrainProtectionName
Associates this cache configuration to a split brain protection.- Parameters:
splitBrainProtectionName
- name of the desired split brain protection- Returns:
- the updated CacheConfig
-
getMergePolicyConfig
Gets theMergePolicyConfig
for this map.- Returns:
- the
MergePolicyConfig
for this map
-
setMergePolicyConfig
Sets theMergePolicyConfig
for this map.- Returns:
- the updated map configuration
-
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
Description copied from interface:DataSerializable
Writes object fields to output stream- Parameters:
out
- output- Throws:
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.- Returns:
- type ID
-
readData
Description copied from interface:DataSerializable
Reads fields from the input stream- Parameters:
in
- input- Throws:
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
- Overrides:
equals
in classAbstractCacheConfig<K,V>
-
toString
-
writeTenant
- Throws:
IOException
-
readTenant
- Throws:
IOException
-
writeKeyValueTypes
- Throws:
IOException
-
readKeyValueTypes
- Throws:
IOException
-
writeFactories
- Throws:
IOException
-
readFactories
- Throws:
IOException
-
writeListenerConfigurations
- Throws:
IOException
-
readListenerConfigurations
- Throws:
IOException
-
copy
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
-