jerryshao commented on code in PR #7625:
URL: https://github.com/apache/gravitino/pull/7625#discussion_r2234527729


##########
core/src/main/java/org/apache/gravitino/policy/PolicyManager.java:
##########
@@ -51,17 +68,51 @@ public PolicyManager(IdGenerator idGenerator, EntityStore 
entityStore) {
 
   @Override
   public String[] listPolicies(String metalake) {
-    throw new UnsupportedOperationException("Not implemented yet");
+    return 
Arrays.stream(listPolicyInfos(metalake)).map(Policy::name).toArray(String[]::new);
   }
 
   @Override
   public Policy[] listPolicyInfos(String metalake) {
-    throw new UnsupportedOperationException("Not implemented yet");
+    NameIdentifier metalakeIdent = NameIdentifierUtil.ofMetalake(metalake);
+    return TreeLockUtils.doWithTreeLock(
+        NameIdentifier.of(NamespaceUtil.ofPolicy(metalake).levels()),
+        LockType.READ,
+        () -> {
+          checkMetalake(metalakeIdent, entityStore);

Review Comment:
   I think we can move the `checkMetalake` out of lock, it is a low probablitiy 
that metalake will not exist or not in use when we do policy operations. Moving 
this out can improve the performance. WDYT?



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

Reply via email to