void replySetConfiguration(Supplier<Collection<CommitInfoProto>> getCommitInfos) { // we allow the pendingRequest to be null in case that the new leader // commits the new configuration while it has not received the retry // request from the client if (pendingSetConf != null) { final RaftClientRequest request = pendingSetConf.getRequest(); LOG.debug("{}: sends success for {}", name, request); // for setConfiguration we do not need to wait for statemachine. send back // reply after it's committed. pendingSetConf.setReply(new RaftClientReply(request, getCommitInfos.get())); pendingSetConf = null; } }
void replySetConfiguration() { // we allow the pendingRequest to be null in case that the new leader // commits the new configuration while it has not received the retry // request from the client if (pendingSetConf != null) { // for setConfiguration we do not need to wait for statemachine. send back // reply after it's committed. pendingSetConf.setReply(new RaftClientReply(pendingSetConf.getRequest(), server.getCommitInfos())); pendingSetConf = null; } }
TransactionContext setNotLeaderException(NotLeaderException nle) { setReply(new RaftClientReply(getRequest(), nle, null)); return getEntry(); }
TransactionContext setNotLeaderException(NotLeaderException nle, Collection<CommitInfoProto> commitInfos) { setReply(new RaftClientReply(getRequest(), nle, commitInfos)); return getEntry(); }
PendingRequest addPendingRequest(long index, RaftClientRequest request, TransactionContext entry) { // externally synced for now Preconditions.assertTrue(request.is(RaftClientRequestProto.TypeCase.WRITE)); if (last != null && !(last.getRequest() instanceof SetConfigurationRequest)) { Preconditions.assertTrue(index == last.getIndex() + 1, () -> "index = " + index + " != last.getIndex() + 1, last=" + last); } return add(index, request, entry); }
boolean replyPendingRequest(long index, RaftClientReply reply) { final PendingRequest pending = pendingRequests.remove(index); if (pending != null) { Preconditions.assertTrue(pending.getIndex() == index); final ReplicationLevel replication = pending.getRequest().getType().getWrite().getReplication(); if (replication == ReplicationLevel.ALL) { if (delayedReplies.delay(pending, reply)) { return false; } } pending.setReply(reply); } return true; }