Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
jerqi committed Jun 11, 2024
1 parent f39720a commit b85e8c1
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit b85e8c1

Please sign in to comment.