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

[HUDI-4624] Implement Closable for S3EventsSource #7086

Merged
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 @@ -32,6 +32,8 @@
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;

import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -41,7 +43,7 @@
* to check S3 files activity over time. The hudi table created by this source is consumed by
* {@link S3EventsHoodieIncrSource} to apply changes to the hudi table corresponding to user data.
*/
public class S3EventsSource extends RowSource {
public class S3EventsSource extends RowSource implements Closeable {

private final S3EventsMetaSelector pathSelector;
private final List<Message> processedMessages = new ArrayList<>();
Expand Down Expand Up @@ -79,6 +81,12 @@ public Pair<Option<Dataset<Row>>, String> fetchNextBatch(Option<String> lastCkpt
}
}

@Override
public void close() throws IOException {
// close resource
this.sqs.shutdown();
}

@Override
public void onCommit(String lastCkptStr) {
pathSelector.deleteProcessedMessages(sqs, pathSelector.queueUrl, processedMessages);
Expand Down