Skip to content

Commit

Permalink
[testclient] Replace '--auth_plugin' with '--auth-plugin' (apache#12263)
Browse files Browse the repository at this point in the history
### Motivation
The name of the option should be linked with a horizontal line(-) instead of an underline(_) in CLI, so that it conforms to the unified standard.
Therefore, option --auth_plugin should be deprecated and replaced with --auth-plugin.

### Modifications
Hidden --auth_plugin
--auth_plug takes effect when --auth-plugin is blank and --auth_plugin is not blank
  • Loading branch information
yuruguo authored Oct 12, 2021
1 parent 3d7c3f8 commit 794f054
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.LongAdder;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -95,7 +94,10 @@ static class Arguments {
@Parameter(names = { "-t", "--num-topic" }, description = "Number of topics", validateWith = PositiveNumberParameterValidator.class)
public int numTopics = 1;

@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name")
@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name", hidden = true)
public String deprecatedAuthPluginClassName;

@Parameter(names = { "--auth-plugin" }, description = "Authentication plugin class name")
public String authPluginClassName;

@Parameter(
Expand Down Expand Up @@ -135,6 +137,10 @@ public Arguments loadArguments(String[] args) {
PerfClientUtils.exit(-1);
}

if (isBlank(arguments.authPluginClassName) && !isBlank(arguments.deprecatedAuthPluginClassName)) {
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
}

if (arguments.topics.size() != 1) {
System.err.println("Only one topic name is allowed");
jc.usage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ static class Arguments {
@Parameter(names = { "-u", "--service-url" }, description = "Pulsar Service URL")
public String serviceURL;

@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name")
@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name", hidden = true)
public String deprecatedAuthPluginClassName;

@Parameter(names = { "--auth-plugin" }, description = "Authentication plugin class name")
public String authPluginClassName;

@Parameter(names = { "--listener-name" }, description = "Listener name for the broker.")
Expand Down Expand Up @@ -202,6 +205,10 @@ public static void main(String[] args) throws Exception {
PerfClientUtils.exit(-1);
}

if (isBlank(arguments.authPluginClassName) && !isBlank(arguments.deprecatedAuthPluginClassName)) {
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
}

if (arguments.topic != null && arguments.topic.size() != arguments.numTopics) {
// keep compatibility with the previous version
if (arguments.topic.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ static class Arguments {
@Parameter(names = { "-au", "--admin-url" }, description = "Pulsar Admin URL")
public String adminURL;

@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name")
@Parameter(names = { "--auth_plugin" }, description = "Authentication plugin class name", hidden = true)
public String deprecatedAuthPluginClassName;

@Parameter(names = { "--auth-plugin" }, description = "Authentication plugin class name")
public String authPluginClassName;

@Parameter(names = { "--listener-name" }, description = "Listener name for the broker.")
Expand Down Expand Up @@ -271,6 +274,10 @@ public static void main(String[] args) throws Exception {
PerfClientUtils.exit(-1);
}

if (isBlank(arguments.authPluginClassName) && !isBlank(arguments.deprecatedAuthPluginClassName)) {
arguments.authPluginClassName = arguments.deprecatedAuthPluginClassName;
}

if (arguments.topics != null && arguments.topics.size() != arguments.numTopics) {
// keep compatibility with the previous version
if (arguments.topics.size() == 1) {
Expand Down
4 changes: 2 additions & 2 deletions site2/docs/performance-pulsar-perf.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ The following table lists configuration options available for the `pulsar-perf p
| access-mode | Set the producer access mode. Valid values are `Shared`, `Exclusive` and `WaitForExclusive`. | Shared |
| admin-url | Set the Pulsar admin URL. | N/A |
| auth-params | Set the authentication parameters, whose format is determined by the implementation of the `configure` method in the authentication plugin class, such as "key1:val1,key2:val2" or "{"key1":"val1","key2":"val2"}". | N/A |
| auth_plugin | Set the authentication plugin class name. | N/A |
| auth-plugin | Set the authentication plugin class name. | N/A |
| listener-name | Set the listener name for the broker. | N/A |
| batch-max-bytes | Set the maximum number of bytes for each batch. | 4194304 |
| batch-max-messages | Set the maximum number of messages for each batch. | 1000 |
Expand Down Expand Up @@ -122,7 +122,7 @@ The following table lists configuration options available for the `pulsar-perf c
|----|----|----|
| acks-delay-millis | Set the acknowledgment grouping delay in milliseconds. | 100 ms |
| auth-params | Set the authentication parameters, whose format is determined by the implementation of the `configure` method in the authentication plugin class, such as "key1:val1,key2:val2" or "{"key1":"val1","key2":"val2"}". | N/A |
| auth_plugin | Set the authentication plugin class name. | N/A |
| auth-plugin | Set the authentication plugin class name. | N/A |
| auto_ack_chunk_q_full | Configure whether to automatically ack for the oldest message in receiver queue if the queue is full. | false |
| listener-name | Set the listener name for the broker. | N/A |
| batch-index-ack | Enable or disable the batch index acknowledgment. | false |
Expand Down
8 changes: 4 additions & 4 deletions site2/docs/reference-cli-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ Options
|Flag|Description|Default|
|---|---|---|
|`--auth-params`|Authentication parameters, whose format is determined by the implementation of method `configure` in authentication plugin class. For example, `key1:val1,key2:val2` or `{"key1":"val1","key2":"val2"}`.||
|`--auth_plugin`|Authentication plugin class name||
|`--auth-plugin`|Authentication plugin class name||
|`-ac`, `--auto_ack_chunk_q_full`|Auto ack for the oldest message in consumer's receiver queue if the queue full|false|
|`--listener-name`|Listener name for the broker||
|`--acks-delay-millis`|Acknowledgements grouping delay in millis|100|
Expand Down Expand Up @@ -479,7 +479,7 @@ Options
|`-am`, `--access-mode`|Producer access mode. Valid values are `Shared`, `Exclusive` and `WaitForExclusive`|Shared|
|`-au`, `--admin-url`|Pulsar admin URL||
|`--auth-params`|Authentication parameters, whose format is determined by the implementation of method `configure` in authentication plugin class. For example, `key1:val1,key2:val2` or `{"key1":"val1","key2":"val2"}`.||
|`--auth_plugin`|Authentication plugin class name||
|`--auth-plugin`|Authentication plugin class name||
|`--listener-name`|Listener name for the broker||
|`-b`, `--batch-time-window`|Batch messages in a window of the specified number of milliseconds|1|
|`-bb`, `--batch-max-bytes`|Maximum number of bytes per batch|4194304|
Expand Down Expand Up @@ -533,7 +533,7 @@ Options
|Flag|Description|Default|
|---|---|---|
|`--auth-params`|Authentication parameters, whose format is determined by the implementation of method `configure` in authentication plugin class. For example, `key1:val1,key2:val2` or `{"key1":"val1","key2":"val2"}`.||
|`--auth_plugin`|Authentication plugin class name||
|`--auth-plugin`|Authentication plugin class name||
|`--listener-name`|Listener name for the broker||
|`--conf-file`|Configuration file||
|`-h`, `--help`|Help message|false|
Expand Down Expand Up @@ -564,7 +564,7 @@ Options
|Flag|Description|Default|
|---|---|---|
|`--auth-params`|Authentication parameters, whose format is determined by the implementation of method `configure` in authentication plugin class. For example, `key1:val1,key2:val2` or `{"key1":"val1","key2":"val2"}`.||
|`--auth_plugin`|Authentication plugin class name||
|`--auth-plugin`|Authentication plugin class name||
|`--conf-file`|Configuration file||
|`-h`, `--help`|Help message|false|
|`-m`, `--num-messages`|Number of messages to publish in total. If this value is less than or equal to 0, it keeps publishing messages.|0|
Expand Down
2 changes: 1 addition & 1 deletion site2/docs/security-oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ This example shows how to use pulsar-perf to connect to a cluster through OAuth2

```shell script
bin/pulsar-perf produce --service-url pulsar+ssl://streamnative.cloud:6651 \
--auth_plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
--auth-plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
--auth-params '{"privateKey":"file:///path/to/key/file.json",
"issuerUrl":"https://dev-kt-aa9ne.us.auth0.com",
"audience":"https://dev-kt-aa9ne.us.auth0.com/api/v2/"}' \
Expand Down
2 changes: 1 addition & 1 deletion site2/website-next/docs/security-oauth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ This example shows how to use pulsar-perf to connect to a cluster through OAuth2

```shell script
bin/pulsar-perf produce --service-url pulsar+ssl://streamnative.cloud:6651 \
--auth_plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
--auth-plugin org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2 \
--auth-params '{"privateKey":"file:///path/to/key/file.json",
"issuerUrl":"https://dev-kt-aa9ne.us.auth0.com",
"audience":"https://dev-kt-aa9ne.us.auth0.com/api/v2/"}' \
Expand Down

0 comments on commit 794f054

Please sign in to comment.