diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java index f982622fd34e820ce5556ab88f8cdce796894857..8d8ecc23637ab7cbcc825c52e23d7b6aa6add422 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java @@ -18,6 +18,7 @@ */ package org.apache.pulsar.testclient; +import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.FileInputStream; @@ -100,6 +101,14 @@ public class PerformanceConsumer { @Parameter(names = { "--auth_params" }, description = "Authentication parameters, e.g., \"key1:val1,key2:val2\"") public String authParams; + + @Parameter(names = { + "--use-tls" }, description = "Use TLS encryption on the connection") + public boolean useTls; + + @Parameter(names = { + "--trust-cert-file" }, description = "Path for the trusted TLS certificate file") + public String tlsTrustCertsFilePath = ""; } public static void main(String[] args) throws Exception { @@ -150,6 +159,14 @@ public class PerformanceConsumer { if (arguments.authParams == null) { arguments.authParams = prop.getProperty("authParams", null); } + + if (arguments.useTls == false) { + arguments.useTls = Boolean.parseBoolean(prop.getProperty("useTls")); + } + + if (isBlank(arguments.tlsTrustCertsFilePath)) { + arguments.tlsTrustCertsFilePath = prop.getProperty("tlsTrustCertsFilePath", ""); + } } // Dump config variables @@ -181,6 +198,8 @@ public class PerformanceConsumer { if (isNotBlank(arguments.authPluginClassName)) { clientConf.setAuthentication(arguments.authPluginClassName, arguments.authParams); } + clientConf.setUseTls(arguments.useTls); + clientConf.setTlsTrustCertsFilePath(arguments.tlsTrustCertsFilePath); PulsarClient pulsarClient = new PulsarClientImpl(arguments.serviceURL, clientConf); List> futures = Lists.newArrayList(); @@ -235,4 +254,4 @@ public class PerformanceConsumer { } private static final Logger log = LoggerFactory.getLogger(PerformanceConsumer.class); -} \ No newline at end of file +} diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java index f20fa52834ff4cd6317491da6a24e3ca6e5db440..8de85bf1a108cbd3e6d13cc3f5b8c0b688c4b91b 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java @@ -19,6 +19,7 @@ package org.apache.pulsar.testclient; import static java.util.concurrent.TimeUnit.NANOSECONDS; +import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.FileInputStream; @@ -132,6 +133,14 @@ public class PerformanceProducer { @Parameter(names = { "-time", "--test-duration" }, description = "Test duration in secs. If 0, it will keep publishing") public long testTime = 0; + + @Parameter(names = { + "--use-tls" }, description = "Use TLS encryption on the connection") + public boolean useTls; + + @Parameter(names = { + "--trust-cert-file" }, description = "Path for the trusted TLS certificate file") + public String tlsTrustCertsFilePath = ""; } public static void main(String[] args) throws Exception { @@ -182,6 +191,14 @@ public class PerformanceProducer { if (arguments.authParams == null) { arguments.authParams = prop.getProperty("authParams", null); } + + if (arguments.useTls == false) { + arguments.useTls = Boolean.parseBoolean(prop.getProperty("useTls")); + } + + if (isBlank(arguments.tlsTrustCertsFilePath)) { + arguments.tlsTrustCertsFilePath = prop.getProperty("tlsTrustCertsFilePath", ""); + } } arguments.testTime = TimeUnit.SECONDS.toMillis(arguments.testTime); @@ -210,6 +227,8 @@ public class PerformanceProducer { if (isNotBlank(arguments.authPluginClassName)) { clientConf.setAuthentication(arguments.authPluginClassName, arguments.authParams); } + clientConf.setUseTls(arguments.useTls); + clientConf.setTlsTrustCertsFilePath(arguments.tlsTrustCertsFilePath); PulsarClient client = new PulsarClientImpl(arguments.serviceURL, clientConf); diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java index f3c42f9cdb7f0490dd356b025a089094a40bfbe7..9d158926867b6f9323c3ec928baa67f9b229378e 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java @@ -18,6 +18,7 @@ */ package org.apache.pulsar.testclient; +import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank; import java.io.FileInputStream; @@ -95,6 +96,14 @@ public class PerformanceReader { @Parameter(names = { "--auth-params" }, description = "Authentication parameters, e.g., \"key1:val1,key2:val2\"") public String authParams; + + @Parameter(names = { + "--use-tls" }, description = "Use TLS encryption on the connection") + public boolean useTls; + + @Parameter(names = { + "--trust-cert-file" }, description = "Path for the trusted TLS certificate file") + public String tlsTrustCertsFilePath = ""; } public static void main(String[] args) throws Exception { @@ -145,6 +154,14 @@ public class PerformanceReader { if (arguments.authParams == null) { arguments.authParams = prop.getProperty("authParams", null); } + + if (arguments.useTls == false) { + arguments.useTls = Boolean.parseBoolean(prop.getProperty("useTls")); + } + + if (isBlank(arguments.tlsTrustCertsFilePath)) { + arguments.tlsTrustCertsFilePath = prop.getProperty("tlsTrustCertsFilePath", ""); + } } // Dump config variables @@ -172,6 +189,8 @@ public class PerformanceReader { if (isNotBlank(arguments.authPluginClassName)) { clientConf.setAuthentication(arguments.authPluginClassName, arguments.authParams); } + clientConf.setUseTls(arguments.useTls); + clientConf.setTlsTrustCertsFilePath(arguments.tlsTrustCertsFilePath); PulsarClient pulsarClient = new PulsarClientImpl(arguments.serviceURL, clientConf); List> futures = Lists.newArrayList(); @@ -222,4 +241,4 @@ public class PerformanceReader { } private static final Logger log = LoggerFactory.getLogger(PerformanceReader.class); -} \ No newline at end of file +}