-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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-17374: add bootstrap.controller to kafka-reassign-partitions.sh #16964
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4912a69
wip
m1a2st be9f5c2
wip
m1a2st 40b3001
add new test for ReassignPartitionsCommandArgsTest
m1a2st 6411ba4
rewrite bootstrapControllerOpt description
m1a2st 3f34b6d
fix the bootstrap controller description
m1a2st 3db69e7
fix the bootstrap server description
m1a2st 9fced42
fix test and add validate
m1a2st 4570cf9
cancellation is work
m1a2st 00ff096
add new test for ReassignPartitionsCommand
m1a2st 097a526
add new test fot curReassignmentsToString
m1a2st fe0d823
fix unsupported action
m1a2st 4a6c498
remove test
m1a2st 1fe7c52
addressed by comments
m1a2st 6bec152
addressed by comments
m1a2st 4dc4e62
remove unused method
m1a2st 6c56ab4
Merge branch 'trunk' into gh-KAFKA-17374
m1a2st File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,12 @@ public static void main(String[] args) { | |
Properties props = opts.options.has(opts.commandConfigOpt) | ||
? Utils.loadProps(opts.options.valueOf(opts.commandConfigOpt)) | ||
: new Properties(); | ||
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, opts.options.valueOf(opts.bootstrapServerOpt)); | ||
validateBootstrapControllerNotSupportedAction(opts); | ||
if (opts.options.has(opts.bootstrapControllerOpt)) { | ||
props.put(AdminClientConfig.BOOTSTRAP_CONTROLLERS_CONFIG, opts.options.valueOf(opts.bootstrapControllerOpt)); | ||
} else { | ||
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, opts.options.valueOf(opts.bootstrapServerOpt)); | ||
} | ||
props.putIfAbsent(AdminClientConfig.CLIENT_ID_CONFIG, "reassign-partitions-tool"); | ||
adminClient = Admin.create(props); | ||
handleAction(adminClient, opts); | ||
|
@@ -151,6 +156,14 @@ public static void main(String[] args) { | |
} | ||
} | ||
|
||
private static void validateBootstrapControllerNotSupportedAction(ReassignPartitionsCommandOptions opts) { | ||
if (opts.options.has(opts.bootstrapControllerOpt)) { | ||
if (opts.options.has(opts.verifyOpt) || opts.options.has(opts.executeOpt) || opts.options.has(opts.generateOpt)) { | ||
throw new UnsupportedOperationException("The --bootstrap-controller option is not supported with these action."); | ||
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. Could you please add the unsupported actions to the comment? |
||
} | ||
} | ||
} | ||
|
||
private static void handleAction(Admin adminClient, ReassignPartitionsCommandOptions opts) throws IOException, ExecutionException, InterruptedException, TerseException { | ||
if (opts.options.has(opts.verifyOpt)) { | ||
verifyAssignment(adminClient, | ||
|
@@ -1405,9 +1418,15 @@ static ReassignPartitionsCommandOptions validateAndParseArgs(String[] args) { | |
} | ||
|
||
OptionSpec<?> action = allActions.get(0); | ||
|
||
if (!opts.options.has(opts.bootstrapServerOpt)) | ||
CommandLineUtils.printUsageAndExit(opts.parser, "Please specify --bootstrap-server"); | ||
|
||
OptionSpec<String> bootstrapOpt = null; | ||
|
||
if (opts.options.has(opts.bootstrapServerOpt) && opts.options.has(opts.bootstrapControllerOpt)) | ||
CommandLineUtils.printUsageAndExit(opts.parser, "Please don't specify both --bootstrap-server and --bootstrap-controller"); | ||
else if (!opts.options.has(opts.bootstrapServerOpt) && !opts.options.has(opts.bootstrapControllerOpt)) | ||
CommandLineUtils.printUsageAndExit(opts.parser, "Please specify either --bootstrap-server or --bootstrap-controller"); | ||
else | ||
bootstrapOpt = opts.options.has(opts.bootstrapServerOpt) ? opts.bootstrapServerOpt : opts.bootstrapControllerOpt; | ||
|
||
// Make sure that we have all the required arguments for our action. | ||
Map<OptionSpec<?>, List<OptionSpec<?>>> requiredArgs = new HashMap<>(); | ||
|
@@ -1432,32 +1451,32 @@ static ReassignPartitionsCommandOptions validateAndParseArgs(String[] args) { | |
Map<OptionSpec<?>, List<OptionSpec<?>>> permittedArgs = new HashMap<>(); | ||
|
||
permittedArgs.put(opts.verifyOpt, Arrays.asList( | ||
opts.bootstrapServerOpt, | ||
bootstrapOpt, | ||
opts.commandConfigOpt, | ||
opts.preserveThrottlesOpt | ||
)); | ||
permittedArgs.put(opts.generateOpt, Arrays.asList( | ||
opts.bootstrapServerOpt, | ||
bootstrapOpt, | ||
opts.brokerListOpt, | ||
opts.commandConfigOpt, | ||
opts.disableRackAware | ||
)); | ||
permittedArgs.put(opts.executeOpt, Arrays.asList( | ||
opts.additionalOpt, | ||
opts.bootstrapServerOpt, | ||
bootstrapOpt, | ||
opts.commandConfigOpt, | ||
opts.interBrokerThrottleOpt, | ||
opts.replicaAlterLogDirsThrottleOpt, | ||
opts.timeoutOpt | ||
)); | ||
permittedArgs.put(opts.cancelOpt, Arrays.asList( | ||
opts.bootstrapServerOpt, | ||
bootstrapOpt, | ||
opts.commandConfigOpt, | ||
opts.preserveThrottlesOpt, | ||
opts.timeoutOpt | ||
)); | ||
permittedArgs.put(opts.listOpt, Arrays.asList( | ||
opts.bootstrapServerOpt, | ||
bootstrapOpt, | ||
opts.commandConfigOpt | ||
)); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ public class ReassignPartitionsCommandOptions extends CommandDefaultOptions { | |
final OptionSpec<String> reassignmentJsonFileOpt; | ||
final OptionSpec<String> topicsToMoveJsonFileOpt; | ||
final OptionSpec<String> brokerListOpt; | ||
final OptionSpec<String> bootstrapControllerOpt; | ||
final OptionSpec<?> disableRackAware; | ||
final OptionSpec<Long> interBrokerThrottleOpt; | ||
final OptionSpec<Long> replicaAlterLogDirsThrottleOpt; | ||
|
@@ -54,8 +55,8 @@ public ReassignPartitionsCommandOptions(String[] args) { | |
listOpt = parser.accepts("list", "List all active partition reassignments."); | ||
|
||
// Arguments | ||
bootstrapServerOpt = parser.accepts("bootstrap-server", "REQUIRED: the server(s) to use for bootstrapping.") | ||
.withRequiredArg() | ||
bootstrapServerOpt = parser.accepts("bootstrap-server", "the server(s) to use for bootstrapping.") | ||
.withOptionalArg() | ||
.describedAs("Server(s) to use for bootstrapping") | ||
.ofType(String.class); | ||
|
||
|
@@ -83,6 +84,13 @@ public ReassignPartitionsCommandOptions(String[] args) { | |
.withRequiredArg() | ||
.describedAs("brokerlist") | ||
.ofType(String.class); | ||
|
||
bootstrapControllerOpt = parser.accepts("bootstrap-controller", "The controller to use for reassignment. " + | ||
"By default, the tool will get the quorum controller.") | ||
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. Please add the supported actions to the docs |
||
.withOptionalArg() | ||
.describedAs("bootstrap controller to connect to") | ||
.ofType(String.class); | ||
|
||
disableRackAware = parser.accepts("disable-rack-aware", "Disable rack aware replica assignment"); | ||
interBrokerThrottleOpt = parser.accepts("throttle", "The movement of partitions between brokers will be throttled to this value (bytes/sec). " + | ||
"This option can be included with --execute when a reassignment is started, and it can be altered by resubmitting the current reassignment " + | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you please move this to
validateAndParseArgs
?