Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#2920]feat(core): supports more table event (#2895)

FANNG0ff45cd526ee
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/TableEventDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/TableEventDispatcher.java
index 987b2687b9..bb2735527d 100644
--- a/core/src/main/java/com/datastrato/gravitino/catalog/TableEventDispatcher.java
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/TableEventDispatcher.java
@@ -11,10 +11,18 @@ import com.datastrato.gravitino.exceptions.NoSuchSchemaException;
import com.datastrato.gravitino.exceptions.NoSuchTableException;
import com.datastrato.gravitino.exceptions.TableAlreadyExistsException;
import com.datastrato.gravitino.listener.EventBus;
+import com.datastrato.gravitino.listener.api.event.AlterTableEvent;
+import com.datastrato.gravitino.listener.api.event.AlterTableFailureEvent;
import com.datastrato.gravitino.listener.api.event.CreateTableEvent;
import com.datastrato.gravitino.listener.api.event.CreateTableFailureEvent;
import com.datastrato.gravitino.listener.api.event.DropTableEvent;
import com.datastrato.gravitino.listener.api.event.DropTableFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListTableEvent;
+import com.datastrato.gravitino.listener.api.event.ListTableFailureEvent;
+import com.datastrato.gravitino.listener.api.event.LoadTableEvent;
+import com.datastrato.gravitino.listener.api.event.LoadTableFailureEvent;
+import com.datastrato.gravitino.listener.api.event.PurgeTableEvent;
+import com.datastrato.gravitino.listener.api.event.PurgeTableFailureEvent;
import com.datastrato.gravitino.listener.api.info.TableInfo;
import com.datastrato.gravitino.rel.Column;
import com.datastrato.gravitino.rel.Table;
@@ -50,12 +58,29 @@ public class TableEventDispatcher implements TableDispatcher {
@Override
public NameIdentifier[] listTables(Namespace namespace) throws NoSuchSchemaException {
- return dispatcher.listTables(namespace);
+ try {
+ NameIdentifier[] nameIdentifiers = dispatcher.listTables(namespace);
+ eventBus.dispatchEvent(new ListTableEvent(PrincipalUtils.getCurrentUserName(), namespace));
+ return nameIdentifiers;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new ListTableFailureEvent(PrincipalUtils.getCurrentUserName(), namespace, e));
+ throw e;
+ }
}
@Override
public Table loadTable(NameIdentifier ident) throws NoSuchTableException {
- return dispatcher.loadTable(ident);
+ try {
+ Table table = dispatcher.loadTable(ident);
+ eventBus.dispatchEvent(
+ new LoadTableEvent(PrincipalUtils.getCurrentUserName(), ident, new TableInfo(table)));
+ return table;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new LoadTableFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+ throw e;
+ }
}
@Override
@@ -98,7 +123,17 @@ public class TableEventDispatcher implements TableDispatcher {
@Override
public Table alterTable(NameIdentifier ident, TableChange... changes)
throws NoSuchTableException, IllegalArgumentException {
- return dispatcher.alterTable(ident, changes);
+ try {
+ Table table = dispatcher.alterTable(ident, changes);
+ eventBus.dispatchEvent(
+ new AlterTableEvent(
+ PrincipalUtils.getCurrentUserName(), ident, changes, new TableInfo(table)));
+ return table;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new AlterTableFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e, changes));
+ throw e;
+ }
}
@Override
@@ -117,7 +152,16 @@ public class TableEventDispatcher implements TableDispatcher {
@Override
public boolean purgeTable(NameIdentifier ident) {
- return dispatcher.purgeTable(ident);
+ try {
+ boolean isExists = dispatcher.purgeTable(ident);
+ eventBus.dispatchEvent(
+ new PurgeTableEvent(PrincipalUtils.getCurrentUserName(), ident, isExists));
+ return isExists;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new PurgeTableFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+ throw e;
+ }
}
@Override
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableEvent.java
new file mode 100644
index 0000000000..a18359c70f
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableEvent.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+import com.datastrato.gravitino.listener.api.info.TableInfo;
+import com.datastrato.gravitino.rel.TableChange;
+
+/** Represents an event fired when a table is successfully altered. */
+@DeveloperApi
+public final class AlterTableEvent extends TableEvent {
+ private final TableInfo updatedTableInfo;
+ private final TableChange[] tableChanges;
+
+ /**
+ * Constructs an instance of {@code AlterTableEvent}, encapsulating the key details about the
+ * successful alteration of a table.
+ *
+ * @param user The username of the individual responsible for initiating the table alteration.
+ * @param identifier The unique identifier of the altered table, serving as a clear reference
+ * point for the table in question.
+ * @param tableChanges An array of {@link TableChange} objects representing the specific changes
+ * applied to the table during the alteration process.
+ * @param updatedTableInfo The post-alteration state of the table.
+ */
+ public AlterTableEvent(
+ String user,
+ NameIdentifier identifier,
+ TableChange[] tableChanges,
+ TableInfo updatedTableInfo) {
+ super(user, identifier);
+ this.tableChanges = tableChanges.clone();
+ this.updatedTableInfo = updatedTableInfo;
+ }
+
+ /**
+ * Retrieves the updated state of the table after the successful alteration.
+ *
+ * @return A {@link TableInfo} instance encapsulating the details of the altered table.
+ */
+ public TableInfo updatedTableInfo() {
+ return updatedTableInfo;
+ }
+
+ /**
+ * Retrieves the specific changes that were made to the table during the alteration process.
+ *
+ * @return An array of {@link TableChange} objects detailing each modification applied to the
+ * table.
+ */
+ public TableChange[] tableChanges() {
+ return tableChanges;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableFailureEvent.java
new file mode 100644
index 0000000000..0c8b1edbfb
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterTableFailureEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+import com.datastrato.gravitino.rel.TableChange;
+
+/**
+ * Represents an event that is triggered when an attempt to alter a table fails due to an exception.
+ */
+@DeveloperApi
+public final class AlterTableFailureEvent extends TableFailureEvent {
+ private final TableChange[] tableChanges;
+
+ /**
+ * Constructs an {@code AlterTableFailureEvent} instance, capturing detailed information about the
+ * failed table alteration attempt.
+ *
+ * @param user The user who initiated the table alteration operation.
+ * @param identifier The identifier of the table that was attempted to be altered.
+ * @param exception The exception that was thrown during the table alteration operation.
+ * @param tableChanges The changes that were attempted on the table.
+ */
+ public AlterTableFailureEvent(
+ String user, NameIdentifier identifier, Exception exception, TableChange[] tableChanges) {
+ super(user, identifier, exception);
+ this.tableChanges = tableChanges.clone();
+ }
+
+ /**
+ * Retrieves the changes that were attempted on the table.
+ *
+ * @return An array of {@link TableChange} objects representing the attempted modifications to the
+ * table.
+ */
+ public TableChange[] tableChanges() {
+ return tableChanges;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableEvent.java
index b68dee9db0..fe89dcc8f6 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableEvent.java
@@ -9,16 +9,7 @@ import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.annotation.DeveloperApi;
import com.datastrato.gravitino.listener.api.info.TableInfo;
-/**
- * Represents an event triggered upon the successful creation of a table. This class extends {@link
- * TableEvent} to provide detailed information specifically related to the table's creation. This
- * includes the final table information as it is returned to the user once the creation process has
- * successfully completed.
- *
- * <p>Such an event is instrumental for a variety of purposes including, but not limited to,
- * auditing activities associated with table creation, monitoring the creation of tables within a
- * system, and acquiring insights into the final configuration and state of a newly created table.
- */
+/** Represents an event triggered upon the successful creation of a table. */
@DeveloperApi
public final class CreateTableEvent extends TableEvent {
private final TableInfo createdTableInfo;
@@ -27,17 +18,9 @@ public final class CreateTableEvent extends TableEvent {
* Constructs an instance of {@code CreateTableEvent}, capturing essential details about the
* successful creation of a table.
*
- * <p>This constructor documents the successful culmination of the table creation process by
- * encapsulating the final state of the table. This includes any adjustments or resolutions made
- * to the table's properties or configuration during the creation process.
- *
- * @param user The username of the individual who initiated the table creation. This information
- * is vital for tracking the source of changes and for audit trails.
- * @param identifier The unique identifier of the table that was created, providing a precise
- * reference to the affected table.
- * @param createdTableInfo The final state of the table post-creation. This information is
- * reflective of the table's configuration, including any default settings or properties
- * applied during the creation process.
+ * @param user The username of the individual who initiated the table creation.
+ * @param identifier The unique identifier of the table that was created.
+ * @param createdTableInfo The final state of the table post-creation.
*/
public CreateTableEvent(String user, NameIdentifier identifier, TableInfo createdTableInfo) {
super(user, identifier);
@@ -45,11 +28,11 @@ public final class CreateTableEvent extends TableEvent {
}
/**
- * Retrieves the final state and configuration information of the table as it was returned to the
- * user after successful creation.
+ * Retrieves the final state of the table as it was returned to the user after successful
+ * creation.
*
* @return A {@link TableInfo} instance encapsulating the comprehensive details of the newly
- * created table, highlighting its configuration and any default settings applied.
+ * created table.
*/
public TableInfo createdTableInfo() {
return createdTableInfo;
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableFailureEvent.java
index 6370378b3f..dc60ad44c8 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableFailureEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateTableFailureEvent.java
@@ -8,14 +8,10 @@ package com.datastrato.gravitino.listener.api.event;
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.annotation.DeveloperApi;
import com.datastrato.gravitino.listener.api.info.TableInfo;
-import com.datastrato.gravitino.rel.Table;
/**
* Represents an event that is generated when an attempt to create a table fails due to an
- * exception. This class extends {@link TableFailureEvent} to specifically address failure scenarios
- * encountered during the table creation process. It encapsulates both the exception that caused the
- * failure and the original request details for the table creation, providing comprehensive context
- * for the failure.
+ * exception.
*/
@DeveloperApi
public final class CreateTableFailureEvent extends TableFailureEvent {
@@ -25,10 +21,8 @@ public final class CreateTableFailureEvent extends TableFailureEvent {
* Constructs a {@code CreateTableFailureEvent} instance, capturing detailed information about the
* failed table creation attempt.
*
- * @param user The user who initiated the table creation operation. This information is essential
- * for auditing and diagnosing the cause of the failure.
- * @param identifier The identifier of the table that was attempted to be created. This helps in
- * pinpointing the specific table related to the failure.
+ * @param user The user who initiated the table creation operation.
+ * @param identifier The identifier of the table that was attempted to be created.
* @param exception The exception that was thrown during the table creation operation, providing
* insight into what went wrong.
* @param createTableRequest The original request information used to attempt to create the table.
@@ -42,12 +36,10 @@ public final class CreateTableFailureEvent extends TableFailureEvent {
}
/**
- * Retrieves the original request information for the attempted table creation. This information
- * can be valuable for understanding the configuration and expectations that led to the failure,
- * facilitating analysis and potential corrective actions.
+ * Retrieves the original request information for the attempted table creation.
*
- * @return The {@link Table} instance representing the request information for the failed table
- * creation attempt.
+ * @return The {@link TableInfo} instance representing the request information for the failed
+ * table creation attempt.
*/
public TableInfo createTableRequest() {
return createTableRequest;
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableEvent.java
index a75939eaf6..6e2ba0a6dd 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableEvent.java
@@ -10,9 +10,6 @@ import com.datastrato.gravitino.annotation.DeveloperApi;
/**
* Represents an event that is generated after a table is successfully dropped from the database.
- * This class extends {@link TableEvent} to capture specific details related to the dropping of a
- * table, including the status of the table's existence at the time of the operation and identifying
- * information about the table and the user who initiated the drop operation.
*/
@DeveloperApi
public final class DropTableEvent extends TableEvent {
@@ -22,12 +19,9 @@ public final class DropTableEvent extends TableEvent {
* Constructs a new {@code DropTableEvent} instance, encapsulating information about the outcome
* of a table drop operation.
*
- * @param user The user who initiated the drop table operation. This information is important for
- * auditing purposes and understanding who is responsible for the change.
- * @param identifier The identifier of the table that was attempted to be dropped. This provides a
- * clear reference to the specific table affected by the operation.
+ * @param user The user who initiated the drop table operation.
+ * @param identifier The identifier of the table that was attempted to be dropped.
* @param isExists A boolean flag indicating whether the table existed at the time of the drop
- * operation. This can be useful to understand the state of the database prior to the
* operation.
*/
public DropTableEvent(String user, NameIdentifier identifier, boolean isExists) {
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableFailureEvent.java
index 78076fe961..87eef3b9e2 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableFailureEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropTableFailureEvent.java
@@ -10,11 +10,7 @@ import com.datastrato.gravitino.annotation.DeveloperApi;
/**
* Represents an event that is generated when an attempt to drop a table from the database fails due
- * to an exception. This class extends {@link TableFailureEvent} to provide specific context related
- * to table drop failures, encapsulating details about the user who initiated the operation, the
- * identifier of the table that was attempted to be dropped, and the exception that led to the
- * failure. This event can be used for auditing purposes and to facilitate error handling and
- * diagnostic processes.
+ * to an exception.
*/
@DeveloperApi
public final class DropTableFailureEvent extends TableFailureEvent {
@@ -22,11 +18,8 @@ public final class DropTableFailureEvent extends TableFailureEvent {
* Constructs a new {@code DropTableFailureEvent} instance, capturing detailed information about
* the failed attempt to drop a table.
*
- * @param user The user who initiated the drop table operation. This information is crucial for
- * understanding the context of the operation and for auditing who is responsible for the
- * attempted change.
- * @param identifier The identifier of the table that the operation attempted to drop. This
- * provides a clear reference to the specific table involved in the failure.
+ * @param user The user who initiated the drop table operation.
+ * @param identifier The identifier of the table that the operation attempted to drop.
* @param exception The exception that was thrown during the drop table operation, offering
* insights into what went wrong and why the operation failed.
*/
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/Event.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/Event.java
index 484120a8bc..e4ed6d474f 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/Event.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/Event.java
@@ -7,6 +7,7 @@ package com.datastrato.gravitino.listener.api.event;
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.annotation.DeveloperApi;
+import javax.annotation.Nullable;
/**
* The abstract base class for all events. It encapsulates common information such as the user who
@@ -16,7 +17,7 @@ import com.datastrato.gravitino.annotation.DeveloperApi;
@DeveloperApi
public abstract class Event {
private final String user;
- private final NameIdentifier identifier;
+ @Nullable private final NameIdentifier identifier;
/**
* Constructs an Event instance with the specified user and resource identifier details.
@@ -43,9 +44,13 @@ public abstract class Event {
/**
* Retrieves the resource identifier associated with this event.
*
+ * <p>For list operations within a namespace, the identifier is the identifier corresponds to that
+ * namespace. For metalake list operation, identifier is null.
+ *
* @return A NameIdentifier object that represents the resource, like a metalake, catalog, schema,
* table, etc., associated with the event.
*/
+ @Nullable
public NameIdentifier identifier() {
return identifier;
}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/FailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FailureEvent.java
index ca0c263c20..471c9baad9 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/FailureEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FailureEvent.java
@@ -23,8 +23,7 @@ public abstract class FailureEvent extends Event {
* Constructs a new {@code FailureEvent} instance with the specified user, resource identifier,
* and the exception that was thrown.
*
- * @param user The user associated with the operation that resulted in a failure. This information
- * is important for auditing and understanding the context of the failure.
+ * @param user The user associated with the operation that resulted in a failure.
* @param identifier The identifier of the resource involved in the operation that failed. This
* provides a clear reference to what was being acted upon when the exception occurred.
* @param exception The exception that was thrown during the operation. This is the primary piece
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableEvent.java
new file mode 100644
index 0000000000..63eb0d410c
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.Namespace;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/**
+ * Represents an event that is triggered upon the successful list of tables within a namespace.
+ *
+ * <p>To optimize memory usage and avoid the potential overhead associated with storing a large
+ * number of tables directly within the ListTableEvent, the actual tables listed are not maintained
+ * in this event. This design decision helps in managing resource efficiency, especially in
+ * environments with extensive table listings.
+ */
+@DeveloperApi
+public final class ListTableEvent extends TableEvent {
+ private final Namespace namespace;
+
+ /**
+ * Constructs an instance of {@code ListTableEvent}.
+ *
+ * @param user The username of the individual who initiated the table listing.
+ * @param namespace The namespace from which tables were listed.
+ */
+ public ListTableEvent(String user, Namespace namespace) {
+ super(user, NameIdentifier.parse(namespace.toString()));
+ this.namespace = namespace;
+ }
+
+ /**
+ * Provides the namespace associated with this event.
+ *
+ * @return A {@link Namespace} instance from which tables were listed.
+ */
+ public Namespace namespace() {
+ return namespace;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableFailureEvent.java
new file mode 100644
index 0000000000..706fc71d16
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListTableFailureEvent.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.Namespace;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/**
+ * Represents an event that is triggered when an attempt to list tables within a namespace fails due
+ * to an exception.
+ */
+@DeveloperApi
+public final class ListTableFailureEvent extends TableFailureEvent {
+ private final Namespace namespace;
+
+ /**
+ * Constructs a {@code ListTableFailureEvent} instance.
+ *
+ * @param user The username of the individual who initiated the operation to list tables.
+ * @param namespace The namespace for which the table listing was attempted.
+ * @param exception The exception encountered during the attempt to list tables.
+ */
+ public ListTableFailureEvent(String user, Namespace namespace, Exception exception) {
+ super(user, NameIdentifier.of(namespace.toString()), exception);
+ this.namespace = namespace;
+ }
+
+ /**
+ * Retrieves the namespace associated with this failure event.
+ *
+ * @return A {@link Namespace} instance for which the table listing was attempted
+ */
+ public Namespace namespace() {
+ return namespace;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableEvent.java
new file mode 100644
index 0000000000..f3bfb4236d
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableEvent.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+import com.datastrato.gravitino.listener.api.info.TableInfo;
+
+/** Represents an event triggered upon the successful loading of a table. */
+@DeveloperApi
+public final class LoadTableEvent extends TableEvent {
+ private final TableInfo loadedTableInfo;
+
+ /**
+ * Constructs an instance of {@code LoadTableEvent}.
+ *
+ * @param user The username of the individual who initiated the table loading.
+ * @param identifier The unique identifier of the table that was loaded.
+ * @param tableInfo The state of the table post-loading.
+ */
+ public LoadTableEvent(String user, NameIdentifier identifier, TableInfo tableInfo) {
+ super(user, identifier);
+ this.loadedTableInfo = tableInfo;
+ }
+
+ /**
+ * Retrieves the state of the table as it was made available to the user after successful loading.
+ *
+ * @return A {@link TableInfo} instance encapsulating the details of the table as loaded.
+ */
+ public TableInfo loadedTableInfo() {
+ return loadedTableInfo;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableFailureEvent.java
new file mode 100644
index 0000000000..b01b849320
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadTableFailureEvent.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that occurs when an attempt to load a table fails due to an exception. */
+@DeveloperApi
+public final class LoadTableFailureEvent extends TableFailureEvent {
+ /**
+ * Constructs a {@code LoadTableFailureEvent} instance.
+ *
+ * @param user The user who initiated the table loading operation.
+ * @param identifier The identifier of the table that the loading attempt was made for.
+ * @param exception The exception that was thrown during the table loading operation, offering
+ * insight into the issues encountered.
+ */
+ public LoadTableFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableEvent.java
new file mode 100644
index 0000000000..fd3048ee46
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableEvent.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that occurs after a table is successfully purged from the database. */
+@DeveloperApi
+public final class PurgeTableEvent extends TableEvent {
+ private final boolean isExists;
+
+ /**
+ * Constructs a new {@code PurgeTableEvent} instance.
+ *
+ * @param user The user who initiated the purge table operation.
+ * @param identifier The identifier of the table that was targeted for purging.
+ * @param isExists A boolean indicator reflecting whether the table was present in the database at
+ * the time of the purge operation.
+ */
+ public PurgeTableEvent(String user, NameIdentifier identifier, boolean isExists) {
+ super(user, identifier);
+ this.isExists = isExists;
+ }
+
+ /**
+ * Retrieves the status of the table's existence at the time of the purge operation.
+ *
+ * @return A boolean value indicating the table's existence status. {@code true} signifies that
+ * the table was present before the operation, {@code false} indicates it was not.
+ */
+ public boolean isExists() {
+ return isExists;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableFailureEvent.java
new file mode 100644
index 0000000000..42fddfc0f1
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/PurgeTableFailureEvent.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.event;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/**
+ * Represents an event triggered when an attempt to purge a table from the database fails due to an
+ * exception.
+ */
+@DeveloperApi
+public final class PurgeTableFailureEvent extends TableFailureEvent {
+ /**
+ * Constructs a new {@code PurgeTableFailureEvent} instance.
+ *
+ * @param user The user who initiated the table purge operation.
+ * @param identifier The identifier of the table intended to be purged.
+ * @param exception The exception encountered during the table purge operation, providing insights
+ * into the reasons behind the operation's failure.
+ */
+ public PurgeTableFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableEvent.java
index 238ad0eea4..19e10d5f22 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableEvent.java
@@ -22,8 +22,7 @@ public abstract class TableEvent extends Event {
/**
* Constructs a new {@code TableEvent} with the specified user and table identifier.
*
- * @param user The user responsible for triggering the table operation. This information is
- * crucial for auditing and tracking purposes.
+ * @param user The user responsible for triggering the table operation.
* @param identifier The identifier of the table involved in the operation. This encapsulates
* details such as the metalake, catalog, schema, and table name.
*/
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableFailureEvent.java
index 8b78df964c..e87d1281fa 100644
--- a/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableFailureEvent.java
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/TableFailureEvent.java
@@ -24,11 +24,8 @@ public abstract class TableFailureEvent extends FailureEvent {
* Constructs a new {@code TableFailureEvent} instance, capturing information about the failed
* table operation.
*
- * @param user The user associated with the failed table operation. This information helps in
- * auditing and understanding the context of the operation that resulted in a failure.
- * @param identifier The identifier of the table that was involved in the failed operation. This
- * provides a clear reference to the specific table that the operation was attempting to
- * modify or interact with.
+ * @param user The user associated with the failed table operation.
+ * @param identifier The identifier of the table that was involved in the failed operation.
* @param exception The exception that was thrown during the table operation, indicating the cause
* of the failure.
*/