World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#6078] feat(core): Support model event to Gravitino server (#6688)
Lord of Abyss9cba55beb21f
diff --git a/core/src/main/java/org/apache/gravitino/listener/ModelEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/ModelEventDispatcher.javaindex b98d12f457..243657df1c 100644--- a/core/src/main/java/org/apache/gravitino/listener/ModelEventDispatcher.java+++ b/core/src/main/java/org/apache/gravitino/listener/ModelEventDispatcher.java@@ -28,22 +28,31 @@ import org.apache.gravitino.exceptions.ModelVersionAliasesAlreadyExistException;import org.apache.gravitino.exceptions.NoSuchModelException;import org.apache.gravitino.exceptions.NoSuchModelVersionException;import org.apache.gravitino.exceptions.NoSuchSchemaException;+import org.apache.gravitino.listener.api.event.DeleteModelEvent;import org.apache.gravitino.listener.api.event.DeleteModelFailureEvent;import org.apache.gravitino.listener.api.event.DeleteModelPreEvent;+import org.apache.gravitino.listener.api.event.DeleteModelVersionEvent;import org.apache.gravitino.listener.api.event.DeleteModelVersionFailureEvent;import org.apache.gravitino.listener.api.event.DeleteModelVersionPreEvent;+import org.apache.gravitino.listener.api.event.GetModelEvent;import org.apache.gravitino.listener.api.event.GetModelFailureEvent;import org.apache.gravitino.listener.api.event.GetModelPreEvent;+import org.apache.gravitino.listener.api.event.GetModelVersionEvent;import org.apache.gravitino.listener.api.event.GetModelVersionFailureEvent;import org.apache.gravitino.listener.api.event.GetModelVersionPreEvent;+import org.apache.gravitino.listener.api.event.LinkModelVersionEvent;import org.apache.gravitino.listener.api.event.LinkModelVersionFailureEvent;import org.apache.gravitino.listener.api.event.LinkModelVersionPreEvent;+import org.apache.gravitino.listener.api.event.ListModelEvent;import org.apache.gravitino.listener.api.event.ListModelFailureEvent;import org.apache.gravitino.listener.api.event.ListModelPreEvent;import org.apache.gravitino.listener.api.event.ListModelVersionFailureEvent;import org.apache.gravitino.listener.api.event.ListModelVersionPreEvent;+import org.apache.gravitino.listener.api.event.ListModelVersionsEvent;+import org.apache.gravitino.listener.api.event.RegisterAndLinkModelEvent;import org.apache.gravitino.listener.api.event.RegisterAndLinkModelFailureEvent;import org.apache.gravitino.listener.api.event.RegisterAndLinkModelPreEvent;+import org.apache.gravitino.listener.api.event.RegisterModelEvent;import org.apache.gravitino.listener.api.event.RegisterModelFailureEvent;import org.apache.gravitino.listener.api.event.RegisterModelPreEvent;import org.apache.gravitino.listener.api.info.ModelInfo;@@ -81,10 +90,12 @@ public class ModelEventDispatcher implements ModelDispatcher {throws NoSuchSchemaException, ModelAlreadyExistsException {String user = PrincipalUtils.getCurrentUserName();ModelInfo registerRequest = new ModelInfo(ident.name(), properties, comment);+eventBus.dispatchEvent(new RegisterModelPreEvent(user, ident, registerRequest));try {Model model = dispatcher.registerModel(ident, comment, properties);- // TODO: ModelEvent+ ModelInfo registeredModel = new ModelInfo(model);+ eventBus.dispatchEvent(new RegisterModelEvent(user, ident, registeredModel));return model;} catch (Exception e) {eventBus.dispatchEvent(new RegisterModelFailureEvent(user, ident, e, registerRequest));@@ -106,14 +117,16 @@ public class ModelEventDispatcher implements ModelDispatcher {ModelVersionInfo linkModelVersionRequest =new ModelVersionInfo(uri, comment, properties, aliases);String user = PrincipalUtils.getCurrentUserName();-RegisterAndLinkModelPreEvent registerAndLinkModelPreEvent =new RegisterAndLinkModelPreEvent(user, ident, registerModelRequest, linkModelVersionRequest);+eventBus.dispatchEvent(registerAndLinkModelPreEvent);try {- // TODO: ModelEvent- return dispatcher.registerModel(ident, uri, aliases, comment, properties);+ Model registeredModel = dispatcher.registerModel(ident, uri, aliases, comment, properties);+ ModelInfo registeredModelInfo = new ModelInfo(registeredModel);+ eventBus.dispatchEvent(new RegisterAndLinkModelEvent(user, ident, registeredModelInfo, uri));+ return registeredModel;} catch (Exception e) {eventBus.dispatchEvent(new RegisterAndLinkModelFailureEvent(@@ -126,10 +139,12 @@ public class ModelEventDispatcher implements ModelDispatcher {@Overridepublic Model getModel(NameIdentifier ident) throws NoSuchModelException {String user = PrincipalUtils.getCurrentUserName();+eventBus.dispatchEvent(new GetModelPreEvent(user, ident));try {Model model = dispatcher.getModel(ident);- // TODO: ModelEvent+ ModelInfo modelInfo = new ModelInfo(model);+ eventBus.dispatchEvent(new GetModelEvent(user, ident, modelInfo));return model;} catch (Exception e) {eventBus.dispatchEvent(new GetModelFailureEvent(user, ident, e));@@ -141,10 +156,12 @@ public class ModelEventDispatcher implements ModelDispatcher {@Overridepublic boolean deleteModel(NameIdentifier ident) {String user = PrincipalUtils.getCurrentUserName();+eventBus.dispatchEvent(new DeleteModelPreEvent(user, ident));try {- // TODO: ModelEvent- return dispatcher.deleteModel(ident);+ boolean isExists = dispatcher.deleteModel(ident);+ eventBus.dispatchEvent(new DeleteModelEvent(user, ident, isExists));+ return isExists;} catch (Exception e) {eventBus.dispatchEvent(new DeleteModelFailureEvent(user, ident, e));throw e;@@ -155,10 +172,11 @@ public class ModelEventDispatcher implements ModelDispatcher {@Overridepublic NameIdentifier[] listModels(Namespace namespace) throws NoSuchSchemaException {String user = PrincipalUtils.getCurrentUserName();+eventBus.dispatchEvent(new ListModelPreEvent(user, namespace));try {NameIdentifier[] models = dispatcher.listModels(namespace);- // TODO: ModelEvent+ eventBus.dispatchEvent(new ListModelEvent(user, namespace));return models;} catch (Exception e) {eventBus.dispatchEvent(new ListModelFailureEvent(user, namespace, e));@@ -181,7 +199,7 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new LinkModelVersionPreEvent(user, ident, linkModelRequest));try {dispatcher.linkModelVersion(ident, uri, aliases, comment, properties);- // TODO: ModelEvent+ eventBus.dispatchEvent(new LinkModelVersionEvent(user, ident, linkModelRequest));} catch (Exception e) {eventBus.dispatchEvent(new LinkModelVersionFailureEvent(user, ident, e, linkModelRequest));throw e;@@ -196,8 +214,11 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new GetModelVersionPreEvent(user, ident, null, version));try {- // TODO: ModelEvent- return dispatcher.getModelVersion(ident, version);+ ModelVersion modelVersion = dispatcher.getModelVersion(ident, version);+ ModelVersionInfo modelVersionInfo = new ModelVersionInfo(modelVersion);+ eventBus.dispatchEvent(+ new GetModelVersionEvent(user, ident, modelVersionInfo, null, version));+ return modelVersion;} catch (Exception e) {eventBus.dispatchEvent(new GetModelVersionFailureEvent(user, ident, e, null, version));throw e;@@ -213,7 +234,8 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new GetModelVersionPreEvent(user, ident, alias, null));try {ModelVersion modelVersion = dispatcher.getModelVersion(ident, alias);- // TODO: ModelEvent+ ModelVersionInfo modelVersionInfo = new ModelVersionInfo(modelVersion);+ eventBus.dispatchEvent(new GetModelVersionEvent(user, ident, modelVersionInfo, alias, null));return modelVersion;} catch (Exception e) {eventBus.dispatchEvent(new GetModelVersionFailureEvent(user, ident, e, alias, null));@@ -229,7 +251,7 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new DeleteModelVersionPreEvent(user, ident, null, version));try {boolean isExists = dispatcher.deleteModelVersion(ident, version);- // TODO: ModelEvent+ eventBus.dispatchEvent(new DeleteModelVersionEvent(user, ident, isExists, null, version));return isExists;} catch (Exception e) {eventBus.dispatchEvent(new DeleteModelVersionFailureEvent(user, ident, e, null, version));@@ -245,7 +267,7 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new DeleteModelVersionPreEvent(user, ident, alias, null));try {boolean isExists = dispatcher.deleteModelVersion(ident, alias);- // TODO: ModelEvent+ eventBus.dispatchEvent(new DeleteModelVersionEvent(user, ident, isExists, alias, null));return isExists;} catch (Exception e) {eventBus.dispatchEvent(new DeleteModelVersionFailureEvent(user, ident, e, alias, null));@@ -261,7 +283,7 @@ public class ModelEventDispatcher implements ModelDispatcher {eventBus.dispatchEvent(new ListModelVersionPreEvent(user, ident));try {int[] versions = dispatcher.listModelVersions(ident);- // TODO: ModelEvent+ eventBus.dispatchEvent(new ListModelVersionsEvent(user, ident, versions));return versions;} catch (Exception e) {eventBus.dispatchEvent(new ListModelVersionFailureEvent(user, ident, e));diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelEvent.javanew file mode 100644index 0000000000..e51b27f699--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelEvent.java@@ -0,0 +1,63 @@+/*+ * 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 event that is generated after a model is successfully deleted. */+@DeveloperApi+public class DeleteModelEvent extends ModelEvent {+ private final boolean isExists;++ /**+ * Constructs a new instance of {@code DeleteModelEvent}, capturing essential details about the+ * successful drop of a model.+ *+ * @param user The username of the individual who initiated the model drop operation.+ * @param identifier The unique identifier of the model that was dropped.+ * @param isExists A boolean flag indicating whether the model existed at the time of the drop+ * operation.+ */+ public DeleteModelEvent(String user, NameIdentifier identifier, boolean isExists) {+ super(user, identifier);+ this.isExists = isExists;+ }++ /**+ * Retrieves the existence status of the model at the time of the drop operation.+ *+ * @return A boolean value indicating whether the model existed. {@code true} if the model+ * existed, otherwise {@code false}.+ */+ public boolean isExists() {+ return isExists;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.DELETE_MODEL;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionEvent.javanew file mode 100644index 0000000000..b2ff6a2f28--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionEvent.java@@ -0,0 +1,98 @@+/*+ * 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 java.util.Optional;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;++/**+ * Represents an event that is generated after a model version is successfully deleted from the+ * model.+ */+@DeveloperApi+public class DeleteModelVersionEvent extends ModelEvent {++ private final boolean isExists;+ private final Optional<String> alias;+ private final Optional<Integer> version;++ /**+ * Constructs a new {@code DeleteModelVersionEvent} instance, encapsulating information about the+ * outcome of a model version drop operation.+ *+ * @param user The user who initiated the drop model version operation.+ * @param identifier The identifier of the model that was attempted to be dropped a version.+ * @param isExists A boolean flag indicating whether the model version existed at the time of the+ * drop operation.+ * @param alias The alias of the model version to be deleted. If the alias is not provided, the+ * value will be an empty {@link Optional}.+ * @param version The version of the model version to be deleted. If the version is not provided,+ * the value will be an empty {@link Optional}.+ */+ public DeleteModelVersionEvent(+ String user, NameIdentifier identifier, boolean isExists, String alias, Integer version) {+ super(user, identifier);++ this.isExists = isExists;+ this.alias = Optional.ofNullable(alias);+ this.version = Optional.ofNullable(version);+ }++ /**+ * Returns the alias of the model version to be deleted.+ *+ * @return A {@link Optional} instance containing the alias if it was provided, or an empty {@link+ * Optional} otherwise.+ */+ public Optional<String> alias() {+ return alias;+ }++ /**+ * Returns the version of the model version to be deleted.+ *+ * @return A {@link Optional} instance containing the version if it was provided, or an empty+ * {@link Optional} otherwise.+ */+ public Optional<Integer> version() {+ return version;+ }++ /**+ * Retrieves the existence status of the model version at the time of the drop operation.+ *+ * @return A boolean value indicating whether the model version existed. {@code true} if the model+ * version existed, otherwise {@code false}.+ */+ public boolean isExists() {+ return isExists;+ }++ /**+ * Returns the type of operation.+ *+ * @return the operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.DELETE_MODEL_VERSION;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionPreEvent.javaindex 0b70db145d..d0ff037662 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionPreEvent.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteModelVersionPreEvent.java@@ -29,16 +29,6 @@ public class DeleteModelVersionPreEvent extends ModelPreEvent {private final Optional<String> alias;private final Optional<Integer> version;- /**- * Create a new {@link DeleteModelVersionPreEvent} instance.- *- * @param user The username of the individual who initiated the model version linking.- * @param identifier The unique identifier of the model that was linked.- */- public DeleteModelVersionPreEvent(String user, NameIdentifier identifier) {- this(user, identifier, null, null);- }-/*** Create a new {@link DeleteModelVersionPreEvent} instance. only one of alias or version are* valid.diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelEvent.javanew file mode 100644index 0000000000..8a9bb79afd--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelEvent.java@@ -0,0 +1,62 @@+/*+ * 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.listener.api.info.ModelInfo;++/** Represents an event that is generated after a model has been successfully retrieved. */+@DeveloperApi+public class GetModelEvent extends ModelEvent {+ private final ModelInfo modelInfo;++ /**+ * Constructs an instance of {@code GetModelEvent}, capturing essential details about the+ * successful getting of a model.+ *+ * @param user The username of the individual who initiated the model get.+ * @param identifier The unique identifier of the model that was get.+ * @param modelInfo The state of the model post-get.+ */+ public GetModelEvent(String user, NameIdentifier identifier, ModelInfo modelInfo) {+ super(user, identifier);+ this.modelInfo = modelInfo;+ }++ /**+ * Retrieves the state of the model as it was made available to the user after successful getting.+ *+ * @return A {@link ModelInfo} instance encapsulating the details of the model as get.+ */+ public ModelInfo modelInfo() {+ return modelInfo;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.GET_MODEL;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelVersionEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelVersionEvent.javanew file mode 100644index 0000000000..a69b39bbd5--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetModelVersionEvent.java@@ -0,0 +1,99 @@+/*+ * 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 java.util.Optional;+import org.apache.gravitino.NameIdentifier;+import org.apache.gravitino.annotation.DeveloperApi;+import org.apache.gravitino.listener.api.info.ModelInfo;+import org.apache.gravitino.listener.api.info.ModelVersionInfo;++/** Represents an event that is generated after a model version is successfully retrieved. */+@DeveloperApi+public class GetModelVersionEvent extends ModelEvent {+ private final ModelVersionInfo modelVersionInfo;+ private final Optional<String> alias;+ private final Optional<Integer> version;++ /**+ * Constructs an instance of {@code GetModelVersionEvent}, containing the details of the event.+ * only one of alias or version are valid.+ *+ * @param user The username of the individual who initiated the get model version event.+ * @param identifier The unique identifier of the model that was getting the version.+ * @param modelVersionInfo The state of the model after the version was loaded.+ * @param alias The alias of the model version to be deleted. If the alias is not provided, the+ * value will be an empty {@link Optional}.+ * @param version The version of the model version to be deleted. If the version is not provided,+ * the value will be an empty {@link Optional}.+ */+ public GetModelVersionEvent(+ String user,+ NameIdentifier identifier,+ ModelVersionInfo modelVersionInfo,+ String alias,+ Integer version) {+ super(user, identifier);++ this.modelVersionInfo = modelVersionInfo;+ this.alias = Optional.ofNullable(alias);+ this.version = Optional.ofNullable(version);+ }++ /**+ * Returns the alias of the model version to be deleted.+ *+ * @return A {@link Optional} instance containing the alias if it was provided, or an empty {@link+ * Optional} otherwise.+ */+ public Optional<String> alias() {+ return alias;+ }++ /**+ * Returns the version of the model version to be deleted.+ *+ * @return A {@link Optional} instance containing the version if it was provided, or an empty+ * {@link Optional} otherwise.+ */+ public Optional<Integer> version() {+ return version;+ }++ /**+ * Retrieves the state of the model as it was made available to the user after successful getting+ * the version.+ *+ * @return A {@link ModelInfo} instance encapsulating the details of the model version.+ */+ public ModelVersionInfo modelVersionInfo() {+ return modelVersionInfo;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.GET_MODEL_VERSION;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/LinkModelVersionEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/LinkModelVersionEvent.javanew file mode 100644index 0000000000..b6a1ec4819--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/LinkModelVersionEvent.java@@ -0,0 +1,64 @@+/*+ * 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.listener.api.info.ModelInfo;+import org.apache.gravitino.listener.api.info.ModelVersionInfo;++/** Represents an event that is generated after a model version is successfully linked. */+public class LinkModelVersionEvent extends ModelEvent {+ private ModelVersionInfo modelVersionInfo;++ /**+ * Constructs an instance of {@code LinkModelVersionEvent}, capturing essential details about the+ * successful linking of a model version.+ *+ * @param user The username of the individual who initiated the model version linking.+ * @param identifier The unique identifier of the model that was linked.+ * @param modelVersionInfo The final state of the model version after linking.+ */+ public LinkModelVersionEvent(+ String user, NameIdentifier identifier, ModelVersionInfo modelVersionInfo) {+ super(user, identifier);+ this.modelVersionInfo = modelVersionInfo;+ }++ /**+ * Retrieves the final state of the model, as it was returned to the user after successful link a+ * model version.+ *+ * @return A {@link ModelInfo} instance encapsulating the comprehensive details of the newly model+ * version.+ */+ public ModelVersionInfo linkedModelVersionInfo() {+ return modelVersionInfo;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.LINK_MODEL_VERSION;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelEvent.javanew file mode 100644index 0000000000..1a43fd892c--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelEvent.java@@ -0,0 +1,60 @@+/*+ * 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.Namespace;+import org.apache.gravitino.annotation.DeveloperApi;++/** Represents an event that is generated after a model listing operation. */+@DeveloperApi+public class ListModelEvent extends ModelEvent {+ private final Namespace namespace;++ /**+ * Constructs an instance of {@code ListModelEvent}, with the specified user and namespace.+ *+ * @param user The username of the individual who initiated the model listing.+ * @param namespace The namespace from which models were listed.+ */+ public ListModelEvent(String user, Namespace namespace) {+ super(user, NameIdentifier.of(namespace.levels()));+ this.namespace = namespace;+ }++ /**+ * Provides the namespace associated with this event.+ *+ * @return A {@link Namespace} instance from which models were listed.+ */+ public Namespace namespace() {+ return namespace;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.LIST_MODEL;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelVersionsEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelVersionsEvent.javanew file mode 100644index 0000000000..04974964ac--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListModelVersionsEvent.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;++/** Represents an event that is generated after a model version listing operation. */+public class ListModelVersionsEvent extends ModelEvent {+ private final int[] versions;++ /**+ * Constructs an instance of {@code ListModelVersionsEvent}, with the specified user and model+ * identifier.+ *+ * @param user The username of the individual who initiated the model version listing.+ * @param identifier The unique identifier of the model that it's version was listed.+ */+ public ListModelVersionsEvent(String user, NameIdentifier identifier, int[] versions) {+ super(user, identifier);++ this.versions = versions;+ }++ /**+ * Returns the versions of the model in this list operation.+ *+ * @return The versions of the model.+ */+ public int[] versions() {+ return versions;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.LIST_MODEL_VERSIONS;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ModelEvent.javanew file mode 100644index 0000000000..3d46e011d1--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ModelEvent.java@@ -0,0 +1,52 @@+/*+ * 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 base class for events related to Model operations. This class extends+ * {@link Event} to provide a more specific context involving operations on Models, such as link,+ * register, or modification. It captures essential information including the user performing the+ * operation and the identifier of the model being operated on.+ *+ * <p>Concrete implementations of this class should provide additional details pertinent to the+ * specific type of model operation being represented.+ */+@DeveloperApi+public abstract class ModelEvent extends Event {++ /**+ * Constructs a new {@link ModelEvent} with the specified user and model identifier.+ *+ * @param user The user responsible for triggering the model operation.+ * @param identifier The identifier of the Model involved in the operation. This encapsulates+ * details such as the metalake, catalog, schema, and Model name.+ */+ protected ModelEvent(String user, NameIdentifier identifier) {+ super(user, identifier);+ }++ @Override+ public OperationStatus operationStatus() {+ return OperationStatus.SUCCESS;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterAndLinkModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterAndLinkModelEvent.javanew file mode 100644index 0000000000..f3c5e1c1fd--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterAndLinkModelEvent.java@@ -0,0 +1,78 @@+/*+ * 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.listener.api.info.ModelInfo;++/**+ * Represents an event that is generated after a model is successfully registered and a model+ * version is linked.+ */+public class RegisterAndLinkModelEvent extends ModelEvent {+ private final ModelInfo registeredModelInfo;+ private final String uri;++ /**+ * Constructs a new instance of {@link RegisterAndLinkModelEvent}, capturing the user, identifier,+ * registered model information, and linked model version information.+ *+ * @param user The user responsible for triggering the model operation.+ * @param identifier The identifier of the Model involved in the operation. This encapsulates some+ * information.+ * @param registeredModelInfo The final state of the model post-creation.+ * @param uri The uri of the linked model version.+ */+ public RegisterAndLinkModelEvent(+ String user, NameIdentifier identifier, ModelInfo registeredModelInfo, String uri) {+ super(user, identifier);++ this.registeredModelInfo = registeredModelInfo;+ this.uri = uri;+ }++ /**+ * Retrieves the registered model information.+ *+ * @return The model information.+ */+ public ModelInfo registeredModelInfo() {+ return registeredModelInfo;+ }++ /**+ * Retrieves the uri of the linked model version.+ *+ * @return+ */+ public String uri() {+ return uri;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.REGISTER_AND_LINK_MODEL_VERSION;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterModelEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterModelEvent.javanew file mode 100644index 0000000000..fa8029bc35--- /dev/null+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/RegisterModelEvent.java@@ -0,0 +1,64 @@+/*+ * 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.listener.api.info.ModelInfo;++/** Represents an event that is generated after a model is successfully registered. */+@DeveloperApi+public class RegisterModelEvent extends ModelEvent {+ private final ModelInfo registeredModelInfo;++ /**+ * Constructs an instance of {@link RegisterModelEvent}, capturing essential details about the+ * successful registration of a model.+ *+ * @param user The user responsible for triggering the model operation.+ * @param identifier The identifier of the Model involved in the operation. This encapsulates+ * details such as the metalake, catalog, schema, and Model name.+ * @param registeredModelInfo The final state of the model post-creation.+ */+ public RegisterModelEvent(String user, NameIdentifier identifier, ModelInfo registeredModelInfo) {+ super(user, identifier);+ this.registeredModelInfo = registeredModelInfo;+ }++ /**+ * Retrieves the final state of the model as it was returned to the user after successful+ * registration.+ *+ * @return The model information.+ */+ public ModelInfo registeredModelInfo() {+ return registeredModelInfo;+ }++ /**+ * Returns the type of operation.+ *+ * @return The operation type.+ */+ @Override+ public OperationType operationType() {+ return OperationType.REGISTER_MODEL;+ }+}diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/ModelVersionInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/ModelVersionInfo.javaindex 5eea942d1f..6f4c956433 100644--- a/core/src/main/java/org/apache/gravitino/listener/api/info/ModelVersionInfo.java+++ b/core/src/main/java/org/apache/gravitino/listener/api/info/ModelVersionInfo.java@@ -35,7 +35,7 @@ public class ModelVersionInfo {private final Optional<String[]> aliases;private final Optional<String> comment;- private final Optional<Audit> auditInfo;+ private final Optional<Audit> audit;/*** Constructs a {@link ModelVersionInfo} instance based on a given {@link ModelVersion}.@@ -85,7 +85,7 @@ public class ModelVersionInfo {this.properties = properties == null ? ImmutableMap.of() : ImmutableMap.copyOf(properties);this.comment = Optional.ofNullable(comment);- this.auditInfo = Optional.ofNullable(auditInfo);+ this.audit = Optional.ofNullable(auditInfo);this.aliases = Optional.ofNullable(aliases);}@@ -132,6 +132,6 @@ public class ModelVersionInfo {* @return the audit information of the model version or null if not set.*/public Optional<Audit> audit() {- return auditInfo;+ return audit;}}diff --git a/core/src/test/java/org/apache/gravitino/listener/api/event/TestModelEvent.java b/core/src/test/java/org/apache/gravitino/listener/api/event/TestModelEvent.javaindex 3ffa7c38b9..a23b82e31c 100644--- a/core/src/test/java/org/apache/gravitino/listener/api/event/TestModelEvent.java+++ b/core/src/test/java/org/apache/gravitino/listener/api/event/TestModelEvent.java@@ -78,7 +78,7 @@ public class TestModelEvent {this.dummyEventListener = new DummyEventListener();EventBus eventBus = new EventBus(Collections.singletonList(dummyEventListener));- this.dispatcher = new ModelEventDispatcher(eventBus, mockTagDispatcher());+ this.dispatcher = new ModelEventDispatcher(eventBus, mockModelDispatcher());this.failureDispatcher = new ModelEventDispatcher(eventBus, mockExceptionModelDispatcher());}@@ -148,6 +148,19 @@ public class TestModelEvent {ModelInfo modelInfoPreEvent = registerModelPreEvent.registerModelRequest();checkModelInfo(modelInfoPreEvent, modelA);++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(RegisterModelEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.REGISTER_MODEL, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ // validate post-event model info+ RegisterModelEvent registerModelEvent = (RegisterModelEvent) postEvent;+ Assertions.assertEquals(existingIdentA, registerModelEvent.identifier());+ ModelInfo modelInfo = registerModelEvent.registeredModelInfo();++ checkModelInfo(modelInfo, modelA);}@Test@@ -204,6 +217,23 @@ public class TestModelEvent {checkArray(firstModelVersion.aliases(), linkModelVersionRequest.aliases().orElse(null));checkProperties(firstModelVersion.properties(), linkModelVersionRequest.properties());checkAudit(firstModelVersion.auditInfo(), linkModelVersionRequest.audit());++ // valiate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(RegisterAndLinkModelEvent.class, postEvent.getClass());+ Assertions.assertEquals(+ OperationType.REGISTER_AND_LINK_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ // validate post-event model info+ RegisterAndLinkModelEvent registerAndLinkModelEvent = (RegisterAndLinkModelEvent) postEvent;+ ModelInfo modelInfo = registerAndLinkModelEvent.registeredModelInfo();++ checkModelInfo(modelInfo, modelA);++ // validate post-event model uri info+ String versionUri = registerAndLinkModelEvent.uri();+ Assertions.assertEquals(firstModelVersion.uri(), versionUri);}@Test@@ -255,6 +285,18 @@ public class TestModelEvent {GetModelPreEvent getModelPreEvent = (GetModelPreEvent) preEvent;Assertions.assertEquals(existingIdentA, getModelPreEvent.identifier());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(GetModelEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.GET_MODEL, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ GetModelEvent getModelEvent = (GetModelEvent) postEvent;+ Assertions.assertEquals(existingIdentA, getModelEvent.identifier());+ ModelInfo modelInfo = getModelEvent.modelInfo();++ checkModelInfo(modelInfo, modelA);}@Test@@ -286,6 +328,16 @@ public class TestModelEvent {DeleteModelPreEvent deleteModelPreEvent = (DeleteModelPreEvent) preEvent;Assertions.assertEquals(existingIdentA, deleteModelPreEvent.identifier());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(DeleteModelEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.DELETE_MODEL, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ DeleteModelEvent deleteModelEvent = (DeleteModelEvent) postEvent;+ Assertions.assertEquals(existingIdentA, deleteModelEvent.identifier());+ Assertions.assertTrue(deleteModelEvent.isExists());}@Test@@ -317,6 +369,15 @@ public class TestModelEvent {ListModelPreEvent listModelPreEvent = (ListModelPreEvent) preEvent;Assertions.assertEquals(namespace, listModelPreEvent.namespace());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(ListModelEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.LIST_MODEL, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ ListModelEvent listModelEvent = (ListModelEvent) postEvent;+ checkArray(namespace.levels(), listModelEvent.namespace().levels());}@Test@@ -356,6 +417,18 @@ public class TestModelEvent {ModelVersionInfo modelVersionInfo = linkModelVersionPreEvent.linkModelVersionRequest();checkModelVersionInfo(modelVersionInfo, firstModelVersion);++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(LinkModelVersionEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.LINK_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ LinkModelVersionEvent linkModelVersionEvent = (LinkModelVersionEvent) postEvent;+ Assertions.assertEquals(existingIdentA, linkModelVersionEvent.identifier());+ ModelVersionInfo postEventModelVersionInfo = linkModelVersionEvent.linkedModelVersionInfo();++ checkModelVersionInfo(postEventModelVersionInfo, firstModelVersion);}@Test@@ -403,6 +476,23 @@ public class TestModelEvent {Assertions.assertTrue(getModelVersionPreEvent.version().isPresent());Assertions.assertEquals(1, getModelVersionPreEvent.version().get());Assertions.assertFalse(getModelVersionPreEvent.alias().isPresent());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(GetModelVersionEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.GET_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ GetModelVersionEvent getModelVersionEvent = (GetModelVersionEvent) postEvent;+ Assertions.assertEquals(existingIdentA, getModelVersionEvent.identifier());+ ModelVersionInfo modelVersionInfo = getModelVersionEvent.modelVersionInfo();++ // validate post-event fields+ Assertions.assertTrue(getModelVersionEvent.version().isPresent());+ Assertions.assertEquals(1, getModelVersionEvent.version().get());+ Assertions.assertFalse(getModelVersionEvent.alias().isPresent());++ checkModelVersionInfo(modelVersionInfo, firstModelVersion);}@Test@@ -442,6 +532,21 @@ public class TestModelEvent {Assertions.assertTrue(getModelVersionPreEvent.alias().isPresent());Assertions.assertEquals("aliasTest", getModelVersionPreEvent.alias().get());Assertions.assertFalse(getModelVersionPreEvent.version().isPresent());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(GetModelVersionEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.GET_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ // validate post-event fields+ GetModelVersionEvent getModelVersionEvent = (GetModelVersionEvent) postEvent;+ ModelVersionInfo modelVersionInfo = getModelVersionEvent.modelVersionInfo();+ Assertions.assertTrue(getModelVersionEvent.alias().isPresent());+ Assertions.assertEquals("aliasTest", getModelVersionEvent.alias().get());+ Assertions.assertFalse(getModelVersionEvent.version().isPresent());++ checkModelVersionInfo(modelVersionInfo, secondModelVersion);}@Test@@ -480,6 +585,18 @@ public class TestModelEvent {Assertions.assertTrue(deleteModelVersionPreEvent.version().isPresent());Assertions.assertEquals(1, deleteModelVersionPreEvent.version().get());Assertions.assertFalse(deleteModelVersionPreEvent.alias().isPresent());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(DeleteModelVersionEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.DELETE_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ DeleteModelVersionEvent deleteModelVersionEvent = (DeleteModelVersionEvent) postEvent;+ Assertions.assertTrue(deleteModelVersionEvent.version().isPresent());+ Assertions.assertEquals(1, deleteModelVersionEvent.version().get());+ Assertions.assertFalse(deleteModelVersionEvent.alias().isPresent());+ Assertions.assertTrue(deleteModelVersionEvent.isExists());}@Test@@ -519,6 +636,18 @@ public class TestModelEvent {Assertions.assertTrue(deleteModelVersionPreEvent.alias().isPresent());Assertions.assertEquals("aliasTest", deleteModelVersionPreEvent.alias().get());Assertions.assertFalse(deleteModelVersionPreEvent.version().isPresent());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(DeleteModelVersionEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.DELETE_MODEL_VERSION, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ DeleteModelVersionEvent deleteModelVersionEvent = (DeleteModelVersionEvent) postEvent;+ Assertions.assertTrue(deleteModelVersionEvent.alias().isPresent());+ Assertions.assertEquals("aliasTest", deleteModelVersionEvent.alias().get());+ Assertions.assertFalse(deleteModelVersionEvent.version().isPresent());+ Assertions.assertTrue(deleteModelVersionEvent.isExists());}@Test@@ -555,6 +684,17 @@ public class TestModelEvent {ListModelVersionPreEvent listModelVersionsPreEvent = (ListModelVersionPreEvent) preEvent;Assertions.assertEquals(existingIdentA, listModelVersionsPreEvent.identifier());++ // validate post-event+ Event postEvent = dummyEventListener.popPostEvent();+ Assertions.assertEquals(ListModelVersionsEvent.class, postEvent.getClass());+ Assertions.assertEquals(OperationType.LIST_MODEL_VERSIONS, postEvent.operationType());+ Assertions.assertEquals(OperationStatus.SUCCESS, postEvent.operationStatus());++ ListModelVersionsEvent listModelVersionsEvent = (ListModelVersionsEvent) postEvent;+ Assertions.assertEquals(existingIdentA, listModelVersionsEvent.identifier());+ Assertions.assertEquals(2, listModelVersionsEvent.versions().length);+ Assertions.assertArrayEquals(new int[] {1, 2}, listModelVersionsEvent.versions());}@Test@@ -584,13 +724,20 @@ public class TestModelEvent {});}- private ModelDispatcher mockTagDispatcher() {+ private ModelDispatcher mockModelDispatcher() {ModelDispatcher dispatcher = mock(ModelDispatcher.class);when(dispatcher.registerModel(existingIdentA, "commentA", ImmutableMap.of("color", "#FFFFFF"))).thenReturn(modelA);when(dispatcher.registerModel(existingIdentB, "commentB", ImmutableMap.of("color", "#FFFFFF"))).thenReturn(modelB);+ when(dispatcher.registerModel(+ existingIdentA,+ "uriA",+ new String[] {"aliasProduction"},+ "commentA",+ ImmutableMap.of("color", "#FFFFFF")))+ .thenReturn(modelA);when(dispatcher.getModel(existingIdentA)).thenReturn(modelA);when(dispatcher.getModel(existingIdentB)).thenReturn(modelB);diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.mdindex f9f5d2105f..08c9beaec4 100644--- a/docs/gravitino-server-config.md+++ b/docs/gravitino-server-config.md@@ -118,17 +118,17 @@ Gravitino triggers a pre-event before the operation, a post-event after the comp##### Post-event-| Operation type | Post-event | Since Version |-|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|-| table operation | `CreateTableEvent`, `AlterTableEvent`, `DropTableEvent`, `LoadTableEvent`, `ListTableEvent`, `PurgeTableFailureEvent`, `CreateTableFailureEvent`, `AlterTableFailureEvent`, `DropTableFailureEvent`, `LoadTableFailureEvent`, `ListTableFailureEvent`, `PurgeTableFailureEvent` | 0.5.0 |-| fileset operation | `CreateFileSetEvent`, `AlterFileSetEvent`, `DropFileSetEvent`, `LoadFileSetEvent`, `ListFileSetEvent`, `CreateFileSetFailureEvent`, `AlterFileSetFailureEvent`, `DropFileSetFailureEvent`, `LoadFileSetFailureEvent`, `ListFileSetFailureEvent` | 0.5.0 |-| topic operation | `CreateTopicEvent`, `AlterTopicEvent`, `DropTopicEvent`, `LoadTopicEvent`, `ListTopicEvent`, `CreateTopicFailureEvent`, `AlterTopicFailureEvent`, `DropTopicFailureEvent`, `LoadTopicFailureEvent`, `ListTopicFailureEvent` | 0.5.0 |-| schema operation | `CreateSchemaEvent`, `AlterSchemaEvent`, `DropSchemaEvent`, `LoadSchemaEvent`, `ListSchemaEvent`, `CreateSchemaFailureEvent`, `AlterSchemaFailureEvent`, `DropSchemaFailureEvent`, `LoadSchemaFailureEvent`, `ListSchemaFailureEvent` | 0.5.0 |-| catalog operation | `CreateCatalogEvent`, `AlterCatalogEvent`, `DropCatalogEvent`, `LoadCatalogEvent`, `ListCatalogEvent`, `CreateCatalogFailureEvent`, `AlterCatalogFailureEvent`, `DropCatalogFailureEvent`, `LoadCatalogFailureEvent`, `ListCatalogFailureEvent` | 0.5.0 |-| metalake operation | `CreateMetalakeEvent`, `AlterMetalakeEvent`, `DropMetalakeEvent`, `LoadMetalakeEvent`, `ListMetalakeEvent`, `CreateMetalakeFailureEvent`, `AlterMetalakeFailureEvent`, `DropMetalakeFailureEvent`, `LoadMetalakeFailureEvent`, `ListMetalakeFailureEvent` | 0.5.0 |-| Iceberg REST server table operation | `IcebergCreateTableEvent`, `IcebergUpdateTableEvent`, `IcebergDropTableEvent`, `IcebergLoadTableEvent`, `IcebergListTableEvent`, `IcebergTableExistsEvent`, `IcebergRenameTableEvent`, `IcebergCreateTableFailureEvent`, `IcebergUpdateTableFailureEvent`, `IcebergDropTableFailureEvent`, `IcebergLoadTableFailureEvent`, `IcebergListTableFailureEvent`, `IcebergRenameTableFailureEvent`, `IcebergTableExistsFailureEvent` | 0.7.0-incubating |-| tag operation | `ListTagsEvent`, `ListTagsInfoEvent`, `CreateTagEvent`, `GetTagEvent`, `AlterTagEvent`, `DeleteTagEvent`, `ListMetadataObjectsForTagEvent`, `ListTagsForMetadataObjectEvent`, `ListTagsInfoForMetadataObjectEvent`, `AssociateTagsForMetadataObjectEvent`, `GetTagForMetadataObjectEvent`, `ListTagsFailureEvent`, `ListTagInfoFailureEvent`, `CreateTagFailureEvent`, `GetTagFailureEvent`, `AlterTagFailureEvent`, `DeleteTagFailureEvent`, `ListMetadataObjectsForTagFailureEvent`, `ListTagsForMetadataObjectFailureEvent`, `ListTagsInfoForMetadataObjectFailureEvent`, `AssociateTagsForMetadataObjectFailureEvent`, `GetTagForMetadataObjectFailureEvent` | 0.9.0-incubating |-| model operation | `DeleteModelFailureEvent`, `DeleteModelVersionFailureEvent`, `GetModelFailureEvent`, `GetModelVersionFailureEvent`, `LinkModelVersionFailureEvent`, `ListModelFailureEvent`, `ListModelVersionFailureEvent`, `RegisterAndLinkModelFailureEvent`, `RegisterModelFailureEvent` | 0.9.0-incubating |+| Operation type | Post-event | Since Version |+|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|+| table operation | `CreateTableEvent`, `AlterTableEvent`, `DropTableEvent`, `LoadTableEvent`, `ListTableEvent`, `PurgeTableFailureEvent`, `CreateTableFailureEvent`, `AlterTableFailureEvent`, `DropTableFailureEvent`, `LoadTableFailureEvent`, `ListTableFailureEvent`, `PurgeTableFailureEvent` | 0.5.0 |+| fileset operation | `CreateFileSetEvent`, `AlterFileSetEvent`, `DropFileSetEvent`, `LoadFileSetEvent`, `ListFileSetEvent`, `CreateFileSetFailureEvent`, `AlterFileSetFailureEvent`, `DropFileSetFailureEvent`, `LoadFileSetFailureEvent`, `ListFileSetFailureEvent` | 0.5.0 |+| topic operation | `CreateTopicEvent`, `AlterTopicEvent`, `DropTopicEvent`, `LoadTopicEvent`, `ListTopicEvent`, `CreateTopicFailureEvent`, `AlterTopicFailureEvent`, `DropTopicFailureEvent`, `LoadTopicFailureEvent`, `ListTopicFailureEvent` | 0.5.0 |+| schema operation | `CreateSchemaEvent`, `AlterSchemaEvent`, `DropSchemaEvent`, `LoadSchemaEvent`, `ListSchemaEvent`, `CreateSchemaFailureEvent`, `AlterSchemaFailureEvent`, `DropSchemaFailureEvent`, `LoadSchemaFailureEvent`, `ListSchemaFailureEvent` | 0.5.0 |+| catalog operation | `CreateCatalogEvent`, `AlterCatalogEvent`, `DropCatalogEvent`, `LoadCatalogEvent`, `ListCatalogEvent`, `CreateCatalogFailureEvent`, `AlterCatalogFailureEvent`, `DropCatalogFailureEvent`, `LoadCatalogFailureEvent`, `ListCatalogFailureEvent` | 0.5.0 |+| metalake operation | `CreateMetalakeEvent`, `AlterMetalakeEvent`, `DropMetalakeEvent`, `LoadMetalakeEvent`, `ListMetalakeEvent`, `CreateMetalakeFailureEvent`, `AlterMetalakeFailureEvent`, `DropMetalakeFailureEvent`, `LoadMetalakeFailureEvent`, `ListMetalakeFailureEvent` | 0.5.0 |+| Iceberg REST server table operation | `IcebergCreateTableEvent`, `IcebergUpdateTableEvent`, `IcebergDropTableEvent`, `IcebergLoadTableEvent`, `IcebergListTableEvent`, `IcebergTableExistsEvent`, `IcebergRenameTableEvent`, `IcebergCreateTableFailureEvent`, `IcebergUpdateTableFailureEvent`, `IcebergDropTableFailureEvent`, `IcebergLoadTableFailureEvent`, `IcebergListTableFailureEvent`, `IcebergRenameTableFailureEvent`, `IcebergTableExistsFailureEvent` | 0.7.0-incubating |+| tag operation | `ListTagsEvent`, `ListTagsInfoEvent`, `CreateTagEvent`, `GetTagEvent`, `AlterTagEvent`, `DeleteTagEvent`, `ListMetadataObjectsForTagEvent`, `ListTagsForMetadataObjectEvent`, `ListTagsInfoForMetadataObjectEvent`, `AssociateTagsForMetadataObjectEvent`, `GetTagForMetadataObjectEvent`, `ListTagsFailureEvent`, `ListTagInfoFailureEvent`, `CreateTagFailureEvent`, `GetTagFailureEvent`, `AlterTagFailureEvent`, `DeleteTagFailureEvent`, `ListMetadataObjectsForTagFailureEvent`, `ListTagsForMetadataObjectFailureEvent`, `ListTagsInfoForMetadataObjectFailureEvent`, `AssociateTagsForMetadataObjectFailureEvent`, `GetTagForMetadataObjectFailureEvent` | 0.9.0-incubating |+| model operation | `DeleteModelEvent`, `DeleteModelVersionEvent`, `GetModelEvent`, `GetModelVersionEvent`, `LinkModelVersionEvent`, `ListModelEvent`, `ListModelVersionsEvent`, `RegisterAndLinkModelEvent`, `RegisterModelEvent`, `DeleteModelFailureEvent`, `DeleteModelVersionFailureEvent`, `GetModelFailureEvent`, `GetModelVersionFailureEvent`, `LinkModelVersionFailureEvent`, `ListModelFailureEvent`, `ListModelVersionFailureEvent`, `RegisterAndLinkModelFailureEvent`, `RegisterModelFailureEvent` | 0.9.0-incubating |##### Pre-event