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(); }
LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){ this.logger.info("detect a configuration change that is not committed yet at index %d", i);
LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){ this.logger.info("detect a configuration change that is not committed yet at index %d", i);
LogEntry logEntry = this.logStore.getLogEntryAt(i); if(logEntry.getValueType() == LogValueType.Configuration){ this.logger.info("detect a configuration change that is not committed yet at index %d", i);
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); long logTermToCompact = this.logStore.getLogEntryAt(indexToCompact).getTerm(); Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> {
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); long logTermToCompact = this.logStore.getLogEntryAt(indexToCompact).getTerm(); Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> {
config = ClusterConfiguration.fromBytes(this.logStore.getLogEntryAt(config.getLastLogIndex()).getValue()); long logTermToCompact = this.logStore.getLogEntryAt(indexToCompact).getTerm(); Snapshot snapshot = new Snapshot(indexToCompact, logTermToCompact, config); this.stateMachine.createSnapshot(snapshot).whenCompleteAsync((Boolean result, Throwable error) -> {
LogEntry logEntry = server.logStore.getLogEntryAt(currentCommitIndex); if(logEntry.getValueType() == LogValueType.Application){ server.stateMachine.commit(currentCommitIndex, logEntry.getValue());
LogEntry logEntry = server.logStore.getLogEntryAt(currentCommitIndex); if(logEntry.getValueType() == LogValueType.Application){ server.stateMachine.commit(currentCommitIndex, logEntry.getValue());
LogEntry logEntry = server.logStore.getLogEntryAt(currentCommitIndex); if(logEntry.getValueType() == LogValueType.Application){ server.stateMachine.commit(currentCommitIndex, logEntry.getValue());
while(index < this.logStore.getFirstAvailableIndex() && logIndex < logEntries.length && logEntries[logIndex].getTerm() == this.logStore.getLogEntryAt(index).getTerm()){ logIndex ++; index ++; LogEntry oldEntry = this.logStore.getLogEntryAt(index); if(oldEntry.getValueType() == LogValueType.Application){ this.stateMachine.rollback(index, oldEntry.getValue());
while(index < this.logStore.getFirstAvailableIndex() && logIndex < logEntries.length && logEntries[logIndex].getTerm() == this.logStore.getLogEntryAt(index).getTerm()){ logIndex ++; index ++; LogEntry oldEntry = this.logStore.getLogEntryAt(index); if(oldEntry.getValueType() == LogValueType.Application){ this.stateMachine.rollback(index, oldEntry.getValue());
while(index < this.logStore.getFirstAvailableIndex() && logIndex < logEntries.length && logEntries[logIndex].getTerm() == this.logStore.getLogEntryAt(index).getTerm()){ logIndex ++; index ++; LogEntry oldEntry = this.logStore.getLogEntryAt(index); if(oldEntry.getValueType() == LogValueType.Application){ this.stateMachine.rollback(index, oldEntry.getValue());