-
Notifications
You must be signed in to change notification settings - Fork 14.6k
KAFKA-19623: Implement KIP-1147 for console producer/consumer/share-consumer. #20479
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -132,7 +132,9 @@ static final class ConsoleProducerOptions extends CommandDefaultOptions { | |||||
private final OptionSpec<String> propertyOpt; | ||||||
private final OptionSpec<String> readerConfigOpt; | ||||||
private final OptionSpec<String> producerPropertyOpt; | ||||||
private OptionSpec<String> commandPropertyOpt; | ||||||
private final OptionSpec<String> producerConfigOpt; | ||||||
private OptionSpec<String> commandConfigOpt; | ||||||
|
||||||
public ConsoleProducerOptions(String[] args) { | ||||||
super(args); | ||||||
|
@@ -250,11 +252,20 @@ public ConsoleProducerOptions(String[] args) { | |||||
.withRequiredArg() | ||||||
.describedAs("config file") | ||||||
.ofType(String.class); | ||||||
producerPropertyOpt = parser.accepts("producer-property", "A mechanism to pass user-defined properties in the form key=value to the producer. ") | ||||||
producerPropertyOpt = parser.accepts("producer-property", "(DEPRECATED) A mechanism to pass user-defined properties in the form key=value to the producer." + | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space
Suggested change
|
||||||
"This option will be removed in a future version. Use --command-property instead.") | ||||||
.withRequiredArg() | ||||||
.describedAs("producer_prop") | ||||||
.ofType(String.class); | ||||||
producerConfigOpt = parser.accepts("producer.config", "Producer config properties file. Note that " + producerPropertyOpt + " takes precedence over this config.") | ||||||
commandPropertyOpt = parser.accepts("command-property", "A mechanism to pass user-defined properties in the form key=value to the producer.") | ||||||
.withRequiredArg() | ||||||
.describedAs("producer_prop") | ||||||
.ofType(String.class); | ||||||
producerConfigOpt = parser.accepts("producer.config", "(DEPRECATED) Producer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config. This option will be removed in a future version. Use --command-config instead.") | ||||||
.withRequiredArg() | ||||||
.describedAs("config file") | ||||||
.ofType(String.class); | ||||||
commandConfigOpt = parser.accepts("command-config", "Producer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config.") | ||||||
.withRequiredArg() | ||||||
.describedAs("config file") | ||||||
.ofType(String.class); | ||||||
|
@@ -273,6 +284,23 @@ void checkArgs() { | |||||
|
||||||
CommandLineUtils.checkRequiredArgs(parser, options, topicOpt); | ||||||
|
||||||
if (options.has(commandConfigOpt) && options.has(producerConfigOpt)) { | ||||||
CommandLineUtils.printUsageAndExit(parser, "Options --command-config and --producer.config cannot be specified together."); | ||||||
} | ||||||
if (options.has(commandPropertyOpt) && options.has(producerPropertyOpt)) { | ||||||
CommandLineUtils.printUsageAndExit(parser, "Options --command-property and --producer-property cannot be specified together."); | ||||||
} | ||||||
|
||||||
if (options.has(producerPropertyOpt)) { | ||||||
System.out.println("Warning: --producer-property is deprecated and will be removed in a future version. Use --command-property instead."); | ||||||
commandPropertyOpt = producerPropertyOpt; | ||||||
} | ||||||
|
||||||
if (options.has(producerConfigOpt)) { | ||||||
System.out.println("Warning: --producer.config is deprecated and will be removed in a future version. Use --command-config instead."); | ||||||
commandConfigOpt = producerConfigOpt; | ||||||
} | ||||||
|
||||||
try { | ||||||
ToolsUtils.validateBootstrapServer(options.valueOf(bootstrapServerOpt)); | ||||||
} catch (IllegalArgumentException e) { | ||||||
|
@@ -314,11 +342,11 @@ Map<String, String> readerProps() throws IOException { | |||||
Properties producerProps() throws IOException { | ||||||
Properties props = new Properties(); | ||||||
|
||||||
if (options.has(producerConfigOpt)) { | ||||||
props.putAll(loadProps(options.valueOf(producerConfigOpt))); | ||||||
if (options.has(commandConfigOpt)) { | ||||||
props.putAll(loadProps(options.valueOf(commandConfigOpt))); | ||||||
} | ||||||
|
||||||
props.putAll(parseKeyValueArgs(options.valuesOf(producerPropertyOpt))); | ||||||
props.putAll(parseKeyValueArgs(options.valuesOf(commandPropertyOpt))); | ||||||
props.put(BOOTSTRAP_SERVERS_CONFIG, options.valueOf(bootstrapServerOpt)); | ||||||
props.put(COMPRESSION_TYPE_CONFIG, compressionCodec()); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,11 +87,21 @@ public ConsoleConsumerOptions(String[] args) throws IOException { | |
.describedAs("consume offset") | ||
.ofType(String.class) | ||
.defaultsTo("latest"); | ||
OptionSpec<String> consumerPropertyOpt = parser.accepts("consumer-property", "A mechanism to pass user-defined properties in the form key=value to the consumer.") | ||
OptionSpec<String> consumerPropertyOpt = parser.accepts("consumer-property", "(DEPRECATED) A mechanism to pass user-defined properties in the form key=value to the consumer." + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. Deprecated tag |
||
"This option will be removed in a future version. Use --command-property instead.") | ||
.withRequiredArg() | ||
.describedAs("consumer_prop") | ||
.ofType(String.class); | ||
OptionSpec<String> consumerConfigOpt = parser.accepts("consumer.config", "Consumer config properties file. Note that " + consumerPropertyOpt + " takes precedence over this config.") | ||
OptionSpec<String> commandPropertyOpt = parser.accepts("command-property", "A mechanism to pass user-defined properties in the form key=value to the consumer.") | ||
.withRequiredArg() | ||
.describedAs("consumer_prop") | ||
.ofType(String.class); | ||
OptionSpec<String> consumerConfigOpt = parser.accepts("consumer.config", "(DEPRECATED) Consumer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config." + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space. |
||
"This option will be removed in a future version. Use --command-config instead.") | ||
.withRequiredArg() | ||
.describedAs("config file") | ||
.ofType(String.class); | ||
OptionSpec<String> commandConfigOpt = parser.accepts("command-config", "Consumer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config.") | ||
.withRequiredArg() | ||
.describedAs("config file") | ||
.ofType(String.class); | ||
|
@@ -170,11 +180,25 @@ public ConsoleConsumerOptions(String[] args) throws IOException { | |
CommandLineUtils.maybePrintHelpOrVersion(this, "This tool helps to read data from Kafka topics and outputs it to standard output."); | ||
|
||
checkRequiredArgs(); | ||
if (options.has(consumerPropertyOpt) && options.has(commandPropertyOpt)) { | ||
CommandLineUtils.printUsageAndExit(parser, "Options --consumer-property and --command-property cannot be specified together."); | ||
} | ||
if (options.has(consumerConfigOpt) && options.has(commandConfigOpt)) { | ||
CommandLineUtils.printUsageAndExit(parser, "Options --consumer.config and --command-config cannot be specified together."); | ||
} | ||
|
||
Properties consumerPropsFromFile = options.has(consumerConfigOpt) | ||
? Utils.loadProps(options.valueOf(consumerConfigOpt)) | ||
if (options.has(consumerPropertyOpt)) { | ||
System.out.println("Option --consumer-property is deprecated and will be removed in a future version. Use --command-property instead."); | ||
commandPropertyOpt = consumerPropertyOpt; | ||
} | ||
if (options.has(consumerConfigOpt)) { | ||
System.out.println("Option --consumer.config is deprecated and will be removed in a future version. Use --command-config instead."); | ||
commandConfigOpt = consumerConfigOpt; | ||
} | ||
Properties consumerPropsFromFile = options.has(commandConfigOpt) | ||
? Utils.loadProps(options.valueOf(commandConfigOpt)) | ||
: new Properties(); | ||
Properties extraConsumerProps = CommandLineUtils.parseKeyValueArgs(options.valuesOf(consumerPropertyOpt)); | ||
Properties extraConsumerProps = CommandLineUtils.parseKeyValueArgs(options.valuesOf(commandPropertyOpt)); | ||
Set<String> groupIdsProvided = checkConsumerGroup(consumerPropsFromFile, extraConsumerProps); | ||
consumerProps = buildConsumerProps(consumerPropsFromFile, extraConsumerProps, groupIdsProvided); | ||
offset = parseOffset(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,11 +58,21 @@ public ConsoleShareConsumerOptions(String[] args) throws IOException { | |
.withRequiredArg() | ||
.describedAs("topic") | ||
.ofType(String.class); | ||
OptionSpec<String> consumerPropertyOpt = parser.accepts("consumer-property", "A mechanism to pass user-defined properties in the form key=value to the consumer.") | ||
OptionSpec<String> consumerPropertyOpt = parser.accepts("consumer-property", "(DEPRECATED) A mechanism to pass user-defined properties in the form key=value to the consumer. " + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. Deprecated tag |
||
"This option will be removed in a future version. Use --command-property instead.") | ||
.withRequiredArg() | ||
.describedAs("consumer_prop") | ||
.ofType(String.class); | ||
OptionSpec<String> consumerConfigOpt = parser.accepts("consumer-config", "Consumer config properties file. Note that " + consumerPropertyOpt + " takes precedence over this config.") | ||
OptionSpec<String> commandPropertyOpt = parser.accepts("command-property", "A mechanism to pass user-defined properties in the form key=value to the consumer.") | ||
.withRequiredArg() | ||
.describedAs("consumer_prop") | ||
.ofType(String.class); | ||
OptionSpec<String> consumerConfigOpt = parser.accepts("consumer-config", "(DEPRECATED) Consumer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config. " + | ||
"This option will be removed in a future version. Use --command-config instead.") | ||
.withRequiredArg() | ||
.describedAs("config file") | ||
.ofType(String.class); | ||
OptionSpec<String> commandConfigOpt = parser.accepts("command-config", "Consumer config properties file. Note that " + commandPropertyOpt + " takes precedence over this config.") | ||
.withRequiredArg() | ||
.describedAs("config file") | ||
.ofType(String.class); | ||
|
@@ -141,10 +151,26 @@ public ConsoleShareConsumerOptions(String[] args) throws IOException { | |
CommandLineUtils.printUsageAndExit(parser, "At most one of --reject and --release may be specified."); | ||
} | ||
|
||
Properties consumerPropsFromFile = options.has(consumerConfigOpt) | ||
? Utils.loadProps(options.valueOf(consumerConfigOpt)) | ||
if (options.has(consumerPropertyOpt) && options.has(commandPropertyOpt)) { | ||
CommandLineUtils.printUsageAndExit(parser, "Options --consumer-property and --command-property cannot be specified together."); | ||
} | ||
if (options.has(consumerConfigOpt) && options.has(commandConfigOpt)) { | ||
CommandLineUtils.printUsageAndExit(parser, "Options --consumer-config and --command-config cannot be specified together."); | ||
} | ||
|
||
if (options.has(consumerPropertyOpt)) { | ||
System.out.println("Option --consumer-property is deprecated and will be removed in a future version. Use --command-property instead."); | ||
commandPropertyOpt = consumerPropertyOpt; | ||
} | ||
if (options.has(consumerConfigOpt)) { | ||
System.out.println("Option --consumer-config is deprecated and will be removed in a future version. Use --command-config instead."); | ||
commandConfigOpt = consumerConfigOpt; | ||
} | ||
|
||
Properties consumerPropsFromFile = options.has(commandConfigOpt) | ||
? Utils.loadProps(options.valueOf(commandConfigOpt)) | ||
: new Properties(); | ||
Properties extraConsumerProps = CommandLineUtils.parseKeyValueArgs(options.valuesOf(consumerPropertyOpt)); | ||
Properties extraConsumerProps = CommandLineUtils.parseKeyValueArgs(options.valuesOf(commandPropertyOpt)); | ||
|
||
Set<String> groupIdsProvided = checkShareGroup(consumerPropsFromFile, extraConsumerProps); | ||
consumerProps = buildConsumerProps(consumerPropsFromFile, extraConsumerProps, groupIdsProvided); | ||
|
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.
Please add deprecate tag like @deprecated(since = "4.2", forRemoval = true)