mchades commented on code in PR #9574:
URL: https://github.com/apache/gravitino/pull/9574#discussion_r2659293350


##########
core/src/main/java/org/apache/gravitino/connector/BaseCatalog.java:
##########
@@ -190,6 +194,39 @@ public CatalogOperations ops() {
     return ops;
   }
 
+  public void checkMetalakeAndCatalogInUse(CatalogEntity catalogEntity) {
+    Map<String, String> catalogProperties = catalogEntity.getProperties();
+    if (catalogProperties == null) {
+      return;
+    }
+
+    boolean metalakeInuse =
+        Boolean.parseBoolean(
+            catalogProperties.getOrDefault(Catalog.PROPERTY_METALAKE_IN_USE, 
"true"));
+    if (!metalakeInuse) {
+      throw new MetalakeNotInUseException(
+          "The metalake that holds catalog %s is not in use", 
catalogEntity.name());
+    }
+
+    // Check the stack and find whether its within method `dropCatalog` as we 
don't need to check
+    // the catalog in use status when dropping the catalog.
+    if (isInvokedBy("dropCatalog")) {
+      LOG.info("Skip checking catalog in use status since it's invoked by 
dropCatalog method.");
+      return;

Review Comment:
   Does this mean we are doing redundant checks? Can we optimize this part of 
the logic?



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