World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#5437] feat(core): add schema event for Iceberg REST server (#5651)
JUNdbeb0177360d
diff --git a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.javaindex ee5d901f4f..93c9ff7358 100644--- a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java+++ b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java@@ -49,6 +49,7 @@ public class CompatibilityUtils {.put(OperationType.DROP_SCHEMA, Operation.DROP_SCHEMA).put(OperationType.LOAD_SCHEMA, Operation.LOAD_SCHEMA).put(OperationType.LIST_SCHEMA, Operation.LIST_SCHEMA)+ .put(OperationType.SCHEMA_EXISTS, Operation.UNKNOWN_OPERATION)// Table operation.put(OperationType.CREATE_TABLE, Operation.CREATE_TABLE)@@ -58,6 +59,8 @@ public class CompatibilityUtils {.put(OperationType.LOAD_TABLE, Operation.LOAD_TABLE).put(OperationType.TABLE_EXISTS, Operation.UNKNOWN_OPERATION).put(OperationType.LIST_TABLE, Operation.LIST_TABLE)+ .put(OperationType.RENAME_TABLE, Operation.UNKNOWN_OPERATION)+ .put(OperationType.REGISTER_TABLE, Operation.UNKNOWN_OPERATION)// Partition operation.put(OperationType.ADD_PARTITION, Operation.UNKNOWN_OPERATION)@@ -82,6 +85,15 @@ public class CompatibilityUtils {.put(OperationType.DROP_TOPIC, Operation.DROP_TOPIC).put(OperationType.LOAD_TOPIC, Operation.LOAD_TOPIC).put(OperationType.LIST_TOPIC, Operation.LIST_TOPIC)++ // View operation+ .put(OperationType.CREATE_VIEW, Operation.UNKNOWN_OPERATION)+ .put(OperationType.ALTER_VIEW, Operation.UNKNOWN_OPERATION)+ .put(OperationType.DROP_VIEW, Operation.UNKNOWN_OPERATION)+ .put(OperationType.LOAD_VIEW, Operation.UNKNOWN_OPERATION)+ .put(OperationType.VIEW_EXISTS, Operation.UNKNOWN_OPERATION)+ .put(OperationType.RENAME_VIEW, Operation.UNKNOWN_OPERATION)+ .put(OperationType.LIST_VIEW, Operation.UNKNOWN_OPERATION).build();static Operation toAuditLogOperation(OperationType operationType) {diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.javaindex 10e4759105..00cbf1e1a4 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java@@ -28,6 +28,7 @@ public enum OperationType {LIST_TABLE,ALTER_TABLE,RENAME_TABLE,+ REGISTER_TABLE,TABLE_EXISTS,// Schema operations@@ -36,6 +37,7 @@ public enum OperationType {ALTER_SCHEMA,LOAD_SCHEMA,LIST_SCHEMA,+ SCHEMA_EXISTS,// Fileset operationsDROP_FILESET,diff --git a/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java b/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.javaindex aa98ee08fa..3941a069a7 100644--- a/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java+++ b/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java@@ -48,6 +48,7 @@ public class TestCompatibilityUtils {{OperationType.DROP_SCHEMA, Operation.DROP_SCHEMA},{OperationType.LOAD_SCHEMA, Operation.LOAD_SCHEMA},{OperationType.LIST_SCHEMA, Operation.LIST_SCHEMA},+ {OperationType.SCHEMA_EXISTS, Operation.UNKNOWN_OPERATION},{OperationType.CREATE_TABLE, Operation.CREATE_TABLE},{OperationType.ALTER_TABLE, Operation.ALTER_TABLE},{OperationType.DROP_TABLE, Operation.DROP_TABLE},@@ -55,6 +56,8 @@ public class TestCompatibilityUtils {{OperationType.LOAD_TABLE, Operation.LOAD_TABLE},{OperationType.TABLE_EXISTS, Operation.UNKNOWN_OPERATION},{OperationType.LIST_TABLE, Operation.LIST_TABLE},+ {OperationType.RENAME_TABLE, Operation.UNKNOWN_OPERATION},+ {OperationType.REGISTER_TABLE, Operation.UNKNOWN_OPERATION},{OperationType.ADD_PARTITION, Operation.UNKNOWN_OPERATION},{OperationType.DROP_PARTITION, Operation.UNKNOWN_OPERATION},{OperationType.PURGE_PARTITION, Operation.PURGE_PARTITION},@@ -73,6 +76,13 @@ public class TestCompatibilityUtils {{OperationType.DROP_TOPIC, Operation.DROP_TOPIC},{OperationType.LOAD_TOPIC, Operation.LOAD_TOPIC},{OperationType.LIST_TOPIC, Operation.LIST_TOPIC},+ {OperationType.CREATE_VIEW, Operation.UNKNOWN_OPERATION},+ {OperationType.ALTER_VIEW, Operation.UNKNOWN_OPERATION},+ {OperationType.DROP_VIEW, Operation.UNKNOWN_OPERATION},+ {OperationType.LOAD_VIEW, Operation.UNKNOWN_OPERATION},+ {OperationType.VIEW_EXISTS, Operation.UNKNOWN_OPERATION},+ {OperationType.RENAME_VIEW, Operation.UNKNOWN_OPERATION},+ {OperationType.LIST_VIEW, Operation.UNKNOWN_OPERATION},{null, Operation.UNKNOWN_OPERATION}};diff --git a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.javaindex de265ed34f..a6da28f7a1 100644--- a/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java+++ b/iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java@@ -134,7 +134,7 @@ public class IcebergCatalogWrapper implements AutoCloseable {return CatalogHandlers.loadNamespace(asNamespaceCatalog, namespace);}- public boolean existNamespace(Namespace namespace) {+ public boolean namespaceExists(Namespace namespace) {validateNamespace(Optional.of(namespace));return asNamespaceCatalog.namespaceExists(namespace);}@@ -234,7 +234,7 @@ public class IcebergCatalogWrapper implements AutoCloseable {CatalogHandlers.renameView(getViewCatalog(), request);}- public boolean existView(TableIdentifier viewIdentifier) {+ public boolean viewExists(TableIdentifier viewIdentifier) {return getViewCatalog().viewExists(viewIdentifier);}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.javaindex d8fdc26f32..aa19aef777 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/RESTService.java@@ -28,6 +28,9 @@ import org.apache.gravitino.iceberg.common.IcebergConfig;import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapperProvider;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceEventDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationExecutor;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableEventDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationExecutor;@@ -97,6 +100,11 @@ public class RESTService implements GravitinoAuxiliaryService {new IcebergViewOperationExecutor(icebergCatalogWrapperManager);IcebergViewEventDispatcher icebergViewEventDispatcher =new IcebergViewEventDispatcher(icebergViewOperationExecutor, eventBus, metalakeName);+ IcebergNamespaceOperationExecutor icebergNamespaceOperationExecutor =+ new IcebergNamespaceOperationExecutor(icebergCatalogWrapperManager);+ IcebergNamespaceEventDispatcher icebergNamespaceEventDispatcher =+ new IcebergNamespaceEventDispatcher(+ icebergNamespaceOperationExecutor, eventBus, metalakeName);config.register(new AbstractBinder() {@@ -106,6 +114,9 @@ public class RESTService implements GravitinoAuxiliaryService {bind(icebergMetricsManager).to(IcebergMetricsManager.class).ranked(1);bind(icebergTableEventDispatcher).to(IcebergTableOperationDispatcher.class).ranked(1);bind(icebergViewEventDispatcher).to(IcebergViewOperationDispatcher.class).ranked(1);+ bind(icebergNamespaceEventDispatcher)+ .to(IcebergNamespaceOperationDispatcher.class)+ .ranked(1);}});diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.javanew file mode 100644index 0000000000..57fa916b7d--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceEventDispatcher.java@@ -0,0 +1,227 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.iceberg.service.dispatcher;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.listener.EventBus;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergListNamespacesEvent;+import org.apache.gravitino.listener.api.event.IcebergListNamespacesFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergListNamespacesPreEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergNamespaceExistsEvent;+import org.apache.gravitino.listener.api.event.IcebergNamespaceExistsFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergNamespaceExistsPreEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTableEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTableFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTablePreEvent;+import org.apache.gravitino.listener.api.event.IcebergRequestContext;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespacePreEvent;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.catalog.TableIdentifier;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;+import org.apache.iceberg.rest.responses.ListNamespacesResponse;+import org.apache.iceberg.rest.responses.LoadTableResponse;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;++/**+ * {@code IcebergNamespaceEventDispatcher} is a decorator for {@link+ * IcebergNamespaceOperationExecutor} that not only delegates namespace operations to the underlying+ * dispatcher but also dispatches corresponding events to an {@link EventBus}.+ */+public class IcebergNamespaceEventDispatcher implements IcebergNamespaceOperationDispatcher {++ private IcebergNamespaceOperationDispatcher operationDispatcher;+ private EventBus eventBus;+ private String metalakeName;++ public IcebergNamespaceEventDispatcher(+ IcebergNamespaceOperationDispatcher operationDispatcher,+ EventBus eventBus,+ String metalakeName) {+ this.operationDispatcher = operationDispatcher;+ this.eventBus = eventBus;+ this.metalakeName = metalakeName;+ }++ @Override+ public CreateNamespaceResponse createNamespace(+ IcebergRequestContext context, CreateNamespaceRequest createRequest) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(+ metalakeName, context.catalogName(), createRequest.namespace());++ eventBus.dispatchEvent(+ new IcebergCreateNamespacePreEvent(context, nameIdentifier, createRequest));++ CreateNamespaceResponse createResponse;+ try {+ createResponse = operationDispatcher.createNamespace(context, createRequest);+ } catch (Exception e) {+ eventBus.dispatchEvent(+ new IcebergCreateNamespaceFailureEvent(context, nameIdentifier, createRequest, e));+ throw e;+ }++ eventBus.dispatchEvent(+ new IcebergCreateNamespaceEvent(context, nameIdentifier, createRequest, createResponse));+ return createResponse;+ }++ @Override+ public UpdateNamespacePropertiesResponse updateNamespace(+ IcebergRequestContext context,+ Namespace namespace,+ UpdateNamespacePropertiesRequest updateRequest) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);++ eventBus.dispatchEvent(+ new IcebergUpdateNamespacePreEvent(context, nameIdentifier, updateRequest));++ UpdateNamespacePropertiesResponse updateResponse;+ try {+ updateResponse = operationDispatcher.updateNamespace(context, namespace, updateRequest);+ } catch (Exception e) {+ eventBus.dispatchEvent(+ new IcebergUpdateNamespaceFailureEvent(context, nameIdentifier, updateRequest, e));+ throw e;+ }++ eventBus.dispatchEvent(+ new IcebergUpdateNamespaceEvent(context, nameIdentifier, updateRequest, updateResponse));+ return updateResponse;+ }++ @Override+ public void dropNamespace(IcebergRequestContext context, Namespace namespace) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ eventBus.dispatchEvent(new IcebergDropNamespacePreEvent(context, nameIdentifier));++ try {+ operationDispatcher.dropNamespace(context, namespace);+ } catch (Exception e) {+ eventBus.dispatchEvent(new IcebergDropNamespaceFailureEvent(context, nameIdentifier, e));+ throw e;+ }++ eventBus.dispatchEvent(new IcebergDropNamespaceEvent(context, nameIdentifier));+ }++ @Override+ public GetNamespaceResponse loadNamespace(IcebergRequestContext context, Namespace namespace) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ eventBus.dispatchEvent(new IcebergLoadNamespacePreEvent(context, nameIdentifier));++ GetNamespaceResponse getResponse;+ try {+ getResponse = operationDispatcher.loadNamespace(context, namespace);+ } catch (Exception e) {+ eventBus.dispatchEvent(new IcebergLoadNamespaceFailureEvent(context, nameIdentifier, e));+ throw e;+ }++ eventBus.dispatchEvent(new IcebergLoadNamespaceEvent(context, nameIdentifier, getResponse));+ return getResponse;+ }++ @Override+ public ListNamespacesResponse listNamespaces(+ IcebergRequestContext context, Namespace parentNamespace) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(+ metalakeName, context.catalogName(), parentNamespace);+ eventBus.dispatchEvent(new IcebergListNamespacesPreEvent(context, nameIdentifier));++ ListNamespacesResponse listResponse;+ try {+ listResponse = operationDispatcher.listNamespaces(context, parentNamespace);+ } catch (Exception e) {+ eventBus.dispatchEvent(new IcebergListNamespacesFailureEvent(context, nameIdentifier, e));+ throw e;+ }++ eventBus.dispatchEvent(new IcebergListNamespacesEvent(context, nameIdentifier));+ return listResponse;+ }++ @Override+ public boolean namespaceExists(IcebergRequestContext context, Namespace namespace) {+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(metalakeName, context.catalogName(), namespace);+ eventBus.dispatchEvent(new IcebergNamespaceExistsPreEvent(context, nameIdentifier));++ boolean isExists;+ try {+ isExists = operationDispatcher.namespaceExists(context, namespace);+ } catch (Exception e) {+ eventBus.dispatchEvent(new IcebergNamespaceExistsFailureEvent(context, nameIdentifier, e));+ throw e;+ }++ eventBus.dispatchEvent(new IcebergNamespaceExistsEvent(context, nameIdentifier, isExists));+ return isExists;+ }++ @Override+ public LoadTableResponse registerTable(+ IcebergRequestContext context,+ Namespace namespace,+ RegisterTableRequest registerTableRequest) {+ TableIdentifier tableIdentifier = TableIdentifier.of(namespace, registerTableRequest.name());+ NameIdentifier nameIdentifier =+ IcebergRestUtils.getGravitinoNameIdentifier(+ metalakeName, context.catalogName(), tableIdentifier);++ eventBus.dispatchEvent(+ new IcebergRegisterTablePreEvent(context, nameIdentifier, registerTableRequest));++ LoadTableResponse loadTableResponse;+ try {+ loadTableResponse =+ operationDispatcher.registerTable(context, namespace, registerTableRequest);+ } catch (Exception e) {+ eventBus.dispatchEvent(+ new IcebergRegisterTableFailureEvent(context, nameIdentifier, registerTableRequest, e));+ throw e;+ }++ eventBus.dispatchEvent(+ new IcebergRegisterTableEvent(+ context, nameIdentifier, registerTableRequest, loadTableResponse));+ return loadTableResponse;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationDispatcher.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationDispatcher.javanew file mode 100644index 0000000000..bc20cb0d77--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationDispatcher.java@@ -0,0 +1,113 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.iceberg.service.dispatcher;++import org.apache.gravitino.listener.api.event.IcebergRequestContext;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;+import org.apache.iceberg.rest.responses.ListNamespacesResponse;+import org.apache.iceberg.rest.responses.LoadTableResponse;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;++/**+ * The {@code IcebergNamespaceOperationDispatcher} interface defines the public API for managing+ * Iceberg namespaces.+ */+public interface IcebergNamespaceOperationDispatcher {++ /**+ * Creates a new Iceberg namespace.+ *+ * @param context Iceberg REST request context information.+ * @param createNamespaceRequest The request object containing the details for creating the+ * namespace.+ * @return A {@link CreateNamespaceResponse} object containing the result of the operation.+ */+ CreateNamespaceResponse createNamespace(+ IcebergRequestContext context, CreateNamespaceRequest createNamespaceRequest);++ /**+ * Updates an Iceberg namespace.+ *+ * @param context Iceberg REST request context information.+ * @param namespace The Iceberg namespace.+ * @param updateNamespacePropertiesRequest The request object containing the details for updating+ * the namespace.+ * @return A {@link UpdateNamespacePropertiesResponse} object containing the result of the+ * operation.+ */+ UpdateNamespacePropertiesResponse updateNamespace(+ IcebergRequestContext context,+ Namespace namespace,+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest);++ /**+ * Drops an Iceberg namespace.+ *+ * @param context Iceberg REST request context information.+ * @param namespace The Iceberg namespace.+ */+ void dropNamespace(IcebergRequestContext context, Namespace namespace);++ /**+ * Loads an Iceberg namespace.+ *+ * @param context Iceberg REST request context information.+ * @param namespace The Iceberg namespace.+ * @return A {@link GetNamespaceResponse} object containing the result of the operation.+ */+ GetNamespaceResponse loadNamespace(IcebergRequestContext context, Namespace namespace);++ /**+ * Lists Iceberg namespaces.+ *+ * @param context Iceberg REST request context information.+ * @param parentNamespace The Iceberg namespace.+ * @return A {@link ListNamespacesResponse} object containing the list of namespaces.+ */+ ListNamespacesResponse listNamespaces(IcebergRequestContext context, Namespace parentNamespace);++ /**+ * Check whether an Iceberg namespace exists.+ *+ * @param context Iceberg REST request context information.+ * @param namespace The Iceberg namespace.+ * @return Whether namespace exists.+ */+ boolean namespaceExists(IcebergRequestContext context, Namespace namespace);++ /**+ * Register a Iceberg table.+ *+ * @param context Iceberg REST request context information.+ * @param namespace The Iceberg namespace.+ * @param registerTableRequest The request object containing the details for registering the+ * table.+ * @return A {@link LoadTableResponse} object containing the result of the operation.+ */+ LoadTableResponse registerTable(+ IcebergRequestContext context,+ Namespace namespace,+ RegisterTableRequest registerTableRequest);+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationExecutor.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationExecutor.javanew file mode 100644index 0000000000..e584d43202--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergNamespaceOperationExecutor.java@@ -0,0 +1,97 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.iceberg.service.dispatcher;++import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;+import org.apache.gravitino.listener.api.event.IcebergRequestContext;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;+import org.apache.iceberg.rest.responses.ListNamespacesResponse;+import org.apache.iceberg.rest.responses.LoadTableResponse;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;++public class IcebergNamespaceOperationExecutor implements IcebergNamespaceOperationDispatcher {++ private IcebergCatalogWrapperManager icebergCatalogWrapperManager;++ public IcebergNamespaceOperationExecutor(+ IcebergCatalogWrapperManager icebergCatalogWrapperManager) {+ this.icebergCatalogWrapperManager = icebergCatalogWrapperManager;+ }++ @Override+ public CreateNamespaceResponse createNamespace(+ IcebergRequestContext context, CreateNamespaceRequest createNamespaceRequest) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .createNamespace(createNamespaceRequest);+ }++ @Override+ public UpdateNamespacePropertiesResponse updateNamespace(+ IcebergRequestContext context,+ Namespace namespace,+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .updateNamespaceProperties(namespace, updateNamespacePropertiesRequest);+ }++ @Override+ public void dropNamespace(IcebergRequestContext context, Namespace namespace) {+ icebergCatalogWrapperManager.getCatalogWrapper(context.catalogName()).dropNamespace(namespace);+ }++ @Override+ public GetNamespaceResponse loadNamespace(IcebergRequestContext context, Namespace namespace) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .loadNamespace(namespace);+ }++ @Override+ public ListNamespacesResponse listNamespaces(+ IcebergRequestContext context, Namespace parentNamespace) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .listNamespace(parentNamespace);+ }++ @Override+ public boolean namespaceExists(IcebergRequestContext context, Namespace namespace) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .namespaceExists(namespace);+ }++ @Override+ public LoadTableResponse registerTable(+ IcebergRequestContext context,+ Namespace namespace,+ RegisterTableRequest registerTableRequest) {+ return icebergCatalogWrapperManager+ .getCatalogWrapper(context.catalogName())+ .registerTable(namespace, registerTableRequest);+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewOperationExecutor.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewOperationExecutor.javaindex 308c20c437..dd503dbbc3 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewOperationExecutor.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/dispatcher/IcebergViewOperationExecutor.java@@ -78,7 +78,7 @@ public class IcebergViewOperationExecutor implements IcebergViewOperationDispatcpublic boolean viewExists(IcebergRequestContext context, TableIdentifier viewIdentifier) {return icebergCatalogWrapperManager.getCatalogWrapper(context.catalogName())- .existView(viewIdentifier);+ .viewExists(viewIdentifier);}@Overridediff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.javaindex c4e3a3fe6e..125fb3d127 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceOperations.java@@ -20,6 +20,9 @@ package org.apache.gravitino.iceberg.service.rest;import com.codahale.metrics.annotation.ResponseMetered;import com.codahale.metrics.annotation.Timed;+import com.fasterxml.jackson.core.JsonProcessingException;+import com.fasterxml.jackson.databind.ObjectMapper;+import com.google.common.annotations.VisibleForTesting;import javax.inject.Inject;import javax.servlet.http.HttpServletRequest;import javax.ws.rs.Consumes;@@ -35,8 +38,10 @@ import javax.ws.rs.QueryParam;import javax.ws.rs.core.Context;import javax.ws.rs.core.MediaType;import javax.ws.rs.core.Response;-import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;+import org.apache.gravitino.iceberg.service.IcebergObjectMapper;import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;+import org.apache.gravitino.listener.api.event.IcebergRequestContext;import org.apache.gravitino.metrics.MetricNames;import org.apache.iceberg.catalog.Namespace;import org.apache.iceberg.rest.RESTUtil;@@ -58,15 +63,16 @@ public class IcebergNamespaceOperations {private static final Logger LOG = LoggerFactory.getLogger(IcebergNamespaceOperations.class);- private IcebergCatalogWrapperManager icebergCatalogWrapperManager;+ private ObjectMapper icebergObjectMapper;+ private IcebergNamespaceOperationDispatcher namespaceOperationDispatcher;- @SuppressWarnings("UnusedVariable")- @Context- private HttpServletRequest httpRequest;+ @Context private HttpServletRequest httpRequest;@Inject- public IcebergNamespaceOperations(IcebergCatalogWrapperManager icebergCatalogWrapperManager) {- this.icebergCatalogWrapperManager = icebergCatalogWrapperManager;+ public IcebergNamespaceOperations(+ IcebergNamespaceOperationDispatcher namespaceOperationDispatcher) {+ this.namespaceOperationDispatcher = namespaceOperationDispatcher;+ this.icebergObjectMapper = IcebergObjectMapper.getInstance();}@GET@@ -75,10 +81,14 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "list-namespace", absolute = true)public Response listNamespaces(@DefaultValue("") @QueryParam("parent") String parent, @PathParam("prefix") String prefix) {+ String catalogName = IcebergRestUtils.getCatalogName(prefix);Namespace parentNamespace =parent.isEmpty() ? Namespace.empty() : RESTUtil.decodeNamespace(parent);+ LOG.info(+ "List Iceberg namespaces, catalog: {}, parentNamespace: {}", catalogName, parentNamespace);+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);ListNamespacesResponse response =- icebergCatalogWrapperManager.getOps(prefix).listNamespace(parentNamespace);+ namespaceOperationDispatcher.listNamespaces(context, parentNamespace);return IcebergRestUtils.ok(response);}@@ -89,10 +99,13 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "load-namespace", absolute = true)public Response loadNamespace(@PathParam("prefix") String prefix, @PathParam("namespace") String namespace) {+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ Namespace icebergNS = RESTUtil.decodeNamespace(namespace);+ LOG.info("Load Iceberg namespace, catalog: {}, namespace: {}", catalogName, icebergNS);++ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);GetNamespaceResponse getNamespaceResponse =- icebergCatalogWrapperManager- .getOps(prefix)- .loadNamespace(RESTUtil.decodeNamespace(namespace));+ namespaceOperationDispatcher.loadNamespace(context, icebergNS);return IcebergRestUtils.ok(getNamespaceResponse);}@@ -103,10 +116,12 @@ public class IcebergNamespaceOperations {@ResponseMetered(name = "namespace-exists", absolute = true)public Response namespaceExists(@PathParam("prefix") String prefix, @PathParam("namespace") String namespace) {- boolean exists =- icebergCatalogWrapperManager- .getOps(prefix)- .existNamespace(RESTUtil.decodeNamespace(namespace));+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ Namespace icebergNS = RESTUtil.decodeNamespace(namespace);+ LOG.info("Check Iceberg namespace exists, catalog: {}, namespace: {}", catalogName, icebergNS);+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);++ boolean exists = namespaceOperationDispatcher.namespaceExists(context, icebergNS);if (exists) {return IcebergRestUtils.noContent();} else {@@ -122,8 +137,11 @@ public class IcebergNamespaceOperations {public Response dropNamespace(@PathParam("prefix") String prefix, @PathParam("namespace") String namespace) {// todo check if table exists in namespace after table ops is added- LOG.info("Drop Iceberg namespace: {}, prefix: {}", namespace, prefix);- icebergCatalogWrapperManager.getOps(prefix).dropNamespace(RESTUtil.decodeNamespace(namespace));+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ Namespace icebergNS = RESTUtil.decodeNamespace(namespace);+ LOG.info("Drop Iceberg namespace, catalog: {}, namespace: {}", catalogName, icebergNS);+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);+ namespaceOperationDispatcher.dropNamespace(context, icebergNS);return IcebergRestUtils.noContent();}@@ -132,11 +150,16 @@ public class IcebergNamespaceOperations {@Timed(name = "create-namespace." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)@ResponseMetered(name = "create-namespace", absolute = true)public Response createNamespace(- @PathParam("prefix") String prefix, CreateNamespaceRequest namespaceRequest) {- LOG.info("Create Iceberg namespace: {}, prefix: {}", namespaceRequest, prefix);- CreateNamespaceResponse response =- icebergCatalogWrapperManager.getOps(prefix).createNamespace(namespaceRequest);- return IcebergRestUtils.ok(response);+ @PathParam("prefix") String prefix, CreateNamespaceRequest createNamespaceRequest) {+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ LOG.info(+ "Create Iceberg namespace, catalog: {}, createNamespaceRequest: {}",+ catalogName,+ createNamespaceRequest);+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);+ CreateNamespaceResponse createNamespaceResponse =+ namespaceOperationDispatcher.createNamespace(context, createNamespaceRequest);+ return IcebergRestUtils.ok(createNamespaceResponse);}@POST@@ -147,13 +170,19 @@ public class IcebergNamespaceOperations {public Response updateNamespace(@PathParam("prefix") String prefix,@PathParam("namespace") String namespace,- UpdateNamespacePropertiesRequest request) {- LOG.info("Update Iceberg namespace: {}, request: {}, prefix: {}", namespace, request, prefix);- UpdateNamespacePropertiesResponse response =- icebergCatalogWrapperManager- .getOps(prefix)- .updateNamespaceProperties(RESTUtil.decodeNamespace(namespace), request);- return IcebergRestUtils.ok(response);+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ Namespace icebergNS = RESTUtil.decodeNamespace(namespace);+ LOG.info(+ "Update Iceberg namespace, catalog: {}, namespace: {}, updateNamespacePropertiesRequest: {}",+ catalogName,+ icebergNS,+ SerializeUpdateNamespacePropertiesRequest(updateNamespacePropertiesRequest));+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);+ UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse =+ namespaceOperationDispatcher.updateNamespace(+ context, icebergNS, updateNamespacePropertiesRequest);+ return IcebergRestUtils.ok(updateNamespacePropertiesResponse);}@POST@@ -164,12 +193,34 @@ public class IcebergNamespaceOperations {public Response registerTable(@PathParam("prefix") String prefix,@PathParam("namespace") String namespace,- RegisterTableRequest request) {- LOG.info("Register table, namespace: {}, request: {}", namespace, request);- LoadTableResponse response =- icebergCatalogWrapperManager- .getOps(prefix)- .registerTable(RESTUtil.decodeNamespace(namespace), request);- return IcebergRestUtils.ok(response);+ RegisterTableRequest registerTableRequest) {+ String catalogName = IcebergRestUtils.getCatalogName(prefix);+ Namespace icebergNS = RESTUtil.decodeNamespace(namespace);+ LOG.info(+ "Register Iceberg table, catalog: {}, namespace: {}, registerTableRequest: {}",+ catalogName,+ icebergNS,+ registerTableRequest);+ IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);+ LoadTableResponse loadTableResponse =+ namespaceOperationDispatcher.registerTable(context, icebergNS, registerTableRequest);++ return IcebergRestUtils.ok(loadTableResponse);+ }++ // HTTP request is null in Jersey test, override with a mock request when testing.+ @VisibleForTesting+ HttpServletRequest httpServletRequest() {+ return httpRequest;+ }++ private String SerializeUpdateNamespacePropertiesRequest(+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {+ try {+ return icebergObjectMapper.writeValueAsString(updateNamespacePropertiesRequest);+ } catch (JsonProcessingException e) {+ LOG.warn("Serialize update namespace properties failed", e);+ return updateNamespacePropertiesRequest.toString();+ }}}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.javaindex 26c466504a..ddcff8d987 100644--- a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergViewOperations.java@@ -138,7 +138,7 @@ public class IcebergViewOperations {String catalogName = IcebergRestUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info(- "Replace Iceberg view, catalog: {}, namespace: {}, table: {}, replaceViewRequest: {}",+ "Replace Iceberg view, catalog: {}, namespace: {}, view: {}, replaceViewRequest: {}",catalogName,icebergNS,view,@@ -162,7 +162,7 @@ public class IcebergViewOperations {String catalogName = IcebergRestUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info(- "Drop Iceberg view, catalog: {}, namespace: {}, table: {}", catalogName, icebergNS, view);+ "Drop Iceberg view, catalog: {}, namespace: {}, view: {}", catalogName, icebergNS, view);TableIdentifier viewIdentifier = TableIdentifier.of(namespace, view);IcebergRequestContext context = new IcebergRequestContext(httpServletRequest(), catalogName);viewOperationDispatcher.dropView(context, viewIdentifier);@@ -181,7 +181,7 @@ public class IcebergViewOperations {String catalogName = IcebergRestUtils.getCatalogName(prefix);Namespace icebergNS = RESTUtil.decodeNamespace(namespace);LOG.info(- "Check Iceberg view exists, catalog: {}, namespace: {}, table: {}",+ "Check Iceberg view exists, catalog: {}, namespace: {}, view: {}",catalogName,icebergNS,view);diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.javanew file mode 100644index 0000000000..9bc1698ef1--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceEvent.java@@ -0,0 +1,61 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;++/** Represent an event after creating Iceberg namespace successfully. */+@DeveloperApi+public class IcebergCreateNamespaceEvent extends IcebergNamespaceEvent {++ private final CreateNamespaceRequest createNamespaceRequest;+ private final CreateNamespaceResponse createNamespaceResponse;++ public IcebergCreateNamespaceEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ CreateNamespaceRequest createNamespaceRequest,+ CreateNamespaceResponse createNamespaceResponse) {+ super(icebergRequestContext, nameIdentifier);+ this.createNamespaceRequest =+ IcebergRestUtils.cloneIcebergRESTObject(+ createNamespaceRequest, CreateNamespaceRequest.class);+ this.createNamespaceResponse =+ IcebergRestUtils.cloneIcebergRESTObject(+ createNamespaceResponse, CreateNamespaceResponse.class);+ }++ public CreateNamespaceRequest createNamespaceRequest() {+ return createNamespaceRequest;+ }++ public CreateNamespaceResponse createNamespaceResponse() {+ return createNamespaceResponse;+ }++ @Override+ public OperationType operationType() {+ return OperationType.CREATE_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.javanew file mode 100644index 0000000000..850e33611d--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespaceFailureEvent.java@@ -0,0 +1,51 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;++/** Represent a failure event when creating Iceberg namespace failed. */+@DeveloperApi+public class IcebergCreateNamespaceFailureEvent extends IcebergNamespaceFailureEvent {+ private final CreateNamespaceRequest createNamespaceRequest;++ public IcebergCreateNamespaceFailureEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ CreateNamespaceRequest createNamespaceRequest,+ Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ this.createNamespaceRequest =+ IcebergRestUtils.cloneIcebergRESTObject(+ createNamespaceRequest, CreateNamespaceRequest.class);+ }++ public CreateNamespaceRequest createNamespaceRequest() {+ return createNamespaceRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.CREATE_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespacePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespacePreEvent.javanew file mode 100644index 0000000000..a908582c63--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergCreateNamespacePreEvent.java@@ -0,0 +1,47 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;++/** Represent a pre event before creating Iceberg namespace. */+@DeveloperApi+public class IcebergCreateNamespacePreEvent extends IcebergNamespacePreEvent {+ private final CreateNamespaceRequest createNamespaceRequest;++ public IcebergCreateNamespacePreEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ CreateNamespaceRequest createNamespaceRequest) {+ super(icebergRequestContext, nameIdentifier);+ this.createNamespaceRequest = createNamespaceRequest;+ }++ public CreateNamespaceRequest createNamespaceRequest() {+ return createNamespaceRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.CREATE_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceEvent.javanew file mode 100644index 0000000000..ba92b3c778--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceEvent.java@@ -0,0 +1,38 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent an event after dropping Iceberg namespace successfully. */+@DeveloperApi+public class IcebergDropNamespaceEvent extends IcebergNamespaceEvent {++ public IcebergDropNamespaceEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.DROP_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceFailureEvent.javanew file mode 100644index 0000000000..8c208ef598--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespaceFailureEvent.java@@ -0,0 +1,38 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a failure event when dropping Iceberg namespace failed. */+@DeveloperApi+public class IcebergDropNamespaceFailureEvent extends IcebergNamespaceFailureEvent {++ public IcebergDropNamespaceFailureEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier, Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ }++ @Override+ public OperationType operationType() {+ return OperationType.DROP_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespacePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespacePreEvent.javanew file mode 100644index 0000000000..5fb915febd--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergDropNamespacePreEvent.java@@ -0,0 +1,38 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a pre event before dropping Iceberg namespace. */+@DeveloperApi+public class IcebergDropNamespacePreEvent extends IcebergNamespacePreEvent {++ public IcebergDropNamespacePreEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.DROP_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesEvent.javanew file mode 100644index 0000000000..c6bf6fdd0c--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesEvent.java@@ -0,0 +1,43 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/**+ * Represent an event after listing Iceberg namespace successfully.+ *+ * <p>To optimize memory usage and avoid the potential overhead associated with storing a large+ * number of namespaces directly within the ListNamespaceEvent, the actual namespaces listed are not+ * maintained in this event.+ */+@DeveloperApi+public class IcebergListNamespacesEvent extends IcebergNamespaceEvent {+ public IcebergListNamespacesEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.LIST_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesFailureEvent.javanew file mode 100644index 0000000000..4a3db66e70--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesFailureEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a failure event when listing Iceberg namespace failed. */+@DeveloperApi+public class IcebergListNamespacesFailureEvent extends IcebergNamespaceFailureEvent {+ public IcebergListNamespacesFailureEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier, Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ }++ @Override+ public OperationType operationType() {+ return OperationType.LIST_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesPreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesPreEvent.javanew file mode 100644index 0000000000..b511d00bdd--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergListNamespacesPreEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a pre event before listing Iceberg namespace. */+@DeveloperApi+public class IcebergListNamespacesPreEvent extends IcebergNamespacePreEvent {+ public IcebergListNamespacesPreEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.LIST_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.javanew file mode 100644index 0000000000..dbfb5b77f6--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceEvent.java@@ -0,0 +1,49 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;++/** Represent an event after loading Iceberg namespace successfully. */+@DeveloperApi+public class IcebergLoadNamespaceEvent extends IcebergNamespaceEvent {+ private final GetNamespaceResponse getNamespaceResponse;++ public IcebergLoadNamespaceEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ GetNamespaceResponse getNamespaceResponse) {+ super(icebergRequestContext, nameIdentifier);+ this.getNamespaceResponse =+ IcebergRestUtils.cloneIcebergRESTObject(getNamespaceResponse, GetNamespaceResponse.class);+ }++ public GetNamespaceResponse getNamespaceResponse() {+ return getNamespaceResponse;+ }++ @Override+ public OperationType operationType() {+ return OperationType.LOAD_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceFailureEvent.javanew file mode 100644index 0000000000..5849d4047c--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespaceFailureEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a failure event when loading Iceberg namespace failed. */+@DeveloperApi+public class IcebergLoadNamespaceFailureEvent extends IcebergNamespaceFailureEvent {+ public IcebergLoadNamespaceFailureEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier, Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ }++ @Override+ public OperationType operationType() {+ return OperationType.LOAD_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespacePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespacePreEvent.javanew file mode 100644index 0000000000..f674ec1a8e--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergLoadNamespacePreEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a pre event before loading Iceberg namespace. */+@DeveloperApi+public class IcebergLoadNamespacePreEvent extends IcebergNamespacePreEvent {+ public IcebergLoadNamespacePreEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.LOAD_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceEvent.javanew file mode 100644index 0000000000..95f9e8d622--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceEvent.java@@ -0,0 +1,30 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;++/** Represents an abstract namespace post event in Gravitino Iceberg REST server. */+public abstract class IcebergNamespaceEvent extends IcebergEvent {+ protected IcebergNamespaceEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsEvent.javanew file mode 100644index 0000000000..54624ef70e--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsEvent.java@@ -0,0 +1,46 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent an event after check Iceberg namespace exists successfully. */+@DeveloperApi+public class IcebergNamespaceExistsEvent extends IcebergNamespaceEvent {+ private final boolean isExists;++ public IcebergNamespaceExistsEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ boolean isExists) {+ super(icebergRequestContext, nameIdentifier);+ this.isExists = isExists;+ }++ public boolean isExists() {+ return isExists;+ }++ @Override+ public OperationType operationType() {+ return OperationType.SCHEMA_EXISTS;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsFailureEvent.javanew file mode 100644index 0000000000..2b6d4d5254--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsFailureEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a failure event when check Iceberg namespace exist failed. */+@DeveloperApi+public class IcebergNamespaceExistsFailureEvent extends IcebergNamespaceFailureEvent {+ public IcebergNamespaceExistsFailureEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier, Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ }++ @Override+ public OperationType operationType() {+ return OperationType.SCHEMA_EXISTS;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsPreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsPreEvent.javanew file mode 100644index 0000000000..b9cc0b2cc2--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceExistsPreEvent.java@@ -0,0 +1,37 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a pre event before checking Iceberg namespace exists. */+@DeveloperApi+public class IcebergNamespaceExistsPreEvent extends IcebergNamespacePreEvent {+ public IcebergNamespaceExistsPreEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier) {+ super(icebergRequestContext, nameIdentifier);+ }++ @Override+ public OperationType operationType() {+ return OperationType.SCHEMA_EXISTS;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceFailureEvent.javanew file mode 100644index 0000000000..6a3389a455--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespaceFailureEvent.java@@ -0,0 +1,32 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represent a failure event when do Iceberg namespace operation failed. */+@DeveloperApi+public abstract class IcebergNamespaceFailureEvent extends IcebergFailureEvent {+ protected IcebergNamespaceFailureEvent(+ IcebergRequestContext icebergRequestContext, NameIdentifier nameIdentifier, Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespacePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespacePreEvent.javanew file mode 100644index 0000000000..c9bfccbeda--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergNamespacePreEvent.java@@ -0,0 +1,31 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represents an abstract namespace pre event in Gravitino Iceberg REST server. */+@DeveloperApi+public abstract class IcebergNamespacePreEvent extends IcebergPreEvent {+ protected IcebergNamespacePreEvent(IcebergRequestContext context, NameIdentifier nameIdentifier) {+ super(context, nameIdentifier);+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.javanew file mode 100644index 0000000000..87b875079e--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableEvent.java@@ -0,0 +1,59 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.responses.LoadTableResponse;++/** Represent an event after registering Iceberg table successfully. */+@DeveloperApi+public class IcebergRegisterTableEvent extends IcebergTableEvent {++ private final RegisterTableRequest registerTableRequest;+ private final LoadTableResponse loadTableResponse;++ public IcebergRegisterTableEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier resourceIdentifier,+ RegisterTableRequest registerTableRequest,+ LoadTableResponse loadTableResponse) {+ super(icebergRequestContext, resourceIdentifier);+ this.registerTableRequest =+ IcebergRestUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);+ this.loadTableResponse =+ IcebergRestUtils.cloneIcebergRESTObject(loadTableResponse, LoadTableResponse.class);+ }++ public RegisterTableRequest registerTableRequest() {+ return registerTableRequest;+ }++ public LoadTableResponse loadTableResponse() {+ return loadTableResponse;+ }++ @Override+ public OperationType operationType() {+ return OperationType.REGISTER_TABLE;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.javanew file mode 100644index 0000000000..49770a3ba8--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTableFailureEvent.java@@ -0,0 +1,50 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.RegisterTableRequest;++/** Represent a failure event when registering Iceberg table failed. */+@DeveloperApi+public class IcebergRegisterTableFailureEvent extends IcebergTableFailureEvent {+ private final RegisterTableRequest registerTableRequest;++ public IcebergRegisterTableFailureEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ RegisterTableRequest registerTableRequest,+ Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ this.registerTableRequest =+ IcebergRestUtils.cloneIcebergRESTObject(registerTableRequest, RegisterTableRequest.class);+ }++ public RegisterTableRequest registerTableRequest() {+ return registerTableRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.REGISTER_TABLE;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTablePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTablePreEvent.javanew file mode 100644index 0000000000..5f4e7bb263--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergRegisterTablePreEvent.java@@ -0,0 +1,47 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.iceberg.rest.requests.RegisterTableRequest;++/** Represent a pre event before registering Iceberg table. */+@DeveloperApi+public class IcebergRegisterTablePreEvent extends IcebergTablePreEvent {+ private final RegisterTableRequest registerTableRequest;++ public IcebergRegisterTablePreEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier resourceIdentifier,+ RegisterTableRequest registerTableRequest) {+ super(icebergRequestContext, resourceIdentifier);+ this.registerTableRequest = registerTableRequest;+ }++ public RegisterTableRequest registerTableRequest() {+ return registerTableRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.REGISTER_TABLE;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.javanew file mode 100644index 0000000000..5d6ab88b6d--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceEvent.java@@ -0,0 +1,61 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;++/** Represent an event after updating Iceberg namespace successfully. */+@DeveloperApi+public class IcebergUpdateNamespaceEvent extends IcebergNamespaceEvent {++ private final UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest;+ private final UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse;++ public IcebergUpdateNamespaceEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest,+ UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse) {+ super(icebergRequestContext, nameIdentifier);+ this.updateNamespacePropertiesRequest =+ IcebergRestUtils.cloneIcebergRESTObject(+ updateNamespacePropertiesRequest, UpdateNamespacePropertiesRequest.class);+ this.updateNamespacePropertiesResponse =+ IcebergRestUtils.cloneIcebergRESTObject(+ updateNamespacePropertiesResponse, UpdateNamespacePropertiesResponse.class);+ }++ public UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest() {+ return updateNamespacePropertiesRequest;+ }++ public UpdateNamespacePropertiesResponse updateNamespacePropertiesResponse() {+ return updateNamespacePropertiesResponse;+ }++ @Override+ public OperationType operationType() {+ return OperationType.ALTER_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.javanew file mode 100644index 0000000000..82e968667b--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespaceFailureEvent.java@@ -0,0 +1,51 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.iceberg.service.IcebergRestUtils;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;++/** Represent a failure event when updating Iceberg namespace failed. */+@DeveloperApi+public class IcebergUpdateNamespaceFailureEvent extends IcebergNamespaceFailureEvent {+ private final UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest;++ public IcebergUpdateNamespaceFailureEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest,+ Exception e) {+ super(icebergRequestContext, nameIdentifier, e);+ this.updateNamespacePropertiesRequest =+ IcebergRestUtils.cloneIcebergRESTObject(+ updateNamespacePropertiesRequest, UpdateNamespacePropertiesRequest.class);+ }++ public UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest() {+ return updateNamespacePropertiesRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.ALTER_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespacePreEvent.java b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespacePreEvent.javanew file mode 100644index 0000000000..04e3b1392e--- /dev/null+++ b/iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/listener/api/event/IcebergUpdateNamespacePreEvent.java@@ -0,0 +1,47 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.listener.api.event;++import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;++/** Represent a pre event before updating Iceberg namespace. */+@DeveloperApi+public class IcebergUpdateNamespacePreEvent extends IcebergNamespacePreEvent {+ private final UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest;++ public IcebergUpdateNamespacePreEvent(+ IcebergRequestContext icebergRequestContext,+ NameIdentifier nameIdentifier,+ UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest) {+ super(icebergRequestContext, nameIdentifier);+ this.updateNamespacePropertiesRequest = updateNamespacePropertiesRequest;+ }++ public UpdateNamespacePropertiesRequest updateNamespacePropertiesRequest() {+ return updateNamespacePropertiesRequest;+ }++ @Override+ public OperationType operationType() {+ return OperationType.ALTER_SCHEMA;+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceTestBase.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceTestBase.javanew file mode 100644index 0000000000..0b5f1d7627--- /dev/null+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergNamespaceTestBase.java@@ -0,0 +1,186 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */+package org.apache.gravitino.iceberg.service.rest;++import com.google.common.collect.ImmutableMap;+import java.util.Arrays;+import java.util.List;+import java.util.Map;+import java.util.Optional;+import java.util.stream.Collectors;+import javax.ws.rs.client.Entity;+import javax.ws.rs.core.MediaType;+import javax.ws.rs.core.Response;+import javax.ws.rs.core.Response.Status;+import org.apache.iceberg.catalog.Namespace;+import org.apache.iceberg.rest.requests.CreateNamespaceRequest;+import org.apache.iceberg.rest.requests.ImmutableRegisterTableRequest;+import org.apache.iceberg.rest.requests.RegisterTableRequest;+import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;+import org.apache.iceberg.rest.responses.CreateNamespaceResponse;+import org.apache.iceberg.rest.responses.GetNamespaceResponse;+import org.apache.iceberg.rest.responses.ListNamespacesResponse;+import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;+import org.junit.jupiter.api.Assertions;++public class IcebergNamespaceTestBase extends IcebergTestBase {++ private final Map<String, String> properties = ImmutableMap.of("a", "b");+ private final Map<String, String> updatedProperties = ImmutableMap.of("b", "c");++ protected Response doCreateNamespace(String... name) {+ CreateNamespaceRequest request =+ CreateNamespaceRequest.builder()+ .withNamespace(Namespace.of(name))+ .setProperties(properties)+ .build();+ return getNamespaceClientBuilder()+ .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));+ }++ private Response doRegisterTable(String tableName) {+ RegisterTableRequest request =+ ImmutableRegisterTableRequest.builder().name(tableName).metadataLocation("mock").build();+ return getNamespaceClientBuilder(+ Optional.of("register_ns"), Optional.of("register"), Optional.empty())+ .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));+ }++ private Response doListNamespace(Optional<String> parent) {+ Optional<Map<String, String>> queryParam =+ parent.isPresent()+ ? Optional.of(ImmutableMap.of("parent", parent.get()))+ : Optional.empty();+ return getNamespaceClientBuilder(Optional.empty(), Optional.empty(), queryParam).get();+ }++ private Response doUpdateNamespace(String name) {+ UpdateNamespacePropertiesRequest request =+ UpdateNamespacePropertiesRequest.builder()+ .removeAll(Arrays.asList("a", "a1"))+ .updateAll(updatedProperties)+ .build();+ return getUpdateNamespaceClientBuilder(name)+ .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));+ }++ private Response doLoadNamespace(String name) {+ return getNamespaceClientBuilder(Optional.of(name)).get();+ }++ private Response doNamespaceExists(String name) {+ return getNamespaceClientBuilder(Optional.of(name)).head();+ }++ private Response doDropNamespace(String name) {+ return getNamespaceClientBuilder(Optional.of(name)).delete();+ }++ protected void verifyLoadNamespaceFail(int status, String name) {+ Response response = doLoadNamespace(name);+ Assertions.assertEquals(status, response.getStatus());+ }++ protected void verifyLoadNamespaceSucc(String name) {+ Response response = doLoadNamespace(name);+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());++ GetNamespaceResponse r = response.readEntity(GetNamespaceResponse.class);+ Assertions.assertEquals(name, r.namespace().toString());+ Assertions.assertEquals(properties, r.properties());+ }++ protected void verifyDropNamespaceSucc(String name) {+ Response response = doDropNamespace(name);+ Assertions.assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());+ }++ protected void verifyDropNamespaceFail(int status, String name) {+ Response response = doDropNamespace(name);+ Assertions.assertEquals(status, response.getStatus());+ }++ protected void verifyNamespaceExistsStatusCode(int status, String name) {+ Response response = doNamespaceExists(name);+ Assertions.assertEquals(status, response.getStatus());+ }++ protected void verifyCreateNamespaceSucc(String... name) {+ Response response = doCreateNamespace(name);+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());++ CreateNamespaceResponse namespaceResponse = response.readEntity(CreateNamespaceResponse.class);+ Assertions.assertTrue(namespaceResponse.namespace().equals(Namespace.of(name)));++ Assertions.assertEquals(namespaceResponse.properties(), properties);+ }++ protected void verifyRegisterTableSucc(String tableName) {+ Response response = doRegisterTable(tableName);+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());+ }++ protected void verifyRegisterTableFail(int statusCode, String tableName) {+ Response response = doRegisterTable(tableName);+ Assertions.assertEquals(statusCode, response.getStatus());+ }++ protected void verifyCreateNamespaceFail(int statusCode, String... name) {+ Response response = doCreateNamespace(name);+ Assertions.assertEquals(statusCode, response.getStatus());+ }++ protected void dropAllExistingNamespace() {+ Response response = doListNamespace(Optional.empty());+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());++ ListNamespacesResponse r = response.readEntity(ListNamespacesResponse.class);+ r.namespaces().forEach(n -> doDropNamespace(n.toString()));+ }++ protected void verifyListNamespaceFail(Optional<String> parent, int status) {+ Response response = doListNamespace(parent);+ Assertions.assertEquals(status, response.getStatus());+ }++ protected void verifyListNamespaceSucc(Optional<String> parent, List<String> schemas) {+ Response response = doListNamespace(parent);+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());++ ListNamespacesResponse r = response.readEntity(ListNamespacesResponse.class);+ List<String> ns = r.namespaces().stream().map(n -> n.toString()).collect(Collectors.toList());+ Assertions.assertEquals(schemas, ns);+ }++ protected void verifyUpdateNamespaceSucc(String name) {+ Response response = doUpdateNamespace(name);+ Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());++ UpdateNamespacePropertiesResponse r =+ response.readEntity(UpdateNamespacePropertiesResponse.class);+ Assertions.assertEquals(Arrays.asList("a"), r.removed());+ Assertions.assertEquals(Arrays.asList("a1"), r.missing());+ Assertions.assertEquals(Arrays.asList("b"), r.updated());+ }++ protected void verifyUpdateNamespaceFail(int status, String name) {+ Response response = doUpdateNamespace(name);+ Assertions.assertEquals(status, response.getStatus());+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.javaindex 56b7fa2b02..19309dc05a 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/IcebergRestTestUtil.java@@ -36,6 +36,9 @@ import org.apache.gravitino.iceberg.common.IcebergConfig;import org.apache.gravitino.iceberg.service.IcebergCatalogWrapperManager;import org.apache.gravitino.iceberg.service.IcebergExceptionMapper;import org.apache.gravitino.iceberg.service.IcebergObjectMapperProvider;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceEventDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationExecutor;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableEventDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationDispatcher;import org.apache.gravitino.iceberg.service.dispatcher.IcebergTableOperationExecutor;@@ -121,6 +124,11 @@ public class IcebergRestTestUtil {IcebergViewEventDispatcher icebergViewEventDispatcher =new IcebergViewEventDispatcher(icebergViewOperationExecutor, eventBus, configProvider.getMetalakeName());+ IcebergNamespaceOperationExecutor icebergNamespaceOperationExecutor =+ new IcebergNamespaceOperationExecutor(icebergCatalogWrapperManager);+ IcebergNamespaceEventDispatcher icebergNamespaceEventDispatcher =+ new IcebergNamespaceEventDispatcher(+ icebergNamespaceOperationExecutor, eventBus, configProvider.getMetalakeName());IcebergMetricsManager icebergMetricsManager = new IcebergMetricsManager(new IcebergConfig());resourceConfig.register(@@ -131,6 +139,9 @@ public class IcebergRestTestUtil {bind(icebergMetricsManager).to(IcebergMetricsManager.class).ranked(2);bind(icebergTableEventDispatcher).to(IcebergTableOperationDispatcher.class).ranked(2);bind(icebergViewEventDispatcher).to(IcebergViewOperationDispatcher.class).ranked(2);+ bind(icebergNamespaceEventDispatcher)+ .to(IcebergNamespaceOperationDispatcher.class)+ .ranked(2);}});}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.javanew file mode 100644index 0000000000..7c955c7b55--- /dev/null+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/MockIcebergNamespaceOperations.java@@ -0,0 +1,39 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing,+ * software distributed under the License is distributed on an+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+ * KIND, either express or implied. See the License for the+ * specific language governing permissions and limitations+ * under the License.+ */++package org.apache.gravitino.iceberg.service.rest;++import javax.inject.Inject;+import javax.servlet.http.HttpServletRequest;+import org.apache.gravitino.iceberg.service.dispatcher.IcebergNamespaceOperationDispatcher;++public class MockIcebergNamespaceOperations extends IcebergNamespaceOperations {++ @Inject+ public MockIcebergNamespaceOperations(+ IcebergNamespaceOperationDispatcher namespaceOperationDispatcher) {+ super(namespaceOperationDispatcher);+ }++ // HTTP request is null in Jersey test, create a mock request+ @Override+ HttpServletRequest httpServletRequest() {+ return IcebergRestTestUtil.createMockHttpRequest();+ }+}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceOperations.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceOperations.javaindex 59e94442d1..248bf9393d 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceOperations.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergNamespaceOperations.java@@ -18,149 +18,59 @@*/package org.apache.gravitino.iceberg.service.rest;-import com.google.common.collect.ImmutableMap;import java.util.Arrays;-import java.util.List;-import java.util.Map;import java.util.Optional;-import java.util.stream.Collectors;-import javax.ws.rs.client.Entity;import javax.ws.rs.core.Application;-import javax.ws.rs.core.MediaType;-import javax.ws.rs.core.Response;-import javax.ws.rs.core.Response.Status;-import org.apache.iceberg.catalog.Namespace;-import org.apache.iceberg.rest.requests.CreateNamespaceRequest;-import org.apache.iceberg.rest.requests.ImmutableRegisterTableRequest;-import org.apache.iceberg.rest.requests.RegisterTableRequest;-import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;-import org.apache.iceberg.rest.responses.CreateNamespaceResponse;-import org.apache.iceberg.rest.responses.GetNamespaceResponse;-import org.apache.iceberg.rest.responses.ListNamespacesResponse;-import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse;+import org.apache.gravitino.listener.api.event.Event;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergCreateNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergDropNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergLoadNamespacePreEvent;+import org.apache.gravitino.listener.api.event.IcebergNamespaceExistsEvent;+import org.apache.gravitino.listener.api.event.IcebergNamespaceExistsPreEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTableEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTableFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergRegisterTablePreEvent;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespaceEvent;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespaceFailureEvent;+import org.apache.gravitino.listener.api.event.IcebergUpdateNamespacePreEvent;+import org.glassfish.jersey.server.ResourceConfig;import org.junit.jupiter.api.Assertions;import org.junit.jupiter.api.Test;import org.junit.jupiter.params.ParameterizedTest;import org.junit.jupiter.params.provider.ValueSource;-public class TestIcebergNamespaceOperations extends IcebergTestBase {+public class TestIcebergNamespaceOperations extends IcebergNamespaceTestBase {- private final Map<String, String> properties = ImmutableMap.of("a", "b");- private final Map<String, String> updatedProperties = ImmutableMap.of("b", "c");+ private DummyEventListener dummyEventListener;@Overrideprotected Application configure() {- return IcebergRestTestUtil.getIcebergResourceConfig(IcebergNamespaceOperations.class);- }-- private Response doCreateNamespace(String... name) {- CreateNamespaceRequest request =- CreateNamespaceRequest.builder()- .withNamespace(Namespace.of(name))- .setProperties(properties)- .build();- return getNamespaceClientBuilder()- .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));- }-- private Response doRegisterTable(String tableName) {- RegisterTableRequest request =- ImmutableRegisterTableRequest.builder().name(tableName).metadataLocation("mock").build();- return getNamespaceClientBuilder(- Optional.of("register_ns"), Optional.of("register"), Optional.empty())- .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));- }-- private Response doListNamespace(Optional<String> parent) {- Optional<Map<String, String>> queryParam =- parent.isPresent()- ? Optional.of(ImmutableMap.of("parent", parent.get()))- : Optional.empty();- return getNamespaceClientBuilder(Optional.empty(), Optional.empty(), queryParam).get();- }-- private Response doUpdateNamespace(String name) {- UpdateNamespacePropertiesRequest request =- UpdateNamespacePropertiesRequest.builder()- .removeAll(Arrays.asList("a", "a1"))- .updateAll(updatedProperties)- .build();- return getUpdateNamespaceClientBuilder(name)- .post(Entity.entity(request, MediaType.APPLICATION_JSON_TYPE));- }-- private Response doLoadNamespace(String name) {- return getNamespaceClientBuilder(Optional.of(name)).get();- }-- private Response doNamespaceExists(String name) {- return getNamespaceClientBuilder(Optional.of(name)).head();- }-- private Response doDropNamespace(String name) {- return getNamespaceClientBuilder(Optional.of(name)).delete();- }-- private void verifyLoadNamespaceFail(int status, String name) {- Response response = doLoadNamespace(name);- Assertions.assertEquals(status, response.getStatus());- }-- private void verifyLoadNamespaceSucc(String name) {- Response response = doLoadNamespace(name);- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());-- GetNamespaceResponse r = response.readEntity(GetNamespaceResponse.class);- Assertions.assertEquals(name, r.namespace().toString());- Assertions.assertEquals(properties, r.properties());- }-- protected void verifyDropNamespaceSucc(String name) {- Response response = doDropNamespace(name);- Assertions.assertEquals(Status.NO_CONTENT.getStatusCode(), response.getStatus());- }-- private void verifyDropNamespaceFail(int status, String name) {- Response response = doDropNamespace(name);- Assertions.assertEquals(status, response.getStatus());- }-- private void verifyNamespaceExistsStatusCode(int status, String name) {- Response response = doNamespaceExists(name);- Assertions.assertEquals(status, response.getStatus());- }-- protected void verifyCreateNamespaceSucc(String... name) {- Response response = doCreateNamespace(name);- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());-- CreateNamespaceResponse namespaceResponse = response.readEntity(CreateNamespaceResponse.class);- Assertions.assertTrue(namespaceResponse.namespace().equals(Namespace.of(name)));-- Assertions.assertEquals(namespaceResponse.properties(), properties);- }-- private void verifyRegisterTableSucc(String tableName) {- Response response = doRegisterTable(tableName);- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());- }-- private void verifyRegisterTableFail(int statusCode, String tableName) {- Response response = doRegisterTable(tableName);- Assertions.assertEquals(statusCode, response.getStatus());- }-- private void verifyCreateNamespaceFail(int statusCode, String... name) {- Response response = doCreateNamespace(name);- Assertions.assertEquals(statusCode, response.getStatus());+ this.dummyEventListener = new DummyEventListener();+ ResourceConfig resourceConfig =+ IcebergRestTestUtil.getIcebergResourceConfig(+ MockIcebergNamespaceOperations.class, true, Arrays.asList(dummyEventListener));+ return resourceConfig;}@Testvoid testCreateNamespace() {verifyCreateNamespaceSucc("create_foo1");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergCreateNamespacePreEvent);+ Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof IcebergCreateNamespaceEvent);// Already Exists ExceptionverifyCreateNamespaceFail(409, "create_foo1");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergCreateNamespacePreEvent);+ Assertions.assertTrue(+ dummyEventListener.popPostEvent() instanceof IcebergCreateNamespaceFailureEvent);// multi level namespacesverifyCreateNamespaceSucc("create_foo2", "create_foo3");@@ -171,26 +81,55 @@ public class TestIcebergNamespaceOperations extends IcebergTestBase {@Testvoid testLoadNamespace() {verifyCreateNamespaceSucc("load_foo1");+ dummyEventListener.clearEvent();+verifyLoadNamespaceSucc("load_foo1");+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergLoadNamespacePreEvent);+ Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof IcebergLoadNamespaceEvent);+// load a schema not existsverifyLoadNamespaceFail(404, "load_foo2");+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergLoadNamespacePreEvent);+ Assertions.assertTrue(+ dummyEventListener.popPostEvent() instanceof IcebergLoadNamespaceFailureEvent);}@Testvoid testNamespaceExists() {verifyNamespaceExistsStatusCode(404, "exists_foo1");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergNamespaceExistsPreEvent);+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertTrue(postEvent instanceof IcebergNamespaceExistsEvent);+ Assertions.assertEquals(false, ((IcebergNamespaceExistsEvent) postEvent).isExists());+verifyCreateNamespaceSucc("exists_foo1");+ dummyEventListener.clearEvent();verifyNamespaceExistsStatusCode(204, "exists_foo1");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergNamespaceExistsPreEvent);+ postEvent = dummyEventListener.popPostEvent();+ Assertions.assertTrue(postEvent instanceof IcebergNamespaceExistsEvent);+ Assertions.assertEquals(true, ((IcebergNamespaceExistsEvent) postEvent).isExists());}@Testvoid testDropNamespace() {verifyCreateNamespaceSucc("drop_foo1");+ dummyEventListener.clearEvent();verifyDropNamespaceSucc("drop_foo1");+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergDropNamespacePreEvent);+ Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof IcebergDropNamespaceEvent);+verifyLoadNamespaceFail(404, "drop_foo1");// drop fail, no such namespace+ dummyEventListener.clearEvent();verifyDropNamespaceFail(404, "drop_foo2");+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergDropNamespacePreEvent);+ Assertions.assertTrue(+ dummyEventListener.popPostEvent() instanceof IcebergDropNamespaceFailureEvent);+// jersery route failedverifyDropNamespaceFail(500, "");}@@ -198,30 +137,14 @@ public class TestIcebergNamespaceOperations extends IcebergTestBase {@Testvoid testRegisterTable() {verifyRegisterTableSucc("register_foo1");+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergRegisterTablePreEvent);+ Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof IcebergRegisterTableEvent);+// Iceberg REST service will throw AlreadyExistsException in test if table name contains 'fail'verifyRegisterTableFail(409, "fail_register_foo1");- }-- private void dropAllExistingNamespace() {- Response response = doListNamespace(Optional.empty());- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());-- ListNamespacesResponse r = response.readEntity(ListNamespacesResponse.class);- r.namespaces().forEach(n -> doDropNamespace(n.toString()));- }-- private void verifyListNamespaceFail(Optional<String> parent, int status) {- Response response = doListNamespace(parent);- Assertions.assertEquals(status, response.getStatus());- }-- private void verifyListNamespaceSucc(Optional<String> parent, List<String> schemas) {- Response response = doListNamespace(parent);- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());-- ListNamespacesResponse r = response.readEntity(ListNamespacesResponse.class);- List<String> ns = r.namespaces().stream().map(n -> n.toString()).collect(Collectors.toList());- Assertions.assertEquals(schemas, ns);+ Assertions.assertTrue(dummyEventListener.popPreEvent() instanceof IcebergRegisterTablePreEvent);+ Assertions.assertTrue(+ dummyEventListener.popPostEvent() instanceof IcebergRegisterTableFailureEvent);}@ParameterizedTest@@ -242,27 +165,19 @@ public class TestIcebergNamespaceOperations extends IcebergTestBase {verifyListNamespaceFail(Optional.of("list_fooxx"), 404);}- private void verifyUpdateNamespaceSucc(String name) {- Response response = doUpdateNamespace(name);- Assertions.assertEquals(Status.OK.getStatusCode(), response.getStatus());-- UpdateNamespacePropertiesResponse r =- response.readEntity(UpdateNamespacePropertiesResponse.class);- Assertions.assertEquals(Arrays.asList("a"), r.removed());- Assertions.assertEquals(Arrays.asList("a1"), r.missing());- Assertions.assertEquals(Arrays.asList("b"), r.updated());- }-- private void verifyUpdateNamespaceFail(int status, String name) {- Response response = doUpdateNamespace(name);- Assertions.assertEquals(status, response.getStatus());- }-@Testvoid testUpdateNamespace() {verifyCreateNamespaceSucc("update_foo1");+ dummyEventListener.clearEvent();verifyUpdateNamespaceSucc("update_foo1");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergUpdateNamespacePreEvent);+ Assertions.assertTrue(dummyEventListener.popPostEvent() instanceof IcebergUpdateNamespaceEvent);verifyUpdateNamespaceFail(404, "update_foo2");+ Assertions.assertTrue(+ dummyEventListener.popPreEvent() instanceof IcebergUpdateNamespacePreEvent);+ Assertions.assertTrue(+ dummyEventListener.popPostEvent() instanceof IcebergUpdateNamespaceFailureEvent);}}diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.javaindex e6a6b393ba..568044441a 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergTableOperations.java@@ -77,7 +77,7 @@ import org.junit.jupiter.api.Test;import org.junit.jupiter.params.ParameterizedTest;import org.junit.jupiter.params.provider.ValueSource;-public class TestIcebergTableOperations extends TestIcebergNamespaceOperations {+public class TestIcebergTableOperations extends IcebergNamespaceTestBase {private static final Schema tableSchema =new Schema(NestedField.of(1, false, "foo_string", StringType.get()));@@ -94,7 +94,7 @@ public class TestIcebergTableOperations extends TestIcebergNamespaceOperations {IcebergRestTestUtil.getIcebergResourceConfig(MockIcebergTableOperations.class, true, Arrays.asList(dummyEventListener));// create namespace before each table test- resourceConfig.register(IcebergNamespaceOperations.class);+ resourceConfig.register(MockIcebergNamespaceOperations.class);resourceConfig.register(MockIcebergTableRenameOperations.class);return resourceConfig;diff --git a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergViewOperations.java b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergViewOperations.javaindex df896b1529..0de6db8022 100644--- a/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergViewOperations.java+++ b/iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergViewOperations.java@@ -69,7 +69,7 @@ import org.junit.jupiter.api.Test;import org.junit.jupiter.params.ParameterizedTest;import org.junit.jupiter.params.provider.ValueSource;-public class TestIcebergViewOperations extends TestIcebergNamespaceOperations {+public class TestIcebergViewOperations extends IcebergNamespaceTestBase {private static final Schema viewSchema =new Schema(Types.NestedField.of(1, false, "foo_string", Types.StringType.get()));@@ -87,7 +87,7 @@ public class TestIcebergViewOperations extends TestIcebergNamespaceOperations {IcebergRestTestUtil.getIcebergResourceConfig(MockIcebergViewOperations.class, true, Arrays.asList(dummyEventListener));// create namespace before each view test- resourceConfig.register(IcebergNamespaceOperations.class);+ resourceConfig.register(MockIcebergNamespaceOperations.class);resourceConfig.register(MockIcebergViewRenameOperations.class);return resourceConfig;