Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd committed Nov 21, 2024
1 parent 5bbca7c commit e2a102f
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3489,10 +3489,14 @@ private void updateResultIfNewer(OldestPositionInfo updatedResult) {

public CompletableFuture<Void> updateOldPositionInfo() {
TopicName topicName = TopicName.get(getName());
ManagedCursorContainer managedCursorContainer = (ManagedCursorContainer) ledger.getCursors();
CursorInfo oldestMarkDeleteCursorInfo = managedCursorContainer.getCursorWithOldestPosition();

if (!(ledger.getCursors() instanceof ManagedCursorContainer managedCursorContainer)) {
return CompletableFuture.failedFuture(new IllegalStateException(
String.format("[%s] No valid cursors found. Skip update old position info.", topicName)));
}

// If we have no durable cursor since `ledger.getCursors()` only managed durable cursors
CursorInfo oldestMarkDeleteCursorInfo = managedCursorContainer.getCursorWithOldestPosition();
if (oldestMarkDeleteCursorInfo == null || oldestMarkDeleteCursorInfo.getPosition() == null) {
if (log.isDebugEnabled()) {
log.debug("[{}] No durable cursor found. Skip update old position info.", topicName);
Expand Down

0 comments on commit e2a102f

Please sign in to comment.