Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Failed chunks should move offset backwards
[controller.git]
/
opendaylight
/
md-sal
/
sal-akka-raft
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
cluster
/
raft
/
behaviors
/
LeaderInstallSnapshotState.java
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 18881ecd4e69a85ebffc9394101310caac51f3b1..758345214841ba62ab41af0827427a505562198f 100644
(file)
--- 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
@@
-74,8
+74,12
@@
public final class LeaderInstallSnapshotState implements AutoCloseable {
}
int incrementOffset() {
}
int incrementOffset() {
+ // if first chunk was retried, reset offset back to initial 0
+ if (offset == -1) {
+ offset = 0;
+ }
if (replyStatus) {
if (replyStatus) {
- // if prev chunk failed, we would want to sen
t
the same chunk again
+ // if prev chunk failed, we would want to sen
d
the same chunk again
offset = offset + snapshotChunkSize;
}
return offset;
offset = offset + snapshotChunkSize;
}
return offset;
@@
-83,7
+87,7
@@
public final class LeaderInstallSnapshotState implements AutoCloseable {
int incrementChunkIndex() {
if (replyStatus) {
int incrementChunkIndex() {
if (replyStatus) {
- // if prev chunk failed, we would want to sen
t
the same chunk again
+ // if prev chunk failed, we would want to sen
d
the same chunk again
chunkIndex = chunkIndex + 1;
}
return chunkIndex;
chunkIndex = chunkIndex + 1;
}
return chunkIndex;
@@
-126,15
+130,17
@@
public final class LeaderInstallSnapshotState implements AutoCloseable {
replyStatus = true;
lastChunkHashCode = nextChunkHashCode;
} else {
replyStatus = true;
lastChunkHashCode = nextChunkHashCode;
} else {
- // if the chunk sent was failure
-
replyReceivedForOffset = o
ffset;
+ // if the chunk sent was failure
, revert offset to previous so we can retry
+
offset = replyReceivedForO
ffset;
replyStatus = false;
}
}
byte[] getNextChunk() throws IOException {
replyStatus = false;
}
}
byte[] getNextChunk() throws IOException {
+ // increment offset to indicate next chunk is in flight, canSendNextChunk() wont let us hit this again until,
+ // markSendStatus() is called with either success or failure
+ int start = incrementOffset();
if (replyStatus || currentChunk == null) {
if (replyStatus || currentChunk == null) {
- int start = incrementOffset();
int size = snapshotChunkSize;
if (snapshotChunkSize > snapshotSize) {
size = (int) snapshotSize;
int size = snapshotChunkSize;
if (snapshotChunkSize > snapshotSize) {
size = (int) snapshotSize;