/** * Returns the latest contingous index saved in the storage layer. * For a leader, this index < commit index. For other roles, this will be < commit index. */ public int getSavedIndex() throws InterruptedException { return cmember.getSavedIndex(); }
/** * The results are valid only if the local member is the leader. */ public boolean isLogUpToDate() throws Exception { if (peer == null) { return cmember.sentRid.index == cmember.getSavedIndex(); } else { return cmember.sentRid.index == peer.matchIndex; } }
/** * Returns the last saved index for this cluster. */ public int getLastSavedIndex() throws Exception { return cmember.getSavedIndex(); }
/** * The results are valid only if the local member is the leader. */ public boolean isLogUpToDate() throws InterruptedException { if (peer == null) { // Local member return cmember.sentRid.index > 0 && cmember.sentRid.index == cmember.getSavedIndex(); } else { // Remote member return cmember.sentRid.index > 0 && cmember.sentRid.index == peer.matchIndex; } }
/** * Returns the last saved index for this shard. Waits until the storage is settled if necessary. */ public int getLastSavedIndex() throws InterruptedException { return cmember.getSavedIndex(); }
/** * Returns the current status of the slave. * * @return null if the member is not in slave mode. */ public Member.SlaveStatus getSlaveStatus() throws InterruptedException { Member.SlaveStatus ss = new Member.SlaveStatus(); ss.memberId = memberId; ss.masterId = masterId; ss.running = masterId >= 0 && role == Role.FOLLOWER; ss.commitIndex = getCommitIndex(); ss.savedIndex = getSavedIndex(); ss.exception = slaveModeException; if (slaveModeException != null) { // Without synchronization, might lose a subsequent exception. It's ok. slaveModeException = null; } if (ss.masterId < 0) { return null; } return ss; }