World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#124] feat(core): implement metalake management logics (#155)
Jerry Shao33a5efc1f8e0
diff --git a/api/src/main/java/com/datastrato/graviton/SupportMetalakes.java b/api/src/main/java/com/datastrato/graviton/SupportsMetalakes.javasimilarity index 98%rename from api/src/main/java/com/datastrato/graviton/SupportMetalakes.javarename to api/src/main/java/com/datastrato/graviton/SupportsMetalakes.javaindex 8bcd0c3744..67c12e848c 100644--- a/api/src/main/java/com/datastrato/graviton/SupportMetalakes.java+++ b/api/src/main/java/com/datastrato/graviton/SupportsMetalakes.java@@ -8,7 +8,7 @@ import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;import com.datastrato.graviton.exceptions.NoSuchMetalakeException;import java.util.Map;-public interface SupportMetalakes {+public interface SupportsMetalakes {/** List all metalakes. */Metalake[] listMetalakes();diff --git a/client-java/src/main/java/com/datastrato/graviton/GravitonClient.java b/client-java/src/main/java/com/datastrato/graviton/GravitonClient.javaindex c6c816dd72..a013a51408 100644--- a/client-java/src/main/java/com/datastrato/graviton/GravitonClient.java+++ b/client-java/src/main/java/com/datastrato/graviton/GravitonClient.java@@ -27,7 +27,7 @@ import java.util.stream.Collectors;import org.slf4j.Logger;import org.slf4j.LoggerFactory;-public class GravitonClient implements SupportMetalakes, Closeable {+public class GravitonClient implements SupportsMetalakes, Closeable {private static final Logger LOG = LoggerFactory.getLogger(GravitonClient.class);diff --git a/core/src/main/java/com/datastrato/graviton/EntityStore.java b/core/src/main/java/com/datastrato/graviton/EntityStore.javaindex 6e3a628e79..98712736c2 100644--- a/core/src/main/java/com/datastrato/graviton/EntityStore.java+++ b/core/src/main/java/com/datastrato/graviton/EntityStore.java@@ -100,6 +100,7 @@ public interface EntityStore extends Closeable {* <p>Note: the whole update operation should be in one transaction.** @param ident the name identifier of the entity+ * @param type the type of the entity* @param updater the updater function to update the entity* @param <E> the type of the entity* @return E the updated entitydiff --git a/core/src/main/java/com/datastrato/graviton/GravitonEnv.java b/core/src/main/java/com/datastrato/graviton/GravitonEnv.javaindex d619893162..ca9a4b595e 100644--- a/core/src/main/java/com/datastrato/graviton/GravitonEnv.java+++ b/core/src/main/java/com/datastrato/graviton/GravitonEnv.java@@ -6,7 +6,7 @@ package com.datastrato.graviton;import com.datastrato.graviton.catalog.CatalogManager;import com.datastrato.graviton.catalog.CatalogOperationDispatcher;-import com.datastrato.graviton.meta.BaseMetalakesOperations;+import com.datastrato.graviton.meta.MetalakeManager;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -24,8 +24,7 @@ public class GravitonEnv {private CatalogOperationDispatcher catalogOperationDispatcher;- // TODO. We should refactor the BaseMetalakesOperations to align with other class names. @jerry- private BaseMetalakesOperations metalakesOperations;+ private MetalakeManager metalakeManager;private GravitonEnv() {}@@ -51,7 +50,7 @@ public class GravitonEnv {entityStore.setSerDe(entitySerDe);// Create and initialize metalake related modules- this.metalakesOperations = new BaseMetalakesOperations();+ this.metalakeManager = new MetalakeManager(entityStore);// Create and initialize Catalog related modulesthis.catalogManager = new CatalogManager(config, entityStore);@@ -80,8 +79,8 @@ public class GravitonEnv {return catalogOperationDispatcher;}- public BaseMetalakesOperations metalakesOperations() {- return metalakesOperations;+ public MetalakeManager metalakesManager() {+ return metalakeManager;}public void shutdown() {diff --git a/core/src/main/java/com/datastrato/graviton/meta/BaseMetalakesOperations.java b/core/src/main/java/com/datastrato/graviton/meta/BaseMetalakesOperations.javadeleted file mode 100644index 26fdbf0611..0000000000--- a/core/src/main/java/com/datastrato/graviton/meta/BaseMetalakesOperations.java+++ /dev/null@@ -1,43 +0,0 @@-/*- * Copyright 2023 Datastrato.- * This software is licensed under the Apache License version 2.- */-package com.datastrato.graviton.meta;--import com.datastrato.graviton.MetalakeChange;-import com.datastrato.graviton.NameIdentifier;-import com.datastrato.graviton.SupportMetalakes;-import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;-import com.datastrato.graviton.exceptions.NoSuchMetalakeException;-import java.util.Map;--public class BaseMetalakesOperations implements SupportMetalakes {-- @Override- public BaseMetalake[] listMetalakes() {- throw new UnsupportedOperationException("Not implemented yet");- }-- @Override- public BaseMetalake loadMetalake(NameIdentifier ident) throws NoSuchMetalakeException {- throw new UnsupportedOperationException("Not implemented yet");- }-- @Override- public BaseMetalake createMetalake(- NameIdentifier ident, String comment, Map<String, String> properties)- throws MetalakeAlreadyExistsException {- throw new UnsupportedOperationException("Not implemented yet");- }-- @Override- public BaseMetalake alterMetalake(NameIdentifier ident, MetalakeChange... changes)- throws NoSuchMetalakeException, IllegalArgumentException {- throw new UnsupportedOperationException("Not implemented yet");- }-- @Override- public boolean dropMetalake(NameIdentifier ident) {- throw new UnsupportedOperationException("Not implemented yet");- }-}diff --git a/core/src/main/java/com/datastrato/graviton/meta/MetalakeManager.java b/core/src/main/java/com/datastrato/graviton/meta/MetalakeManager.javanew file mode 100644index 0000000000..7948dc8caa--- /dev/null+++ b/core/src/main/java/com/datastrato/graviton/meta/MetalakeManager.java@@ -0,0 +1,173 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.graviton.meta;++import com.datastrato.graviton.EntityAlreadyExistsException;+import com.datastrato.graviton.EntityStore;+import com.datastrato.graviton.MetalakeChange;+import com.datastrato.graviton.NameIdentifier;+import com.datastrato.graviton.Namespace;+import com.datastrato.graviton.NoSuchEntityException;+import com.datastrato.graviton.SupportsMetalakes;+import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;+import com.datastrato.graviton.exceptions.NoSuchMetalakeException;+import com.google.common.collect.Maps;+import java.io.IOException;+import java.time.Instant;+import java.util.Map;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++public class MetalakeManager implements SupportsMetalakes {++ private static final Logger LOG = LoggerFactory.getLogger(MetalakeManager.class);++ private final EntityStore store;++ public MetalakeManager(EntityStore store) {+ this.store = store;+ }++ @Override+ public BaseMetalake[] listMetalakes() {+ try {+ return store.list(Namespace.empty(), BaseMetalake.class).toArray(new BaseMetalake[0]);+ } catch (IOException ioe) {+ LOG.error("Failed to list metalakes due to storage issues", ioe);+ throw new RuntimeException(ioe);+ }+ }++ @Override+ public BaseMetalake loadMetalake(NameIdentifier ident) throws NoSuchMetalakeException {+ try {+ return store.get(ident, BaseMetalake.class);+ } catch (NoSuchEntityException e) {+ LOG.warn("Metalake {} does not exist", ident, e);+ throw new NoSuchMetalakeException("Metalake " + ident + " does not exist");+ } catch (IOException ioe) {+ LOG.error("Failed to load metalake {} due to storage issues", ident, ioe);+ throw new RuntimeException(ioe);+ }+ }++ @Override+ public BaseMetalake createMetalake(+ NameIdentifier ident, String comment, Map<String, String> properties)+ throws MetalakeAlreadyExistsException {+ BaseMetalake metalake =+ new BaseMetalake.Builder()+ .withId(1L /* TODO. use ID generator */)+ .withName(ident.name())+ .withComment(comment)+ .withProperties(properties)+ .withVersion(SchemaVersion.V_0_1)+ .withAuditInfo(+ new AuditInfo.Builder()+ .withCreator("graviton") /*TODO. we should real user later on*/+ .withCreateTime(Instant.now())+ .build())+ .build();++ try {+ store.put(ident, metalake, false /* overwritten */);+ return metalake;++ } catch (EntityAlreadyExistsException e) {+ LOG.warn("Metalake {} already exists", ident, e);+ throw new MetalakeAlreadyExistsException("Metalake " + ident + " already exists");+ } catch (IOException ioe) {+ LOG.error("Failed to create metalake {} due to storage issues", ident, ioe);+ throw new RuntimeException(ioe);+ }+ }++ @Override+ public BaseMetalake alterMetalake(NameIdentifier ident, MetalakeChange... changes)+ throws NoSuchMetalakeException, IllegalArgumentException {+ try {+ return store.update(+ ident,+ BaseMetalake.class,+ metalake -> {+ BaseMetalake.Builder builder =+ new BaseMetalake.Builder()+ .withId(metalake.getId())+ .withName(metalake.name())+ .withComment(metalake.comment())+ .withProperties(metalake.properties())+ .withVersion(metalake.getVersion());++ AuditInfo newInfo =+ new AuditInfo.Builder()+ .withCreator(metalake.auditInfo().creator())+ .withCreateTime(metalake.auditInfo().createTime())+ .withLastModifier(+ metalake.auditInfo().creator()) /*TODO. we should real user later on*/+ .withLastModifiedTime(Instant.now())+ .build();+ builder.withAuditInfo(newInfo);++ Map<String, String> newProps =+ metalake.properties() == null+ ? Maps.newHashMap()+ : Maps.newHashMap(metalake.properties());+ builder = updateEntity(builder, newProps, changes);++ return builder.build();+ });++ } catch (NoSuchEntityException ne) {+ LOG.warn("Metalake {} does not exist", ident, ne);+ throw new NoSuchMetalakeException("Metalake " + ident + " does not exist");++ } catch (IllegalArgumentException iae) {+ LOG.warn("Failed to alter metalake {} due to invalid changes", ident, iae);+ throw iae;++ } catch (IOException ioe) {+ LOG.error("Failed to alter metalake {} due to storage issues", ident, ioe);+ throw new RuntimeException(ioe);+ }+ }++ @Override+ public boolean dropMetalake(NameIdentifier ident) {+ try {+ return store.delete(ident);+ } catch (IOException ioe) {+ LOG.error("Failed to delete metalake {} due to storage issues", ident, ioe);+ throw new RuntimeException(ioe);+ }+ }++ private BaseMetalake.Builder updateEntity(+ BaseMetalake.Builder builder, Map<String, String> newProps, MetalakeChange... changes) {+ for (MetalakeChange change : changes) {+ if (change instanceof MetalakeChange.RenameMetalake) {+ MetalakeChange.RenameMetalake rename = (MetalakeChange.RenameMetalake) change;+ builder.withName(rename.getNewName());++ } else if (change instanceof MetalakeChange.UpdateMetalakeComment) {+ MetalakeChange.UpdateMetalakeComment comment =+ (MetalakeChange.UpdateMetalakeComment) change;+ builder.withComment(comment.getNewComment());++ } else if (change instanceof MetalakeChange.SetProperty) {+ MetalakeChange.SetProperty setProperty = (MetalakeChange.SetProperty) change;+ newProps.put(setProperty.getProperty(), setProperty.getValue());++ } else if (change instanceof MetalakeChange.RemoveProperty) {+ MetalakeChange.RemoveProperty removeProperty = (MetalakeChange.RemoveProperty) change;+ newProps.remove(removeProperty.getProperty());++ } else {+ throw new IllegalArgumentException("Unknown metalake change: " + change);+ }+ }++ return builder.withProperties(newProps);+ }+}diff --git a/core/src/test/java/com/datastrato/graviton/meta/TestMetalakeManager.java b/core/src/test/java/com/datastrato/graviton/meta/TestMetalakeManager.javanew file mode 100644index 0000000000..7179b15773--- /dev/null+++ b/core/src/test/java/com/datastrato/graviton/meta/TestMetalakeManager.java@@ -0,0 +1,167 @@+/*+ * Copyright 2023 Datastrato.+ * This software is licensed under the Apache License version 2.+ */+package com.datastrato.graviton.meta;++import com.datastrato.graviton.Config;+import com.datastrato.graviton.EntityStore;+import com.datastrato.graviton.MetalakeChange;+import com.datastrato.graviton.NameIdentifier;+import com.datastrato.graviton.TestEntityStore;+import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;+import com.datastrato.graviton.exceptions.NoSuchMetalakeException;+import com.google.common.collect.ImmutableMap;+import com.google.common.collect.Sets;+import java.io.IOException;+import java.util.Map;+import java.util.Set;+import org.junit.jupiter.api.AfterAll;+import org.junit.jupiter.api.Assertions;+import org.junit.jupiter.api.BeforeAll;+import org.junit.jupiter.api.Test;++public class TestMetalakeManager {++ private static MetalakeManager metalakeManager;++ private static EntityStore entityStore;++ private static Config config;++ @BeforeAll+ public static void setUp() {+ config = new Config(false) {};++ entityStore = new TestEntityStore.InMemoryEntityStore();+ entityStore.initialize(config);+ entityStore.setSerDe(null);++ metalakeManager = new MetalakeManager(entityStore);+ }++ @AfterAll+ public static void tearDown() throws IOException {+ if (entityStore != null) {+ entityStore.close();+ entityStore = null;+ }+ }++ @Test+ public void testCreateMetalake() {+ NameIdentifier ident = NameIdentifier.of("test1");+ Map<String, String> props = ImmutableMap.of("key1", "value1");++ BaseMetalake metalake = metalakeManager.createMetalake(ident, "comment", props);+ Assertions.assertEquals("test1", metalake.name());+ Assertions.assertEquals("comment", metalake.comment());+ Assertions.assertEquals(props, metalake.properties());++ // Test with MetalakeAlreadyExistsException+ Assertions.assertThrows(+ MetalakeAlreadyExistsException.class,+ () -> metalakeManager.createMetalake(ident, "comment", props));+ }++ @Test+ public void testListMetalakes() {+ NameIdentifier ident1 = NameIdentifier.of("test11");+ NameIdentifier ident2 = NameIdentifier.of("test12");+ Map<String, String> props = ImmutableMap.of("key1", "value1");++ BaseMetalake metalake1 = metalakeManager.createMetalake(ident1, "comment", props);+ BaseMetalake metalake2 = metalakeManager.createMetalake(ident2, "comment", props);++ Set<BaseMetalake> metalakes = Sets.newHashSet(metalakeManager.listMetalakes());+ Assertions.assertTrue(metalakes.contains(metalake1));+ Assertions.assertTrue(metalakes.contains(metalake2));+ }++ @Test+ public void testLoadMetalake() {+ NameIdentifier ident = NameIdentifier.of("test21");+ Map<String, String> props = ImmutableMap.of("key1", "value1");++ BaseMetalake metalake = metalakeManager.createMetalake(ident, "comment", props);+ Assertions.assertEquals("test21", metalake.name());+ Assertions.assertEquals("comment", metalake.comment());+ Assertions.assertEquals(props, metalake.properties());++ BaseMetalake loadedMetalake = metalakeManager.loadMetalake(ident);+ Assertions.assertEquals("test21", loadedMetalake.name());+ Assertions.assertEquals("comment", loadedMetalake.comment());+ Assertions.assertEquals(props, loadedMetalake.properties());++ // Test with NoSuchMetalakeException+ Throwable exception =+ Assertions.assertThrows(+ NoSuchMetalakeException.class,+ () -> metalakeManager.loadMetalake(NameIdentifier.of("test3")));+ Assertions.assertTrue(exception.getMessage().contains("Metalake test3 does not exist"));+ }++ @Test+ public void testAlterMetalake() {+ NameIdentifier ident = NameIdentifier.of("test31");+ Map<String, String> props = ImmutableMap.of("key1", "value1");++ BaseMetalake metalake = metalakeManager.createMetalake(ident, "comment", props);+ Assertions.assertEquals("test31", metalake.name());+ Assertions.assertEquals("comment", metalake.comment());+ Assertions.assertEquals(props, metalake.properties());++ // Test alter name;+ MetalakeChange change = MetalakeChange.rename("test32");+ BaseMetalake alteredMetalake = metalakeManager.alterMetalake(ident, change);+ Assertions.assertEquals("test32", alteredMetalake.name());+ Assertions.assertEquals("comment", alteredMetalake.comment());+ Assertions.assertEquals(props, alteredMetalake.properties());++ // Test alter comment;+ NameIdentifier ident1 = NameIdentifier.of("test32");+ MetalakeChange change1 = MetalakeChange.updateComment("comment2");+ BaseMetalake alteredMetalake1 = metalakeManager.alterMetalake(ident1, change1);+ Assertions.assertEquals("test32", alteredMetalake1.name());+ Assertions.assertEquals("comment2", alteredMetalake1.comment());+ Assertions.assertEquals(props, alteredMetalake1.properties());++ // test alter properties;+ MetalakeChange change2 = MetalakeChange.setProperty("key2", "value2");+ MetalakeChange change3 = MetalakeChange.setProperty("key3", "value3");+ MetalakeChange change4 = MetalakeChange.removeProperty("key3");++ BaseMetalake alteredMetalake2 =+ metalakeManager.alterMetalake(ident1, change2, change3, change4);+ Assertions.assertEquals("test32", alteredMetalake2.name());+ Assertions.assertEquals("comment2", alteredMetalake2.comment());+ Map<String, String> expectedProps = ImmutableMap.of("key1", "value1", "key2", "value2");+ Assertions.assertEquals(expectedProps, alteredMetalake2.properties());++ // Test with NoSuchMetalakeException+ Throwable exception =+ Assertions.assertThrows(+ NoSuchMetalakeException.class,+ () -> metalakeManager.alterMetalake(NameIdentifier.of("test3"), change));+ Assertions.assertTrue(exception.getMessage().contains("Metalake test3 does not exist"));+ }++ @Test+ public void testDropMetalake() {+ NameIdentifier ident = NameIdentifier.of("test41");+ Map<String, String> props = ImmutableMap.of("key1", "value1");++ BaseMetalake metalake = metalakeManager.createMetalake(ident, "comment", props);+ Assertions.assertEquals("test41", metalake.name());+ Assertions.assertEquals("comment", metalake.comment());+ Assertions.assertEquals(props, metalake.properties());++ boolean dropped = metalakeManager.dropMetalake(ident);+ Assertions.assertTrue(dropped);++ // Test with NoSuchMetalakeException+ NameIdentifier ident1 = NameIdentifier.of("test42");+ boolean dropped1 = metalakeManager.dropMetalake(ident1);+ Assertions.assertFalse(dropped1);+ }+}diff --git a/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java b/server/src/main/java/com/datastrato/graviton/server/GravitonServer.javaindex 09a3e9b7d2..bd700687d3 100644--- a/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java+++ b/server/src/main/java/com/datastrato/graviton/server/GravitonServer.java@@ -6,7 +6,7 @@ package com.datastrato.graviton.server;import com.datastrato.graviton.GravitonEnv;import com.datastrato.graviton.catalog.CatalogManager;-import com.datastrato.graviton.meta.BaseMetalakesOperations;+import com.datastrato.graviton.meta.MetalakeManager;import com.datastrato.graviton.server.web.JettyServer;import com.datastrato.graviton.server.web.ObjectMapperProvider;import com.datastrato.graviton.server.web.VersioningFilter;@@ -58,7 +58,7 @@ public class GravitonServer extends ResourceConfig {new AbstractBinder() {@Overrideprotected void configure() {- bind(gravitonEnv.metalakesOperations()).to(BaseMetalakesOperations.class).ranked(1);+ bind(gravitonEnv.metalakesManager()).to(MetalakeManager.class).ranked(1);bind(gravitonEnv.catalogManager()).to(CatalogManager.class).ranked(1);}});diff --git a/server/src/main/java/com/datastrato/graviton/server/web/rest/MetalakeOperations.java b/server/src/main/java/com/datastrato/graviton/server/web/rest/MetalakeOperations.javaindex 20040c53ab..3785e26589 100644--- a/server/src/main/java/com/datastrato/graviton/server/web/rest/MetalakeOperations.java+++ b/server/src/main/java/com/datastrato/graviton/server/web/rest/MetalakeOperations.java@@ -16,7 +16,7 @@ import com.datastrato.graviton.dto.responses.MetalakeResponse;import com.datastrato.graviton.exceptions.MetalakeAlreadyExistsException;import com.datastrato.graviton.exceptions.NoSuchMetalakeException;import com.datastrato.graviton.meta.BaseMetalake;-import com.datastrato.graviton.meta.BaseMetalakesOperations;+import com.datastrato.graviton.meta.MetalakeManager;import com.datastrato.graviton.server.web.Utils;import java.util.Arrays;import javax.inject.Inject;@@ -42,20 +42,20 @@ public class MetalakeOperations {private static final Logger LOG = LoggerFactory.getLogger(MetalakeOperations.class);- private final BaseMetalakesOperations ops;+ private final MetalakeManager manager;@Context private HttpServletRequest httpRequest;@Inject- public MetalakeOperations(BaseMetalakesOperations ops) {- this.ops = ops;+ public MetalakeOperations(MetalakeManager manager) {+ this.manager = manager;}@GET@Produces("application/vnd.graviton.v1+json")public Response listMetalakes() {try {- BaseMetalake[] metalakes = ops.listMetalakes();+ BaseMetalake[] metalakes = manager.listMetalakes();MetalakeDTO[] metalakeDTOS =Arrays.stream(metalakes).map(DTOConverters::toDTO).toArray(MetalakeDTO[]::new);return Utils.ok(new MetalakeListResponse(metalakeDTOS));@@ -81,7 +81,7 @@ public class MetalakeOperations {try {NameIdentifier ident = NameIdentifier.parse(request.getName());BaseMetalake metalake =- ops.createMetalake(ident, request.getComment(), request.getProperties());+ manager.createMetalake(ident, request.getComment(), request.getProperties());return Utils.ok(new MetalakeResponse(DTOConverters.toDTO(metalake)));} catch (MetalakeAlreadyExistsException exception) {@@ -105,7 +105,7 @@ public class MetalakeOperations {try {NameIdentifier identifier = NameIdentifier.parse(metalakeName);- BaseMetalake metalake = ops.loadMetalake(identifier);+ BaseMetalake metalake = manager.loadMetalake(identifier);return Utils.ok(new MetalakeResponse(DTOConverters.toDTO(metalake)));} catch (NoSuchMetalakeException e) {@@ -143,7 +143,7 @@ public class MetalakeOperations {.map(MetalakeUpdateRequest::metalakeChange).toArray(MetalakeChange[]::new);- BaseMetalake updatedMetalake = ops.alterMetalake(identifier, changes);+ BaseMetalake updatedMetalake = manager.alterMetalake(identifier, changes);return Utils.ok(new MetalakeResponse(DTOConverters.toDTO(updatedMetalake)));} catch (NoSuchMetalakeException e) {@@ -172,7 +172,7 @@ public class MetalakeOperations {try {NameIdentifier identifier = NameIdentifier.parse(metalakeName);- boolean dropped = ops.dropMetalake(identifier);+ boolean dropped = manager.dropMetalake(identifier);if (!dropped) {LOG.warn("Failed to drop metalake by name {}", metalakeName);}diff --git a/server/src/test/java/com/datastrato/graviton/server/web/rest/TestMetalakeOperations.java b/server/src/test/java/com/datastrato/graviton/server/web/rest/TestMetalakeOperations.javaindex e7ff1544ed..47dce7df44 100644--- a/server/src/test/java/com/datastrato/graviton/server/web/rest/TestMetalakeOperations.java+++ b/server/src/test/java/com/datastrato/graviton/server/web/rest/TestMetalakeOperations.java@@ -22,7 +22,7 @@ import com.datastrato.graviton.dto.responses.MetalakeResponse;import com.datastrato.graviton.exceptions.NoSuchMetalakeException;import com.datastrato.graviton.meta.AuditInfo;import com.datastrato.graviton.meta.BaseMetalake;-import com.datastrato.graviton.meta.BaseMetalakesOperations;+import com.datastrato.graviton.meta.MetalakeManager;import com.datastrato.graviton.meta.SchemaVersion;import com.google.common.collect.ImmutableMap;import com.google.common.collect.Lists;@@ -50,7 +50,7 @@ public class TestMetalakeOperations extends JerseyTest {}}- private BaseMetalakesOperations metalakesOperations = mock(BaseMetalakesOperations.class);+ private MetalakeManager metalakeManager = mock(MetalakeManager.class);@Overrideprotected Application configure() {@@ -60,7 +60,7 @@ public class TestMetalakeOperations extends JerseyTest {new AbstractBinder() {@Overrideprotected void configure() {- bind(metalakesOperations).to(BaseMetalakesOperations.class).ranked(2);+ bind(metalakeManager).to(MetalakeManager.class).ranked(2);bindFactory(MockServletRequestFactory.class).to(HttpServletRequest.class);}});@@ -82,7 +82,7 @@ public class TestMetalakeOperations extends JerseyTest {.withVersion(SchemaVersion.V_0_1).build();- when(metalakesOperations.listMetalakes()).thenReturn(new BaseMetalake[] {metalake, metalake});+ when(metalakeManager.listMetalakes()).thenReturn(new BaseMetalake[] {metalake, metalake});Response resp =target("/metalakes")@@ -119,7 +119,7 @@ public class TestMetalakeOperations extends JerseyTest {.withVersion(SchemaVersion.V_0_1).build();- when(metalakesOperations.createMetalake(any(), any(), any())).thenReturn(mockMetalake);+ when(metalakeManager.createMetalake(any(), any(), any())).thenReturn(mockMetalake);Response resp =target("/metalakes")@@ -166,7 +166,7 @@ public class TestMetalakeOperations extends JerseyTest {.withVersion(SchemaVersion.V_0_1).build();- when(metalakesOperations.loadMetalake(any())).thenReturn(metalake);+ when(metalakeManager.loadMetalake(any())).thenReturn(metalake);Response resp =target("/metalakes/" + metalakeName)@@ -187,7 +187,7 @@ public class TestMetalakeOperations extends JerseyTest {// Test when specified metalake is not found.doThrow(new NoSuchMetalakeException("Failed to find metalake by name " + metalakeName))- .when(metalakesOperations)+ .when(metalakeManager).loadMetalake(any());Response resp1 =@@ -205,7 +205,7 @@ public class TestMetalakeOperations extends JerseyTest {"Metalake " + metalakeName + " does not exist", errorResponse.getMessage());// Test with internal error- doThrow(new RuntimeException("Internal error")).when(metalakesOperations).loadMetalake(any());+ doThrow(new RuntimeException("Internal error")).when(metalakeManager).loadMetalake(any());Response resp2 =target("/metalakes/" + metalakeName)@@ -245,7 +245,7 @@ public class TestMetalakeOperations extends JerseyTest {.map(MetalakeUpdateRequest::metalakeChange).toArray(MetalakeChange[]::new);- when(metalakesOperations.alterMetalake(any(), any(), any())).thenReturn(metalake);+ when(metalakeManager.alterMetalake(any(), any(), any())).thenReturn(metalake);MetalakeUpdatesRequest req = new MetalakeUpdatesRequest(updateRequests);@@ -267,7 +267,7 @@ public class TestMetalakeOperations extends JerseyTest {// Test when specified metalake is not found.doThrow(new NoSuchMetalakeException("Failed to find metalake by name " + metalakeName))- .when(metalakesOperations)+ .when(metalakeManager).alterMetalake(any(), any(), any());Response resp1 =@@ -283,7 +283,7 @@ public class TestMetalakeOperations extends JerseyTest {// Test with internal errordoThrow(new RuntimeException("Internal error"))- .when(metalakesOperations)+ .when(metalakeManager).alterMetalake(any(), any(), any());Response resp2 =@@ -301,7 +301,7 @@ public class TestMetalakeOperations extends JerseyTest {@Testpublic void testDropMetalake() {- when(metalakesOperations.dropMetalake(any())).thenReturn(true);+ when(metalakeManager.dropMetalake(any())).thenReturn(true);Response resp =target("/metalakes/test").request(MediaType.APPLICATION_JSON_TYPE)@@ -316,7 +316,7 @@ public class TestMetalakeOperations extends JerseyTest {Assertions.assertTrue(dropped);// Test throw an exception when deleting tenant.- doThrow(new RuntimeException("Internal error")).when(metalakesOperations).dropMetalake(any());+ doThrow(new RuntimeException("Internal error")).when(metalakeManager).dropMetalake(any());Response resp1 =target("/metalakes/test")