From b85e8c15f322eebabc81ccac777459cd9a10a2cd Mon Sep 17 00:00:00 2001 From: Rory Date: Wed, 12 Jun 2024 00:27:34 +0800 Subject: [PATCH] fix ut --- .../gravitino/metalake/MetalakeManager.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeManager.java b/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeManager.java index 5542ef0d0ed..c98bba88722 100644 --- a/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeManager.java +++ b/core/src/main/java/com/datastrato/gravitino/metalake/MetalakeManager.java @@ -4,6 +4,7 @@ */ package com.datastrato.gravitino.metalake; +import com.datastrato.gravitino.Entity; import com.datastrato.gravitino.Entity.EntityType; import com.datastrato.gravitino.EntityAlreadyExistsException; import com.datastrato.gravitino.EntityStore; @@ -23,6 +24,7 @@ import com.google.common.collect.Maps; import java.io.IOException; import java.time.Instant; +import java.util.Collections; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,6 +49,15 @@ public class MetalakeManager implements MetalakeDispatcher { public MetalakeManager(EntityStore store, IdGenerator idGenerator) { this.store = store; this.idGenerator = idGenerator; + + try { + NameIdentifier systemMetalake = NameIdentifier.of(Entity.SYSTEM_METALAKE_RESERVED_NAME); + if (store.exists(systemMetalake, EntityType.METALAKE)) { + createMetalake(systemMetalake, "", Collections.emptyMap()); + } + } catch (IOException ioe) { + throw new RuntimeException("Fail to create system metalake", ioe); + } } /** @@ -59,6 +70,7 @@ public MetalakeManager(EntityStore store, IdGenerator idGenerator) { public BaseMetalake[] listMetalakes() { try { return store.list(Namespace.empty(), BaseMetalake.class, EntityType.METALAKE).stream() + .filter(baseMetalake -> !baseMetalake.name().equals(Entity.SYSTEM_METALAKE_RESERVED_NAME)) .toArray(BaseMetalake[]::new); } catch (IOException ioe) { LOG.error("Listing Metalakes failed due to storage issues.", ioe);