You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/05/18 22:41:45 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #6903: PIP-61: Advertise multiple addresses

sijie commented on a change in pull request #6903:
URL: https://github.com/apache/pulsar/pull/6903#discussion_r426917243



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -146,6 +146,14 @@
     )
     private String advertisedAddress;
 
+    //

Review comment:
       nit: remove this line if it is not needed.

##########
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:
       Can you add documentation for these two settings?
   
   Also, can you add these settings to `broker.conf` file?

##########
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<String, AdvertisedListener> getAdvertisedListeners() {
+        if (this.advertisedListeners == null) {
+            return Collections.unmodifiableMap(Collections.EMPTY_MAP);

Review comment:
       nit: I think `EMPTY_MAP` is already unmodifiable.

##########
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:
       same comment as above

##########
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;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * The advertisedListener for broker with brokerServiceUrl and brokerServiceUrlTls.
+ */
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class AdvertisedListener {

Review comment:
       Why do we only include `brokerServiceUrl` and `brokerServiceUrlTls` in AdvertisedListener?

##########
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:
       Why do we get `HttpUrl` and `HttpUrlTls` from NamespaceBundle but get `brokerServiceUrl` and `brokerServiceUrlTls`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org