aloyszhang commented on a change in pull request #13796:
URL: https://github.com/apache/pulsar/pull/13796#discussion_r819637176



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -1171,6 +1173,51 @@ protected void 
internalSplitNamespaceBundle(AsyncResponse asyncResponse, String
         });
     }
 
+    protected TopicHashPositions internalGetTopicHashPositions(String 
bundleRange, List<String> topicList) {

Review comment:
       done

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -1171,6 +1173,51 @@ protected void 
internalSplitNamespaceBundle(AsyncResponse asyncResponse, String
         });
     }
 
+    protected TopicHashPositions internalGetTopicHashPositions(String 
bundleRange, List<String> topicList) {
+        if (log.isDebugEnabled()) {
+            log.debug("[{}] Getting hash position for topic list {}, bundle 
{}", clientAppId(), topicList, bundleRange);
+        }
+        if (topicList == null || topicList.size() == 0) {
+            return null;
+        }
+        validateNamespacePolicyOperation(namespaceName, 
PolicyName.PERSISTENCE, PolicyOperation.READ);
+        Policies policies = getNamespacePolicies(namespaceName);
+        NamespaceBundle bundle = 
validateNamespaceBundleOwnership(namespaceName, policies.bundles, bundleRange,
+                false, true);
+        try {
+            List<String> allTopicsInThisBundle =
+                    
pulsar().getNamespaceService().getOwnedTopicListForNamespaceBundle(bundle).get();
+            if (allTopicsInThisBundle.size() == 0) {
+                return null;
+            }
+            Map<String, Long> topicHashPositions = new HashMap<>();
+            for (String topic : topicList) {
+                // partitioned topic
+                if (TopicName.get(topic).getPartitionIndex() == -1) {
+                    allTopicsInThisBundle.stream()
+                            .filter(t -> 
TopicName.get(t).getPartitionedTopicName()
+                                    
.equals(TopicName.get(topic).getPartitionedTopicName()))
+                            .forEach(partition -> {
+                                topicHashPositions.put(partition,  
pulsar().getNamespaceService()
+                                        
.getNamespaceBundleFactory().getLongHashCode(partition));
+                            });
+                } else { // topic partition
+                    if (allTopicsInThisBundle.contains(topic)) {

Review comment:
       sure




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to