Skip to content

KAFKA-7597: Make Trogdor ProduceBenchWorker support transactions#5885

Merged
cmccabe merged 9 commits intoapache:trunkfrom
stanislavkozlovski:KAFKA-7597-trogdor-transactions
Nov 27, 2018
Merged

KAFKA-7597: Make Trogdor ProduceBenchWorker support transactions#5885
cmccabe merged 9 commits intoapache:trunkfrom
stanislavkozlovski:KAFKA-7597-trogdor-transactions

Conversation

@stanislavkozlovski
Copy link
Copy Markdown
Contributor

It now accepts a new "messagesPerTransaction" field, which, if present, will enable transactional functionality in the bench worker.
The producer will open N transactions with X messages each (bounded by the mandatory "maxMessages" field)

@stanislavkozlovski
Copy link
Copy Markdown
Contributor Author

Retest this please
cc @cmccabe for review

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Nov 19, 2018

Hmm. Just having a static "number of messages per transaction" field seems kind of limiting, right? What if we later want a mix of transactional and non-transactional messages, or transactions of different sizes?

I would suggest making something like PayloadGenerator. Perhaps TransactionGenerator?
Then we can have ZeroTransactionsGenerator (the default if none is configured) and UniformSizeTransactionsGenerator

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: makes more sense as the singular TransactionAction than as the plural TransactionActions since each value represents a single action

Copy link
Copy Markdown
Contributor

@cmccabe cmccabe Nov 20, 2018

Choose a reason for hiding this comment

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

perhaps "zero" is better for a short name used in configuration? Although I guess most people will configure this by leaving it blank.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's probably better to make this synchronized, unless we want to say that TransactionActionGenerator classes are not thread-safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Nov 20, 2018

Looks good overall. I left some comments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry to keep talking about the name of this, but I just don't like how TransactionActionGenerator sounds. TransactionGenerator sounds much better.

Then we could have TransactionGenerator#Action as well and it flows really well

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Nov 21, 2018

Looks almost ready. Left some minor comments

@stanislavkozlovski
Copy link
Copy Markdown
Contributor Author

An unrelated test failed in JDK 8 -the dreaded kafka.admin.ReassignPartitionsClusterTest.shouldExecuteThrottledReassignment. On an unrelated note, I am currently working on fixing that exact test's flakiness

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we name this transactionGenerator for simplicity?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep, good catch on the leftover

Copy link
Copy Markdown
Contributor

@cmccabe cmccabe Nov 26, 2018

Choose a reason for hiding this comment

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

If we use Optional<TransactionGenerator> we can get rid of INIT_TRANSACTIONS (it will be implied if the Optional contains a generator)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The transactional ID should include produce-bench- in it somewhere to make it clear what test created this, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggest a name like enableTransactions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought about this a little bit more, and I think maybe we should just use Optional<TransactionGenerator> rather than having ZeroTransactionsGenerator. The zero generator isn't a real generator and it's kind of confusing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a checkstyle issue. Are you compiling with check to catch these before Jenkins does?

Comment thread gradle/dependencies.gradle Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should call this jacksonJdk8 or something.

Comment thread build.gradle Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should probably add this to other projects that depend on Jackson so that we get reasonable behaviour for Java 8 types.

It now accepts a new "messagesPerTransaction" field, which, if present, will enable transactional functionality in the bench worker.
The producer will open N  transactions with X messages each (bounded by the mandatory "maxMessages" field)
…on vars

Imports new library - jackson-datatype-jdk8. This should be used until jackson 3 comes out, at which point we can switch to it completely
Removed INIT_TRANSACTIONS state from the `TransactionAction` enum, this eases TransactionGenerator implementations
Removed ZeroTransactionsGenerator class - it is much more intuitive to provide null or not define the transactionsGenerator class
* This means that most of the time it should return #{@link TransactionAction#NO_OP}
* to signal the producer that its next step should be to send a message.
*/
TransactionAction action();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nextAction might be a better name here

new SequentialPayloadGenerator(4, 0) : keyGenerator;
this.valueGenerator = valueGenerator == null ?
new ConstantPayloadGenerator(512, new byte[0]) : valueGenerator;
this.transactionGenerator = txGenerator;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should convert null -> none here. Even if Jackson always fills this in, someone may manually create this object

@cmccabe
Copy link
Copy Markdown
Contributor

cmccabe commented Nov 27, 2018

LGTM

@cmccabe cmccabe merged commit 9368743 into apache:trunk Nov 27, 2018
pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
KAFKA-7597: Add configurable transaction support to ProduceBenchWorker.  In order to get support for serializing Optional<> types to JSON, add a new library: jackson-datatype-jdk8. Once Jackson 3 comes out, this library will not be needed.

Reviewers: Colin McCabe <cmccabe@apache.org>, Ismael Juma <ismael@juma.me.uk>
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.

3 participants