Skip to content

Commit

Permalink
Fix single node with error response when batch append (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
TerrellChen authored Nov 8, 2020
1 parent 9a3e83d commit 4eb9b64
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
public class BatchAppendFuture<T> extends AppendFuture<T> {
private long[] positions;

public BatchAppendFuture() {

}

public BatchAppendFuture(long timeOutMs) {
super(timeOutMs);
}
Expand All @@ -30,4 +34,11 @@ public long[] getPositions() {
public void setPositions(long[] positions) {
this.positions = positions;
}

public static <T> BatchAppendFuture<T> newCompletedFuture(long pos, T value) {
BatchAppendFuture<T> future = new BatchAppendFuture<T>();
future.setPos(pos);
future.complete(value);
return future;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ public CompletableFuture<AppendEntryResponse> waitAck(DLedgerEntry entry, boolea
response.setIndex(entry.getIndex());
response.setTerm(entry.getTerm());
response.setPos(entry.getPos());
if (isBatchWait) {
return BatchAppendFuture.newCompletedFuture(entry.getPos(), response);
}
return AppendFuture.newCompletedFuture(entry.getPos(), response);
} else {
checkTermForPendingMap(entry.getTerm(), "waitAck");
Expand Down

0 comments on commit 4eb9b64

Please sign in to comment.