private void onNextImpl(AppendEntriesReplyProto reply) { // update the last rpc time follower.updateLastRpcResponseTime(); if (!firstResponseReceived) { firstResponseReceived = true; } switch (reply.getResult()) { case SUCCESS: onSuccess(reply); break; case NOT_LEADER: onNotLeader(reply); break; case INCONSISTENCY: onInconsistency(reply); break; default: break; } notifyAppend(); }
@Override public void onNext(InstallSnapshotReplyProto reply) { LOG.debug("{} received {} response from {}", server.getId(), (!firstResponseReceived ? "the first" : "a"), follower.getPeer()); // update the last rpc time follower.updateLastRpcResponseTime(); if (!firstResponseReceived) { firstResponseReceived = true; } switch (reply.getResult()) { case SUCCESS: removePending(reply); break; case NOT_LEADER: checkResponseTerm(reply.getTerm()); break; case UNRECOGNIZED: break; } }
private InstallSnapshotReplyProto installSnapshot(SnapshotInfo snapshot) throws InterruptedIOException { String requestId = UUID.randomUUID().toString(); InstallSnapshotReplyProto reply = null; try { for (InstallSnapshotRequestProto request : new SnapshotRequestIter(snapshot, requestId)) { follower.updateLastRpcSendTime(); reply = server.getServerRpc().installSnapshot(request); follower.updateLastRpcResponseTime(); if (!reply.getServerReply().getSuccess()) { return reply; } } } catch (InterruptedIOException iioe) { throw iioe; } catch (Exception ioe) { LOG.warn("{}: Failed to installSnapshot {}: {}", this, snapshot, ioe); handleException(ioe); return null; } if (reply != null) { follower.setSnapshotIndex(snapshot.getTermIndex().getIndex()); LOG.info("{}: install snapshot-{} successfully on follower {}", server.getId(), snapshot.getTermIndex().getIndex(), follower.getPeer()); } return reply; }
private InstallSnapshotReplyProto installSnapshot(SnapshotInfo snapshot) throws InterruptedIOException { String requestId = UUID.randomUUID().toString(); InstallSnapshotReplyProto reply = null; try { for (InstallSnapshotRequestProto request : new SnapshotRequestIter(snapshot, requestId)) { follower.updateLastRpcSendTime(); reply = server.getServerRpc().installSnapshot(request); follower.updateLastRpcResponseTime(); if (!reply.getServerReply().getSuccess()) { return reply; } } } catch (InterruptedIOException iioe) { throw iioe; } catch (Exception ioe) { LOG.warn("{}: Failed to installSnapshot {}: {}", this, snapshot, ioe); handleException(ioe); return null; } if (reply != null) { follower.updateMatchIndex(snapshot.getTermIndex().getIndex()); follower.updateNextIndex(snapshot.getTermIndex().getIndex() + 1); LOG.info("{}: install snapshot-{} successfully on follower {}", server.getId(), snapshot.getTermIndex().getIndex(), follower.getPeer()); } return reply; }