smengcl commented on code in PR #3131:
URL: https://github.com/apache/ozone/pull/3131#discussion_r871751371
##########
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:
I'm reluctant to add new fields to `UserAccessIdInfo` proto message in this
PR. I think I will remove it.
--
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]