public class PersistenceConfig extends Object
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.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DATA_LOAD_TIMEOUT
Default load timeout
|
static int |
DEFAULT_PARALLELISM
Default level of parallelism in Persistence.
|
static int |
DEFAULT_REBALANCE_DELAY |
static int |
DEFAULT_VALIDATION_TIMEOUT
Default validation timeout
|
static String |
PERSISTENCE_BASE_DIR_DEFAULT
Default directory name for the Persistence store's home
|
Constructor and Description |
---|
PersistenceConfig() |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
File |
getBackupDir()
Base directory for persistence backups.
|
File |
getBaseDir()
Base directory for all Persistence stores.
|
PersistenceClusterDataRecoveryPolicy |
getClusterDataRecoveryPolicy()
Returns the policy to be used when the cluster is started
|
int |
getDataLoadTimeoutSeconds()
Returns configured data load timeout for persistence restart process.
|
EncryptionAtRestConfig |
getEncryptionAtRestConfig()
Returns the Persistence Encryption at Rest configuration.
|
int |
getParallelism()
Gets the configured number of Persistence store instance to create for one Hazelcast instance.
|
int |
getRebalanceDelaySeconds()
Get the configured rebalance delay in seconds.
|
int |
getValidationTimeoutSeconds()
Returns configured validation timeout for restart process.
|
int |
hashCode() |
boolean |
isAutoRemoveStaleData()
Returns whether or not automatic removal of stale Persistence restart data is enabled.
|
boolean |
isEnabled()
Returns whether persistence enabled on this member.
|
PersistenceConfig |
setAutoRemoveStaleData(boolean autoRemoveStaleData)
Sets whether or not automatic removal of stale Persistence restart data is enabled.
|
PersistenceConfig |
setBackupDir(File backupDir)
Sets base directory for all Hot Restart stores.
|
PersistenceConfig |
setBaseDir(File baseDir)
Sets base directory for all Persistence stores.
|
PersistenceConfig |
setClusterDataRecoveryPolicy(PersistenceClusterDataRecoveryPolicy clusterDataRecoveryPolicy)
Sets the policy to be used when the cluster is started
|
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.
|
PersistenceConfig |
setEnabled(boolean enabled)
Sets whether persistence is enabled on this member.
|
PersistenceConfig |
setEncryptionAtRestConfig(EncryptionAtRestConfig encryptionAtRestConfig)
Sets the Persistence Encryption at Rest configuration.
|
PersistenceConfig |
setParallelism(int parallelism)
Sets the number of Persistence store instances to create for one Hazelcast instance.
|
PersistenceConfig |
setRebalanceDelaySeconds(int rebalanceDelaySeconds)
Set the rebalance delay in seconds.
|
PersistenceConfig |
setValidationTimeoutSeconds(int validationTimeoutSeconds)
Sets validation timeout for persistence restart process, includes validating
cluster members expected to join and partition table on all cluster.
|
String |
toString() |
public static final String PERSISTENCE_BASE_DIR_DEFAULT
public static final int DEFAULT_VALIDATION_TIMEOUT
public static final int DEFAULT_DATA_LOAD_TIMEOUT
public static final int DEFAULT_PARALLELISM
public static final int DEFAULT_REBALANCE_DELAY
public boolean isEnabled()
public PersistenceConfig setEnabled(boolean enabled)
public PersistenceClusterDataRecoveryPolicy getClusterDataRecoveryPolicy()
public PersistenceConfig setClusterDataRecoveryPolicy(PersistenceClusterDataRecoveryPolicy clusterDataRecoveryPolicy)
clusterDataRecoveryPolicy
- the policy to be used when the cluster is startedpublic File getBaseDir()
public PersistenceConfig setBaseDir(File baseDir)
baseDir
- home directorypublic File getBackupDir()
public PersistenceConfig setBackupDir(File backupDir)
backupDir
- home directorypublic int getParallelism()
public PersistenceConfig setParallelism(int parallelism)
public int getValidationTimeoutSeconds()
public PersistenceConfig setValidationTimeoutSeconds(int validationTimeoutSeconds)
validationTimeoutSeconds
- validation timeout in secondspublic int getDataLoadTimeoutSeconds()
public PersistenceConfig setDataLoadTimeoutSeconds(int dataLoadTimeoutSeconds)
dataLoadTimeoutSeconds
- data load timeout in secondspublic boolean isAutoRemoveStaleData()
public PersistenceConfig setAutoRemoveStaleData(boolean autoRemoveStaleData)
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.
autoRemoveStaleData
- true
to enable auto-removal of stale data, false
otherwisepublic PersistenceConfig setEncryptionAtRestConfig(EncryptionAtRestConfig encryptionAtRestConfig)
encryptionAtRestConfig
- the Encryption at Rest configurationpublic EncryptionAtRestConfig getEncryptionAtRestConfig()
public int getRebalanceDelaySeconds()
setRebalanceDelaySeconds(int)
public PersistenceConfig setRebalanceDelaySeconds(int rebalanceDelaySeconds)
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).rebalanceDelaySeconds
- the desired non-negative rebalance delay in seconds.Copyright © 2021 Hazelcast, Inc.. All rights reserved.