Skip to content

Commit 6993e0e

Browse files
Demogorgon314nikhil-ctds
authored andcommitted
[fix][broker] Fix geo-replication admin client url (apache#22584)
(cherry picked from commit bd4c57d) (cherry picked from commit 3ccc213)
1 parent 48f194a commit 6993e0e

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1516,13 +1516,11 @@ public PulsarAdmin getClusterPulsarAdmin(String cluster, Optional<ClusterData> c
15161516
}
15171517

15181518
boolean isTlsEnabled = data.isBrokerClientTlsEnabled() || conf.isBrokerClientTlsEnabled();
1519-
if (isTlsEnabled && StringUtils.isEmpty(data.getServiceUrlTls())) {
1520-
throw new IllegalArgumentException("serviceUrlTls is empty, brokerClientTlsEnabled: "
1519+
final String adminApiUrl = isTlsEnabled ? data.getServiceUrlTls() : data.getServiceUrl();
1520+
if (StringUtils.isEmpty(adminApiUrl)) {
1521+
throw new IllegalArgumentException("The adminApiUrl is empty, brokerClientTlsEnabled: "
15211522
+ isTlsEnabled);
1522-
} else if (StringUtils.isEmpty(data.getServiceUrl())) {
1523-
throw new IllegalArgumentException("serviceUrl is empty, brokerClientTlsEnabled: " + isTlsEnabled);
15241523
}
1525-
String adminApiUrl = isTlsEnabled ? data.getServiceUrlTls() : data.getServiceUrl();
15261524
builder.serviceHttpUrl(adminApiUrl);
15271525
if (data.isBrokerClientTlsEnabled()) {
15281526
configAdminTlsSettings(builder,

pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTestBase.java

+12-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import static org.testng.Assert.assertEquals;
2222
import static org.testng.Assert.assertNotNull;
23+
import static org.testng.Assert.assertNull;
2324

2425
import com.google.common.io.Resources;
2526
import com.google.common.collect.Sets;
@@ -254,9 +255,7 @@ protected void setup() throws Exception {
254255
.brokerClientTlsTrustStoreType(keyStoreType)
255256
.build());
256257
admin4.clusters().createCluster(cluster4, ClusterData.builder()
257-
.serviceUrl(url4.toString())
258258
.serviceUrlTls(urlTls4.toString())
259-
.brokerServiceUrl(pulsar4.getBrokerServiceUrl())
260259
.brokerServiceUrlTls(pulsar4.getBrokerServiceUrlTls())
261260
.brokerClientTlsEnabled(true)
262261
.brokerClientCertificateFilePath(clientCertFilePath)
@@ -279,9 +278,20 @@ protected void setup() throws Exception {
279278
assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrl(), url1.toString());
280279
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrl(), url2.toString());
281280
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrl(), url3.toString());
281+
assertNull(admin2.clusters().getCluster(cluster4).getServiceUrl());
282282
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrl(), pulsar1.getBrokerServiceUrl());
283283
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrl(), pulsar2.getBrokerServiceUrl());
284284
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrl(), pulsar3.getBrokerServiceUrl());
285+
assertNull(admin2.clusters().getCluster(cluster4).getBrokerServiceUrl());
286+
287+
assertEquals(admin2.clusters().getCluster(cluster1).getServiceUrlTls(), urlTls1.toString());
288+
assertEquals(admin2.clusters().getCluster(cluster2).getServiceUrlTls(), urlTls2.toString());
289+
assertEquals(admin2.clusters().getCluster(cluster3).getServiceUrlTls(), urlTls3.toString());
290+
assertEquals(admin2.clusters().getCluster(cluster4).getServiceUrlTls(), urlTls4.toString());
291+
assertEquals(admin2.clusters().getCluster(cluster1).getBrokerServiceUrlTls(), pulsar1.getBrokerServiceUrlTls());
292+
assertEquals(admin2.clusters().getCluster(cluster2).getBrokerServiceUrlTls(), pulsar2.getBrokerServiceUrlTls());
293+
assertEquals(admin2.clusters().getCluster(cluster3).getBrokerServiceUrlTls(), pulsar3.getBrokerServiceUrlTls());
294+
assertEquals(admin2.clusters().getCluster(cluster4).getBrokerServiceUrlTls(), pulsar4.getBrokerServiceUrlTls());
285295

286296
// Also create V1 namespace for compatibility check
287297
admin1.clusters().createCluster("global", ClusterData.builder()

0 commit comments

Comments
 (0)