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
KAFKA-5126: Implement KIP-98 transactional methods in the MockProducer #2951
KAFKA-5126: Implement KIP-98 transactional methods in the MockProducer #2951
Conversation
Call for review @apurvam @hachikuji @guozhangwang @dguy |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
public void initTransactions() { | ||
verifyProducerState(); | ||
if (this.transactionInitialized) { | ||
throw new IllegalStateException("MockedProducer got already initialized for transactions."); |
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.
nit: "MockProducer has already been initialized"
verifyProducerState(); | ||
verifyTransactionsInitialized(); | ||
if (!transactionInFlight) { | ||
throw new IllegalStateException("There is not open transaction to be committed."); |
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.
"There is no..." ?
verifyProducerState(); | ||
verifyTransactionsInitialized(); | ||
if (!transactionInFlight) { | ||
throw new IllegalStateException("There is not open transaction to be committed."); |
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.
As above
|
||
verifyProducerState(); | ||
verifyTransactionsInitialized(); | ||
if (!transactionInFlight) { |
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.
ok - same thing three times. Maybe extract it to a method verifyTransactionInflight
|
||
private void verifyProducerState() { | ||
if (this.closed) { | ||
throw new IllegalStateException("MockedProducer is already closed."); |
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.
MockedProducer -> MockProducer
public void shouldThrowOnSendOffsetsToTransactionTransactionIfNoTransactionGotStarted() { | ||
producer.initTransactions(); | ||
try { | ||
producer.sendOffsetsToTransaction(null, null); |
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.
fail(...)
public void shouldThrowOnCommitTransactionIfNoTransactionGotStarted() { | ||
producer.initTransactions(); | ||
try { | ||
producer.commitTransaction(); |
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.
fail(..)
public void shouldThrowOnAbortTransactionIfNoTransactionGotStarted() { | ||
producer.initTransactions(); | ||
try { | ||
producer.abortTransaction(); |
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.
fail(..)
} | ||
|
||
@Test | ||
public void shouldThrowOnInitTransactionIfProducerGotClosedAlready() { |
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.
Here and everywhere else. Got doesn't sound right. Maybe something like:
shouldThrowOnInitTransactionIfProducerIsClosed
producer.close(); | ||
try { | ||
producer.initTransactions(); | ||
fail("Should have thrown as producer got closed already"); |
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.
"... as producer is closed"
Same elsewhere
Updated this. |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
Refer to this link for build results (access rights to CI server needed): |
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.
LGTM
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.
Merged to trunk.
No description provided.