This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 8f6e33d  When running standalone broker, force the proxy redirection 
flag (#1449)
8f6e33d is described below

commit 8f6e33d525c0efabe664dbb529e3c4f9d4ab979a
Author: Matteo Merli <mme...@apache.org>
AuthorDate: Tue Mar 27 17:05:13 2018 -0700

    When running standalone broker, force the proxy redirection flag (#1449)
---
 .../java/org/apache/pulsar/broker/ServiceConfiguration.java   | 11 +++++++++++
 .../main/java/org/apache/pulsar/PulsarStandaloneStarter.java  |  1 +
 .../java/org/apache/pulsar/broker/lookup/TopicLookup.java     |  7 ++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
index 40ac189..0ad3fb9 100644
--- 
a/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
+++ 
b/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
@@ -59,6 +59,9 @@ public class ServiceConfiguration implements 
PulsarConfiguration {
     // Enable the WebSocket API service
     private boolean webSocketServiceEnabled = false;
 
+    // Flag to control features that are meant to be used when running in 
standalone mode
+    private boolean isRunningStandalone = false;
+
     // Name of the cluster to which this broker belongs to
     @FieldContext(required = true)
     private String clusterName;
@@ -1517,4 +1520,12 @@ public class ServiceConfiguration implements 
PulsarConfiguration {
     public boolean isFunctionsWorkerEnabled() {
         return functionsWorkerEnabled;
     }
+
+    public boolean isRunningStandalone() {
+        return isRunningStandalone;
+    }
+
+    public void setRunningStandalone(boolean isRunningStandalone) {
+        this.isRunningStandalone = isRunningStandalone;
+    }
 }
diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java 
b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
index 6c8dc14..85b5d89 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarStandaloneStarter.java
@@ -134,6 +134,7 @@ public class PulsarStandaloneStarter {
         // Set ZK server's host to localhost
         config.setZookeeperServers(zkServers + ":" + zkPort);
         config.setGlobalZookeeperServers(zkServers + ":" + zkPort);
+        config.setRunningStandalone(true);
 
         Runtime.getRuntime().addShutdownHook(new Thread() {
             public void run() {
diff --git 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
index 00613f2..f08530a 100644
--- 
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
+++ 
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/lookup/TopicLookup.java
@@ -288,9 +288,14 @@ public class TopicLookup extends PulsarWebResource {
                                         
newLookupResponse(lookupData.getBrokerUrl(), lookupData.getBrokerUrlTls(),
                                                 newAuthoritative, 
LookupType.Redirect, requestId, false));
                             } else {
+                                // When running in standalone mode we want to 
redirect the client through the service
+                                // url, so that the advertised address 
configuration is not relevant anymore.
+                                boolean redirectThroughServiceUrl = 
pulsarService.getConfiguration()
+                                        .isRunningStandalone();
+
                                 lookupfuture.complete(
                                         
newLookupResponse(lookupData.getBrokerUrl(), lookupData.getBrokerUrlTls(),
-                                                true /* authoritative */, 
LookupType.Connect, requestId, false));
+                                                true /* authoritative */, 
LookupType.Connect, requestId, redirectThroughServiceUrl));
                             }
                         }).exceptionally(ex -> {
                             if (ex instanceof CompletionException && 
ex.getCause() instanceof IllegalStateException) {

-- 
To stop receiving notification emails like this one, please contact
mme...@apache.org.

Reply via email to