Skip to content

Conversation

@aromanenko-dev
Copy link
Contributor

Instead of creating new instance of KinesisProducer in every thread, we have to instantiate only one per JVM as recommended in its Javadoc. Also, it's supposed to be thread-safe by design.

R: @iemejia

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

Post-Commit Tests Status (on master branch)

Lang SDK Apex Dataflow Flink Gearpump Samza Spark
Go Build Status --- --- Build Status --- --- Build Status
Java Build Status Build Status Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status
Build Status
Python Build Status
Build Status
--- Build Status
Build Status
Build Status --- --- Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website
Non-portable Build Status Build Status Build Status Build Status
Portable --- Build Status --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

@aromanenko-dev aromanenko-dev requested a review from iemejia June 27, 2019 16:55
@aromanenko-dev
Copy link
Contributor Author

aromanenko-dev commented Jun 28, 2019

I also ran KinesisIOIT test on my local environment against real Kinesis instance with targetParallelism=8. No issues have been seen so far.

Copy link
Member

@iemejia iemejia left a comment

Choose a reason for hiding this comment

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

Almost LGTM pretty minor clean ups to do.

// we remove from failures, so this code is safe.
private void checkForFailures(String message)
throws IOException, InterruptedException, ExecutionException {
if (failures.isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe simpler to inverse the condition and put all the logic inside of the if block

Copy link
Member

Choose a reason for hiding this comment

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

I think it will be clearer to move this validation into the invoker method and do the checkForFailures method just produce the error string and use it only to throw the exception, but it is ok if you prefer to let the logic as it is.

Copy link
Member

Choose a reason for hiding this comment

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

One advantage of the refactor is that you can provide a complete LOG.error if you prefer to.

"Put record was not successful.", new UserRecordFailedException(result)));
}
}
throw new IOException(errorMessage);
Copy link
Member

Choose a reason for hiding this comment

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

maybe inline the errorMessage (or just use the return type if you do the suggested refactor above).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is a reason for that? Not clear for me

Copy link
Member

Choose a reason for hiding this comment

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

For the refactor to return String is just to have a more composable (and testable) signature, for the return time it is just because errorMessage is never used afterwards.

int n = rand.nextInt(numberOfShards) + 1;
return String.valueOf(n);
}

Copy link
Member

Choose a reason for hiding this comment

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

Not related to this PR but I am curious about what is this getExplicitHashKey for? Haven't noticed it is not documented in the interface either.

Copy link
Member

@iemejia iemejia left a comment

Choose a reason for hiding this comment

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

LGTM

@iemejia
Copy link
Member

iemejia commented Jun 28, 2019

Merged manually to fix a typo in the commit message and squash the extra review commit.

@iemejia iemejia closed this Jun 28, 2019
iemejia added a commit that referenced this pull request Jun 28, 2019
@aromanenko-dev aromanenko-dev deleted the BEAM-7589-KinesisIO branch July 4, 2019 13:12
pl04351820 pushed a commit to pl04351820/beam that referenced this pull request Dec 20, 2023
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.

2 participants