Skip to content

KAFKA-14589 ConsumerGroupCommand options and case classes rewritten#14856

Merged
jolshan merged 19 commits into
apache:trunkfrom
nizhikov:KAFKA-14589_options
Jan 23, 2024
Merged

KAFKA-14589 ConsumerGroupCommand options and case classes rewritten#14856
jolshan merged 19 commits into
apache:trunkfrom
nizhikov:KAFKA-14589_options

Conversation

@nizhikov

Copy link
Copy Markdown
Contributor

This PR is part of #14471
It contains ConsumerGroupCommandOptions and case classes used by ConsumerGroupCommand rewritten in java.

The goal of PR is to reduce main PR size.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@nizhikov

Copy link
Copy Markdown
Contributor Author

Hello @mimaison , @jolshan

This PR is first step to transfer ConsumerGroupCommand from scala to java.
Can you, please, take a look.

@nizhikov

nizhikov commented Dec 5, 2023

Copy link
Copy Markdown
Contributor Author

@mimaison Will you be able to take a look?

This is first PR to transfer ConsumerGroupCommand to java.

Comment thread clients/src/main/java/org/apache/kafka/common/utils/Utils.java Outdated
}

@SuppressWarnings("unchecked")
private static <T> Set<T> minus(Set<T> set, T...toRemove) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What about moving this method to CollectionUtils?

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.

Yes maybe we can move this to Utils?

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.

Moved.

@tledkov tledkov left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The patch is OK with me.
Checked:

  • java codestyle, java code patterns for new code;
  • command line string constants.

…merGroupCommandOptions.java

Co-authored-by: Taras Ledkov <tledkov@apache.org>
@nizhikov

nizhikov commented Dec 7, 2023

Copy link
Copy Markdown
Contributor Author

Hello, @mimaison @jolshan

Looks like very straightforward PR for me.
Can you, please, review it, also?

So we can start moving ConsumerGroupCommand to tools.

Full patch is #14471

@nizhikov

nizhikov commented Jan 8, 2024

Copy link
Copy Markdown
Contributor Author

@mimaison can you, please, take a look.

@mimaison mimaison left a comment

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.

Thanks for the PR. I left a few minor comments

if (options.has(describeOpt)) {
if (!options.has(groupOpt) && !options.has(allGroupsOpt))
CommandLineUtils.printUsageAndExit(parser,
"Option $describeOpt takes one of these options: " + Utils.join(allGroupSelectionScopeOpts));

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.

"Option $describeOpt takes -> "Option " + describeOpt + " takes`

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.

Fixed.

this.clientId = clientId;
this.logEndOffset = logEndOffset;
}
} No newline at end of file

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.

Nit: Can we add a newline?

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.

Fixed.

}

@SuppressWarnings("unchecked")
private static <T> Set<T> minus(Set<T> set, T...toRemove) {

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.

Yes maybe we can move this to Utils?

@@ -0,0 +1,263 @@
/*

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.

Is the tools/consumergroup a new folder? I wonder if there is a name that is more consistent with the other folders.

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.

Is the tools/consumergroup a new folder?

yes.

I wonder if there is a name that is more consistent with the other folders.

Couldn't come up with the better naming :)
Do you have one in mind?

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 wasn't sure if we wanted to use the same convention of the other java consumer group files. But maybe that is confusing. They follow a pattern of coordinator/group. Not sure if we really have reusability amongst coordinator tools though.

I think when we have had two word folders we usually put a dash between them (ie consumer-group)

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.

I think when we have had two word folders we usually put a dash between them (ie consumer-group)

Dash can't be used in java package name.

They follow a pattern of coordinator/group

We can move classes to org.apache.kafka.tools.consumer.group package.
What do you think?

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.

That works for me. Thanks!

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.

package renamed.

@jolshan

jolshan commented Jan 17, 2024

Copy link
Copy Markdown
Member

Did we want to delete the old files in this PR or a follow up?

@nizhikov

nizhikov commented Jan 17, 2024

Copy link
Copy Markdown
Contributor Author

@jolshan

Did we want to delete the old files in this PR or a follow up?

For the previous command we remove old files only when command was merged

  1. Reassign case classes and options moved to java - 1fd58e3
  2. Command moved to java and old classes removed - 76b1b50

So I tend to reuse this strategy for the ConsumerGroupCommand.

@nizhikov

Copy link
Copy Markdown
Contributor Author

@mimaison CI seems OK. I addressed all your comments. Please, take a look.

@mimaison mimaison left a comment

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.

Thanks for the updates. Let's avoid adding stuff into clients that are only used by tools.

* @param <T> Element type.
*/
@SuppressWarnings("unchecked")
public static <T> Set<T> minus(Set<T> set, T...toRemove) {

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.

Let's not add methods in the client module that are only used in tools. This can be moved to ToolsUtils.

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.

Moved

* @param collection The list of items
* @return The string representation.
*/
public static <T> String join(Collection<T> collection) {

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.

Do we really need this method? Why can't we call the existing join() method and pass the separator? If you want to keep it, since it's only used in tools let's move it to the tools module.

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.

Method removed

@nizhikov

Copy link
Copy Markdown
Contributor Author

Hello @mimaison , @jolshan do you have any other comments?

public final String group;
public final Optional<Node> coordinator;
public final Optional<String> topic;
public final Optional<Integer> partition;

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 can use OptionalInt

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.

Fixed

public final Optional<Node> coordinator;
public final Optional<String> topic;
public final Optional<Integer> partition;
public final Optional<Long> offset;

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 can use OptionalLong

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.

Fixed

if (!options.has(groupOpt) && !options.has(allGroupsOpt))
CommandLineUtils.printUsageAndExit(parser,
"Option " + resetOffsetsOpt + " takes one of these options: " + join(allGroupSelectionScopeOpts, ", "));
CommandLineUtils.checkInvalidArgs(parser, options, resetToOffsetOpt, minus(allResetOffsetScenarioOpts, resetToOffsetOpt));

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.

hmm -- do we want to line up all the minus arguments here? It adds extra spaces that may be against our style guidelines

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.

Extra spaces removed

@jolshan

jolshan commented Jan 22, 2024

Copy link
Copy Markdown
Member

Thanks @nizhikov just one more small comment from me.

@mimaison mimaison left a comment

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.

LGTM, thanks

@mimaison

Copy link
Copy Markdown
Member

@jolshan Feel free to merge once you're happy with the changes.

@jolshan

jolshan commented Jan 22, 2024

Copy link
Copy Markdown
Member

Thanks. I will wait for the tests to finish 👍

@jolshan jolshan merged commit ff25c35 into apache:trunk Jan 23, 2024
@nizhikov

Copy link
Copy Markdown
Contributor Author

Thanks for review and merge!

drawxy pushed a commit to drawxy/kafka that referenced this pull request Jan 23, 2024
…pache#14856)

This PR is part of apache#14471
It contains ConsumerGroupCommandOptions and case classes used by ConsumerGroupCommand rewritten in java.

The goal of PR is to reduce main PR size.

Co-authored-by: Taras Ledkov <tledkov@apache.org>

Reviewers: Mickael Maison <mickael.maison@gmail.com>, Taras Ledkov <tledkov@apache.org>, Justine Olshan <jolshan@confluent.io>
yyu1993 pushed a commit to yyu1993/kafka that referenced this pull request Feb 15, 2024
…pache#14856)

This PR is part of apache#14471
It contains ConsumerGroupCommandOptions and case classes used by ConsumerGroupCommand rewritten in java.

The goal of PR is to reduce main PR size.

Co-authored-by: Taras Ledkov <tledkov@apache.org>

Reviewers: Mickael Maison <mickael.maison@gmail.com>, Taras Ledkov <tledkov@apache.org>, Justine Olshan <jolshan@confluent.io>
clolov pushed a commit to clolov/kafka that referenced this pull request Apr 5, 2024
…pache#14856)

This PR is part of apache#14471
It contains ConsumerGroupCommandOptions and case classes used by ConsumerGroupCommand rewritten in java.

The goal of PR is to reduce main PR size.

Co-authored-by: Taras Ledkov <tledkov@apache.org>

Reviewers: Mickael Maison <mickael.maison@gmail.com>, Taras Ledkov <tledkov@apache.org>, Justine Olshan <jolshan@confluent.io>
Phuc-Hong-Tran pushed a commit to Phuc-Hong-Tran/kafka that referenced this pull request Jun 6, 2024
…pache#14856)

This PR is part of apache#14471
It contains ConsumerGroupCommandOptions and case classes used by ConsumerGroupCommand rewritten in java.

The goal of PR is to reduce main PR size.

Co-authored-by: Taras Ledkov <tledkov@apache.org>

Reviewers: Mickael Maison <mickael.maison@gmail.com>, Taras Ledkov <tledkov@apache.org>, Justine Olshan <jolshan@confluent.io>
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.

4 participants