Class CacheConfig<K,​V>

  • Type Parameters:
    K - the key type
    V - 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 the ICache.
    See Also:
    Serialized Form
    • 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 this ICache.
        Returns:
        the name of this ICache
      • setName

        public CacheConfig<K,​V> setName​(java.lang.String name)
        Sets the name of this ICache.
        Parameters:
        name - the name to set for this ICache
        Returns:
        the current cache config instance
      • getManagerPrefix

        public java.lang.String getManagerPrefix()
        Gets the manager prefix of the ICache, 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 the ICache.
        Parameters:
        managerPrefix - the manager prefix to set for this ICache
        Returns:
        the current cache config instance
      • getUriString

        public java.lang.String getUriString()
        Gets the URI string which is the global identifier for this ICache.
        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 the ICache.
        Parameters:
        uriString - the URI string to set for this ICache
        Returns:
        the current cache config instance
      • getNameWithPrefix

        public java.lang.String getNameWithPrefix()
        Gets the full name of the ICache, 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 this ICache.
        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 this ICache
        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 this ICache.
        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 this ICache.
        Parameters:
        asyncBackupCount - the number of asynchronous backups to set for this ICache
        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
      • setEvictionConfig

        public CacheConfig<K,​V> setEvictionConfig​(EvictionConfig evictionConfig)
        Sets the EvictionConfig instance for eviction configuration for this ICache.
        Parameters:
        evictionConfig - the EvictionConfig instance to set for the eviction configuration
        Returns:
        the current cache config instance
      • 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 this ICache. 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 is null
      • 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
      • getMerkleTreeConfig

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

        public void setMerkleTreeConfig​(MerkleTreeConfig merkleTreeConfig)
        Sets the MerkleTreeConfig for this CacheConfig
        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 is true, 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 interface DataSerializable
        Parameters:
        out - output
        Throws:
        java.io.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 java.io.IOException
        Description copied from interface: DataSerializable
        Reads fields from the input stream
        Specified by:
        readData in interface DataSerializable
        Parameters:
        in - input
        Throws:
        java.io.IOException - if an I/O error occurs. In particular, an IOException may be thrown if the input stream has been closed.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 given target object whose type extends CacheConfig.
        Type Parameters:
        T - the target object type
        Parameters:
        target - the target object to which this configuration will be copied
        resolved - when true, it is assumed that this cacheConfig's key-value types have already been or will be resolved to loaded classes and the actual keyType and valueType will be copied. Otherwise, this configuration's keyClassName and valueClassName will be copied to the target config, to be resolved at a later time.
        Returns:
        the target config