Class MapConfig

java.lang.Object
com.hazelcast.config.MapConfig
All Implemented Interfaces:
NamedConfig, DataSerializable, IdentifiedDataSerializable

public class MapConfig
extends Object
implements IdentifiedDataSerializable, NamedConfig
Contains the configuration for an IMap.
  • Field Details

    • MIN_BACKUP_COUNT

      public static final int MIN_BACKUP_COUNT
      The minimum number of backups
      See Also:
      Constant Field Values
    • DEFAULT_BACKUP_COUNT

      public static final int DEFAULT_BACKUP_COUNT
      The default number of backups
      See Also:
      Constant Field Values
    • MAX_BACKUP_COUNT

      public static final int MAX_BACKUP_COUNT
      The maximum number of backups
      See Also:
      Constant Field Values
    • DEFAULT_TTL_SECONDS

      public static final int DEFAULT_TTL_SECONDS
      The number of default Time to Live in seconds.
      See Also:
      Constant Field Values
    • DEFAULT_MAX_IDLE_SECONDS

      public static final int DEFAULT_MAX_IDLE_SECONDS
      The number of default time to wait eviction in seconds.
      See Also:
      Constant Field Values
    • DEFAULT_IN_MEMORY_FORMAT

      public static final InMemoryFormat DEFAULT_IN_MEMORY_FORMAT
      Default In-Memory format is binary.
    • DEFAULT_CACHED_DESERIALIZED_VALUES

      public static final CacheDeserializedValues DEFAULT_CACHED_DESERIALIZED_VALUES
      We want to cache values only when an index is defined.
    • DEFAULT_METADATA_POLICY

      public static final MetadataPolicy DEFAULT_METADATA_POLICY
      Default metadata policy
    • DEFAULT_STATISTICS_ENABLED

      public static final boolean DEFAULT_STATISTICS_ENABLED
      Default value of whether statistics are enabled or not
      See Also:
      Constant Field Values
    • DEFAULT_MAX_SIZE

      public static final int DEFAULT_MAX_SIZE
      Default max size.
      See Also:
      Constant Field Values
    • DEFAULT_MAX_SIZE_POLICY

      public static final MaxSizePolicy DEFAULT_MAX_SIZE_POLICY
      Default max size policy
    • DEFAULT_EVICTION_POLICY

      public static final EvictionPolicy DEFAULT_EVICTION_POLICY
      Default eviction policy
  • Constructor Details

    • MapConfig

      public MapConfig()
    • MapConfig

      public MapConfig​(String name)
    • MapConfig

      public MapConfig​(MapConfig config)
  • Method Details

    • getName

      public String getName()
      Returns the name of this IMap
      Specified by:
      getName in interface NamedConfig
      Returns:
      the name of the IMap
    • setName

      public MapConfig setName​(String name)
      Sets the name of the IMap
      Specified by:
      setName in interface NamedConfig
      Parameters:
      name - the name to set for this IMap
    • getInMemoryFormat

      public InMemoryFormat getInMemoryFormat()
      Returns the data type that will be used for storing records.
      Returns:
      data type that will be used for storing records
    • setInMemoryFormat

      public MapConfig setInMemoryFormat​(InMemoryFormat inMemoryFormat)
      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 this IMap
      Throws:
      IllegalArgumentException - if inMemoryFormat is null
    • getEvictionConfig

      public EvictionConfig getEvictionConfig()
      Gets the EvictionConfig instance of the eviction configuration for this IMap.
      Returns:
      the EvictionConfig instance of the eviction configuration
    • setEvictionConfig

      public MapConfig setEvictionConfig​(EvictionConfig evictionConfig)
      Sets the EvictionConfig instance for eviction configuration for this IMap.
      Parameters:
      evictionConfig - the EvictionConfig instance to set for the eviction configuration
      Returns:
      current map config instance
    • getBackupCount

      public int getBackupCount()
      Returns the backupCount for this IMap
      Returns:
      the backupCount for this IMap
      See Also:
      getAsyncBackupCount()
    • setBackupCount

      public MapConfig setBackupCount​(int backupCount)
      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 this IMap
      See Also:
      setAsyncBackupCount(int)
    • getAsyncBackupCount

      public int getAsyncBackupCount()
      Returns the asynchronous backup count for this IMap.
      Returns:
      the asynchronous backup count
      See Also:
      setBackupCount(int)
    • setAsyncBackupCount

      public MapConfig setAsyncBackupCount​(int asyncBackupCount)
      Sets the number of asynchronous backups. 0 means no backups.
      Parameters:
      asyncBackupCount - the number of asynchronous synchronous backups to set
      Returns:
      the updated CacheConfig
      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:
      setBackupCount(int), getAsyncBackupCount()
    • 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

      public MapConfig setTimeToLiveSeconds​(int timeToLiveSeconds)
      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

      public MapConfig setMaxIdleSeconds​(int maxIdleSeconds)
      Maximum number of seconds for each entry to stay idle in the map. Entries that are idle (not touched) for more than maxIdleSeconds will get automatically evicted from the map. Entry is touched if get(), getAll(), put() or containsKey() is called. Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0. 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

      public MapStoreConfig getMapStoreConfig()
      Returns the map store configuration
      Returns:
      the mapStoreConfig (map store configuration)
    • setMapStoreConfig

      public MapConfig setMapStoreConfig​(MapStoreConfig mapStoreConfig)
      Sets the map store configuration
      Parameters:
      mapStoreConfig - the mapStoreConfig (map store configuration) to set
    • getNearCacheConfig

      public NearCacheConfig getNearCacheConfig()
      Returns the Near Cache configuration
      Returns:
      the Near Cache configuration
    • setNearCacheConfig

      public MapConfig setNearCacheConfig​(NearCacheConfig nearCacheConfig)
      Sets the Near Cache configuration
      Parameters:
      nearCacheConfig - the Near Cache configuration
      Returns:
      the updated map configuration
    • getMergePolicyConfig

      public MergePolicyConfig getMergePolicyConfig()
      Gets the MergePolicyConfig for this map.
      Returns:
      the MergePolicyConfig for this map
    • setMergePolicyConfig

      public MapConfig setMergePolicyConfig​(MergePolicyConfig mergePolicyConfig)
      Sets the MergePolicyConfig for this map.
      Returns:
      the updated map configuration
    • isStatisticsEnabled

      public boolean isStatisticsEnabled()
      Checks if statistics are enabled for this map.
      Returns:
      true if statistics are enabled, false otherwise
    • setStatisticsEnabled

      public MapConfig setStatisticsEnabled​(boolean statisticsEnabled)
      Sets statistics to enabled or disabled for this map.
      Parameters:
      statisticsEnabled - true to enable map statistics, false to disable
      Returns:
      the current map config instance
    • isReadBackupData

      public boolean isReadBackupData()
      Checks if read-backup-data (reading local backup entries) is enabled for this map.
      Returns:
      true if read-backup-data is enabled, false otherwise
    • setReadBackupData

      public MapConfig setReadBackupData​(boolean readBackupData)
      Sets read-backup-data (reading local backup entries) for this map.
      Parameters:
      readBackupData - true to enable read-backup-data, false to disable
      Returns:
      the current map config instance
    • getWanReplicationRef

      public WanReplicationRef getWanReplicationRef()
      Gets the WAN target replication reference.
      Returns:
      the WAN target replication reference
    • setWanReplicationRef

      public MapConfig setWanReplicationRef​(WanReplicationRef wanReplicationRef)
      Sets the WAN target replication reference.
      Parameters:
      wanReplicationRef - the WAN target replication reference
      Returns:
      the current map config instance
    • addEntryListenerConfig

      public MapConfig addEntryListenerConfig​(EntryListenerConfig listenerConfig)
    • getEntryListenerConfigs

      public List<EntryListenerConfig> getEntryListenerConfigs()
    • setEntryListenerConfigs

      public MapConfig setEntryListenerConfigs​(List<EntryListenerConfig> listenerConfigs)
    • addMapPartitionLostListenerConfig

      public MapConfig addMapPartitionLostListenerConfig​(MapPartitionLostListenerConfig listenerConfig)
    • getPartitionLostListenerConfigs

      public List<MapPartitionLostListenerConfig> getPartitionLostListenerConfigs()
    • setPartitionLostListenerConfigs

      public MapConfig setPartitionLostListenerConfigs​(List<MapPartitionLostListenerConfig> listenerConfigs)
    • addIndexConfig

      public MapConfig addIndexConfig​(IndexConfig indexConfig)
    • getIndexConfigs

      public List<IndexConfig> getIndexConfigs()
    • setIndexConfigs

      public MapConfig setIndexConfigs​(List<IndexConfig> indexConfigs)
    • addAttributeConfig

      public MapConfig addAttributeConfig​(AttributeConfig attributeConfig)
    • getAttributeConfigs

      public List<AttributeConfig> getAttributeConfigs()
    • setAttributeConfigs

      public MapConfig setAttributeConfigs​(List<AttributeConfig> attributeConfigs)
    • getMetadataPolicy

      public MetadataPolicy getMetadataPolicy()
      Returns MetadataPolicy for this map.
      Returns:
      MetadataPolicy for this map
    • setMetadataPolicy

      public MapConfig setMetadataPolicy​(MetadataPolicy metadataPolicy)
      Sets the metadata policy. See MetadataPolicy for more information.
      Parameters:
      metadataPolicy - the metadata policy
    • addQueryCacheConfig

      public MapConfig addQueryCacheConfig​(QueryCacheConfig queryCacheConfig)
      Adds a new QueryCacheConfig to this MapConfig.
      Parameters:
      queryCacheConfig - the config to be added
      Returns:
      this MapConfig instance
      Throws:
      IllegalArgumentException - if there is already a QueryCache with the same QueryCacheConfig#name
    • getQueryCacheConfigs

      public List<QueryCacheConfig> getQueryCacheConfigs()
      Returns all QueryCacheConfig instances defined on this MapConfig.
      Returns:
      all QueryCacheConfig instances defined on this MapConfig
    • setQueryCacheConfigs

      public MapConfig setQueryCacheConfigs​(List<QueryCacheConfig> queryCacheConfigs)
      Sets QueryCacheConfig instances to this MapConfig.
      Returns:
      this configuration
    • getPartitioningStrategyConfig

      public PartitioningStrategyConfig getPartitioningStrategyConfig()
    • setPartitioningStrategyConfig

      public MapConfig setPartitioningStrategyConfig​(PartitioningStrategyConfig partitioningStrategyConfig)
    • isNearCacheEnabled

      public boolean isNearCacheEnabled()
      Checks if Near Cache is enabled.
      Returns:
      true if Near Cache is enabled, false otherwise
    • setCacheDeserializedValues

      public MapConfig setCacheDeserializedValues​(CacheDeserializedValues cacheDeserializedValues)
      Configure de-serialized value caching. Default: CacheDeserializedValues.INDEX_ONLY
      Returns:
      this MapConfig instance
      Since:
      3.6
      See Also:
      CacheDeserializedValues
    • getHotRestartConfig

      @Nonnull public HotRestartConfig getHotRestartConfig()
      Gets the HotRestartConfig for this MapConfig
      Returns:
      hot restart config
    • setHotRestartConfig

      public MapConfig setHotRestartConfig​(@Nonnull HotRestartConfig hotRestartConfig)
      Sets the HotRestartConfig for this MapConfig
      Parameters:
      hotRestartConfig - hot restart config
      Returns:
      this MapConfig instance
    • getMerkleTreeConfig

      @Nonnull public MerkleTreeConfig getMerkleTreeConfig()
      Gets the MerkleTreeConfig for this MapConfig
      Returns:
      merkle tree config
    • setMerkleTreeConfig

      public MapConfig setMerkleTreeConfig​(@Nonnull MerkleTreeConfig merkleTreeConfig)
      Sets the MerkleTreeConfig for this MapConfig
      Parameters:
      merkleTreeConfig - merkle tree config
      Returns:
      this MapConfig instance
    • getEventJournalConfig

      @Nonnull public EventJournalConfig getEventJournalConfig()
      Gets the EventJournalConfig for this MapConfig
      Returns:
      event journal config
    • setEventJournalConfig

      public MapConfig setEventJournalConfig​(@Nonnull EventJournalConfig eventJournalConfig)
      Sets the EventJournalConfig for this MapConfig
      Parameters:
      eventJournalConfig - event journal config
      Returns:
      this MapConfig instance
    • getCacheDeserializedValues

      public CacheDeserializedValues getCacheDeserializedValues()
      Get current value cache settings
      Returns:
      current value cache settings
      Since:
      3.6
    • getSplitBrainProtectionName

      public String getSplitBrainProtectionName()
    • setSplitBrainProtectionName

      public MapConfig setSplitBrainProtectionName​(String splitBrainProtectionName)
    • equals

      public final boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getFactoryId

      public int getFactoryId()
      Description copied from interface: IdentifiedDataSerializable
      Returns DataSerializableFactory factory ID for this class.
      Specified by:
      getFactoryId in interface IdentifiedDataSerializable
      Returns:
      factory ID
    • 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 interface IdentifiedDataSerializable
      Returns:
      type ID
    • writeData

      public void writeData​(ObjectDataOutput out) throws IOException
      Description copied from interface: DataSerializable
      Writes object fields to output stream
      Specified by:
      writeData in interface DataSerializable
      Parameters:
      out - output
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
    • readData

      public void readData​(ObjectDataInput in) throws IOException
      Description copied from interface: DataSerializable
      Reads fields from the input stream
      Specified by:
      readData in interface DataSerializable
      Parameters:
      in - input
      Throws:
      IOException - if an I/O error occurs. In particular, an IOException may be thrown if the input stream has been closed.