-
Notifications
You must be signed in to change notification settings - Fork 211
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
Add acknowledgement support to aggregate processor #5139
Conversation
@@ -62,6 +82,7 @@ boolean shouldConcludeGroup(final Duration groupDuration) { | |||
|
|||
void resetGroup() { | |||
groupStart = Instant.now(); | |||
this.eventHandle = new AggregateEventHandle(groupStart); |
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.
Should this do something with the old eventHandle
? Release it? Something else?
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.
No. The previous event handle was sent with the concluded event and will be released after the event is sent to Sink. Every "aggregate duration" ONE aggregated event is created and one aggregate event handle is created. The aggregate event handle is attached to the aggregated event and the group will create a new handle for the new duration. If the event handle is not attached to any event, then it will be freed (by garbage collector) when a new event handle is created in resetGroup.
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.
Thanks for the explanation. This is clear. To be sure, are there any paths that could lead to resetting a group where we do need to handle the aggregate event?
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 doesn't look like it. It looks like resetGroup() is called only in closeGroup() which is called only when the group is concluded.
@@ -26,6 +26,14 @@ public interface Processor<InputRecord extends Record<?>, OutputRecord extends R | |||
*/ | |||
Collection<OutputRecord> execute(Collection<InputRecord> records); | |||
|
|||
/** | |||
* indicates if the processor holds the events or not |
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.
Update this to be a little clear on what it means to hold events.
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.
This looks good overall. I'm good once you make a few small tweaks such as documentation improvements and add tests.
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
David has approved changes before the test cases are added
@@ -125,6 +125,7 @@ public Collection<Record<Event>> doExecute(Collection<Record<Event>> records) { | |||
} | |||
final IdentificationKeysHasher.IdentificationKeysMap identificationKeysMap = identificationKeysHasher.createIdentificationKeysMapFromEvent(event); | |||
final AggregateGroup aggregateGroupForEvent = aggregateGroupManager.getAggregateGroup(identificationKeysMap); | |||
aggregateGroupForEvent.attachToEventAcknowledgementSet(event); |
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.
So the solution is to create a new event handle to represent the aggregate group? Makes sense but what is happening exactly to the original event's event handle. Those don't have to be released?
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.
They are released by ProcessWorker. In the following code
records = processor.execute(records);
if (inputEvents != null) {
processAcknowledgements(inputEvents, records);
}
where every event that's not passed to the next processor is acknowledged
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
@@ -125,6 +125,7 @@ public Collection<Record<Event>> doExecute(Collection<Record<Event>> records) { | |||
} | |||
final IdentificationKeysHasher.IdentificationKeysMap identificationKeysMap = identificationKeysHasher.createIdentificationKeysMapFromEvent(event); | |||
final AggregateGroup aggregateGroupForEvent = aggregateGroupManager.getAggregateGroup(identificationKeysMap); |
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.
Consider automating the attachment of an event to the AggregateGroup during object creation so that it's encapsulated within the AggregateGroupManager
public AggregateGroup getAggregateGroup(Map<Object, Object> identificationKeysMap, Event event) {
AggregateGroup aggregateGroup = getOrCreateAggregateGroup(identificationKeysMap);
...
aggregateGroup.attachToEventAcknowledgementSet(event);
return aggregateGroup;
}
public AggregateActionOutput concludeGroup(final AggregateActionInput aggregateActionInput) { | ||
if (aggregateActionInput != null) { | ||
EventHandle eventHandle = aggregateActionInput.getEventHandle(); | ||
if (eventHandle != null) { | ||
eventHandle.release(true); | ||
} | ||
} | ||
return new AggregateActionOutput(Collections.emptyList()); | ||
} |
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.
Can this be default implementation in the interface ? I see the same logic for multiple 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.
That's a good suggestion.
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
@@ -26,6 +27,12 @@ AggregateGroup getAggregateGroup(final IdentificationKeysHasher.IdentificationKe | |||
return allGroups.computeIfAbsent(identificationKeysMap, (hash) -> new AggregateGroup(identificationKeysMap.getKeyMap())); | |||
} | |||
|
|||
AggregateGroup getAggregateGroupForEvent(final IdentificationKeysHasher.IdentificationKeysMap identificationKeysMap, final Event event) { | |||
AggregateGroup aggregateGroup = getAggregateGroup(identificationKeysMap); | |||
aggregateGroup.attachToEventAcknowledgementSet(event); |
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.
we are repeating this in both AggregateGroupManager and AggregateProcessor line 98
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.
Forgot to remove this.
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
* Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments and added tests Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Fixed checkstyle errors Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Fixed test errors by adding await Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Addressed review comments Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Removed unnecessary API Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> * Fixed checkstyle error Signed-off-by: Krishna Kondaka <krishkdk@amazon.com> --------- Signed-off-by: Krishna Kondaka <krishkdk@amazon.com>
Description
Add acknowledgement support to aggregate processor
Unaggregated events are not passed to the next processor in chain. For such events, DataPrepper core (in ProcessWorker) would send acknowledgements. It is possible for some aggregate actions (like TailSampler) to "hold" un-aggregated events.
holdsEvents()
processor API indicates that and DataPrepper code wouldn't send acks for such events.Issues Resolved
Resolves #[Issue number to be closed when this PR is merged]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.