Skip to content

Commit

Permalink
Fix checkstyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
szetszwo committed Aug 1, 2024
1 parent 19be677 commit e4af201
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ private void assertSegment(long expectedStart, int expectedEntryCount, boolean c
final LogRecord last = getLastRecord();
if (last != null) {
Preconditions.assertSame(expectedLastIndex, last.getTermIndex().getIndex(), "Index at the last record");
Preconditions.assertSame(expectedStart, records.getFirst().getTermIndex().getIndex(), "Index at the first record");
final LogRecord first = records.getFirst();
Objects.requireNonNull(first, "first record");
Preconditions.assertSame(expectedStart, first.getTermIndex().getIndex(), "Index at the first record");
}
if (!corrupted) {
Preconditions.assertSame(expectedEnd, expectedLastIndex, "End/last Index");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,18 @@ private void loadLogSegments(long lastIndexInSnapshot,
@Override
public LogEntryProto get(long index) throws RaftLogIOException {
checkLogState();
final LogSegment segment;
final LogRecord record;
{
segment = cache.getSegment(index);
if (segment == null) {
return null;
}
record = segment.getLogRecord(index);
if (record == null) {
return null;
}
final LogEntryProto entry = segment.getEntryFromCache(record.getTermIndex());
if (entry != null) {
getRaftLogMetrics().onRaftLogCacheHit();
return entry;
}
final LogSegment segment = cache.getSegment(index);
if (segment == null) {
return null;
}
final LogRecord record = segment.getLogRecord(index);
if (record == null) {
return null;
}
final LogEntryProto entry = segment.getEntryFromCache(record.getTermIndex());
if (entry != null) {
getRaftLogMetrics().onRaftLogCacheHit();
return entry;
}

// the entry is not in the segment's cache. Load the cache without holding the lock.
Expand Down Expand Up @@ -339,26 +335,20 @@ private void checkAndEvictCache() {
@Override
public TermIndex getTermIndex(long index) {
checkLogState();
{
LogRecord record = cache.getLogRecord(index);
return record != null ? record.getTermIndex() : null;
}
final LogRecord record = cache.getLogRecord(index);
return record != null ? record.getTermIndex() : null;
}

@Override
public LogEntryHeader[] getEntries(long startIndex, long endIndex) {
checkLogState();
{
return cache.getTermIndices(startIndex, endIndex);
}
return cache.getTermIndices(startIndex, endIndex);
}

@Override
public TermIndex getLastEntryTermIndex() {
checkLogState();
{
return cache.getLastTermIndex();
}
return cache.getLastTermIndex();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ void rollOpenSegment(boolean createNewOpen) {
}

LogSegment getSegment(long index) {
final LogSegment openSegment = this.openSegment;
if (openSegment != null && index >= openSegment.getStartIndex()) {
return openSegment;
} else {
Expand Down

0 comments on commit e4af201

Please sign in to comment.