This is an automated email from the ASF dual-hosted git repository.
yubiao pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 3ccc2136ff0 [fix][broker] Fix geo-replication admin client url (#22584)
3ccc2136ff0 is described below
commit 3ccc2136ff0630ea8075dabc5ed63d8d9afc9098
Author: Kai Wang <[email protected]>
AuthorDate: Thu May 9 13:53:02 2024 +0800
[fix][broker] Fix geo-replication admin client url (#22584)
(cherry picked from commit bd4c57d27c4acd37206a4f5ffdad3705cdc96c8c)
---
.../org/apache/pulsar/broker/service/BrokerService.java | 8 +++-----
.../apache/pulsar/broker/service/ReplicatorTestBase.java | 14 ++++++++++++--
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
index 5c369b42fce..cee53e90678 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
@@ -1535,13 +1535,11 @@ public class BrokerService implements Closeable {
}
boolean isTlsEnabled = data.isBrokerClientTlsEnabled() ||
conf.isBrokerClientTlsEnabled();
- if (isTlsEnabled &&
StringUtils.isEmpty(data.getServiceUrlTls())) {
- throw new IllegalArgumentException("serviceUrlTls is
empty, brokerClientTlsEnabled: "
+ final String adminApiUrl = isTlsEnabled ?
data.getServiceUrlTls() : data.getServiceUrl();
+ if (StringUtils.isEmpty(adminApiUrl)) {
+ throw new IllegalArgumentException("The adminApiUrl is
empty, brokerClientTlsEnabled: "
+ isTlsEnabled);
- } else if (StringUtils.isEmpty(data.getServiceUrl())) {
- throw new IllegalArgumentException("serviceUrl is empty,
brokerClientTlsEnabled: " + isTlsEnabled);
}
- String adminApiUrl = isTlsEnabled ? data.getServiceUrlTls() :
data.getServiceUrl();
builder.serviceHttpUrl(adminApiUrl);
if (data.isBrokerClientTlsEnabled()) {
configAdminTlsSettings(builder,
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java
index 97a2f633d81..b3a078552d6 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java
@@ -20,6 +20,7 @@ package org.apache.pulsar.broker.service;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
import com.google.common.io.Resources;
import com.google.common.collect.Sets;
@@ -254,9 +255,7 @@ public abstract class ReplicatorTestBase extends
TestRetrySupport {
.brokerClientTlsTrustStoreType(keyStoreType)
.build());
admin4.clusters().createCluster(cluster4, ClusterData.builder()
- .serviceUrl(url4.toString())
.serviceUrlTls(urlTls4.toString())
- .brokerServiceUrl(pulsar4.getBrokerServiceUrl())
.brokerServiceUrlTls(pulsar4.getBrokerServiceUrlTls())
.brokerClientTlsEnabled(true)
.brokerClientCertificateFilePath(clientCertFilePath)
@@ -279,9 +278,20 @@ public abstract class ReplicatorTestBase extends
TestRetrySupport {
assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrl(),
url1.toString());
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrl(),
url2.toString());
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrl(),
url3.toString());
+ assertNull(admin2.clusters().getCluster(cluster4).getServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrl(),
pulsar1.getBrokerServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrl(),
pulsar2.getBrokerServiceUrl());
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrl(),
pulsar3.getBrokerServiceUrl());
+
assertNull(admin2.clusters().getCluster(cluster4).getBrokerServiceUrl());
+
+
assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrlTls(),
urlTls1.toString());
+
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrlTls(),
urlTls2.toString());
+
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrlTls(),
urlTls3.toString());
+
assertEquals(admin2.clusters().getCluster(cluster4).getServiceUrlTls(),
urlTls4.toString());
+
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrlTls(),
pulsar1.getBrokerServiceUrlTls());
+
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrlTls(),
pulsar2.getBrokerServiceUrlTls());
+
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrlTls(),
pulsar3.getBrokerServiceUrlTls());
+
assertEquals(admin2.clusters().getCluster(cluster4).getBrokerServiceUrlTls(),
pulsar4.getBrokerServiceUrlTls());
// Also create V1 namespace for compatibility check
admin1.clusters().createCluster("global", ClusterData.builder()