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

KAFKA-5126: Implement KIP-98 transactional methods in the MockProducer #2951

Closed

Conversation

mjsax
Copy link
Member

@mjsax mjsax commented May 1, 2017

No description provided.

@mjsax
Copy link
Member Author

mjsax commented May 1, 2017

Call for review @apurvam @hachikuji @guozhangwang @dguy

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3342/
Test PASSed (JDK 8 and Scala 2.11).

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3337/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3333/
Test FAILed (JDK 8 and Scala 2.12).

public void initTransactions() {
verifyProducerState();
if (this.transactionInitialized) {
throw new IllegalStateException("MockedProducer got already initialized for transactions.");
Copy link
Contributor

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.");
Copy link
Contributor

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.");
Copy link
Contributor

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) {
Copy link
Contributor

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.");
Copy link
Contributor

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);
Copy link
Contributor

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();
Copy link
Contributor

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();
Copy link
Contributor

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() {
Copy link
Contributor

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");
Copy link
Contributor

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

@mjsax
Copy link
Member Author

mjsax commented May 2, 2017

Updated this.

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk7-scala2.10/3376/
Test PASSed (JDK 7 and Scala 2.10).

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.12/3373/
Test PASSed (JDK 8 and Scala 2.12).

@asfbot
Copy link

asfbot commented May 2, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/kafka-pr-jdk8-scala2.11/3382/
Test FAILed (JDK 8 and Scala 2.11).

Copy link
Contributor

@dguy dguy left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

Merged to trunk.

@asfgit asfgit closed this in c698423 May 9, 2017
@mjsax mjsax deleted the kafka-5126-add-transactions-to-mock-producer branch May 9, 2017 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
4 participants