smengcl commented on code in PR #3131:
URL: https://github.com/apache/ozone/pull/3131#discussion_r871752123


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OMMultiTenantManagerImpl.java:
##########
@@ -417,26 +495,41 @@ private boolean isTenantAdmin(String username, String 
tenantId,
   public TenantUserList listUsersInTenant(String tenantID, String prefix)
       throws IOException {
 
-    if (!omMetadataManager.getTenantStateTable().isExist(tenantID)) {
-      throw new IOException("Tenant '" + tenantID + "' not found!");
-    }
-
     List<UserAccessIdInfo> userAccessIds = new ArrayList<>();
-    CachedTenantState cachedTenantState = tenantCache.get(tenantID);
-    if (cachedTenantState == null) {
-      throw new IOException("Inconsistent in memory Tenant cache '" + tenantID
-          + "' not found in cache, but present in OM DB!");
-    }
 
-    cachedTenantState.getTenantUsers().stream()
-        .filter(
-            k -> StringUtils.isEmpty(prefix) || k.getKey().startsWith(prefix))
-        .forEach(
-            k -> userAccessIds.add(
+    tenantCacheLock.readLock().lock();
+
+    try {
+      if (!omMetadataManager.getTenantStateTable().isExist(tenantID)) {
+        throw new IOException("Tenant '" + tenantID + "' not found!");
+      }
+
+      CachedTenantState cachedTenantState = tenantCache.get(tenantID);
+
+      if (cachedTenantState == null) {
+        throw new IOException("Inconsistent in memory Tenant cache '" + 
tenantID
+            + "' not found in cache, but present in OM DB!");
+      }
+
+      cachedTenantState.getAccessIdInfoMap().entrySet().stream()
+          .filter(
+              // Include if user principal matches the prefix
+              k -> StringUtils.isEmpty(prefix) ||
+                  k.getValue().getUserPrincipal().startsWith(prefix))
+          .forEach(k -> {
+            final String accessId = k.getKey();
+            final CachedAccessIdInfo cacheEntry = k.getValue();
+            userAccessIds.add(
                 UserAccessIdInfo.newBuilder()
-                    .setUserPrincipal(k.getKey())
-                    .setAccessId(k.getValue())
-                    .build()));
+                    .setUserPrincipal(cacheEntry.getUserPrincipal())
+                    .setAccessId(accessId)
+//                    .setIsAdmin(cacheEntry.isAdmin())

Review Comment:
   It's just that if we want we can easily return the admin/delegated flag to 
the client with list users in tenant now that it is cached.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to