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

Generalize S3 record writes with wrapper to possibly convert to RetriableException #494

Merged
merged 3 commits into from Feb 11, 2022

Conversation

cjolivier01
Copy link
Contributor

@cjolivier01 cjolivier01 commented Feb 11, 2022

Problem

Duplicated catch/throw logic for each format's RecordWriter with respect to retriable AWS exceptions.

Solution

Consolidte the catch/rethrow logic for AWS retriable exceptions by wrapping the anonymous format classes as they are created. Wrapper is intentionally as close as possible to the call/throw sites rather than up another level (or more) in KeyValueHeaderRecordWriterProvider.

No behavioral changes should occur.

Suggest turning off whitespace in comparison since blocks of code were simply shifted right one tab in many places.

Does this solution apply anywhere else?
  • yes
  • no
If yes, where?

Test Strategy

Testing done:
  • Unit tests
  • Integration tests
  • System tests
  • Manual tests

Release Plan

@cjolivier01 cjolivier01 requested a review from a team as a code owner February 11, 2022 00:57
Copy link
Member

@kpatelatwork kpatelatwork left a comment

Choose a reason for hiding this comment

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

@cjolivier01 Thanks a lot for this change, this is a very good refactoring.

I sent some minor nits, please resolve them and then its ready for a final review

@cjolivier01 cjolivier01 requested review from a team February 11, 2022 16:54
private IORecordWriter writer;

public S3RetriableRecordWriter(IORecordWriter writer) {
this.writer = writer;
Copy link
Member

Choose a reason for hiding this comment

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

for my understanding, don't we have to do null check on constructor arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is that a pattern? I looked around just now and I don't see it being done anywhere.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if its the pattern or not, but we could make writer as final and do a null check before assigning a value in constructor. what you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is final now. do what if it is null? throw NullPointerException?

Copy link
Member

Choose a reason for hiding this comment

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

I would do something like this: writer = Preconditions.checkNotNull(writer, "Writer object is null"))

we don't have to use guava-preconditions. but checkNotNull will throw NullPointerException.

Ref: https://guava.dev/releases/19.0/api/docs/com/google/common/base/Preconditions.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added throw if null

@guruz09
Copy link
Member

guruz09 commented Feb 11, 2022

I assume we dont have to add any new unit tests for this change, right?

Copy link
Member

@kpatelatwork kpatelatwork left a comment

Choose a reason for hiding this comment

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

LGTM

@kpatelatwork
Copy link
Member

I assume we dont have to add any new unit tests for this change, right?

We don't need to as this part of code has enough coverage added in main PR and this is just a refactoring.

@cjolivier01 cjolivier01 merged commit b2ff908 into confluentinc:10.0.x Feb 11, 2022
@cjolivier01 cjolivier01 deleted the colivier/genretry branch February 11, 2022 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants