SzyWilliam commented on code in PR #735:
URL: https://github.com/apache/ratis/pull/735#discussion_r963014913
##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ReadRequests.java:
##########
@@ -129,28 +142,75 @@ synchronized AppendEntriesListener add(long commitIndex,
Function<Long, AppendEn
synchronized void onAppendEntriesReply(AppendEntriesReplyProto reply,
Predicate<Predicate<RaftPeerId>>
hasMajority) {
final long callId = reply.getServerReply().getCallId();
- for (;;) {
- final Map.Entry<Long, AppendEntriesListener> first =
sorted.firstEntry();
- if (first == null || first.getKey() > callId) {
+ for (Map.Entry<Long, AppendEntriesListener> entry : sorted.entrySet()) {
+ if (entry.getKey() > callId) {
return;
}
- final AppendEntriesListener listener = first.getValue();
+ final AppendEntriesListener listener = entry.getValue();
if (listener == null) {
continue;
}
if (listener.receive(reply, hasMajority)) {
- final AppendEntriesListener removed = sorted.remove(callId);
+ final AppendEntriesListener removed = sorted.remove(entry.getKey());
Preconditions.assertSame(listener, removed, "AppendEntriesListener");
ackedCommitIndex.updateToMax(listener.commitIndex, s ->
LOG.debug("{}: {}", ReadRequests.this, s));
}
}
}
}
+ static class ReadIndexQueue {
+ private final TimeoutScheduler scheduler = TimeoutScheduler.getInstance();
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]