private long termForLastLog(long logIndex){ if(logIndex == 0){ return 0; } if(logIndex >= this.logStore.getStartIndex()){ return this.logStore.getLogEntryAt(logIndex).getTerm(); } Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null || logIndex != lastSnapshot.getLastLogIndex()){ throw new IllegalArgumentException("logIndex is beyond the range that no term could be retrieved"); } return lastSnapshot.getLastLogTerm(); }
private long termForLastLog(long logIndex){ if(logIndex == 0){ return 0; } if(logIndex >= this.logStore.getStartIndex()){ return this.logStore.getLogEntryAt(logIndex).getTerm(); } Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null || logIndex != lastSnapshot.getLastLogIndex()){ throw new IllegalArgumentException("logIndex is beyond the range that no term could be retrieved"); } return lastSnapshot.getLastLogTerm(); }
private long termForLastLog(long logIndex){ if(logIndex == 0){ return 0; } if(logIndex >= this.logStore.getStartIndex()){ return this.logStore.getLogEntryAt(logIndex).getTerm(); } Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null || logIndex != lastSnapshot.getLastLogIndex()){ throw new IllegalArgumentException("logIndex is beyond the range that no term could be retrieved"); } return lastSnapshot.getLastLogTerm(); }
&& ((indexCommitted - this.logStore.getStartIndex()) > this.context.getRaftParameters().getSnapshotDistance()) && this.snapshotInProgress.compareAndSet(0, 1)){ snapshotInAction = true; while(config.getLogIndex() > indexCommitted && config.getLastLogIndex() >= this.logStore.getStartIndex()){ config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); if(config.getLogIndex() > indexCommitted && config.getLastLogIndex() > 0 && config.getLastLogIndex() < this.logStore.getStartIndex()){ Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null){
for(long i = Math.max(this.state.getCommitIndex() + 1, this.logStore.getStartIndex()); i < this.logStore.getFirstAvailableIndex(); ++i){ LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){
for(long i = Math.max(this.state.getCommitIndex() + 1, this.logStore.getStartIndex()); i < this.logStore.getFirstAvailableIndex(); ++i){ LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){
for(long i = Math.max(this.state.getCommitIndex() + 1, this.logStore.getStartIndex()); i < this.logStore.getFirstAvailableIndex(); ++i){ LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){
&& ((indexCommitted - this.logStore.getStartIndex()) > this.context.getRaftParameters().getSnapshotDistance()) && this.snapshotInProgress.compareAndSet(0, 1)){ snapshotInAction = true; while(config.getLogIndex() > indexCommitted && config.getLastLogIndex() >= this.logStore.getStartIndex()){ config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); if(config.getLogIndex() > indexCommitted && config.getLastLogIndex() > 0 && config.getLastLogIndex() < this.logStore.getStartIndex()){ Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null){
&& ((indexCommitted - this.logStore.getStartIndex()) > this.context.getRaftParameters().getSnapshotDistance()) && this.snapshotInProgress.compareAndSet(0, 1)){ snapshotInAction = true; while(config.getLogIndex() > indexCommitted && config.getLastLogIndex() >= this.logStore.getStartIndex()){ config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); if(config.getLogIndex() > indexCommitted && config.getLastLogIndex() > 0 && config.getLastLogIndex() < this.logStore.getStartIndex()){ Snapshot lastSnapshot = this.stateMachine.getLastSnapshot(); if(lastSnapshot == null){
startingIndex = this.logStore.getStartIndex(); currentNextIndex = this.logStore.getFirstAvailableIndex(); commitIndex = this.quickCommitIndex;
if(startIndex > 0 && startIndex < this.logStore.getStartIndex()){ request = this.createSyncSnapshotRequest(this.serverToJoin, startIndex, this.state.getTerm(), this.quickCommitIndex);
if(startIndex > 0 && startIndex < this.logStore.getStartIndex()){ request = this.createSyncSnapshotRequest(this.serverToJoin, startIndex, this.state.getTerm(), this.quickCommitIndex);
if(startIndex > 0 && startIndex < this.logStore.getStartIndex()){ request = this.createSyncSnapshotRequest(this.serverToJoin, startIndex, this.state.getTerm(), this.quickCommitIndex);
startingIndex = this.logStore.getStartIndex(); currentNextIndex = this.logStore.getFirstAvailableIndex(); commitIndex = this.quickCommitIndex;
startingIndex = this.logStore.getStartIndex(); currentNextIndex = this.logStore.getFirstAvailableIndex(); commitIndex = this.quickCommitIndex;