You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by si...@apache.org on 2020/08/17 20:47:39 UTC

[pulsar] branch master updated: Redirect Get message by id request when broker not serve for the topic (#7786)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6580915  Redirect Get message by id request when broker not serve for the topic (#7786)
6580915 is described below

commit 6580915c2d631fa322a7c2631bc0f1c49b15b957
Author: Rudy Steiner <ru...@163.com>
AuthorDate: Tue Aug 18 04:47:16 2020 +0800

    Redirect Get message by id request when broker not serve for the topic (#7786)
    
    Fixes #7604
    
    Master Issue: #7604
    
    ### Motivation
    
    We should redirect Get message by id request when a broker doesn't serve for the topic
    
    ### Modifications
    
    * Redirect Get message by id request when a broker doesn't serve for the topic
    * ~~Test log config use log4j2.xml not logback.xml
         config by parent pom: -Dlog4j.configurationFile=log4j2.xml~~
    
    ### Verifying this change
    
    This change is a trivial change without any test coverage.
---
 .../org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
index ab2b7ba..f6010f1 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
@@ -1959,11 +1959,11 @@ public class PersistentTopicsBase extends AdminResource {
 
     protected void internalGetMessageById(AsyncResponse asyncResponse, long ledgerId, long entryId,
                                               boolean authoritative) {
-        verifyReadOperation(authoritative);
-
-        PersistentTopic topic = (PersistentTopic) getTopicReference(topicName);
-        ManagedLedgerImpl ledger = (ManagedLedgerImpl) topic.getManagedLedger();
         try {
+            // will redirect if the topic not owned by current broker
+            validateReadOperationOnTopic(authoritative);
+            PersistentTopic topic = (PersistentTopic) getTopicReference(topicName);
+            ManagedLedgerImpl ledger = (ManagedLedgerImpl) topic.getManagedLedger();
             ledger.asyncReadEntry(new PositionImpl(ledgerId, entryId), new AsyncCallbacks.ReadEntryCallback() {
                 @Override
                 public void readEntryFailed(ManagedLedgerException exception, Object ctx) {