Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3663,7 +3663,7 @@ Pair<PositionImpl, Long> getFirstPositionAndCounter() {

public void activateCursor(ManagedCursor cursor) {
synchronized (activeCursors) {
if (activeCursors.get(cursor.getName()) == null) {
if (!cursor.isActive()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If change like this, I think it's better like

if (!cursor.isActive()) {
   Position positionForOrdering = config.isCacheEvictionByMarkDeletedPosition()
                        ? cursor.getMarkDeletedPosition()
                        : cursor.getReadPosition();
     if (positionForOrdering == null) {
             positionForOrdering = PositionImpl.EARLIEST;
     }
     synchronized (activeCursors) {
          activeCursors.add(cursor, positionForOrdering);
     }
}          

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for reference, this change ultimately relies on a call to this method:

public boolean isCursorActive(ManagedCursor cursor) {
return activeCursors.get(cursor.getName()) != null;
}

We don't want to change the scope of the synchronized block, as far as I can tell.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If any refactoring were to be made, I think we should have switched to use the ManagedLedgerImpl#isCursorActive method.

Position positionForOrdering = config.isCacheEvictionByMarkDeletedPosition()
? cursor.getMarkDeletedPosition()
: cursor.getReadPosition();
Expand Down