Class PersistenceConfig
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 Summary
Modifier and TypeFieldDescriptionstatic final int
Default load timeoutstatic final int
Default level of parallelism in Persistence.static final int
static final int
Default validation timeoutstatic final String
Default directory name for the Persistence store's home -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Base directory for persistence backups.Base directory for all Persistence stores.Returns the policy to be used when the cluster is startedint
Returns configured data load timeout for persistence restart process.Returns the Persistence Encryption at Rest configuration.int
Gets the configured number of Persistence store instance to create for one Hazelcast instance.int
Get the configured rebalance delay in seconds.int
Returns configured validation timeout for restart process.final int
hashCode()
boolean
Returns whether or not automatic removal of stale Persistence restart data is enabled.boolean
Returns whether persistence enabled on this member.setAutoRemoveStaleData
(boolean autoRemoveStaleData) Sets whether or not automatic removal of stale Persistence restart data is enabled.setBackupDir
(File backupDir) Sets base directory for all Hot Restart stores.setBaseDir
(File baseDir) Sets base directory for all Persistence stores.setClusterDataRecoveryPolicy
(PersistenceClusterDataRecoveryPolicy clusterDataRecoveryPolicy) Sets the policy to be used when the cluster is startedsetDataLoadTimeoutSeconds
(int dataLoadTimeoutSeconds) Sets data load timeout for persistence restart process, all members in the cluster should complete restoring their local data before this timeout.setEnabled
(boolean enabled) Sets whether persistence is enabled on this member.setEncryptionAtRestConfig
(EncryptionAtRestConfig encryptionAtRestConfig) Sets the Persistence Encryption at Rest configuration.setParallelism
(int parallelism) Sets the number of Persistence store instances to create for one Hazelcast instance.setRebalanceDelaySeconds
(int rebalanceDelaySeconds) Set the rebalance delay in seconds.setValidationTimeoutSeconds
(int validationTimeoutSeconds) Sets validation timeout for persistence restart process, includes validating cluster members expected to join and partition table on all cluster.toString()
-
Field Details
-
PERSISTENCE_BASE_DIR_DEFAULT
Default directory name for the Persistence store's home- See Also:
-
DEFAULT_VALIDATION_TIMEOUT
public static final int DEFAULT_VALIDATION_TIMEOUTDefault validation timeout- See Also:
-
DEFAULT_DATA_LOAD_TIMEOUT
public static final int DEFAULT_DATA_LOAD_TIMEOUTDefault load timeout- See Also:
-
DEFAULT_PARALLELISM
public static final int DEFAULT_PARALLELISMDefault 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
Sets whether persistence is enabled on this member.- Returns:
- PersistenceConfig
-
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
Base directory for all Persistence stores. Can be an absolute or relative path to the node startup directory. -
setBaseDir
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
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
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
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
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
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 or not automatic removal of stale Persistence restart data is enabled.- Returns:
- whether or not automatically removal of stale data is enabled
-
setAutoRemoveStaleData
Sets whether or not 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
Sets the Persistence Encryption at Rest configuration.- Parameters:
encryptionAtRestConfig
- the Encryption at Rest configuration- Returns:
- PersistenceConfig
-
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
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 (egLifecycleService.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
-
hashCode
public final int hashCode() -
toString
-