-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat][broker][PIP-195]Implement Filter out all delayed messages and skip them when reading messages from bookies - part7 #19035
Conversation
*/ | ||
void asyncReadEntries(int numberOfEntriesToRead, ReadEntriesCallback callback, Object ctx, | ||
PositionImpl maxPosition); | ||
PositionImpl maxPosition, Predicate<PositionImpl> skipCondition); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add a new method.
I mean, we'd better not change the existing API directly.
This class is annotated with
@InterfaceAudience.LimitedPrivate
@InterfaceStability.Stable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
1b042a0
to
3aefb59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change!
I like the brilliant solution for skipping the entries.
I just left some minor comments.
* @param ctx opaque context | ||
* @param maxPosition max position can read | ||
*/ | ||
void asyncReadEntriesWithSkip(int numberOfEntriesToRead, long maxSizeBytes, ReadEntriesCallback callback, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to add a default implementation. Otherwise, we will break the user's existing implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mean just add default
default void asyncReadEntriesWithSkip()
if (lastPosition == null || entriesCount != 0) { | ||
lastPosition = (PositionImpl) returnedEntries.get(entriesCount - 1).getPosition(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the returnedEntries
is empty and the lastPosition
is null, we will get an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to we can only judge entriesCount != 0
managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java
Show resolved
Hide resolved
.../java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherMultipleConsumers.java
Outdated
Show resolved
Hide resolved
for (; entryId <= lastEntry; entryId++) { | ||
if (opReadEntry.skipCondition.test(PositionImpl.get(ledger.getId(), entryId))) { | ||
break; | ||
} | ||
lastValidEntry = entryId; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can try to optimize with only one loop to find the first invalid entry range 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
@@ -57,13 +61,13 @@ public static OpReadEntry create(ManagedCursorImpl cursor, PositionImpl readPosi | |||
maxPosition = PositionImpl.LATEST; | |||
} | |||
op.maxPosition = maxPosition; | |||
op.skipCondition = skipCondition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we forget to reset it when recycle this obj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right.
op.ctx = ctx; | ||
op.nextReadPosition = PositionImpl.get(op.readPosition); | ||
return op; | ||
} | ||
|
||
@Override | ||
public void readEntriesComplete(List<Entry> returnedEntries, Object ctx) { | ||
void internalReadEntriesComplete(List<Entry> returnedEntries, Object ctx, PositionImpl lastPosition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it is good to extend this method because we defined a parameter named context
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context
already be opReadEntry.ctx
passing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, please apply @codelipenghui comments.
if (lastPosition == null || entriesCount != 0) { | ||
lastPosition = (PositionImpl) returnedEntries.get(entriesCount - 1).getPosition(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19035 +/- ##
============================================
- Coverage 49.85% 45.79% -4.07%
- Complexity 8658 11061 +2403
============================================
Files 500 772 +272
Lines 54930 74360 +19430
Branches 5867 8009 +2142
============================================
+ Hits 27386 34053 +6667
- Misses 24464 36518 +12054
- Partials 3080 3789 +709
Flags with carried forward coverage won't be shown. Click here to find out more.
|
4197fb6
to
dc17954
Compare
/pulsarbot run-failure-checks |
I noticed this test failed multiple times. Maybe related to the changes of this PR. |
b49f41f
to
c57f05a
Compare
c57f05a
to
fadff0b
Compare
PIP: #16763
Motivation
#16763
Modifications
Implement Filter out all delayed messages and skip them when reading messages from bookies.
The logical changes are mainly in
ManagedLedgerImpl
andOpReadEntry
.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: