- LOG.info("{}: Persisting of snapshot done: {}", persistenceId(), snapshot);
-
- long dataThreshold = totalMemory *
- context.getConfigParams().getSnapshotDataThresholdPercentage() / 100;
- boolean dataSizeThresholdExceeded = context.getReplicatedLog().dataSize() > dataThreshold;
-
- boolean logSizeExceededSnapshotBatchCount =
- context.getReplicatedLog().size() >= context.getConfigParams().getSnapshotBatchCount();
-
- if (dataSizeThresholdExceeded || logSizeExceededSnapshotBatchCount) {
- if(LOG.isDebugEnabled()) {
- if(dataSizeThresholdExceeded) {
- LOG.debug("{}: log data size {} exceeds the memory threshold {} - doing snapshotPreCommit with index {}",
- context.getId(), context.getReplicatedLog().dataSize(), dataThreshold,
- captureSnapshot.getLastAppliedIndex());
+ log.info("{}: Persisting of snapshot done: {}", persistenceId(), snapshot);
+
+ final ConfigParams config = context.getConfigParams();
+ final long absoluteThreshold = config.getSnapshotDataThreshold();
+ final long dataThreshold = absoluteThreshold != 0 ? absoluteThreshold * ConfigParams.MEGABYTE
+ : totalMemory * config.getSnapshotDataThresholdPercentage() / 100;
+
+ final boolean dataSizeThresholdExceeded = context.getReplicatedLog().dataSize() > dataThreshold;
+ final boolean logSizeExceededSnapshotBatchCount =
+ context.getReplicatedLog().size() >= config.getSnapshotBatchCount();
+
+ final RaftActorBehavior currentBehavior = context.getCurrentBehavior();
+ if (dataSizeThresholdExceeded || logSizeExceededSnapshotBatchCount || captureSnapshot.isMandatoryTrim()) {
+ if (log.isDebugEnabled()) {
+ if (dataSizeThresholdExceeded) {
+ log.debug("{}: log data size {} exceeds the memory threshold {} - doing snapshotPreCommit "
+ + "with index {}", context.getId(), context.getReplicatedLog().dataSize(),
+ dataThreshold, captureSnapshot.getLastAppliedIndex());
+ } else if (logSizeExceededSnapshotBatchCount) {
+ log.debug("{}: log size {} exceeds the snapshot batch count {} - doing snapshotPreCommit with "
+ + "index {}", context.getId(), context.getReplicatedLog().size(),
+ config.getSnapshotBatchCount(), captureSnapshot.getLastAppliedIndex());