You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/04/28 03:13:35 UTC

[GitHub] [pulsar] jiazhai commented on a change in pull request #4153: [WIP] PIP 35: Improve topic lookup for topics that have high number of partitions

jiazhai commented on a change in pull request #4153: [WIP] PIP 35: Improve topic lookup for topics that have high number of partitions
URL: https://github.com/apache/pulsar/pull/4153#discussion_r279175676
 
 

 ##########
 File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authorization/AuthorizationService.java
 ##########
 @@ -305,6 +307,55 @@ public boolean canLookup(TopicName topicName, String role, AuthenticationDataSou
         return finalResult;
     }
 
+    public CompletableFuture<List<TopicName>> canBatchLookupAsync(List<TopicName> topicNames, String role,
+                                                                  AuthenticationDataSource authenticationData) {
+        CompletableFuture<List<TopicName>> finalResult = new CompletableFuture<>();
+        List<TopicName> unAuthorizedTopicNames = new ArrayList<>();
+        List<CompletableFuture<Boolean>> results = new ArrayList<>();
+
+        topicNames.forEach(topicName -> {
+            results.add(canLookupAsync(topicName, role, authenticationData));
+        });
+
+        FutureUtil.waitForAll(results).thenRunAsync(() -> {
+            for(int i = 0; i < results.size(); i++) {
+                try {
+                    if (!results.get(i).get()) {
+                        unAuthorizedTopicNames.add(topicNames.get(i));
+                    }
+                } catch (Exception e) {
+                    log.warn("Error occurred while checking authorization on {}, retry needed. ",
+                                                                                    topicNames.get(i).toString());
+                    unAuthorizedTopicNames.add(topicNames.get(i));
+                }
+            };
+            finalResult.complete(unAuthorizedTopicNames);
+        });
+
+        return finalResult;
+    }
+
+    public List<TopicName> canBatchLookup(List<TopicName> topicNames, String role,
 
 Review comment:
   How about  in this function simply call `canBatchLookupAsync.get()`

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services