use of org.apache.ignite.raft.jraft.error.LogEntryCorruptedException in project ignite-3 by apache.
the class LogManagerImpl method getTermFromLogStorage.
private long getTermFromLogStorage(final long index) {
final LogEntry entry = this.logStorage.getEntry(index);
if (entry != null) {
if (this.raftOptions.isEnableLogEntryChecksum() && entry.isCorrupted()) {
// Report error to node and throw exception.
final String msg = String.format("The log entry is corrupted, index=%d, term=%d, expectedChecksum=%d, realChecksum=%d", entry.getId().getIndex(), entry.getId().getTerm(), entry.getChecksum(), entry.checksum());
reportError(RaftError.EIO.getNumber(), msg);
throw new LogEntryCorruptedException(msg);
}
return entry.getId().getTerm();
}
return 0;
}
use of org.apache.ignite.raft.jraft.error.LogEntryCorruptedException in project ignite-3 by apache.
the class LogManagerImpl method getEntry.
@Override
public LogEntry getEntry(final long index) {
this.readLock.lock();
try {
if (index > this.lastLogIndex || index < this.firstLogIndex) {
return null;
}
final LogEntry entry = getEntryFromMemory(index);
if (entry != null) {
return entry;
}
} finally {
this.readLock.unlock();
}
final LogEntry entry = this.logStorage.getEntry(index);
if (entry == null) {
reportError(RaftError.EIO.getNumber(), "Corrupted entry at index=%d, not found", index);
}
// Validate checksum
if (entry != null && this.raftOptions.isEnableLogEntryChecksum() && entry.isCorrupted()) {
String msg = String.format("Corrupted entry at index=%d, term=%d, expectedChecksum=%d, realChecksum=%d", index, entry.getId().getTerm(), entry.getChecksum(), entry.checksum());
// Report error to node and throw exception.
reportError(RaftError.EIO.getNumber(), msg);
throw new LogEntryCorruptedException(msg);
}
return entry;
}
Aggregations