X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FSnapshotManager.java;h=8037fb8d73ce88e6309f6a0f56b6d4fb787e8761;hb=d0f46920468c8e4b67c68bd9058572b2d10d75f1;hp=71803ccf6143387bbf728fa38ec9637b21e5b50d;hpb=bb248f15d352cdd69e53ff7756fcb2c62cdc3eac;p=controller.git diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java index 71803ccf61..8037fb8d73 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/SnapshotManager.java @@ -92,7 +92,7 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean captureWithForcedTrim(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean captureWithForcedTrim(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { return currentState.captureWithForcedTrim(lastLogEntry, replicatedToAllIndex); } @@ -216,7 +216,7 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean captureWithForcedTrim(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean captureWithForcedTrim(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { log.debug("captureWithForcedTrim should not be called in state {}", this); return false; } @@ -265,7 +265,7 @@ public class SnapshotManager implements SnapshotState { //use the term of the temp-min, since we check for isPresent, entry will not be null ReplicatedLogEntry entry = context.getReplicatedLog().get(tempMin); context.getReplicatedLog().snapshotPreCommit(tempMin, entry.getTerm()); - context.getReplicatedLog().snapshotCommit(); + context.getReplicatedLog().snapshotCommit(false); return tempMin; } @@ -291,7 +291,7 @@ public class SnapshotManager implements SnapshotState { @SuppressWarnings("checkstyle:IllegalCatch") private boolean capture(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex, - final String targetFollower, boolean mandatoryTrim) { + final String targetFollower, final boolean mandatoryTrim) { captureSnapshot = newCaptureSnapshot(lastLogEntry, replicatedToAllIndex, mandatoryTrim); OutputStream installSnapshotStream = null; @@ -332,7 +332,7 @@ public class SnapshotManager implements SnapshotState { } @Override - public boolean captureWithForcedTrim(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex) { + public boolean captureWithForcedTrim(final ReplicatedLogEntry lastLogEntry, final long replicatedToAllIndex) { return capture(lastLogEntry, replicatedToAllIndex, null, true); } @@ -379,11 +379,14 @@ public class SnapshotManager implements SnapshotState { log.info("{}: Persisting of snapshot done: {}", persistenceId(), snapshot); - long dataThreshold = totalMemory * context.getConfigParams().getSnapshotDataThresholdPercentage() / 100; - boolean dataSizeThresholdExceeded = context.getReplicatedLog().dataSize() > dataThreshold; + final ConfigParams config = context.getConfigParams(); + final long absoluteThreshold = config.getSnapshotDataThreshold(); + final long dataThreshold = absoluteThreshold != 0 ? absoluteThreshold * ConfigParams.MEGABYTE + : totalMemory * config.getSnapshotDataThresholdPercentage() / 100; - boolean logSizeExceededSnapshotBatchCount = - context.getReplicatedLog().size() >= context.getConfigParams().getSnapshotBatchCount(); + 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()) { @@ -395,10 +398,9 @@ public class SnapshotManager implements SnapshotState { } else if (logSizeExceededSnapshotBatchCount) { log.debug("{}: log size {} exceeds the snapshot batch count {} - doing snapshotPreCommit with " + "index {}", context.getId(), context.getReplicatedLog().size(), - context.getConfigParams().getSnapshotBatchCount(), - captureSnapshot.getLastAppliedIndex()); + config.getSnapshotBatchCount(), captureSnapshot.getLastAppliedIndex()); } else { - log.debug("{}: user triggered or root overwrite snapshot encountered, trimming log up to" + log.debug("{}: user triggered or root overwrite snapshot encountered, trimming log up to " + "last applied index {}", context.getId(), captureSnapshot.getLastAppliedIndex()); } }