jerryshao commented on code in PR #4055:
URL: https://github.com/apache/gravitino/pull/4055#discussion_r1681002619
##########
core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java:
##########
@@ -109,6 +112,37 @@ User getUser(String metalake, String user) throws
NoSuchUserException {
}
}
+ String[] listUserNames(String metalake) {
+ try {
+ AuthorizationUtils.checkMetalakeExists(metalake);
+ Namespace namespace = AuthorizationUtils.ofUserNamespace(metalake);
+ return store.list(namespace, UserEntity.class,
Entity.EntityType.USER).stream()
+ .map(UserEntity::name)
+ .toArray(String[]::new);
+ } catch (NoSuchEntityException e) {
+ LOG.warn("Metalake {} does not exist", metalake, e);
+ throw new NoSuchMetalakeException(METALAKE_DOES_NOT_EXIST_MSG, metalake);
+ } catch (IOException ioe) {
+ LOG.error("Listing user under metalake {} failed due to storage issues",
metalake, ioe);
+ throw new RuntimeException(ioe);
+ }
+ }
+
+ User[] listUsers(String metalake) {
+ try {
+ Namespace namespace = AuthorizationUtils.ofUserNamespace(metalake);
+ return store.list(namespace, UserEntity.class,
Entity.EntityType.USER).stream()
+ .map(entity -> (User) entity)
+ .toArray(User[]::new);
+ } catch (NoSuchEntityException e) {
+ LOG.warn("Metalake {} does not exist", metalake, e);
+ throw new NoSuchMetalakeException(METALAKE_DOES_NOT_EXIST_MSG, metalake);
+ } catch (IOException ioe) {
+ LOG.error("Listing user under metalake {} failed due to storage issues",
metalake, ioe);
+ throw new RuntimeException(ioe);
+ }
+ }
Review Comment:
1. I think you need to use tree lock here.
2. `listUserNames` can be implemented based on `listUsers`, don't need to
duplicate the codes.
--
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]