Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
e25f5ab
KAFKA-14589 WIP
nizhikov Sep 7, 2023
6da9b64
Merge branch 'trunk' into KAFKA-14589
nizhikov Oct 2, 2023
1bba7b5
Merge branch 'trunk' into KAFKA-14589
nizhikov Oct 22, 2023
b2022aa
KAFKA-14589 WIP
nizhikov Oct 22, 2023
0554aaa
KAFKA-14589 WIP
nizhikov Oct 22, 2023
304f584
KAFKA-14589 WIP
nizhikov Oct 22, 2023
a1e3d6c
Merge branch 'trunk' into KAFKA-14589
nizhikov Oct 24, 2023
d57e7c1
KAFKA-14589 WIP
nizhikov Oct 24, 2023
b650bb3
KAFKA-14589 WIP
nizhikov Oct 25, 2023
1f4ea90
KAFKA-14589 WIP
nizhikov Oct 26, 2023
7608683
Merge branch 'trunk' into KAFKA-14589
nizhikov Oct 26, 2023
00b5b01
KAFKA-14589 WIP
nizhikov Oct 26, 2023
6d52f02
KAFKA-14589 WIP
nizhikov Oct 26, 2023
b9c10b9
KAFKA-14589 Command implemented
nizhikov Oct 27, 2023
13e517f
KAFKA-14589 Codestyle fixes.
nizhikov Oct 27, 2023
cf9fcbd
KAFKA-14589 Codestyle fixes.
nizhikov Oct 27, 2023
daba249
Merge branch 'trunk' into KAFKA-14589
nizhikov Oct 30, 2023
ef64af8
KAFKA-14589 ConsumerGroupCommandTest added.
nizhikov Oct 31, 2023
3b740c9
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 1, 2023
4fc836c
KAFKA-14589 Merging with trunk
nizhikov Nov 1, 2023
a1b6398
KAFKA-14589 ListConsumerGroupTest rewritten in java
nizhikov Nov 5, 2023
64a3477
KAFKA-14589 DeleteOffsetsConsumerGroupCommandIntegrationTest rewritte…
nizhikov Nov 5, 2023
c31cba6
KAFKA-14589 DeleteConsumerGroupsTest rewritten in java
nizhikov Nov 5, 2023
f890648
KAFKA-14589 ResetConsumerGroupOffsetTest rewritten in java
nizhikov Nov 6, 2023
a80a8dd
KAFKA-14589 DescribeConsumerGroupTest rewritten in java
nizhikov Nov 8, 2023
f17135b
KAFKA-14589 DescribeConsumerGroupTest rewritten in java
nizhikov Nov 8, 2023
722aa86
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 8, 2023
c829fd0
KAFKA-14589 ConsumerGroupServiceTest rewritten in java
nizhikov Nov 8, 2023
67ddbf1
KAFKA-14589 Transfer final tests and remove scala version of command
nizhikov Nov 8, 2023
303e592
KAFKA-14589 Fix scala 2.12 build
nizhikov Nov 8, 2023
dc07aa3
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 15, 2023
adcb688
KAFKA-14589 Checkstyle fix
nizhikov Nov 15, 2023
e671974
KAFKA-14589 Checkstyle fix
nizhikov Nov 15, 2023
457af5c
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 20, 2023
0efe53b
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 24, 2023
ad6564f
Merge branch 'trunk' into KAFKA-14589
nizhikov Nov 28, 2023
9191f6c
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 5, 2023
a837e84
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 6, 2023
fb5c789
KAFKA-14588 Code review fix
nizhikov Dec 6, 2023
38e43d0
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 12, 2023
c74f4d4
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 21, 2023
8c324ce
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 23, 2023
377270a
Merge branch 'trunk' into KAFKA-14589
nizhikov Dec 27, 2023
8063da1
Merge branch 'trunk' into KAFKA-14589
Jan 22, 2024
0e3f4f4
KAFKA-14589 Update to latest trunk changes
Jan 22, 2024
fc288fe
KAFKA-14589 Change package
Jan 22, 2024
73e2fba
Merge branch 'trunk' into KAFKA-14589
Jan 23, 2024
74cc1d7
KAFKA-14589 WIP
Jan 23, 2024
a7080ae
KAFKA-14589 WIP
Jan 23, 2024
26a437d
Merge branch 'trunk' into KAFKA-14589
Jan 24, 2024
5e49029
Merge branch 'trunk' into KAFKA-14589
Jan 26, 2024
700a358
Merge branch 'trunk' into KAFKA-14589
Jan 26, 2024
1f4b547
KAFKA-14589 Merge fixes
Jan 26, 2024
85cd1d3
KAFKA-14589 Correct package
Jan 29, 2024
96ff15f
Merge branch 'trunk' into KAFKA-14589
Jan 29, 2024
9ae4e2a
KAFKA-14589 Reflection changes from #15211
Jan 29, 2024
a6b1a0b
Merge branch 'trunk' into KAFKA-14589
Feb 1, 2024
6307859
KAFKA-14589 Reflecting changes of 6c09cc9586f823dff32c96131f6f377afae…
Feb 1, 2024
6c870d4
Merge branch 'trunk' into KAFKA-14589
Feb 5, 2024
d29d611
Merge branch 'trunk' into KAFKA-14589
Feb 6, 2024
04f80f5
Merge branch 'trunk' into KAFKA-14589
Feb 13, 2024
170b800
KAFKA-14589 Fixes after merge
Feb 13, 2024
2030962
KAFKA-14589 Fixes after merge
Feb 13, 2024
3569971
KAFKA-14589 Fixes after merge
Feb 13, 2024
e4e0a1e
Merge branch 'trunk' into KAFKA-14589
Feb 13, 2024
b74bd03
KAFKA-14589 Reduce tests run
Feb 13, 2024
a34c6c6
Merge branch 'trunk' into KAFKA-14589
Feb 13, 2024
8426c04
Merge branch 'trunk' into KAFKA-14589
Feb 13, 2024
fd29b3f
KAFKA-14589 Tests rewritten
Feb 14, 2024
54f1017
KAFKA-14589 Reduce changes
Feb 14, 2024
4c60e22
KAFKA-14589 Reduce changes
Feb 14, 2024
a1254d8
Merge branch 'trunk' into KAFKA-14589
Feb 15, 2024
341c81b
Merge branch 'trunk' into KAFKA-14589
Feb 20, 2024
419c0ea
KAFKA-14588 WIP
Feb 20, 2024
4660f76
Merge branch 'trunk' into KAFKA-14589
Feb 27, 2024
3b1d38b
Merge branch 'trunk' into KAFKA-14589
Feb 29, 2024
b4539d8
KAFKA-14588 Reflect changes from KAFKA-15462
Feb 29, 2024
8a173f2
KAFKA-14588 Reflect changes from KAFKA-15462
Feb 29, 2024
311e9fa
Merge branch 'trunk' into KAFKA-14589
Mar 4, 2024
e406967
Merge branch 'trunk' into KAFKA-14589
Mar 5, 2024
3933267
Merge branch 'trunk' into KAFKA-14589
Mar 6, 2024
837a9b2
KAFKA-14588 Code review fixes
Mar 6, 2024
3ade3dc
KAFKA-14589 Revert unnecessary changes
Mar 6, 2024
e9018cd
Merge branch 'trunk' into KAFKA-14589
Mar 7, 2024
dfadfb7
KAFKA-14589 Cleanup
Mar 7, 2024
643dd26
KAFKA-14589 Cleanup
Mar 7, 2024
bfbdfa5
KAFKA-14589 Cleanup
Mar 7, 2024
95ec460
Merge branch 'trunk' into KAFKA-14589
Mar 8, 2024
8365091
KAFKA-14589 Merge updates
Mar 8, 2024
8560d5d
KAFKA-14589 Merge updates
Mar 8, 2024
528c56f
KAFKA-14589 Merge updates
Mar 8, 2024
0dd7e43
KAFKA-14589 Merge updates
Mar 8, 2024
7dbc9e4
Merge branch 'trunk' into KAFKA-14589
Mar 11, 2024
e1175a6
Merge branch 'trunk' into KAFKA-14589
Mar 12, 2024
c7600b8
KAFKA-14589 Code review changes
Mar 12, 2024
4f7befa
KAFKA-14589 Code review changes
Mar 12, 2024
3430af9
Merge branch 'trunk' into KAFKA-14589
Mar 15, 2024
23a01af
KAFKA-14589 Code review changes
Mar 15, 2024
ba9bf6a
Merge branch 'trunk' into KAFKA-14589
Mar 19, 2024
519f016
KAFKA-14589 Code review changes
Mar 19, 2024
6645d62
KAFKA-14589 Code review changes
Mar 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/kafka-consumer-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

exec $(dirname $0)/kafka-run-class.sh kafka.admin.ConsumerGroupCommand "$@"
exec $(dirname $0)/kafka-run-class.sh org.apache.kafka.tools.consumer.group.ConsumerGroupCommand "$@"

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.

Could you please test it manually?

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.

Basic manual testing done.

❯ ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --all-groups

Consumer group 'console-consumer-79292' has no active members.

GROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                           HOST            CLIENT-ID
my_group        first_topic     0          0               0               0               console-consumer-9db50227-1820-46a6-b667-a387553ac536 /192.168.31.66  console-consumer
my_group        first_topic     1          11              11              0               console-consumer-9db50227-1820-46a6-b667-a387553ac536 /192.168.31.66  console-consumer
my_group        first_topic     2          0               0               0               console-consumer-9db50227-1820-46a6-b667-a387553ac536 /192.168.31.66  console-consumer%
❯ ./bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
console-consumer-79292
my_group

2 changes: 1 addition & 1 deletion bin/windows/kafka-consumer-groups.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

"%~dp0kafka-run-class.bat" kafka.admin.ConsumerGroupCommand %*
"%~dp0kafka-run-class.bat" org.apache.kafka.tools.consumer.group.ConsumerGroupCommand %*
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,9 @@ project(':tools') {
implementation project(':log4j-appender')
implementation project(':tools:tools-api')
implementation libs.argparse4j
implementation libs.jacksonDatabind
implementation libs.jacksonDataformatCsv
implementation libs.jacksonJDK8Datatypes
implementation libs.slf4jApi
implementation libs.log4j
implementation libs.joptSimple
Expand Down
1,220 changes: 0 additions & 1,220 deletions core/src/main/scala/kafka/admin/ConsumerGroupCommand.scala

This file was deleted.

2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/utils/ToolsUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ object ToolsUtils {
/**
* This is a simple wrapper around `CommandLineUtils.printUsageAndExit`.
* It is needed for tools migration (KAFKA-14525), as there is no Java equivalent for return type `Nothing`.
* Can be removed once [[kafka.admin.ConsumerGroupCommand]] and [[kafka.tools.ConsoleProducer]] are migrated.
* Can be removed once [[kafka.tools.ConsoleProducer]] are migrated.
*
* @param parser Command line options parser.
* @param message Error message.
Expand Down
15 changes: 15 additions & 0 deletions tools/src/main/java/org/apache/kafka/tools/ToolsUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
*/
package org.apache.kafka.tools;

import joptsimple.OptionParser;
import org.apache.kafka.common.Metric;
import org.apache.kafka.common.MetricName;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.server.util.CommandLineUtils;

import java.io.PrintStream;
import java.util.Arrays;
Expand Down Expand Up @@ -155,4 +157,17 @@ public static <T> Set<T> minus(Set<T> set, T...toRemove) {
return res;
}

/**
* This is a simple wrapper around `CommandLineUtils.printUsageAndExit`.
* It is needed for tools migration (KAFKA-14525), as there is no Java equivalent for return type `Nothing`.
* Can be removed once [[kafka.tools.ConsoleConsumer]]
* and [[kafka.tools.ConsoleProducer]] are migrated.
*
* @param parser Command line options parser.
* @param message Error message.
*/
public static void printUsageAndExit(OptionParser parser, String message) {
CommandLineUtils.printUsageAndExit(parser, message);
throw new AssertionError("printUsageAndExit should not return, but it did.");
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -31,89 +31,99 @@
import static org.apache.kafka.tools.ToolsUtils.minus;

public class ConsumerGroupCommandOptions extends CommandDefaultOptions {
public static final Logger LOGGER = LoggerFactory.getLogger(ConsumerGroupCommandOptions.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ConsumerGroupCommandOptions.class);

public static final String BOOTSTRAP_SERVER_DOC = "REQUIRED: The server(s) to connect to.";
public static final String GROUP_DOC = "The consumer group we wish to act on.";
public static final String TOPIC_DOC = "The topic whose consumer group information should be deleted or topic whose should be included in the reset offset process. " +
private static final String BOOTSTRAP_SERVER_DOC = "REQUIRED: The server(s) to connect to.";
private static final String GROUP_DOC = "The consumer group we wish to act on.";
private static final String TOPIC_DOC = "The topic whose consumer group information should be deleted or topic whose should be included in the reset offset process. " +
"In `reset-offsets` case, partitions can be specified using this format: `topic1:0,1,2`, where 0,1,2 are the partition to be included in the process. " +
"Reset-offsets also supports multiple topic inputs.";
public static final String ALL_TOPICS_DOC = "Consider all topics assigned to a group in the `reset-offsets` process.";
public static final String LIST_DOC = "List all consumer groups.";
public static final String DESCRIBE_DOC = "Describe consumer group and list offset lag (number of messages not yet processed) related to given group.";
public static final String ALL_GROUPS_DOC = "Apply to all consumer groups.";
public static final String NL = System.lineSeparator();
public static final String DELETE_DOC = "Pass in groups to delete topic partition offsets and ownership information " +
private static final String ALL_TOPICS_DOC = "Consider all topics assigned to a group in the `reset-offsets` process.";
private static final String LIST_DOC = "List all consumer groups.";
private static final String DESCRIBE_DOC = "Describe consumer group and list offset lag (number of messages not yet processed) related to given group.";
private static final String ALL_GROUPS_DOC = "Apply to all consumer groups.";
private static final String NL = System.lineSeparator();
private static final String DELETE_DOC = "Pass in groups to delete topic partition offsets and ownership information " +
"over the entire consumer group. For instance --group g1 --group g2";
public static final String TIMEOUT_MS_DOC = "The timeout that can be set for some use cases. For example, it can be used when describing the group " +
private static final String TIMEOUT_MS_DOC = "The timeout that can be set for some use cases. For example, it can be used when describing the group " +
"to specify the maximum amount of time in milliseconds to wait before the group stabilizes (when the group is just created, " +
"or is going through some changes).";
public static final String COMMAND_CONFIG_DOC = "Property file containing configs to be passed to Admin Client and Consumer.";
public static final String RESET_OFFSETS_DOC = "Reset offsets of consumer group. Supports one consumer group at the time, and instances should be inactive" + NL +
private static final String COMMAND_CONFIG_DOC = "Property file containing configs to be passed to Admin Client and Consumer.";
private static final String RESET_OFFSETS_DOC = "Reset offsets of consumer group. Supports one consumer group at the time, and instances should be inactive" + NL +
"Has 2 execution options: --dry-run (the default) to plan which offsets to reset, and --execute to update the offsets. " +
"Additionally, the --export option is used to export the results to a CSV format." + NL +
"You must choose one of the following reset specifications: --to-datetime, --by-duration, --to-earliest, " +
"--to-latest, --shift-by, --from-file, --to-current, --to-offset." + NL +
"To define the scope use --all-topics or --topic. One scope must be specified unless you use '--from-file'.";
public static final String DRY_RUN_DOC = "Only show results without executing changes on Consumer Groups. Supported operations: reset-offsets.";
public static final String EXECUTE_DOC = "Execute operation. Supported operations: reset-offsets.";
public static final String EXPORT_DOC = "Export operation execution to a CSV file. Supported operations: reset-offsets.";
public static final String RESET_TO_OFFSET_DOC = "Reset offsets to a specific offset.";
public static final String RESET_FROM_FILE_DOC = "Reset offsets to values defined in CSV file.";
public static final String RESET_TO_DATETIME_DOC = "Reset offsets to offset from datetime. Format: 'YYYY-MM-DDTHH:mm:SS.sss'";
public static final String RESET_BY_DURATION_DOC = "Reset offsets to offset by duration from current timestamp. Format: 'PnDTnHnMnS'";
public static final String RESET_TO_EARLIEST_DOC = "Reset offsets to earliest offset.";
public static final String RESET_TO_LATEST_DOC = "Reset offsets to latest offset.";
public static final String RESET_TO_CURRENT_DOC = "Reset offsets to current offset.";
public static final String RESET_SHIFT_BY_DOC = "Reset offsets shifting current offset by 'n', where 'n' can be positive or negative.";
public static final String MEMBERS_DOC = "Describe members of the group. This option may be used with '--describe' and '--bootstrap-server' options only." + NL +
private static final String DRY_RUN_DOC = "Only show results without executing changes on Consumer Groups. Supported operations: reset-offsets.";
private static final String EXECUTE_DOC = "Execute operation. Supported operations: reset-offsets.";
private static final String EXPORT_DOC = "Export operation execution to a CSV file. Supported operations: reset-offsets.";
private static final String RESET_TO_OFFSET_DOC = "Reset offsets to a specific offset.";
private static final String RESET_FROM_FILE_DOC = "Reset offsets to values defined in CSV file.";
private static final String RESET_TO_DATETIME_DOC = "Reset offsets to offset from datetime. Format: 'YYYY-MM-DDTHH:mm:SS.sss'";
private static final String RESET_BY_DURATION_DOC = "Reset offsets to offset by duration from current timestamp. Format: 'PnDTnHnMnS'";
private static final String RESET_TO_EARLIEST_DOC = "Reset offsets to earliest offset.";
private static final String RESET_TO_LATEST_DOC = "Reset offsets to latest offset.";
private static final String RESET_TO_CURRENT_DOC = "Reset offsets to current offset.";
private static final String RESET_SHIFT_BY_DOC = "Reset offsets shifting current offset by 'n', where 'n' can be positive or negative.";
private static final String MEMBERS_DOC = "Describe members of the group. This option may be used with '--describe' and '--bootstrap-server' options only." + NL +
"Example: --bootstrap-server localhost:9092 --describe --group group1 --members";
public static final String VERBOSE_DOC = "Provide additional information, if any, when describing the group. This option may be used " +
private static final String VERBOSE_DOC = "Provide additional information, if any, when describing the group. This option may be used " +
"with '--offsets'/'--members'/'--state' and '--bootstrap-server' options only." + NL + "Example: --bootstrap-server localhost:9092 --describe --group group1 --members --verbose";
public static final String OFFSETS_DOC = "Describe the group and list all topic partitions in the group along with their offset lag. " +
private static final String OFFSETS_DOC = "Describe the group and list all topic partitions in the group along with their offset lag. " +
"This is the default sub-action of and may be used with '--describe' and '--bootstrap-server' options only." + NL +
"Example: --bootstrap-server localhost:9092 --describe --group group1 --offsets";
public static final String STATE_DOC = "When specified with '--describe', includes the state of the group." + NL +
private static final String STATE_DOC = "When specified with '--describe', includes the state of the group." + NL +
"Example: --bootstrap-server localhost:9092 --describe --group group1 --state" + NL +
"When specified with '--list', it displays the state of all groups. It can also be used to list groups with specific states." + NL +
"Example: --bootstrap-server localhost:9092 --list --state stable,empty" + NL +
"This option may be used with '--describe', '--list' and '--bootstrap-server' options only.";
public static final String DELETE_OFFSETS_DOC = "Delete offsets of consumer group. Supports one consumer group at the time, and multiple topics.";
private static final String TYPE_DOC = "When specified with '--list', it displays the types of all the groups. It can also be used to list groups with specific types." + NL +
"Example: --bootstrap-server localhost:9092 --list --type classic,consumer" + NL +
"This option may be used with the '--list' option only.";
private static final String DELETE_OFFSETS_DOC = "Delete offsets of consumer group. Supports one consumer group at the time, and multiple topics.";

public final OptionSpec<String> bootstrapServerOpt;
public final OptionSpec<String> groupOpt;
public final OptionSpec<String> topicOpt;
public final OptionSpec<Void> allTopicsOpt;
public final OptionSpec<Void> listOpt;
public final OptionSpec<Void> describeOpt;
public final OptionSpec<Void> allGroupsOpt;
public final OptionSpec<Void> deleteOpt;
public final OptionSpec<Long> timeoutMsOpt;
public final OptionSpec<String> commandConfigOpt;
public final OptionSpec<Void> resetOffsetsOpt;
public final OptionSpec<Void> deleteOffsetsOpt;
public final OptionSpec<Void> dryRunOpt;
public final OptionSpec<Void> executeOpt;
public final OptionSpec<Void> exportOpt;
public final OptionSpec<Long> resetToOffsetOpt;
public final OptionSpec<String> resetFromFileOpt;
public final OptionSpec<String> resetToDatetimeOpt;
public final OptionSpec<String> resetByDurationOpt;
public final OptionSpec<Void> resetToEarliestOpt;
public final OptionSpec<Void> resetToLatestOpt;
public final OptionSpec<Void> resetToCurrentOpt;
public final OptionSpec<Long> resetShiftByOpt;
public final OptionSpec<Void> membersOpt;
public final OptionSpec<Void> verboseOpt;
public final OptionSpec<Void> offsetsOpt;
public final OptionSpec<String> stateOpt;
final OptionSpec<String> bootstrapServerOpt;
final OptionSpec<String> groupOpt;
final OptionSpec<String> topicOpt;
final OptionSpec<Void> allTopicsOpt;
final OptionSpec<Void> listOpt;
final OptionSpec<Void> describeOpt;
final OptionSpec<Void> allGroupsOpt;
final OptionSpec<Void> deleteOpt;
final OptionSpec<Long> timeoutMsOpt;
final OptionSpec<String> commandConfigOpt;
final OptionSpec<Void> resetOffsetsOpt;
final OptionSpec<Void> deleteOffsetsOpt;
final OptionSpec<Void> dryRunOpt;
final OptionSpec<Void> executeOpt;
final OptionSpec<Void> exportOpt;
final OptionSpec<Long> resetToOffsetOpt;
final OptionSpec<String> resetFromFileOpt;
final OptionSpec<String> resetToDatetimeOpt;
final OptionSpec<String> resetByDurationOpt;
final OptionSpec<Void> resetToEarliestOpt;
final OptionSpec<Void> resetToLatestOpt;
final OptionSpec<Void> resetToCurrentOpt;
final OptionSpec<Long> resetShiftByOpt;
final OptionSpec<Void> membersOpt;
final OptionSpec<Void> verboseOpt;
final OptionSpec<Void> offsetsOpt;
final OptionSpec<String> stateOpt;
final OptionSpec<String> typeOpt;

public final Set<OptionSpec<?>> allGroupSelectionScopeOpts;
public final Set<OptionSpec<?>> allConsumerGroupLevelOpts;
public final Set<OptionSpec<?>> allResetOffsetScenarioOpts;
public final Set<OptionSpec<?>> allDeleteOffsetsOpts;
final Set<OptionSpec<?>> allGroupSelectionScopeOpts;
final Set<OptionSpec<?>> allConsumerGroupLevelOpts;
final Set<OptionSpec<?>> allResetOffsetScenarioOpts;
final Set<OptionSpec<?>> allDeleteOffsetsOpts;

public ConsumerGroupCommandOptions(String[] args) {
public static ConsumerGroupCommandOptions fromArgs(String[] args) {
ConsumerGroupCommandOptions opts = new ConsumerGroupCommandOptions(args);
opts.checkArgs();
return opts;
}

private ConsumerGroupCommandOptions(String[] args) {
super(args);

bootstrapServerOpt = parser.accepts("bootstrap-server", BOOTSTRAP_SERVER_DOC)
Expand Down Expand Up @@ -180,6 +190,10 @@ public ConsumerGroupCommandOptions(String[] args) {
.availableIf(describeOpt, listOpt)
.withOptionalArg()
.ofType(String.class);
typeOpt = parser.accepts("type", TYPE_DOC)
.availableIf(listOpt)
.withOptionalArg()
.ofType(String.class);

allGroupSelectionScopeOpts = new HashSet<>(Arrays.asList(groupOpt, allGroupsOpt));
allConsumerGroupLevelOpts = new HashSet<>(Arrays.asList(listOpt, describeOpt, deleteOpt, resetOffsetsOpt));
Expand All @@ -191,7 +205,7 @@ public ConsumerGroupCommandOptions(String[] args) {
}

@SuppressWarnings({"CyclomaticComplexity", "NPathComplexity"})
public void checkArgs() {
void checkArgs() {
CommandLineUtils.checkRequiredArgs(parser, options, bootstrapServerOpt);

if (options.has(describeOpt)) {
Expand Down
Loading