Class PersistenceConfig

java.lang.Object
com.hazelcast.config.PersistenceConfig

public class PersistenceConfig extends Object
Configures the Persistence stores.

Persistence stores are used to hold copy of in-memory data in disk to be able to restart very fast without needing to load data from a central storage.

PersistenceConfig configures whether persistence is enabled, where disk data will be stored, should data be persisted sync or async etc.

Note: If either, but not both, persistence (PersistenceConfig) or hot-restart-persistence (HotRestartPersistenceConfig) is enabled, Hazelcast will use the configuration of the enabled element. If both are enabled, Hazelcast will use the persistence (PersistenceConfig) configuration. hot-restart-persistence element (and thus HotRestartPersistenceConfig) will be removed in a future release.

  • Field Details

    • PERSISTENCE_BASE_DIR_DEFAULT

      public static final String PERSISTENCE_BASE_DIR_DEFAULT
      Default directory name for the Persistence store's home
      See Also:
    • DEFAULT_VALIDATION_TIMEOUT

      public static final int DEFAULT_VALIDATION_TIMEOUT
      Default validation timeout
      See Also:
    • DEFAULT_DATA_LOAD_TIMEOUT

      public static final int DEFAULT_DATA_LOAD_TIMEOUT
      Default load timeout
      See Also:
    • DEFAULT_PARALLELISM

      public static final int DEFAULT_PARALLELISM
      Default level of parallelism in Persistence. Controls the number of instances operating with a single IO thread and a single GC thread.
      See Also:
    • DEFAULT_REBALANCE_DELAY

      public static final int DEFAULT_REBALANCE_DELAY
      See Also:
  • Constructor Details

    • PersistenceConfig

      public PersistenceConfig()
  • Method Details

    • isEnabled

      public boolean isEnabled()
      Returns whether persistence enabled on this member.
      Returns:
      true if persistence enabled, false otherwise
    • setEnabled

      public PersistenceConfig setEnabled(boolean enabled)
      Sets whether persistence is enabled on this member.
      Returns:
      PersistenceConfig
    • getClusterDataRecoveryPolicy

      public PersistenceClusterDataRecoveryPolicy getClusterDataRecoveryPolicy()
      Returns the policy to be used when the cluster is started
      Returns:
      the policy to be used when the cluster is started
    • setClusterDataRecoveryPolicy

      public PersistenceConfig setClusterDataRecoveryPolicy(PersistenceClusterDataRecoveryPolicy clusterDataRecoveryPolicy)
      Sets the policy to be used when the cluster is started
      Parameters:
      clusterDataRecoveryPolicy - the policy to be used when the cluster is started
      Returns:
      PersistenceConfig
    • getBaseDir

      public File getBaseDir()
      Base directory for all Persistence stores. Can be an absolute or relative path to the node startup directory.
    • setBaseDir

      public PersistenceConfig setBaseDir(File baseDir)
      Sets base directory for all Persistence stores. Can be an absolute or relative path to the node startup directory.
      Parameters:
      baseDir - home directory
      Returns:
      PersistenceConfig
    • getBackupDir

      public File getBackupDir()
      Base directory for persistence backups. Each new backup will be created in a separate directory inside this one. Can be an absolute or relative path to the node startup directory.
    • setBackupDir

      public PersistenceConfig setBackupDir(File backupDir)
      Sets base directory for all Hot Restart stores.
      Parameters:
      backupDir - home directory
      Returns:
      PersistenceConfig
    • getParallelism

      public int getParallelism()
      Gets the configured number of Persistence store instance to create for one Hazelcast instance.
    • setParallelism

      public PersistenceConfig setParallelism(int parallelism)
      Sets the number of Persistence store instances to create for one Hazelcast instance.
    • getValidationTimeoutSeconds

      public int getValidationTimeoutSeconds()
      Returns configured validation timeout for restart process.
      Returns:
      validation timeout in seconds
    • setValidationTimeoutSeconds

      public PersistenceConfig setValidationTimeoutSeconds(int validationTimeoutSeconds)
      Sets validation timeout for persistence restart process, includes validating cluster members expected to join and partition table on all cluster.
      Parameters:
      validationTimeoutSeconds - validation timeout in seconds
      Returns:
      PersistenceConfig
    • getDataLoadTimeoutSeconds

      public int getDataLoadTimeoutSeconds()
      Returns configured data load timeout for persistence restart process.
      Returns:
      data load timeout in seconds
    • setDataLoadTimeoutSeconds

      public PersistenceConfig setDataLoadTimeoutSeconds(int dataLoadTimeoutSeconds)
      Sets data load timeout for persistence restart process, all members in the cluster should complete restoring their local data before this timeout.
      Parameters:
      dataLoadTimeoutSeconds - data load timeout in seconds
      Returns:
      PersistenceConfig
    • isAutoRemoveStaleData

      public boolean isAutoRemoveStaleData()
      Returns whether automatic removal of stale Persistence restart data is enabled.
      Returns:
      whether automatically removal of stale data is enabled
    • setAutoRemoveStaleData

      public PersistenceConfig setAutoRemoveStaleData(boolean autoRemoveStaleData)
      Sets whether automatic removal of stale Persistence restart data is enabled.

      When a member terminates or crashes when cluster state is ClusterState.ACTIVE, remaining members redistributes data among themselves and data persisted on terminated member's storage becomes stale. That terminated member cannot rejoin the cluster without removing Persistence data. When auto-removal of stale Persistence data is enabled, while restarting that member, Persistence data is automatically removed, and it joins the cluster as a completely new member. Otherwise, Persistence data should be removed manually.

      Parameters:
      autoRemoveStaleData - true to enable auto-removal of stale data, false otherwise
      Returns:
      PersistenceConfig
    • setEncryptionAtRestConfig

      public PersistenceConfig setEncryptionAtRestConfig(EncryptionAtRestConfig encryptionAtRestConfig)
      Sets the Persistence Encryption at Rest configuration.
      Parameters:
      encryptionAtRestConfig - the Encryption at Rest configuration
      Returns:
      PersistenceConfig
    • getEncryptionAtRestConfig

      public EncryptionAtRestConfig getEncryptionAtRestConfig()
      Returns the Persistence Encryption at Rest configuration.
      Returns:
      the Encryption at Rest configuration
    • getRebalanceDelaySeconds

      public int getRebalanceDelaySeconds()
      Get the configured rebalance delay in seconds.
      Returns:
      the configured rebalance delay in seconds.
      Since:
      5.0
      See Also:
    • setRebalanceDelaySeconds

      public PersistenceConfig setRebalanceDelaySeconds(int rebalanceDelaySeconds)
      Set the rebalance delay in seconds. This is the time to wait before triggering automatic partition rebalancing after a member leaves the cluster unexpectedly. Unexpectedly in this context means that a member leaves the cluster by means other than graceful shutdown: programmatic termination (eg LifecycleService.terminate()), a process crash or network partition. Default is 0, which means rebalancing is triggered immediately. Setting this to a higher value will allow some time for members that are gone to rejoin the cluster. The benefit is that partition rebalancing in this case will be avoided, saving the burden of migrating partition data over the network. Do not use this option if your cluster also stores in-memory data. This option stops the cluster from migrating in-memory data. As a result any data that is not persisted will be lost if the member restarts within the configured delay, including backups. While members are gone, operations on partitions for which the owner is missing may fail immediately or will be retried until the member rejoins or operation timeout is exceeded. Notice that this delay only applies when cluster members leave the cluster; when the cluster is being scaled up and members are being added, partition rebalancing will be triggered immediately (subject to limitations imposed by the current cluster state).
      Parameters:
      rebalanceDelaySeconds - the desired non-negative rebalance delay in seconds.
      Returns:
      PersistenceConfig
      Since:
      5.0
    • 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