jerryshao commented on code in PR #5155:
URL: https://github.com/apache/gravitino/pull/5155#discussion_r1806230271
##########
core/src/main/java/org/apache/gravitino/metalake/MetalakeManager.java:
##########
@@ -204,23 +241,112 @@ public BaseMetalake alterMetalake(NameIdentifier ident,
MetalakeChange... change
}
}
- /**
- * Deletes a Metalake.
- *
- * @param ident The identifier of the Metalake to be deleted.
- * @return `true` if the Metalake was successfully deleted, `false`
otherwise.
- * @throws RuntimeException If deleting the Metalake encounters storage
issues.
- */
@Override
- public boolean dropMetalake(NameIdentifier ident) {
+ public boolean dropMetalake(NameIdentifier ident, boolean force)
+ throws NonEmptyEntityException, MetalakeInUseException {
try {
- return store.delete(ident, EntityType.METALAKE);
- } catch (IOException ioe) {
- LOG.error("Deleting metalake {} failed due to storage issues", ident,
ioe);
- throw new RuntimeException(ioe);
+ boolean inUse = metalakeInUse(store, ident);
+ if (inUse && !force) {
+ throw new MetalakeInUseException(
+ "Metalake %s is in use, please deactivate it first or use force
option", ident);
+ }
+
+ List<CatalogEntity> catalogEntities =
+ store.list(Namespace.of(ident.name()), CatalogEntity.class,
EntityType.CATALOG);
+ if (!catalogEntities.isEmpty() && !force) {
+ throw new NonEmptyEntityException(
+ "Metalake %s has catalogs, please drop them first or use force
option", ident);
+ }
+
+ // If reached here, it implies that the metalake is not in use or force
is true.
+ if (inUse) {
+ // force is true, so deactivate the metalake first.
+ disableMetalake(ident);
+ }
Review Comment:
The same here for metalake, we don't need to disable this before the drop.
--
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]