private boolean containPrevious(TermIndex previous) { if (LOG.isTraceEnabled()) { LOG.trace("{}: prev:{}, latestSnapshot:{}, latestInstalledSnapshot:{}", getId(), previous, state.getLatestSnapshot(), state.getLatestInstalledSnapshot()); } return state.getLog().contains(previous) || (state.getLatestSnapshot() != null && state.getLatestSnapshot().getTermIndex().equals(previous)) || (state.getLatestInstalledSnapshot() != null) && state.getLatestInstalledSnapshot().equals(previous); }
private boolean containPrevious(TermIndex previous) { if (LOG.isTraceEnabled()) { LOG.trace("{}: prev:{}, latestSnapshot:{}, latestInstalledSnapshot:{}", getId(), previous, state.getLatestSnapshot(), state.getLatestInstalledSnapshot()); } return state.getLog().contains(previous) || (state.getLatestSnapshot() != null && state.getLatestSnapshot().getTermIndex().equals(previous)) || (state.getLatestInstalledSnapshot() != null) && state.getLatestInstalledSnapshot().equals(previous); }
protected SnapshotInfo shouldInstallSnapshot() { final long logStartIndex = raftLog.getStartIndex(); // we should install snapshot if the follower needs to catch up and: // 1. there is no local log entry but there is snapshot // 2. or the follower's next index is smaller than the log start index if (follower.getNextIndex() < raftLog.getNextIndex()) { SnapshotInfo snapshot = server.getState().getLatestSnapshot(); if (follower.getNextIndex() < logStartIndex || (logStartIndex == INVALID_LOG_INDEX && snapshot != null)) { return snapshot; } } return null; }
protected SnapshotInfo shouldInstallSnapshot() { final long logStartIndex = raftLog.getStartIndex(); // we should install snapshot if the follower needs to catch up and: // 1. there is no local log entry but there is snapshot // 2. or the follower's next index is smaller than the log start index if (follower.getNextIndex() < raftLog.getNextIndex()) { SnapshotInfo snapshot = server.getState().getLatestSnapshot(); if (follower.getNextIndex() < logStartIndex || (logStartIndex == INVALID_LOG_INDEX && snapshot != null)) { return snapshot; } } return null; }
private TermIndex getPrevious() { TermIndex previous = raftLog.getTermIndex(follower.getNextIndex() - 1); if (previous == null) { // if previous is null, nextIndex must be equal to the log start // index (otherwise we will install snapshot). Preconditions.assertTrue(follower.getNextIndex() == raftLog.getStartIndex(), "%s: follower's next index %s, local log start index %s", this, follower.getNextIndex(), raftLog.getStartIndex()); SnapshotInfo snapshot = server.getState().getLatestSnapshot(); previous = snapshot == null ? null : snapshot.getTermIndex(); } return previous; }
private TermIndex getPrevious() { TermIndex previous = raftLog.getTermIndex(follower.getNextIndex() - 1); if (previous == null) { // if previous is null, nextIndex must be equal to the log start // index (otherwise we will install snapshot). Preconditions.assertTrue(follower.getNextIndex() == raftLog.getStartIndex(), "%s: follower's next index %s, local log start index %s", this, follower.getNextIndex(), raftLog.getStartIndex()); SnapshotInfo snapshot = server.getState().getLatestSnapshot(); previous = snapshot == null ? null : snapshot.getTermIndex(); } return previous; }
if (lastEntry == null) { SnapshotInfo snapshot = state.getLatestSnapshot(); if (snapshot != null) { lastEntry = snapshot.getTermIndex();
if (lastEntry == null) { SnapshotInfo snapshot = state.getLatestSnapshot(); if (snapshot != null) { lastEntry = snapshot.getTermIndex();