X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2Fbehaviors%2FLeaderInstallSnapshotState.java;h=81c3eff45180b70b6c5001563bfba394dbc87c4e;hp=100c99bb5eff1f53a0826eae8b464a4746d2c267;hb=95d3c7975a423951dcbdecfbfa4cb6b7a23591cc;hpb=d3e310b940b60f6590f0e94a576aece95a055942 diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderInstallSnapshotState.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderInstallSnapshotState.java index 100c99bb5e..81c3eff451 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderInstallSnapshotState.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderInstallSnapshotState.java @@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory; /** * Encapsulates the leader state and logic for sending snapshot chunks to a follower. */ -class LeaderInstallSnapshotState { +public final class LeaderInstallSnapshotState { private static final Logger LOG = LoggerFactory.getLogger(LeaderInstallSnapshotState.class); // The index of the first chunk that is sent when installing a snapshot @@ -40,12 +40,12 @@ class LeaderInstallSnapshotState { private int lastChunkHashCode = INITIAL_LAST_CHUNK_HASH_CODE; private int nextChunkHashCode = INITIAL_LAST_CHUNK_HASH_CODE; - public LeaderInstallSnapshotState(ByteString snapshotBytes, int snapshotChunkSize, String logName) { + LeaderInstallSnapshotState(ByteString snapshotBytes, int snapshotChunkSize, String logName) { this.snapshotChunkSize = snapshotChunkSize; this.snapshotBytes = snapshotBytes; this.logName = logName; int size = snapshotBytes.size(); - totalChunks = (size / snapshotChunkSize) + + totalChunks = size / snapshotChunkSize + (size % snapshotChunkSize > 0 ? 1 : 0); LOG.debug("{}: Snapshot {} bytes, total chunks to send: {}", logName, size, totalChunks); @@ -110,7 +110,7 @@ class LeaderInstallSnapshotState { int size = snapshotChunkSize; if (snapshotChunkSize > snapshotLength) { size = snapshotLength; - } else if ((start + snapshotChunkSize) > snapshotLength) { + } else if (start + snapshotChunkSize > snapshotLength) { size = snapshotLength - start; }