-
Notifications
You must be signed in to change notification settings - Fork 210
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 acknowledgments for the ddb source #3575
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
package org.opensearch.dataprepper.plugins.source.dynamodb.converter; | ||
|
||
import org.opensearch.dataprepper.buffer.common.BufferAccumulator; | ||
import org.opensearch.dataprepper.model.acknowledgements.AcknowledgementSet; | ||
import org.opensearch.dataprepper.model.event.Event; | ||
import org.opensearch.dataprepper.model.event.EventMetadata; | ||
import org.opensearch.dataprepper.model.event.JacksonEvent; | ||
|
@@ -70,7 +71,7 @@ void flushBuffer() throws Exception { | |
* @param eventName Event name | ||
* @throws Exception Exception if failed to write to buffer. | ||
*/ | ||
public void addToBuffer(Map<String, Object> data, Map<String, Object> keys, long eventCreationTimeMillis, String eventName) throws Exception { | ||
public void addToBuffer(final AcknowledgementSet acknowledgementSet, Map<String, Object> data, Map<String, Object> keys, long eventCreationTimeMillis, String eventName) throws Exception { | ||
Event event = JacksonEvent.builder() | ||
.withEventType(getEventType()) | ||
.withData(data) | ||
|
@@ -90,13 +91,16 @@ public void addToBuffer(Map<String, Object> data, Map<String, Object> keys, long | |
} else { | ||
eventMetadata.setAttribute(PRIMARY_KEY_DOCUMENT_ID_METADATA_ATTRIBUTE, partitionKey); | ||
} | ||
if (acknowledgementSet != null) { | ||
acknowledgementSet.add(event); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't fully understand how this works, but will this have any memory issue? I only see there is a add of event, will that be a clear of event somewhere else. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just adds an |
||
} | ||
bufferAccumulator.add(new Record<>(event)); | ||
} | ||
|
||
public void addToBuffer(Map<String, Object> data) throws Exception { | ||
public void addToBuffer(final AcknowledgementSet acknowledgementSet, Map<String, Object> data) throws Exception { | ||
// Export data doesn't have an event timestamp | ||
// Default to current timestamp when the event is added to buffer | ||
addToBuffer(data, data, System.currentTimeMillis(), null); | ||
addToBuffer(acknowledgementSet, data, data, System.currentTimeMillis(), null); | ||
} | ||
|
||
private String mapStreamEventNameToBulkAction(final String streamEventName) { | ||
|
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.
Not really an issue, but just want to point out that I have never tested whether it can support s3 in a different region or not. Even it can, it will be strange since ddb and opensearch are in the same region, what is the point to write or read data files from another region.
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.
Yeah I don't know why anyone would do that but users have the option to export to a different region's bucket. By default this can be ignored for same region though, so it can't really hurt to have