Skip to content

Commit

Permalink
Cleaned up some code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghuazhu committed Dec 20, 2024
1 parent 415799f commit cb607bd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public final class ReferenceCountedLeakDetector {
private static final Logger LOG = LoggerFactory.getLogger(ReferenceCountedLeakDetector.class);
// Leak detection is turned off by default.

private static final AtomicReference<Mode> FACTORY = new AtomicReference<>(Mode.NONE);
private static final Supplier<LeakDetector> SUPPLIER
= MemoizedSupplier.valueOf(() -> new LeakDetector(FACTORY.get().name()).start());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,6 @@ public CompletableFuture<LifeCycle.State> stopAsync() {
grpcServerMetrics.unregister();
return super.stopAsync();
}
/*grpcServerMetrics.unregister();
CompletableFuture<LifeCycle.State> future = super.stopAsync();
if (appendLogRequestObserver != null) {
appendLogRequestObserver.stop();
appendLogRequestObserver = null;
}
return future;*/
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ public ReferenceCountedObject<LogEntryProto> load(LogRecord key) throws IOExcept
final AtomicReference<ReferenceCountedObject<LogEntryProto>> toReturn = new AtomicReference<>();
final LogSegmentStartEnd startEnd = LogSegmentStartEnd.valueOf(startIndex, endIndex, isOpen);
readSegmentFile(file, startEnd, maxOpSize, getLogCorruptionPolicy(), raftLogMetrics, entryRef -> {
final LogEntryProto entry = entryRef.retain();
try {
final LogEntryProto entry = entryRef.retain();
final TermIndex ti = TermIndex.valueOf(entry);
putEntryCache(ti, entryRef, Op.LOAD_SEGMENT_FILE);
if (ti.equals(key.getTermIndex())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,17 +282,14 @@ private void loadLogSegments(long lastIndexInSnapshot,

@Override
public LogEntryProto get(long index) throws RaftLogIOException {
ReferenceCountedObject<LogEntryProto> ref = null;
final ReferenceCountedObject<LogEntryProto> ref = retainLog(index);
if (ref == null) {
return null;
}
try {
ref = retainLog(index);
if (ref == null) {
return null;
}
return LogProtoUtils.copy(ref.get());
} finally {
if (ref != null) {
ref.release();
}
ref.release();
}
}

Expand Down

0 comments on commit cb607bd

Please sign in to comment.