[ 
https://issues.apache.org/jira/browse/KNOX-3585?focusedWorklogId=1055791&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1055791
 ]

ASF GitHub Bot logged work on KNOX-3585:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 18/Nov/26 22:19
            Start Date: 18/Nov/26 22:19
    Worklog Time Spent: 10m 
      Work Description: handavid commented on code in PR #1522:
URL: https://github.com/apache/knox/pull/1522#discussion_r4621645170


##########
gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/interceptor/LDAPRolesLookupInterceptor.java:
##########
@@ -277,18 +296,125 @@ private EntryFilteringCursor 
handleSearch(SearchOperationContext ctx) throws Lda
             
ctx.setReturningAttributes(withAttributes(originalReturningAttributes, 
augmentedAttributes));
         }
 
+        int numUserAndGroupEntries = 0;
         final List<Entry> entries = new ArrayList<>();
         try (EntryFilteringCursor cursor = next(ctx)) {
             while (cursor.next()) {
+                Entry entry = cursor.get();
+                if (LdapUtils.isUserEntry(entry) || 
LdapUtils.isGroupEntry(entry)) {
+                    numUserAndGroupEntries++;
+                }
                 entries.add(cursor.get());
             }
         } catch (Exception e) {
             LOG.ldapRolesLookupFailed(LdapUtils.extractGroupName(ctx.getDn()), 
e);
             throw new LdapException(e);
         }
 
+        // Populating the roles through lookup results in one lookup request 
per entry.
+        // It is more efficient to list all the roles when the number of 
entries is large.

Review Comment:
   I added a bulk call and left the calculation as num entries > num roles. I'm 
not concerned about the +-1 for simplicity of the code.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1055791)
    Time Spent: 1.5h  (was: 1h 20m)

> Optimize roles lookup for large result sets
> -------------------------------------------
>
>                 Key: KNOX-3585
>                 URL: https://issues.apache.org/jira/browse/KNOX-3585
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: LDAP
>    Affects Versions: 3.0.0
>            Reporter: David Han
>            Assignee: David Han
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> The roles lookup interceptor makes a lookup call for each user entry. If the 
> entry set is large, this may result in 1000s of calls to the roles lookup 
> server before the results are returned.
> If the number of results are greater than the number of roles, it would be 
> faster to retrieve all roles from the role server and perform the mapping in 
> the roles lookup interceptor.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to