This is an automated email from the ASF dual-hosted git repository.
nodece pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new c800b52f081 [improve][admin] Apply all configurations instead of
partial ones (#25245)
c800b52f081 is described below
commit c800b52f081465ec8e2b35f47dac5eb4907c002c
Author: Zixuan Liu <[email protected]>
AuthorDate: Fri May 1 22:42:13 2026 +0800
[improve][admin] Apply all configurations instead of partial ones (#25245)
---
conf/client.conf | 2 +-
.../admin/cli/PulsarAdminPropertiesProvider.java | 2 +
.../apache/pulsar/admin/cli/PulsarAdminTool.java | 49 ++++-------------
.../client/cli/PulsarClientPropertiesProvider.java | 2 +
.../apache/pulsar/client/cli/PulsarClientTool.java | 64 ++++------------------
5 files changed, 25 insertions(+), 94 deletions(-)
diff --git a/conf/client.conf b/conf/client.conf
index 25d65c3947e..5942bdb75cb 100644
--- a/conf/client.conf
+++ b/conf/client.conf
@@ -92,7 +92,7 @@ webserviceTlsProvider=
proxyServiceUrl=
#Proxy protocol to select type of routing at proxy
-proxyProtocol=
+#proxyProtocol=
# Pulsar Admin Custom Commands
#customCommandFactoriesDirectory=commandFactories
diff --git
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminPropertiesProvider.java
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminPropertiesProvider.java
index 85d350ce99b..5bfb082dfe6 100644
---
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminPropertiesProvider.java
+++
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminPropertiesProvider.java
@@ -21,10 +21,12 @@ package org.apache.pulsar.admin.cli;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.Properties;
+import lombok.Getter;
import picocli.CommandLine.PropertiesDefaultProvider;
class PulsarAdminPropertiesProvider extends PropertiesDefaultProvider {
private static final String webServiceUrlKey = "webServiceUrl";
+ @Getter
private final Properties properties;
private PulsarAdminPropertiesProvider(Properties properties) {
diff --git
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
index 17d3e60cb38..8d4ea43ec3b 100644
---
a/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
+++
b/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/PulsarAdminTool.java
@@ -37,7 +37,6 @@ import
org.apache.pulsar.admin.cli.utils.CustomCommandFactoryProvider;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminBuilder;
import org.apache.pulsar.client.admin.internal.PulsarAdminImpl;
-import org.apache.pulsar.common.util.DefaultPulsarSslFactory;
import org.apache.pulsar.common.util.ShutdownUtil;
import org.apache.pulsar.internal.CommandHook;
import org.apache.pulsar.internal.CommanderFactory;
@@ -108,47 +107,20 @@ public class PulsarAdminTool implements CommandHook {
public PulsarAdminTool(Properties properties) throws Exception {
// Use -v instead -V
System.setProperty("picocli.version.name.0", "-v");
+ pulsarAdminPropertiesProvider =
PulsarAdminPropertiesProvider.create(properties);
commander = CommanderFactory.createRootCommanderWithHook(this,
pulsarAdminPropertiesProvider);
- pulsarAdminSupplier = new
PulsarAdminSupplier(createAdminBuilderFromProperties(properties), rootParams);
- initCommander(properties);
+ pulsarAdminSupplier =
+ new
PulsarAdminSupplier(createAdminBuilderFromProperties(pulsarAdminPropertiesProvider.getProperties()),
+ rootParams);
+ initCommander(pulsarAdminPropertiesProvider.getProperties());
}
private static PulsarAdminBuilder
createAdminBuilderFromProperties(Properties properties) {
- boolean useKeyStoreTls = Boolean
- .parseBoolean(properties.getProperty("useKeyStoreTls",
"false"));
- String tlsTrustStoreType = properties.getProperty("tlsTrustStoreType",
"JKS");
- String tlsTrustStorePath = properties.getProperty("tlsTrustStorePath");
- String tlsTrustStorePassword =
properties.getProperty("tlsTrustStorePassword");
- String tlsKeyStoreType = properties.getProperty("tlsKeyStoreType",
"JKS");
- String tlsKeyStorePath = properties.getProperty("tlsKeyStorePath");
- String tlsKeyStorePassword =
properties.getProperty("tlsKeyStorePassword");
- String tlsKeyFilePath = properties.getProperty("tlsKeyFilePath");
- String tlsCertificateFilePath =
properties.getProperty("tlsCertificateFilePath");
-
- boolean tlsAllowInsecureConnection = Boolean.parseBoolean(properties
- .getProperty("tlsAllowInsecureConnection", "false"));
-
- boolean tlsEnableHostnameVerification = Boolean.parseBoolean(properties
- .getProperty("tlsEnableHostnameVerification", "false"));
- final String tlsTrustCertsFilePath =
properties.getProperty("tlsTrustCertsFilePath");
- final String sslFactoryPlugin =
properties.getProperty("sslFactoryPlugin",
- DefaultPulsarSslFactory.class.getName());
- final String sslFactoryPluginParams =
properties.getProperty("sslFactoryPluginParams", "");
-
- return
PulsarAdmin.builder().allowTlsInsecureConnection(tlsAllowInsecureConnection)
- .enableTlsHostnameVerification(tlsEnableHostnameVerification)
- .tlsTrustCertsFilePath(tlsTrustCertsFilePath)
- .useKeyStoreTls(useKeyStoreTls)
- .tlsTrustStoreType(tlsTrustStoreType)
- .tlsTrustStorePath(tlsTrustStorePath)
- .tlsTrustStorePassword(tlsTrustStorePassword)
- .tlsKeyStoreType(tlsKeyStoreType)
- .tlsKeyStorePath(tlsKeyStorePath)
- .tlsKeyStorePassword(tlsKeyStorePassword)
- .tlsKeyFilePath(tlsKeyFilePath)
- .tlsCertificateFilePath(tlsCertificateFilePath)
- .sslFactoryPlugin(sslFactoryPlugin)
- .sslFactoryPluginParams(sslFactoryPluginParams);
+ Map<String, Object> conf = new HashMap<>();
+ for (String key : properties.stringPropertyNames()) {
+ conf.put(key, properties.getProperty(key));
+ }
+ return PulsarAdmin.builder().loadConf(conf);
}
private void setupCommands(Properties properties) {
@@ -268,7 +240,6 @@ public class PulsarAdminTool implements CommandHook {
private void initCommander(Properties properties) throws IOException {
customCommandFactories =
CustomCommandFactoryProvider.createCustomCommandFactories(properties);
- pulsarAdminPropertiesProvider =
PulsarAdminPropertiesProvider.create(properties);
commander.setDefaultValueProvider(pulsarAdminPropertiesProvider);
commandMap = new HashMap<>();
commandMap.put("clusters", CmdClusters.class);
diff --git
a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientPropertiesProvider.java
b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientPropertiesProvider.java
index accc5df8595..5976a3728b0 100644
---
a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientPropertiesProvider.java
+++
b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientPropertiesProvider.java
@@ -21,10 +21,12 @@ package org.apache.pulsar.client.cli;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.Properties;
+import lombok.Getter;
import picocli.CommandLine.PropertiesDefaultProvider;
class PulsarClientPropertiesProvider extends PropertiesDefaultProvider {
private static final String brokerServiceUrlKey = "brokerServiceUrl";
+ @Getter
private final Properties properties;
private PulsarClientPropertiesProvider(Properties properties) {
diff --git
a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientTool.java
b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientTool.java
index 98f12944173..4203d75ba4a 100644
---
a/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientTool.java
+++
b/pulsar-client-tools/src/main/java/org/apache/pulsar/client/cli/PulsarClientTool.java
@@ -22,6 +22,8 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
import com.google.common.annotations.VisibleForTesting;
import java.io.FileInputStream;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Properties;
import lombok.Getter;
import lombok.SneakyThrows;
@@ -96,23 +98,6 @@ public class PulsarClientTool implements CommandHook {
@ArgGroup(exclusive = false)
protected RootParams rootParams = new RootParams();
- boolean tlsAllowInsecureConnection;
- boolean tlsEnableHostnameVerification;
-
- String tlsKeyFilePath;
- String tlsCertificateFilePath;
-
-
- // for tls with keystore type config
- boolean useKeyStoreTls;
- String tlsTrustStoreType;
- String tlsTrustStorePath;
- String tlsTrustStorePassword;
- String tlsKeyStoreType;
- String tlsKeyStorePath;
- String tlsKeyStorePassword;
- String sslFactoryPlugin;
- String sslFactoryPluginParams;
protected final CommandLine commander;
protected CmdProduce produceCommand;
@@ -139,24 +124,6 @@ public class PulsarClientTool implements CommandHook {
readCommand = new CmdRead();
generateDocumentation = new CmdGenerateDocumentation();
- this.tlsAllowInsecureConnection = Boolean
-
.parseBoolean(properties.getProperty("tlsAllowInsecureConnection", "false"));
- this.tlsEnableHostnameVerification = Boolean
-
.parseBoolean(properties.getProperty("tlsEnableHostnameVerification", "false"));
- this.useKeyStoreTls = Boolean
- .parseBoolean(properties.getProperty("useKeyStoreTls",
"false"));
- this.tlsTrustStoreType = properties.getProperty("tlsTrustStoreType",
"JKS");
- this.tlsTrustStorePath = properties.getProperty("tlsTrustStorePath");
- this.tlsTrustStorePassword =
properties.getProperty("tlsTrustStorePassword");
-
- this.tlsKeyStoreType = properties.getProperty("tlsKeyStoreType",
"JKS");
- this.tlsKeyStorePath = properties.getProperty("tlsKeyStorePath");
- this.tlsKeyStorePassword =
properties.getProperty("tlsKeyStorePassword");
- this.tlsKeyFilePath = properties.getProperty("tlsKeyFilePath");
- this.tlsCertificateFilePath =
properties.getProperty("tlsCertificateFilePath");
- this.sslFactoryPlugin = properties.getProperty("sslFactoryPlugin");
- this.sslFactoryPluginParams =
properties.getProperty("sslFactoryPluginParams");
-
pulsarClientPropertiesProvider =
PulsarClientPropertiesProvider.create(properties);
commander.setDefaultValueProvider(pulsarClientPropertiesProvider);
commander.addSubcommand("produce", produceCommand);
@@ -170,7 +137,13 @@ public class PulsarClientTool implements CommandHook {
}
private int updateConfig() throws UnsupportedAuthenticationException {
- ClientBuilder clientBuilder = PulsarClient.builder()
+ Map<String, Object> conf = new HashMap<>();
+ Properties properties = pulsarClientPropertiesProvider.getProperties();
+ for (String key : properties.stringPropertyNames()) {
+ conf.put(key, properties.getProperty(key));
+ }
+
+ ClientBuilder clientBuilder = PulsarClient.builder().loadConf(conf)
.memoryLimit(rootParams.memoryLimit, SizeUnit.BYTES);
Authentication authentication = null;
if (isNotBlank(this.rootParams.authPluginClassName)) {
@@ -180,25 +153,8 @@ public class PulsarClientTool implements CommandHook {
if (isNotBlank(this.rootParams.listenerName)) {
clientBuilder.listenerName(this.rootParams.listenerName);
}
-
clientBuilder.allowTlsInsecureConnection(this.tlsAllowInsecureConnection);
-
clientBuilder.enableTlsHostnameVerification(this.tlsEnableHostnameVerification);
clientBuilder.serviceUrl(rootParams.serviceURL);
-
-
clientBuilder.tlsTrustCertsFilePath(this.rootParams.tlsTrustCertsFilePath)
- .tlsKeyFilePath(tlsKeyFilePath)
- .tlsCertificateFilePath(tlsCertificateFilePath);
-
- clientBuilder.useKeyStoreTls(useKeyStoreTls)
- .tlsTrustStoreType(tlsTrustStoreType)
- .tlsTrustStorePath(tlsTrustStorePath)
- .tlsTrustStorePassword(tlsTrustStorePassword)
- .tlsKeyStoreType(tlsKeyStoreType)
- .tlsKeyStorePath(tlsKeyStorePath)
- .tlsKeyStorePassword(tlsKeyStorePassword);
-
- clientBuilder.sslFactoryPlugin(sslFactoryPlugin)
- .sslFactoryPluginParams(sslFactoryPluginParams);
-
+
clientBuilder.tlsTrustCertsFilePath(this.rootParams.tlsTrustCertsFilePath);
if (isNotBlank(rootParams.proxyServiceURL)) {
if (rootParams.proxyProtocol == null) {
commander.getErr().println("proxy-protocol must be provided
with proxy-url");