zplinuxlover commented on a change in pull request #6903:
URL: https://github.com/apache/pulsar/pull/6903#discussion_r42175
##
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##
@@ -146,6 +146,14 @@
)
private String advertisedAddress;
+//
+@FieldContext(category=CATEGORY_SERVER, doc = "")
Review comment:
I have add the configuration doc here
##
File path:
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##
@@ -146,6 +146,14 @@
)
private String advertisedAddress;
+//
Review comment:
I have remove the code for this line
##
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceEphemeralData.java
##
@@ -63,9 +81,17 @@ public void setDisabled(boolean flag) {
this.disabled = flag;
}
+@NotNull
+public Map getAdvertisedListeners() {
+if (this.advertisedListeners == null) {
+return Collections.unmodifiableMap(Collections.EMPTY_MAP);
Review comment:
I have fix the code
##
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
##
@@ -367,7 +387,22 @@ public boolean registerNamespace(String namespace, boolean
ensureOwned) throws P
if (LOG.isDebugEnabled()) {
LOG.debug("Namespace bundle {} already owned by {} ",
bundle, nsData);
}
-future.complete(Optional.of(new
LookupResult(nsData.get(;
+// find the target
+if (StringUtils.isNotBlank(advertisedListenerName)) {
+AdvertisedListener listener =
nsData.get().getAdvertisedListeners().get(advertisedListenerName);
+if (listener == null) {
+future.completeExceptionally(
+new PulsarServerException("the broker do
not have " + advertisedListenerName + " listener"));
+return;
+} else {
+future.complete(Optional.of(new LookupResult(
+nsData.get().getHttpUrl(),
nsData.get().getHttpUrlTls(), listener.getBrokerServiceUrl().toString(),
Review comment:
currently we only concern pulsar protocol here, the HttpUrl and
HttpUrlTls behavior as before
##
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/namespace/NamespaceService.java
##
@@ -447,8 +488,23 @@ private void searchForCandidateBroker(NamespaceBundle
bundle,
// Schedule the task to pre-load topics
pulsar.loadNamespaceTopics(bundle);
-
-lookupFuture.complete(Optional.of(new
LookupResult(ownerInfo)));
+// find the target
+if (StringUtils.isNotBlank(advertisedListenerName)) {
+AdvertisedListener listener =
ownerInfo.getAdvertisedListeners().get(advertisedListenerName);
+if (listener == null) {
+lookupFuture.completeExceptionally(
+new PulsarServerException("the broker
do not have " + advertisedListenerName + " listener"));
+return;
+} else {
+lookupFuture.complete(Optional.of(new
LookupResult(
+ownerInfo.getHttpUrl(),
ownerInfo.getHttpUrlTls(), listener.getBrokerServiceUrl().toString(),
Review comment:
currently we only concern pulsar protocol here, the HttpUrl and
HttpUrlTls behavior as before.
##
File path:
pulsar-common/src/main/java/org/apache/pulsar/policies/data/loadbalancer/AdvertisedListener.java
##
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.policies.data.loadbalancer;
+
+import java.net.URI;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter