merlimat closed pull request #1449: When running standalone broker, force the
proxy redirection flag
URL: https://github.com/apache/incubator-pulsar/pull/1449
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
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 f851f7dd9..76c33c8df 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 @@
// 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;
@@ -1507,4 +1510,12 @@ public void setFunctionsWorkerEnabled(boolean enabled) {
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 6c8dc14dc..85b5d8970 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 PulsarStandaloneStarter(String[] args) throws
Exception {
// 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 eed36810e..577fef91f 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
@@ -279,9 +279,14 @@ public String
getNamespaceBundle(@PathParam("topic-domain") String topicDomain,
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) {
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services