Package com.hazelcast.config
Class MapConfig
java.lang.Object
com.hazelcast.config.MapConfig
- All Implemented Interfaces:
NamedConfig,UserCodeNamespaceAwareConfig<MapConfig>,DataSerializable,IdentifiedDataSerializable,com.hazelcast.nio.serialization.impl.Versioned
public class MapConfig
extends Object
implements IdentifiedDataSerializable, NamedConfig, com.hazelcast.nio.serialization.impl.Versioned, UserCodeNamespaceAwareConfig<MapConfig>
Contains the configuration for an
IMap.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default number of backupsstatic final CacheDeserializedValuesWe want to cache values only when an index is defined.static final booleanDefault value of whether per entry statistics are enabled or notstatic final EvictionPolicyDefault eviction policystatic final InMemoryFormatDefault In-Memory format is binary.static final intThe number of default time to wait eviction in seconds.static final intDefault max size.static final MaxSizePolicyDefault max size policystatic final MetadataPolicyDefault metadata policystatic final booleanDefault value of whether statistics are enabled or notstatic final intThe number of default Time to Live in seconds.static final intThe number of Time to Live that represents disabling TTL.static final intThe maximum number of backupsstatic final intThe minimum number of backupsFields inherited from interface com.hazelcast.config.UserCodeNamespaceAwareConfig
DEFAULT_NAMESPACE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeConfig(AttributeConfig attributeConfig) addEntryListenerConfig(EntryListenerConfig listenerConfig) addIndexConfig(IndexConfig indexConfig) addMapPartitionLostListenerConfig(MapPartitionLostListenerConfig listenerConfig) addQueryCacheConfig(QueryCacheConfig queryCacheConfig) Adds a newQueryCacheConfigto thisMapConfig.final booleanintReturns the asynchronous backup count for thisIMap.intReturns the backupCount for thisIMapGet current value cache settingsintReturns type identifier for this class.Gets theDataPersistenceConfigfor thisMapConfigGets theEventJournalConfigfor thisMapConfigGets theEvictionConfiginstance of the eviction configuration for thisIMap.intReturns DataSerializableFactory factory ID for this class.Gets theHotRestartConfigfor thisMapConfigReturns the data type that will be used for storing records.Returns the map store configurationintReturns the maximum number of seconds for each entry to stay idle in the map.Gets theMergePolicyConfigfor this map.Gets theMerkleTreeConfigfor thisMapConfigReturnsMetadataPolicyfor this map.getName()Returns the name of thisIMapReturns the Near Cache configurationGet Partition Attribute configs used for creation ofAttributePartitioningStrategyReturns allQueryCacheConfiginstances defined on thisMapConfig.Gets theTieredStoreConfigfor thisMapConfigintReturns the maximum number of seconds for each entry to stay in the map.intReturns the total number of backups: backupCount plus asyncBackupCount.Retrieve the User Code Deployment Namespace to be used forClassLoaderawareness during operations related to the structure associated with this configuration.Gets the WAN target replication reference.final inthashCode()booleanChecks if Near Cache is enabled.booleanChecks if entry level statistics are enabled for this map.booleanChecks if read-backup-data (reading local backup entries) is enabled for this map.booleanChecks if statistics are enabled for this map.voidReads fields from the input streamsetAsyncBackupCount(int asyncBackupCount) Sets the number of asynchronous backups.setAttributeConfigs(List<AttributeConfig> attributeConfigs) setBackupCount(int backupCount) Number of synchronous backups.setCacheDeserializedValues(CacheDeserializedValues cacheDeserializedValues) Configure de-serialized value caching.setDataPersistenceConfig(DataPersistenceConfig dataPersistenceConfig) Sets theDataPersistenceConfigfor thisMapConfigsetEntryListenerConfigs(List<EntryListenerConfig> listenerConfigs) setEventJournalConfig(EventJournalConfig eventJournalConfig) Sets theEventJournalConfigfor thisMapConfigsetEvictionConfig(EvictionConfig evictionConfig) Sets theEvictionConfiginstance for eviction configuration for thisIMap.setHotRestartConfig(HotRestartConfig hotRestartConfig) Deprecated.setIndexConfigs(List<IndexConfig> indexConfigs) setInMemoryFormat(InMemoryFormat inMemoryFormat) Binary type that will be used for storing records.setMapStoreConfig(MapStoreConfig mapStoreConfig) Sets the map store configurationsetMaxIdleSeconds(int maxIdleSeconds) Maximum number of seconds for each entry to stay idle in the map.setMergePolicyConfig(MergePolicyConfig mergePolicyConfig) Sets theMergePolicyConfigfor this map.setMerkleTreeConfig(MerkleTreeConfig merkleTreeConfig) Sets theMerkleTreeConfigfor thisMapConfigsetMetadataPolicy(MetadataPolicy metadataPolicy) Sets the metadata policy.Sets the name of theIMapsetNearCacheConfig(NearCacheConfig nearCacheConfig) Sets the Near Cache configurationsetPartitioningAttributeConfigs(List<PartitioningAttributeConfig> partitioningAttributeConfigs) setPartitioningStrategyConfig(PartitioningStrategyConfig partitioningStrategyConfig) setPartitionLostListenerConfigs(List<MapPartitionLostListenerConfig> listenerConfigs) setPerEntryStatsEnabled(boolean perEntryStatsEnabled) Set to enable/disable per entry statistics.setQueryCacheConfigs(List<QueryCacheConfig> queryCacheConfigs) SetsQueryCacheConfiginstances to thisMapConfig.setReadBackupData(boolean readBackupData) Sets read-backup-data (reading local backup entries) for this map.setSplitBrainProtectionName(String splitBrainProtectionName) setStatisticsEnabled(boolean statisticsEnabled) Set to enable/disable map level statistics for this map.setTieredStoreConfig(TieredStoreConfig tieredStoreConfig) Sets theTieredStoreConfigfor thisMapConfigsetTimeToLiveSeconds(int timeToLiveSeconds) The maximum number of seconds for each entry to stay in the map.setUserCodeNamespace(String userCodeNamespace) Associates the provided Namespace Name with this structure forClassLoaderawareness.setWanReplicationRef(WanReplicationRef wanReplicationRef) Sets the WAN target replication reference.toString()voidWrites object fields to output stream
-
Field Details
-
MIN_BACKUP_COUNT
public static final int MIN_BACKUP_COUNTThe minimum number of backups- See Also:
-
DEFAULT_BACKUP_COUNT
public static final int DEFAULT_BACKUP_COUNTThe default number of backups- See Also:
-
MAX_BACKUP_COUNT
public static final int MAX_BACKUP_COUNTThe maximum number of backups- See Also:
-
DISABLED_TTL_SECONDS
public static final int DISABLED_TTL_SECONDSThe number of Time to Live that represents disabling TTL.- See Also:
-
DEFAULT_TTL_SECONDS
public static final int DEFAULT_TTL_SECONDSThe number of default Time to Live in seconds.- See Also:
-
DEFAULT_MAX_IDLE_SECONDS
public static final int DEFAULT_MAX_IDLE_SECONDSThe number of default time to wait eviction in seconds.- See Also:
-
DEFAULT_IN_MEMORY_FORMAT
Default In-Memory format is binary. -
DEFAULT_CACHED_DESERIALIZED_VALUES
We want to cache values only when an index is defined. -
DEFAULT_METADATA_POLICY
Default metadata policy -
DEFAULT_STATISTICS_ENABLED
public static final boolean DEFAULT_STATISTICS_ENABLEDDefault value of whether statistics are enabled or not- See Also:
-
DEFAULT_ENTRY_STATS_ENABLED
public static final boolean DEFAULT_ENTRY_STATS_ENABLEDDefault value of whether per entry statistics are enabled or not- See Also:
-
DEFAULT_MAX_SIZE
public static final int DEFAULT_MAX_SIZEDefault max size.- See Also:
-
DEFAULT_MAX_SIZE_POLICY
Default max size policy -
DEFAULT_EVICTION_POLICY
Default eviction policy
-
-
Constructor Details
-
MapConfig
public MapConfig() -
MapConfig
-
MapConfig
-
-
Method Details
-
getName
Returns the name of thisIMap- Specified by:
getNamein interfaceNamedConfig- Returns:
- the name of the
IMap
-
setName
Sets the name of theIMap- Specified by:
setNamein interfaceNamedConfig- Parameters:
name- the name to set for thisIMap
-
getInMemoryFormat
Returns the data type that will be used for storing records.- Returns:
- data type that will be used for storing records
-
setInMemoryFormat
Binary type that will be used for storing records. 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 for thisIMap- Throws:
IllegalArgumentException- if inMemoryFormat isnull
-
getEvictionConfig
Gets theEvictionConfiginstance of the eviction configuration for thisIMap.- Returns:
- the
EvictionConfiginstance of the eviction configuration
-
setEvictionConfig
Sets theEvictionConfiginstance for eviction configuration for thisIMap.- Parameters:
evictionConfig- theEvictionConfiginstance to set for the eviction configuration- Returns:
- current map config instance
-
getBackupCount
public int getBackupCount()Returns the backupCount for thisIMap- Returns:
- the backupCount for this
IMap - See Also:
-
setBackupCount
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 sync backup.- Parameters:
backupCount- the number of synchronous backups to set for thisIMap- Returns:
- the updated MapConfig
- See Also:
-
getAsyncBackupCount
public int getAsyncBackupCount()Returns the asynchronous backup count for thisIMap.- Returns:
- the asynchronous backup count
- See Also:
-
setAsyncBackupCount
Sets the number of asynchronous backups. 0 means no backups.- Parameters:
asyncBackupCount- the number of asynchronous synchronous backups to set- Returns:
- the updated MapConfig
- 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:
-
getTotalBackupCount
public int getTotalBackupCount()Returns the total number of backups: backupCount plus asyncBackupCount.- Returns:
- the total number of backups: synchronous + asynchronous
-
getTimeToLiveSeconds
public int getTimeToLiveSeconds()Returns the maximum number of seconds for each entry to stay in the map.- Returns:
- the maximum number of seconds for each entry to stay in the map
-
setTimeToLiveSeconds
The maximum number of seconds for each entry to stay in the map. Entries that are older than timeToLiveSeconds will be automatically evicted from the map. Updates on the entry will change the eviction time. Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.- Parameters:
timeToLiveSeconds- the timeToLiveSeconds to set
-
getMaxIdleSeconds
public int getMaxIdleSeconds()Returns the maximum number of seconds for each entry to stay idle in the map.- Returns:
- the maximum number of seconds for each entry to stay idle in the map
-
setMaxIdleSeconds
Maximum number of seconds for each entry to stay idle in the map. Entries that are idle (not touched) for more thanmaxIdleSecondswill get automatically evicted from the map. Entry is touched ifget(),getAll(),put()orcontainsKey()is called. Any integer between0andInteger.MAX_VALUE.0means infinite. Default is0. The time precision is limited by 1 second. The MaxIdle that less than 1 second can lead to unexpected behaviour.- Parameters:
maxIdleSeconds- the maxIdleSeconds (the maximum number of seconds for each entry to stay idle in the map) to set
-
getMapStoreConfig
Returns the map store configuration- Returns:
- the mapStoreConfig (map store configuration)
-
setMapStoreConfig
Sets the map store configuration- Parameters:
mapStoreConfig- the mapStoreConfig (map store configuration) to set
-
getNearCacheConfig
Returns the Near Cache configuration- Returns:
- the Near Cache configuration
-
setNearCacheConfig
Sets the Near Cache configuration- Parameters:
nearCacheConfig- the Near Cache configuration- Returns:
- the updated map configuration
-
getMergePolicyConfig
Gets theMergePolicyConfigfor this map.- Returns:
- the
MergePolicyConfigfor this map
-
setMergePolicyConfig
Sets theMergePolicyConfigfor this map.Note that you may need to enable per entry stats via
setPerEntryStatsEnabled(boolean)to see all fields of entry view in yourSplitBrainMergePolicyimplementation.- Returns:
- the updated map configuration
-
isStatisticsEnabled
public boolean isStatisticsEnabled()Checks if statistics are enabled for this map.- Returns:
trueif statistics are enabled,falseotherwise
-
setStatisticsEnabled
Set to enable/disable map level statistics for this map.This setting is only for map level stats such as last access time to map, total number of hits etc. For entry level stats see
perEntryStatsEnabled- Parameters:
statisticsEnabled-trueto enable map statistics,falseto disable- Returns:
- the current map config instance
- See Also:
-
isPerEntryStatsEnabled
public boolean isPerEntryStatsEnabled()Checks if entry level statistics are enabled for this map.- Returns:
trueif entry level statistics are enabled,falseotherwise- Since:
- 4.2
-
setPerEntryStatsEnabled
Set to enable/disable per entry statistics. Its default value isfalse.When you enable per entry stats, you can retrieve entry level statistics such as hits, creation time, last access time, last update time, last stored time for an entry.
- Parameters:
perEntryStatsEnabled-trueto enable entry level statistics,falseto disable- Returns:
- the current map config instance
- Since:
- 4.2
-
isReadBackupData
public boolean isReadBackupData()Checks if read-backup-data (reading local backup entries) is enabled for this map.- Returns:
trueif read-backup-data is enabled,falseotherwise
-
setReadBackupData
Sets read-backup-data (reading local backup entries) for this map.- Parameters:
readBackupData-trueto enable read-backup-data,falseto disable- Returns:
- the current map config instance
-
getWanReplicationRef
Gets the WAN target replication reference.- Returns:
- the WAN target replication reference
-
setWanReplicationRef
Sets the WAN target replication reference.- Parameters:
wanReplicationRef- the WAN target replication reference- Returns:
- the current map config instance
-
addEntryListenerConfig
-
getEntryListenerConfigs
-
setEntryListenerConfigs
-
addMapPartitionLostListenerConfig
-
getPartitionLostListenerConfigs
-
setPartitionLostListenerConfigs
public MapConfig setPartitionLostListenerConfigs(List<MapPartitionLostListenerConfig> listenerConfigs) -
addIndexConfig
-
getIndexConfigs
-
setIndexConfigs
-
addAttributeConfig
-
getAttributeConfigs
-
setAttributeConfigs
-
getMetadataPolicy
ReturnsMetadataPolicyfor this map.- Returns:
MetadataPolicyfor this map
-
setMetadataPolicy
Sets the metadata policy. SeeMetadataPolicyfor more information.- Parameters:
metadataPolicy- the metadata policy
-
addQueryCacheConfig
Adds a newQueryCacheConfigto thisMapConfig.- Parameters:
queryCacheConfig- the config to be added- Returns:
- this
MapConfiginstance - Throws:
IllegalArgumentException- if there is already aQueryCachewith the sameQueryCacheConfig#name
-
getQueryCacheConfigs
Returns allQueryCacheConfiginstances defined on thisMapConfig.- Returns:
- all
QueryCacheConfiginstances defined on thisMapConfig
-
setQueryCacheConfigs
SetsQueryCacheConfiginstances to thisMapConfig.- Returns:
- this configuration
-
getPartitioningStrategyConfig
-
setPartitioningStrategyConfig
public MapConfig setPartitioningStrategyConfig(PartitioningStrategyConfig partitioningStrategyConfig) -
isNearCacheEnabled
public boolean isNearCacheEnabled()Checks if Near Cache is enabled.- Returns:
trueif Near Cache is enabled,falseotherwise
-
setCacheDeserializedValues
Configure de-serialized value caching. Default:CacheDeserializedValues.INDEX_ONLY- Returns:
- this
MapConfiginstance - Since:
- 3.6
- See Also:
-
getHotRestartConfig
Gets theHotRestartConfigfor thisMapConfig- Returns:
- hot restart config
-
getDataPersistenceConfig
Gets theDataPersistenceConfigfor thisMapConfig- Returns:
- dataPersistenceConfig config
-
setHotRestartConfig
Deprecated.since 5.0 usesetDataPersistenceConfig(DataPersistenceConfig)Sets theHotRestartConfigfor thisMapConfig- Parameters:
hotRestartConfig- hot restart config- Returns:
- this
MapConfiginstance
-
setDataPersistenceConfig
Sets theDataPersistenceConfigfor thisMapConfig- Parameters:
dataPersistenceConfig- dataPersistenceConfig config- Returns:
- this
MapConfiginstance
-
getMerkleTreeConfig
Gets theMerkleTreeConfigfor thisMapConfig- Returns:
- merkle tree config
-
setMerkleTreeConfig
Sets theMerkleTreeConfigfor thisMapConfig- Parameters:
merkleTreeConfig- merkle tree config- Returns:
- this
MapConfiginstance
-
getEventJournalConfig
Gets theEventJournalConfigfor thisMapConfig- Returns:
- event journal config
-
setEventJournalConfig
Sets theEventJournalConfigfor thisMapConfig- Parameters:
eventJournalConfig- event journal config- Returns:
- this
MapConfiginstance
-
getTieredStoreConfig
Gets theTieredStoreConfigfor thisMapConfig- Returns:
- tiered-store config
-
setTieredStoreConfig
Sets theTieredStoreConfigfor thisMapConfig- Parameters:
tieredStoreConfig- tiered-store config- Returns:
- this
MapConfiginstance
-
getCacheDeserializedValues
Get current value cache settings- Returns:
- current value cache settings
- Since:
- 3.6
-
getSplitBrainProtectionName
-
setSplitBrainProtectionName
-
getPartitioningAttributeConfigs
Get Partition Attribute configs used for creation ofAttributePartitioningStrategy- Returns:
- list of partitioning attribute configs
-
setPartitioningAttributeConfigs
public MapConfig setPartitioningAttributeConfigs(List<PartitioningAttributeConfig> partitioningAttributeConfigs) -
getUserCodeNamespace
Retrieve the User Code Deployment Namespace to be used forClassLoaderawareness during operations related to the structure associated with this configuration.- Specified by:
getUserCodeNamespacein interfaceUserCodeNamespaceAwareConfig<MapConfig>- Returns:
- Namespace Name for use with the
UserCodeNamespaceService, ornullif there is no User Code Namespace to associate with.
-
setUserCodeNamespace
Associates the provided Namespace Name with this structure forClassLoaderawareness.The behaviour of setting this to
nullis outlined in the documentation forUserCodeNamespaceAwareConfig.DEFAULT_NAMESPACE.- Specified by:
setUserCodeNamespacein interfaceUserCodeNamespaceAwareConfig<MapConfig>- Parameters:
userCodeNamespace- The ID of the Namespace to associate with this structure.- Returns:
- the updated
MapConfiginstance - Since:
- 5.4
-
equals
-
hashCode
public final int hashCode() -
toString
-
getFactoryId
public int getFactoryId()Description copied from interface:IdentifiedDataSerializableReturns DataSerializableFactory factory ID for this class.- Specified by:
getFactoryIdin interfaceIdentifiedDataSerializable- Returns:
- factory ID
-
getClassId
public int getClassId()Description copied from interface:IdentifiedDataSerializableReturns type identifier for this class. It should be unique per DataSerializableFactory.- Specified by:
getClassIdin interfaceIdentifiedDataSerializable- Returns:
- type ID
-
writeData
Description copied from interface:DataSerializableWrites object fields to output stream- Specified by:
writeDatain interfaceDataSerializable- Parameters:
out- output- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the output stream has been closed.
-
readData
Description copied from interface:DataSerializableReads fields from the input stream- Specified by:
readDatain interfaceDataSerializable- Parameters:
in- input- Throws:
IOException- if an I/O error occurs. In particular, anIOExceptionmay be thrown if the input stream has been closed.
-
setDataPersistenceConfig(DataPersistenceConfig)