You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "Demogorgon314 (via GitHub)" <gi...@apache.org> on 2024/04/12 07:40:04 UTC

[PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Demogorgon314 opened a new pull request, #22487:
URL: https://github.com/apache/pulsar/pull/22487

   ### Motivation
   
   Support lookup options for extensible load manager to align with the old behavior.
   
   ### Modifications
   
   Support the following lookup options:
   * readOnly
   * requestHttps
   * advertisedListenerName
   
   ### TODO
   
   Support `LookupOptions.loadTopicsInBundle`
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1574488674


##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java:
##########
@@ -405,7 +405,7 @@ public void testIsolationPolicy() throws Exception {
                         admin.lookups().lookupTopicAsync(topic).get(5, TimeUnit.SECONDS);

Review Comment:
   Should you add `fail()` here?



##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java:
##########
@@ -405,7 +405,7 @@ public void testIsolationPolicy() throws Exception {
                         admin.lookups().lookupTopicAsync(topic).get(5, TimeUnit.SECONDS);
                     } catch (Exception ex) {
                         log.error("Failed to lookup topic: ", ex);

Review Comment:
   It seems that the lookup error could be `TimeoutException` before retrying until the error becomes "Service Unavailable". Is it expected?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1566617744


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java:
##########
@@ -544,22 +550,19 @@ private CompletableFuture<Optional<BrokerLookupData>> getBrokerLookupData(
             String bundle) {
         return owner.thenCompose(broker -> {
             if (broker.isEmpty()) {
-                String errorMsg = String.format(
-                        "Failed to get or assign the owner for bundle:%s", bundle);
-                log.error(errorMsg);
-                throw new IllegalStateException(errorMsg);
-            }
-            return CompletableFuture.completedFuture(broker.get());
-        }).thenCompose(broker -> this.getBrokerRegistry().lookupAsync(broker).thenCompose(brokerLookupData -> {
-            if (brokerLookupData.isEmpty()) {
-                String errorMsg = String.format(
-                        "Failed to lookup broker:%s for bundle:%s, the broker has not been registered.",
-                        broker, bundle);
-                log.error(errorMsg);
-                throw new IllegalStateException(errorMsg);
+                return CompletableFuture.completedFuture(Optional.empty());

Review Comment:
   For `options.isReadOnly()` it may return an `Optional.empty()`, which means no owner broker.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower merged PR #22487:
URL: https://github.com/apache/pulsar/pull/22487


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1562705484


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImpl.java:
##########
@@ -544,22 +550,19 @@ private CompletableFuture<Optional<BrokerLookupData>> getBrokerLookupData(
             String bundle) {
         return owner.thenCompose(broker -> {
             if (broker.isEmpty()) {
-                String errorMsg = String.format(
-                        "Failed to get or assign the owner for bundle:%s", bundle);
-                log.error(errorMsg);
-                throw new IllegalStateException(errorMsg);
-            }
-            return CompletableFuture.completedFuture(broker.get());
-        }).thenCompose(broker -> this.getBrokerRegistry().lookupAsync(broker).thenCompose(brokerLookupData -> {
-            if (brokerLookupData.isEmpty()) {
-                String errorMsg = String.format(
-                        "Failed to lookup broker:%s for bundle:%s, the broker has not been registered.",
-                        broker, bundle);
-                log.error(errorMsg);
-                throw new IllegalStateException(errorMsg);
+                return CompletableFuture.completedFuture(Optional.empty());

Review Comment:
   nit: Shouldn't we return the IllegalStateException?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1574549415


##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java:
##########
@@ -405,7 +405,7 @@ public void testIsolationPolicy() throws Exception {
                         admin.lookups().lookupTopicAsync(topic).get(5, TimeUnit.SECONDS);

Review Comment:
   Yes, updated.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1574550415


##########
tests/integration/src/test/java/org/apache/pulsar/tests/integration/loadbalance/ExtensibleLoadManagerTest.java:
##########
@@ -405,7 +405,7 @@ public void testIsolationPolicy() throws Exception {
                         admin.lookups().lookupTopicAsync(topic).get(5, TimeUnit.SECONDS);
                     } catch (Exception ex) {
                         log.error("Failed to lookup topic: ", ex);

Review Comment:
   This PR should not cause the `TimeoutException`, I think we should merge this PR first, then I will try to find the root cause and push another PR to fix it.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#discussion_r1572038446


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/LoadManager.java:
##########
@@ -63,7 +65,7 @@ public interface LoadManager {
     Optional<ResourceUnit> getLeastLoaded(ServiceUnitId su) throws Exception;
 
     default CompletableFuture<Optional<LookupResult>> findBrokerServiceUrl(
-            Optional<ServiceUnitId> topic, ServiceUnitId bundle) {
+            Optional<ServiceUnitId> topic, NamespaceBundle bundle, LookupOptions options) {
         throw new UnsupportedOperationException();
     }

Review Comment:
   It's better to keep the API compatibility since it's an interface that can be configured. You can keep the 2nd parameter as `ServiceUnitId` and add a new default method.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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


Re: [PR] [fix][broker] Support lookup options for extensible load manager [pulsar]

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on PR #22487:
URL: https://github.com/apache/pulsar/pull/22487#issuecomment-2063077514

   Could you resolve the conflicts?


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

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