Skip to content
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

[#1481] Update peekEvent accordingly #1484

Merged
merged 10 commits into from Aug 14, 2020
Merged

[#1481] Update peekEvent accordingly #1484

merged 10 commits into from Aug 14, 2020

Conversation

smcvb
Copy link
Member

@smcvb smcvb commented Aug 7, 2020

This pull request updates the EventBuffer, to ensure it no longer loops for the defined 500ms "wait time" in the hasNextAvailable method. This loop was performed as the while-loop validated whether the peekEvent == null, thus the event of the constructed Iterator<TrackedEventMessage<?>> eventStream. However the waitForData method calls the delegate EventStream#peek method. The latter returns true, causing the lock to be released, but the while-loop kept on going as it didn't change the peekEvent.

The javadoc adjustments of the SequencingPolicy were added unintentionally, but don't hurt this PR.

This PR resolves #1481

Fix javadoc discrepancy stating that the SequentialPolicy is the default
 policy, whilst the SequentialPerAggregatePolicy is the defautl
The EventBuffer used by the AxonServerConnector as the
TrackingEventStream currently contains a blocking loop, taking up to
500ms to exit. This so happens to correspond to the minimum wait time
used by the hasNextAvailable method. This occurs because the peakEvent,
validated in a do-while-loop, isn't updated when the lock's Condition is
 signaled. Subsequently, adjust the test to timeout if it takes longer
 dan 450ms, as that's a signal the loop occurs again whilst it shouldn't

#1481
@smcvb smcvb added Type: Bug Use to signal issues that describe a bug within the system. Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. Status: In Progress Use to signal this issue is actively worked on. labels Aug 7, 2020
@smcvb smcvb added this to the Release 4.4.2 milestone Aug 7, 2020
@smcvb smcvb requested review from abuijze and MGathier August 7, 2020 13:41
@smcvb smcvb self-assigned this Aug 7, 2020
Add short trace logging showing whether we were signaled or waited 500ms

#1481
The current solution introduces a form of side effect _why_ it no longer
 loops in the do-while-loop. Namely, subsequent invocations of the
 hasNextAvailable method currently introduce the scenario that the next
 entry from the Iterator is retrieved. This means, the following entry
 is removed from the delegate EventStream. Although this make sure an
 early return occurs, it still does an additional unnecessary loop.
Instead, we should consistently use one way to validate an event is
present, and omit the side effect inducing operation. As this means
we'll no longer perform direct invocations of the EventStream which
could lead to an exception, we should validate whether the stream is
closed prior to proceeding.

#1481
For some, the createEventData method was to slow, hence causing the
testDataUpcastAndDeserialized with the timeout to fail. Making the
result a static field will resolve this

#1481
Copy link
Member

@abuijze abuijze left a comment

Choose a reason for hiding this comment

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

The code is fine, but the changes made allow for some simplification of this class, which will improve the understandability of the code used. Maybe the waitForData can then also be inlined and some of the checks simplified.

- Rename the constant
- Add private peekNullable method and use instead of peek() / peekEvent
== null
- Pair two if-breaks
- Switch do-while-loop to while-loop
- Inline waitForData
- Remove unintended debug log line

#1481
@smcvb smcvb requested a review from abuijze August 13, 2020 12:12
- Reorder field assignment in constructor
- Drop if-continue check, as it's no longer needed through the switch
from a do-while-loop to the while-loop
- Move waitTime creation and validation to occur just before the await
invocation

#1481
Waiting on events should happen if there is no event AND the wait time
is bigger than zero.

#1481
Further reordering, for a different kind of OCD

#1481
Move the EventStream#isClosed check to the peekNullable method. That way
 we can ensure we validate this operation everytime we try to retrieve a
 new event from the delegate stream.

#1481
@sonarcloud
Copy link

sonarcloud bot commented Aug 14, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

92.9% 92.9% Coverage
0.0% 0.0% Duplication

@smcvb smcvb merged commit bbae673 into axon-4.4.x Aug 14, 2020
@smcvb smcvb deleted the bug/1481 branch August 14, 2020 10:42
@smcvb smcvb added Status: Resolved Use to signal that work on this issue is done. and removed Status: In Progress Use to signal this issue is actively worked on. labels Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 1: Must Highest priority. A release cannot be made if this issue isn’t resolved. Status: Resolved Use to signal that work on this issue is done. Type: Bug Use to signal issues that describe a bug within the system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants