-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[pulsar-admin] Perfect judgment conditions of pulsar-admin #12315
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
[pulsar-admin] Perfect judgment conditions of pulsar-admin #12315
Conversation
|
Could you add more context about this change? It seems that your pulsar-admin command didn't find the config file. |
A detailed description has been added. |
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
Show resolved
Hide resolved
|
Did you move the configuration file? Then this exception occurs. |
you are right |
* up/master: [Doc] Add explanations for setting geo-replication at topic level (apache#12633) commit chapter Tiered Storage (apache#12592) [pulsar-admin] Add remove-subscription-types-enabled command for namespace (apache#12392) Enable CLI to publish non-batched messages (apache#12641) [Doc] Add doc for tokenSettingPrefix (apache#12662) [pulsar-admin] Add corresponding get command for namespace (apache#12322) [pulsar-admin] Perfect judgment conditions of pulsar-admin (apache#12315) [broker] Avoid unnecessary recalculation of maxSubscriptionsPerTopic in AbstractTopic (apache#12658) [Transaction]Stop TB recovering with exception (apache#12636) [website][upgrade]feat: docs migration - 2.7.1 / client (apache#12612) [website][upgrade]feat: docs migration - 2.7.1 / performance (apache#12611) [website][upgrade]feat: docs migration - 2.7.1 / security (apache#12610) [Modernizer] Apply Modernizer plugin for pulsar broker common module and fix violation. (apache#12657) [Authorization] Support GET_METADATA topic op after enable auth (apache#12656) Fix StringIndexOutOfBoundsException in org.apache.pulsar.broker.resources.NamespaceResources#pathIsFromNamespace (apache#12659)
* up/master: [Doc] Add explanations for setting geo-replication at topic level (apache#12633) commit chapter Tiered Storage (apache#12592) [pulsar-admin] Add remove-subscription-types-enabled command for namespace (apache#12392) Enable CLI to publish non-batched messages (apache#12641) [Doc] Add doc for tokenSettingPrefix (apache#12662) [pulsar-admin] Add corresponding get command for namespace (apache#12322) [pulsar-admin] Perfect judgment conditions of pulsar-admin (apache#12315) [broker] Avoid unnecessary recalculation of maxSubscriptionsPerTopic in AbstractTopic (apache#12658) [Transaction]Stop TB recovering with exception (apache#12636) [website][upgrade]feat: docs migration - 2.7.1 / client (apache#12612) [website][upgrade]feat: docs migration - 2.7.1 / performance (apache#12611) [website][upgrade]feat: docs migration - 2.7.1 / security (apache#12610) [Modernizer] Apply Modernizer plugin for pulsar broker common module and fix violation. (apache#12657) [Authorization] Support GET_METADATA topic op after enable auth (apache#12656) Fix StringIndexOutOfBoundsException in org.apache.pulsar.broker.resources.NamespaceResources#pathIsFromNamespace (apache#12659) # Conflicts: # site2/website-next/versioned_sidebars/version-2.7.2-sidebars.json
### Motivation Perfect judgment conditions of `bin/pulsar-admin`, included parameter `CONF_FILE_PATH` and field `serviceUrl`. **Details are as follows:** **First of all**, the configuration file `CONF_FILE_PATH` is a required option rather than an optional option (from the [source code](https://github.com/apache/pulsar/blob/master/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java#L288-L299), the configuration file is regarded as an optional option) , because some very important [default values](https://github.com/apache/pulsar/blob/master/conf/client.conf#L22-L30) (such as `webServiceUrl=http://localhost:8080/`, `brokerServiceUrl=pulsar://localhost:6650/`) cannot be obtained without a configuration file, and will mistake args[0] as the configuration file, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 Exception in thread "main" java.io.FileNotFoundException: topics (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:93) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:296) ``` so we first need to judge whether the configuration file `CONF_FILE_PATH` exists, and give the correct command line format (`Usage: pulsar-admin CONF_FILE_PATH [options] [command] [command options]`) if it is illegal. **Secondly**, `serviceUrl` is a very important field, because pulsarAdmin can connect to the pulsar server through this value. If the configuration file does not have releated `key`=`value`(such as `webServiceUrl`=, `brokerServiceUrl`=) and the user does not specify option `--admin-url`, then NPE will appear, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 java.lang.NullPointerException at org.apache.pulsar.client.admin.internal.PulsarAdminImpl.<init>(PulsarAdminImpl.java:189) at org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl.build(PulsarAdminBuilderImpl.java:47) at org.apache.pulsar.admin.cli.PulsarAdminTool.lambda$main$2(PulsarAdminTool.java:320) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:174) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:161) at org.apache.pulsar.admin.cli.CmdBase.getAdmin(CmdBase.java:111) at org.apache.pulsar.admin.cli.CmdTopics.getTopics(CmdTopics.java:2360) at org.apache.pulsar.admin.cli.CmdTopics.access$11000(CmdTopics.java:73) at org.apache.pulsar.admin.cli.CmdTopics$PartitionedTopicListCmd.run(CmdTopics.java:275) at org.apache.pulsar.admin.cli.CmdBase.run(CmdBase.java:86) at org.apache.pulsar.admin.cli.PulsarAdminTool.run(PulsarAdminTool.java:282) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:330) class java.lang.NullPointerException: null ``` so we need to judge whether field `serviceUrl` exists. (cherry picked from commit f976500)
) ### Motivation Perfect judgment conditions of `bin/pulsar-admin`, included parameter `CONF_FILE_PATH` and field `serviceUrl`. **Details are as follows:** **First of all**, the configuration file `CONF_FILE_PATH` is a required option rather than an optional option (from the [source code](https://github.com/apache/pulsar/blob/master/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java#L288-L299), the configuration file is regarded as an optional option) , because some very important [default values](https://github.com/apache/pulsar/blob/master/conf/client.conf#L22-L30) (such as `webServiceUrl=http://localhost:8080/`, `brokerServiceUrl=pulsar://localhost:6650/`) cannot be obtained without a configuration file, and will mistake args[0] as the configuration file, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 Exception in thread "main" java.io.FileNotFoundException: topics (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:93) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:296) ``` so we first need to judge whether the configuration file `CONF_FILE_PATH` exists, and give the correct command line format (`Usage: pulsar-admin CONF_FILE_PATH [options] [command] [command options]`) if it is illegal. **Secondly**, `serviceUrl` is a very important field, because pulsarAdmin can connect to the pulsar server through this value. If the configuration file does not have releated `key`=`value`(such as `webServiceUrl`=, `brokerServiceUrl`=) and the user does not specify option `--admin-url`, then NPE will appear, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 java.lang.NullPointerException at org.apache.pulsar.client.admin.internal.PulsarAdminImpl.<init>(PulsarAdminImpl.java:189) at org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl.build(PulsarAdminBuilderImpl.java:47) at org.apache.pulsar.admin.cli.PulsarAdminTool.lambda$main$2(PulsarAdminTool.java:320) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:174) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:161) at org.apache.pulsar.admin.cli.CmdBase.getAdmin(CmdBase.java:111) at org.apache.pulsar.admin.cli.CmdTopics.getTopics(CmdTopics.java:2360) at org.apache.pulsar.admin.cli.CmdTopics.access$11000(CmdTopics.java:73) at org.apache.pulsar.admin.cli.CmdTopics$PartitionedTopicListCmd.run(CmdTopics.java:275) at org.apache.pulsar.admin.cli.CmdBase.run(CmdBase.java:86) at org.apache.pulsar.admin.cli.PulsarAdminTool.run(PulsarAdminTool.java:282) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:330) class java.lang.NullPointerException: null ``` so we need to judge whether field `serviceUrl` exists.
### Motivation Perfect judgment conditions of `bin/pulsar-admin`, included parameter `CONF_FILE_PATH` and field `serviceUrl`. **Details are as follows:** **First of all**, the configuration file `CONF_FILE_PATH` is a required option rather than an optional option (from the [source code](https://github.com/apache/pulsar/blob/master/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java#L288-L299), the configuration file is regarded as an optional option) , because some very important [default values](https://github.com/apache/pulsar/blob/master/conf/client.conf#L22-L30) (such as `webServiceUrl=http://localhost:8080/`, `brokerServiceUrl=pulsar://localhost:6650/`) cannot be obtained without a configuration file, and will mistake args[0] as the configuration file, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 Exception in thread "main" java.io.FileNotFoundException: topics (No such file or directory) at java.io.FileInputStream.open0(Native Method) at java.io.FileInputStream.open(FileInputStream.java:195) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:93) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:296) ``` so we first need to judge whether the configuration file `CONF_FILE_PATH` exists, and give the correct command line format (`Usage: pulsar-admin CONF_FILE_PATH [options] [command] [command options]`) if it is illegal. **Secondly**, `serviceUrl` is a very important field, because pulsarAdmin can connect to the pulsar server through this value. If the configuration file does not have releated `key`=`value`(such as `webServiceUrl`=, `brokerServiceUrl`=) and the user does not specify option `--admin-url`, then NPE will appear, as follows: ``` ./bin/pulsar-admin topics list-partitioned-topics test/app1 java.lang.NullPointerException at org.apache.pulsar.client.admin.internal.PulsarAdminImpl.<init>(PulsarAdminImpl.java:189) at org.apache.pulsar.client.admin.internal.PulsarAdminBuilderImpl.build(PulsarAdminBuilderImpl.java:47) at org.apache.pulsar.admin.cli.PulsarAdminTool.lambda$main$2(PulsarAdminTool.java:320) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:174) at org.apache.pulsar.admin.cli.PulsarAdminTool$PulsarAdminSupplier.get(PulsarAdminTool.java:161) at org.apache.pulsar.admin.cli.CmdBase.getAdmin(CmdBase.java:111) at org.apache.pulsar.admin.cli.CmdTopics.getTopics(CmdTopics.java:2360) at org.apache.pulsar.admin.cli.CmdTopics.access$11000(CmdTopics.java:73) at org.apache.pulsar.admin.cli.CmdTopics$PartitionedTopicListCmd.run(CmdTopics.java:275) at org.apache.pulsar.admin.cli.CmdBase.run(CmdBase.java:86) at org.apache.pulsar.admin.cli.PulsarAdminTool.run(PulsarAdminTool.java:282) at org.apache.pulsar.admin.cli.PulsarAdminTool.main(PulsarAdminTool.java:330) class java.lang.NullPointerException: null ``` so we need to judge whether field `serviceUrl` exists. (cherry picked from commit f976500)
Motivation
Perfect judgment conditions of
bin/pulsar-admin, included parameterCONF_FILE_PATHand fieldserviceUrl.Details are as follows:
First of all, the configuration file
CONF_FILE_PATHis a required option rather than an optional option (from the source code, the configuration file is regarded as an optional option) , because some very important default values (such aswebServiceUrl=http://localhost:8080/,brokerServiceUrl=pulsar://localhost:6650/) cannot be obtained without a configuration file, and will mistake args[0] as the configuration file, as follows:so we first need to judge whether the configuration file
CONF_FILE_PATHexists, and give the correct command line format (Usage: pulsar-admin CONF_FILE_PATH [options] [command] [command options]) if it is illegal.Secondly,
serviceUrlis a very important field, because pulsarAdmin can connect to the pulsar server through this value. If the configuration file does not have releatedkey=value(such aswebServiceUrl=,brokerServiceUrl=) and the user does not specify option--admin-url, then NPE will appear, as follows:so we need to judge whether field
serviceUrlexists.Documentation