Skip to content

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

[#2767] feat(core): supports fileset event for event listener (#2882)

FANNGf2fb33558045
diff --git a/core/src/main/java/com/datastrato/gravitino/GravitinoEnv.java b/core/src/main/java/com/datastrato/gravitino/GravitinoEnv.java
index c357c9bcc0..61144fe3e4 100644
--- a/core/src/main/java/com/datastrato/gravitino/GravitinoEnv.java
+++ b/core/src/main/java/com/datastrato/gravitino/GravitinoEnv.java
@@ -7,6 +7,8 @@ package com.datastrato.gravitino;
import com.datastrato.gravitino.authorization.AccessControlManager;
import com.datastrato.gravitino.auxiliary.AuxiliaryServiceManager;
import com.datastrato.gravitino.catalog.CatalogManager;
+import com.datastrato.gravitino.catalog.FilesetDispatcher;
+import com.datastrato.gravitino.catalog.FilesetEventDispatcher;
import com.datastrato.gravitino.catalog.FilesetOperationDispatcher;
import com.datastrato.gravitino.catalog.SchemaOperationDispatcher;
import com.datastrato.gravitino.catalog.TableDispatcher;
@@ -43,7 +45,7 @@ public class GravitinoEnv {
private TableDispatcher tableDispatcher;
- private FilesetOperationDispatcher filesetOperationDispatcher;
+ private FilesetDispatcher filesetDispatcher;
private TopicOperationDispatcher topicOperationDispatcher;
@@ -132,8 +134,9 @@ public class GravitinoEnv {
TableOperationDispatcher tableOperationDispatcher =
new TableOperationDispatcher(catalogManager, entityStore, idGenerator);
this.tableDispatcher = new TableEventDispatcher(eventBus, tableOperationDispatcher);
- this.filesetOperationDispatcher =
+ FilesetOperationDispatcher filesetOperationDispatcher =
new FilesetOperationDispatcher(catalogManager, entityStore, idGenerator);
+ this.filesetDispatcher = new FilesetEventDispatcher(eventBus, filesetOperationDispatcher);
this.topicOperationDispatcher =
new TopicOperationDispatcher(catalogManager, entityStore, idGenerator);
@@ -201,12 +204,12 @@ public class GravitinoEnv {
}
/**
- * Get the FilesetOperationDispatcher associated with the Gravitino environment.
+ * Get the FilesetDispatcher associated with the Gravitino environment.
*
- * @return The FilesetOperationDispatcher instance.
+ * @return The FilesetDispatcher instance.
*/
- public FilesetOperationDispatcher filesetOperationDispatcher() {
- return filesetOperationDispatcher;
+ public FilesetDispatcher filesetDispatcher() {
+ return filesetDispatcher;
}
/**
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/FilesetDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetDispatcher.java
new file mode 100644
index 0000000000..f2d0daf280
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetDispatcher.java
@@ -0,0 +1,16 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.catalog;
+
+import com.datastrato.gravitino.file.FilesetCatalog;
+
+/**
+ * {@code FilesetDispatcher} interface acts as a specialization of the {@link FilesetCatalog}
+ * interface. This interface is designed to potentially add custom behaviors or operations related
+ * to dispatching or handling fileset-related events or actions that are not covered by the standard
+ * {@code FilesetCatalog} operations.
+ */
+public interface FilesetDispatcher extends FilesetCatalog {}
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/FilesetEventDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetEventDispatcher.java
new file mode 100644
index 0000000000..edc98bb166
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetEventDispatcher.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.catalog;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.Namespace;
+import com.datastrato.gravitino.exceptions.FilesetAlreadyExistsException;
+import com.datastrato.gravitino.exceptions.NoSuchFilesetException;
+import com.datastrato.gravitino.exceptions.NoSuchSchemaException;
+import com.datastrato.gravitino.file.Fileset;
+import com.datastrato.gravitino.file.FilesetChange;
+import com.datastrato.gravitino.listener.EventBus;
+import com.datastrato.gravitino.listener.api.event.AlterFilesetEvent;
+import com.datastrato.gravitino.listener.api.event.AlterFilesetFailureEvent;
+import com.datastrato.gravitino.listener.api.event.CreateFilesetEvent;
+import com.datastrato.gravitino.listener.api.event.CreateFilesetFailureEvent;
+import com.datastrato.gravitino.listener.api.event.DropFilesetEvent;
+import com.datastrato.gravitino.listener.api.event.DropFilesetFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListFilesetEvent;
+import com.datastrato.gravitino.listener.api.event.ListFilesetFailureEvent;
+import com.datastrato.gravitino.listener.api.event.LoadFilesetEvent;
+import com.datastrato.gravitino.listener.api.event.LoadFilesetFailureEvent;
+import com.datastrato.gravitino.listener.api.info.FilesetInfo;
+import com.datastrato.gravitino.utils.PrincipalUtils;
+import java.util.Map;
+
+/**
+ * {@code FilesetEventDispatcher} is a decorator for {@link FilesetDispatcher} that not only
+ * delegates fileset operations to the underlying catalog dispatcher but also dispatches
+ * corresponding events to an {@link EventBus} after each operation is completed. This allows for
+ * event-driven workflows or monitoring of fileset operations.
+ */
+public class FilesetEventDispatcher implements FilesetDispatcher {
+ private final EventBus eventBus;
+ private final FilesetDispatcher dispatcher;
+
+ public FilesetEventDispatcher(EventBus eventBus, FilesetDispatcher dispatcher) {
+ this.eventBus = eventBus;
+ this.dispatcher = dispatcher;
+ }
+
+ @Override
+ public NameIdentifier[] listFilesets(Namespace namespace) throws NoSuchSchemaException {
+ try {
+ NameIdentifier[] nameIdentifiers = dispatcher.listFilesets(namespace);
+ eventBus.dispatchEvent(new ListFilesetEvent(PrincipalUtils.getCurrentUserName(), namespace));
+ return nameIdentifiers;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new ListFilesetFailureEvent(PrincipalUtils.getCurrentUserName(), namespace, e));
+ throw e;
+ }
+ }
+
+ @Override
+ public Fileset loadFileset(NameIdentifier ident) throws NoSuchFilesetException {
+ try {
+ Fileset fileset = dispatcher.loadFileset(ident);
+ eventBus.dispatchEvent(
+ new LoadFilesetEvent(
+ PrincipalUtils.getCurrentUserName(), ident, new FilesetInfo(fileset)));
+ return fileset;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new LoadFilesetFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+ throw e;
+ }
+ }
+
+ @Override
+ public Fileset createFileset(
+ NameIdentifier ident,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> properties)
+ throws NoSuchSchemaException, FilesetAlreadyExistsException {
+ try {
+ Fileset fileset = dispatcher.createFileset(ident, comment, type, storageLocation, properties);
+ eventBus.dispatchEvent(
+ new CreateFilesetEvent(
+ PrincipalUtils.getCurrentUserName(), ident, new FilesetInfo(fileset)));
+ return fileset;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new CreateFilesetFailureEvent(
+ PrincipalUtils.getCurrentUserName(),
+ ident,
+ e,
+ new FilesetInfo(ident.name(), comment, type, storageLocation, properties, null)));
+ throw e;
+ }
+ }
+
+ @Override
+ public Fileset alterFileset(NameIdentifier ident, FilesetChange... changes)
+ throws NoSuchFilesetException, IllegalArgumentException {
+ try {
+ Fileset fileset = dispatcher.alterFileset(ident, changes);
+ eventBus.dispatchEvent(
+ new AlterFilesetEvent(
+ PrincipalUtils.getCurrentUserName(), ident, changes, new FilesetInfo(fileset)));
+ return fileset;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new AlterFilesetFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e, changes));
+ throw e;
+ }
+ }
+
+ @Override
+ public boolean dropFileset(NameIdentifier ident) {
+ try {
+ boolean isExists = dispatcher.dropFileset(ident);
+ eventBus.dispatchEvent(
+ new DropFilesetEvent(PrincipalUtils.getCurrentUserName(), ident, isExists));
+ return isExists;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new DropFilesetFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+ throw e;
+ }
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/catalog/FilesetOperationDispatcher.java b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetOperationDispatcher.java
index 892b444e1f..d462e6ac26 100644
--- a/core/src/main/java/com/datastrato/gravitino/catalog/FilesetOperationDispatcher.java
+++ b/core/src/main/java/com/datastrato/gravitino/catalog/FilesetOperationDispatcher.java
@@ -17,12 +17,11 @@ import com.datastrato.gravitino.exceptions.NoSuchFilesetException;
import com.datastrato.gravitino.exceptions.NoSuchSchemaException;
import com.datastrato.gravitino.exceptions.NonEmptyEntityException;
import com.datastrato.gravitino.file.Fileset;
-import com.datastrato.gravitino.file.FilesetCatalog;
import com.datastrato.gravitino.file.FilesetChange;
import com.datastrato.gravitino.storage.IdGenerator;
import java.util.Map;
-public class FilesetOperationDispatcher extends OperationDispatcher implements FilesetCatalog {
+public class FilesetOperationDispatcher extends OperationDispatcher implements FilesetDispatcher {
/**
* Creates a new FilesetOperationDispatcher instance.
*
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetEvent.java
new file mode 100644
index 0000000000..57fed2e8db
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetEvent.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.file.FilesetChange;
+import com.datastrato.gravitino.listener.api.info.FilesetInfo;
+
+/** Represents an event that occurs when a fileset is altered. */
+@DeveloperApi
+public final class AlterFilesetEvent extends FilesetEvent {
+ private final FilesetInfo updatedFilesetInfo;
+ private final FilesetChange[] filesetChanges;
+
+ /**
+ * Constructs a new {@code AlterFilesetEvent} instance.
+ *
+ * @param user The username of the individual who initiated the fileset alteration.
+ * @param identifier The unique identifier of the fileset that was altered.
+ * @param filesetChanges An array of {@link FilesetChange} objects representing the specific
+ * changes applied to the fileset.
+ * @param updatedFilesetInfo The {@link FilesetInfo} object representing the state of the fileset
+ * after the changes were applied.
+ */
+ public AlterFilesetEvent(
+ String user,
+ NameIdentifier identifier,
+ FilesetChange[] filesetChanges,
+ FilesetInfo updatedFilesetInfo) {
+ super(user, identifier);
+ this.filesetChanges = filesetChanges.clone();
+ this.updatedFilesetInfo = updatedFilesetInfo;
+ }
+
+ /**
+ * Retrieves the array of changes made to the fileset.
+ *
+ * @return An array of {@link FilesetChange} objects detailing the modifications applied to the
+ * fileset.
+ */
+ public FilesetChange[] filesetChanges() {
+ return filesetChanges;
+ }
+
+ /**
+ * Retrieves the information about the fileset after the alterations.
+ *
+ * @return A {@link FilesetInfo} object representing the current state of the fileset
+ * post-alteration.
+ */
+ public FilesetInfo updatedFilesetInfo() {
+ return updatedFilesetInfo;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetFailureEvent.java
new file mode 100644
index 0000000000..515f8cdce9
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/AlterFilesetFailureEvent.java
@@ -0,0 +1,46 @@
+/*
+ * 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.file.FilesetChange;
+
+/**
+ * Represents an event that is generated when an attempt to alter a fileset fails due to an
+ * exception.
+ */
+@DeveloperApi
+public final class AlterFilesetFailureEvent extends FilesetFailureEvent {
+ private final FilesetChange[] filesetChanges;
+
+ /**
+ * Constructs a new {@code AlterFilesetFailureEvent}, capturing detailed information about the
+ * failed attempt to alter a fileset.
+ *
+ * @param user The user who initiated the fileset alteration operation.
+ * @param identifier The identifier of the fileset that was attempted to be altered.
+ * @param exception The exception that was encountered during the alteration attempt, providing
+ * insight into the cause of the failure.
+ * @param filesetChanges An array of {@link FilesetChange} objects representing the changes that
+ * were attempted on the fileset.
+ */
+ public AlterFilesetFailureEvent(
+ String user, NameIdentifier identifier, Exception exception, FilesetChange[] filesetChanges) {
+ super(user, identifier, exception);
+ this.filesetChanges = filesetChanges.clone();
+ }
+
+ /**
+ * Retrieves the changes that were attempted on the fileset, leading to the failure.
+ *
+ * @return An array of {@link FilesetChange} objects detailing the modifications that were
+ * attempted on the fileset.
+ */
+ public FilesetChange[] filesetChanges() {
+ return filesetChanges;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetEvent.java
new file mode 100644
index 0000000000..d5e091dd72
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetEvent.java
@@ -0,0 +1,41 @@
+/*
+ * 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.FilesetInfo;
+
+/** Represents an event that is triggered following the successful creation of a fileset. */
+@DeveloperApi
+public final class CreateFilesetEvent extends FilesetEvent {
+ private final FilesetInfo createdFilesetInfo;
+
+ /**
+ * Constructs a new {@code CreateFilesetEvent}, capturing the essential details surrounding the
+ * successful creation of a fileset.
+ *
+ * @param user The username of the person who initiated the creation of the fileset.
+ * @param identifier The unique identifier of the newly created fileset.
+ * @param createdFilesetInfo The state of the fileset immediately following its creation,
+ * including details such as its location, structure, and access permissions.
+ */
+ public CreateFilesetEvent(
+ String user, NameIdentifier identifier, FilesetInfo createdFilesetInfo) {
+ super(user, identifier);
+ this.createdFilesetInfo = createdFilesetInfo;
+ }
+
+ /**
+ * Provides information about the fileset as it was configured at the moment of creation.
+ *
+ * @return A {@link FilesetInfo} object encapsulating the state of the fileset immediately after
+ * its creation.
+ */
+ public FilesetInfo createdFilesetInfo() {
+ return createdFilesetInfo;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetFailureEvent.java
new file mode 100644
index 0000000000..6e2a49c0a0
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/CreateFilesetFailureEvent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.FilesetInfo;
+
+/** Represents an event triggered upon the unsuccessful attempt to create a fileset. */
+@DeveloperApi
+public final class CreateFilesetFailureEvent extends FilesetFailureEvent {
+ private final FilesetInfo createFilesetRequest;
+
+ /**
+ * Constructs a new {@code CreateFilesetFailureEvent}, capturing the specifics of the failed
+ * fileset creation attempt.
+ *
+ * @param user The user who initiated the attempt to create the fileset.
+ * @param identifier The identifier of the fileset intended for creation.
+ * @param exception The exception encountered during the fileset creation process, shedding light
+ * on the potential reasons behind the failure.
+ * @param createFilesetRequest The original request information used to attempt to create the
+ * fileset.
+ */
+ public CreateFilesetFailureEvent(
+ String user,
+ NameIdentifier identifier,
+ Exception exception,
+ FilesetInfo createFilesetRequest) {
+ super(user, identifier, exception);
+ this.createFilesetRequest = createFilesetRequest;
+ }
+
+ /**
+ * Provides insight into the intended configuration of the fileset at the time of the failed
+ * creation attempt.
+ *
+ * @return The {@link FilesetInfo} instance representing the request information for the failed
+ * fileset creation attempt.
+ */
+ public FilesetInfo createFilesetRequest() {
+ return createFilesetRequest;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetEvent.java
new file mode 100644
index 0000000000..dd65eac931
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetEvent.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 when a fileset is dropped from the system. */
+@DeveloperApi
+public final class DropFilesetEvent extends FilesetEvent {
+ private final boolean isExists;
+
+ /**
+ * Constructs a new {@code DropFilesetEvent}, recording the attempt to drop a fileset.
+ *
+ * @param user The user who initiated the drop fileset operation.
+ * @param identifier The identifier of the fileset that was attempted to be dropped.
+ * @param isExists A boolean flag indicating whether the fileset existed at the time of the
+ * operation.
+ */
+ public DropFilesetEvent(String user, NameIdentifier identifier, boolean isExists) {
+ super(user, identifier);
+ this.isExists = isExists;
+ }
+
+ /**
+ * Retrieves the existence status of the fileset at the time of the drop operation.
+ *
+ * @return {@code true} if the fileset existed at the time of the operation, otherwise {@code
+ * false}.
+ */
+ public boolean isExists() {
+ return isExists;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetFailureEvent.java
new file mode 100644
index 0000000000..dcfb8b733c
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/DropFilesetFailureEvent.java
@@ -0,0 +1,27 @@
+/*
+ * 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 is generated when an attempt to drop a fileset from the system fails.
+ */
+@DeveloperApi
+public final class DropFilesetFailureEvent extends FilesetFailureEvent {
+ /**
+ * Constructs a new {@code DropFilesetFailureEvent}.
+ *
+ * @param user The user who initiated the drop fileset operation.
+ * @param identifier The identifier of the fileset that was attempted to be dropped.
+ * @param exception The exception that was thrown during the drop operation. This exception is key
+ * to diagnosing the failure, providing insights into what went wrong during the operation.
+ */
+ public DropFilesetFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetEvent.java
new file mode 100644
index 0000000000..2e9e0722c1
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetEvent.java
@@ -0,0 +1,34 @@
+/*
+ * 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 abstract base class for events related to fileset operations. Extending {@link
+ * com.datastrato.gravitino.listener.api.event.Event}, this class narrows the focus to operations
+ * performed on filesets, such as creation, deletion, or modification. It captures vital information
+ * including the user performing the operation and the identifier of the fileset being manipulated.
+ *
+ * <p>Concrete implementations of this class are expected to provide additional specifics relevant
+ * to the particular type of fileset operation being represented, enriching the contextual
+ * understanding of each event.
+ */
+@DeveloperApi
+public abstract class FilesetEvent extends Event {
+ /**
+ * Constructs a new {@code FilesetEvent} with the specified user and fileset identifier.
+ *
+ * @param user The user responsible for initiating the fileset operation. This information is
+ * critical for auditing and tracking the origin of actions.
+ * @param identifier The identifier of the fileset involved in the operation. This includes
+ * details essential for pinpointing the specific fileset affected by the operation.
+ */
+ protected FilesetEvent(String user, NameIdentifier identifier) {
+ super(user, identifier);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetFailureEvent.java
new file mode 100644
index 0000000000..010d25c36c
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/FilesetFailureEvent.java
@@ -0,0 +1,33 @@
+/*
+ * 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;
+
+/**
+ * An abstract class representing events that are triggered when a fileset operation fails due to an
+ * exception.
+ *
+ * <p>Implementations of this class can be used to convey detailed information about failures in
+ * operations such as creating, updating, deleting, or querying filesets, making it easier to
+ * diagnose and respond to issues.
+ */
+@DeveloperApi
+public abstract class FilesetFailureEvent extends FailureEvent {
+ /**
+ * Constructs a new {@code FilesetFailureEvent} instance, capturing information about the failed
+ * fileset operation.
+ *
+ * @param user The user associated with the failed fileset operation.
+ * @param identifier The identifier of the fileset that was involved in the failed operation.
+ * @param exception The exception that was thrown during the fileset operation, indicating the
+ * cause of the failure.
+ */
+ protected FilesetFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetEvent.java
new file mode 100644
index 0000000000..c5e99d6a70
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetEvent.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.Namespace;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+
+/**
+ * Represents an event that is triggered upon the successful listing of filesets within a system.
+ */
+@DeveloperApi
+public final class ListFilesetEvent extends FilesetEvent {
+ private final Namespace namespace;
+ /**
+ * Constructs a new {@code ListFilesetEvent}.
+ *
+ * @param user The user who initiated the listing of filesets.
+ * @param namespace The namespace within which the filesets are listed. The namespace provides
+ * contextual information, identifying the scope and boundaries of the listing operation.
+ */
+ public ListFilesetEvent(String user, Namespace namespace) {
+ super(user, NameIdentifier.of(namespace.toString()));
+ this.namespace = namespace;
+ }
+
+ /**
+ * Retrieves the namespace associated with the failed listing event.
+ *
+ * @return The {@link Namespace} that was targeted during the failed listing operation.
+ */
+ public Namespace namespace() {
+ return namespace;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetFailureEvent.java
new file mode 100644
index 0000000000..bf063fd891
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/ListFilesetFailureEvent.java
@@ -0,0 +1,41 @@
+/*
+ * 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 filesets within a namespace fails.
+ */
+@DeveloperApi
+public final class ListFilesetFailureEvent extends FilesetFailureEvent {
+ private final Namespace namespace;
+
+ /**
+ * Constructs a new {@code ListFilesetFailureEvent}.
+ *
+ * @param user The username of the individual associated with the failed fileset listing
+ * operation.
+ * @param namespace The namespace in which the fileset listing was attempted.
+ * @param exception The exception encountered during the fileset listing attempt, which serves as
+ * an indicator of the issues that caused the failure.
+ */
+ public ListFilesetFailureEvent(String user, Namespace namespace, Exception exception) {
+ super(user, NameIdentifier.of(namespace.toString()), exception);
+ this.namespace = namespace;
+ }
+
+ /**
+ * Retrieves the namespace associated with the failed listing event.
+ *
+ * @return The {@link Namespace} that was targeted during the failed listing operation.
+ */
+ public Namespace namespace() {
+ return namespace;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetEvent.java
new file mode 100644
index 0000000000..8d7d238ff9
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetEvent.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.FilesetInfo;
+
+/** Represents an event that occurs when a fileset is loaded into the system. */
+@DeveloperApi
+public final class LoadFilesetEvent extends FilesetEvent {
+ private final FilesetInfo loadedFilesetInfo;
+ /**
+ * Constructs a new {@code LoadFilesetEvent}.
+ *
+ * @param user The user who initiated the loading of the fileset.
+ * @param identifier The unique identifier of the fileset being loaded.
+ * @param loadedFilesetInfo The state of the fileset post-loading.
+ */
+ public LoadFilesetEvent(String user, NameIdentifier identifier, FilesetInfo loadedFilesetInfo) {
+ super(user, identifier);
+ this.loadedFilesetInfo = loadedFilesetInfo;
+ }
+
+ /**
+ * Retrieves the state of the fileset as it was made available to the user after successful
+ * loading.
+ *
+ * @return A {@link FilesetInfo} instance encapsulating the details of the fileset as loaded.
+ */
+ public FilesetInfo loadedFilesetInfo() {
+ return loadedFilesetInfo;
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetFailureEvent.java b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetFailureEvent.java
new file mode 100644
index 0000000000..724bd384b8
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/event/LoadFilesetFailureEvent.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 fileset into the system fails. */
+@DeveloperApi
+public final class LoadFilesetFailureEvent extends FilesetFailureEvent {
+ /**
+ * Constructs a new {@code FilesetFailureEvent} instance.
+ *
+ * @param user The user associated with the failed fileset operation.
+ * @param identifier The identifier of the fileset that was involved in the failed operation.
+ * @param exception The exception that was thrown during the fileset operation, indicating the
+ * cause of the failure.
+ */
+ public LoadFilesetFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/com/datastrato/gravitino/listener/api/info/FilesetInfo.java b/core/src/main/java/com/datastrato/gravitino/listener/api/info/FilesetInfo.java
new file mode 100644
index 0000000000..eb81f86510
--- /dev/null
+++ b/core/src/main/java/com/datastrato/gravitino/listener/api/info/FilesetInfo.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2024 Datastrato Pvt Ltd.
+ * This software is licensed under the Apache License version 2.
+ */
+
+package com.datastrato.gravitino.listener.api.info;
+
+import com.datastrato.gravitino.Audit;
+import com.datastrato.gravitino.annotation.DeveloperApi;
+import com.datastrato.gravitino.file.Fileset;
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import javax.annotation.Nullable;
+
+@DeveloperApi
+public final class FilesetInfo {
+ private final String name;
+ @Nullable private final String comment;
+ private final Fileset.Type type;
+ private final String storageLocation;
+ private final Map<String, String> properties;
+ @Nullable private final Audit audit;
+
+ public FilesetInfo(Fileset fileset) {
+ this(
+ fileset.name(),
+ fileset.comment(),
+ fileset.type(),
+ fileset.storageLocation(),
+ fileset.properties(),
+ fileset.auditInfo());
+ }
+
+ public FilesetInfo(
+ String name,
+ String comment,
+ Fileset.Type type,
+ String storageLocation,
+ Map<String, String> properties,
+ Audit audit) {
+ this.name = name;
+ this.comment = comment;
+ this.type = type;
+ this.storageLocation = storageLocation;
+ if (properties == null) {
+ this.properties = ImmutableMap.of();
+ } else {
+ this.properties = ImmutableMap.<String, String>builder().putAll(properties).build();
+ }
+ this.audit = audit;
+ }
+
+ @Nullable
+ public Audit auditInfo() {
+ return audit;
+ }
+
+ public String name() {
+ return name;
+ }
+
+ public Fileset.Type getType() {
+ return type;
+ }
+
+ public String getStorageLocation() {
+ return storageLocation;
+ }
+
+ @Nullable
+ public String comment() {
+ return comment;
+ }
+
+ public Map<String, String> properties() {
+ return properties;
+ }
+}
diff --git a/server/src/main/java/com/datastrato/gravitino/server/GravitinoServer.java b/server/src/main/java/com/datastrato/gravitino/server/GravitinoServer.java
index 67756319a6..9c7ba40a3a 100644
--- a/server/src/main/java/com/datastrato/gravitino/server/GravitinoServer.java
+++ b/server/src/main/java/com/datastrato/gravitino/server/GravitinoServer.java
@@ -7,7 +7,7 @@ package com.datastrato.gravitino.server;
import com.datastrato.gravitino.Configs;
import com.datastrato.gravitino.GravitinoEnv;
import com.datastrato.gravitino.catalog.CatalogManager;
-import com.datastrato.gravitino.catalog.FilesetOperationDispatcher;
+import com.datastrato.gravitino.catalog.FilesetDispatcher;
import com.datastrato.gravitino.catalog.SchemaOperationDispatcher;
import com.datastrato.gravitino.catalog.TableDispatcher;
import com.datastrato.gravitino.metalake.MetalakeManager;
@@ -83,9 +83,7 @@ public class GravitinoServer extends ResourceConfig {
.to(SchemaOperationDispatcher.class)
.ranked(1);
bind(gravitinoEnv.tableDispatcher()).to(TableDispatcher.class).ranked(1);
- bind(gravitinoEnv.filesetOperationDispatcher())
- .to(FilesetOperationDispatcher.class)
- .ranked(1);
+ bind(gravitinoEnv.filesetDispatcher()).to(FilesetDispatcher.class).ranked(1);
bind(gravitinoEnv.topicOperationDispatcher())
.to(com.datastrato.gravitino.catalog.TopicOperationDispatcher.class)
.ranked(1);
diff --git a/server/src/main/java/com/datastrato/gravitino/server/web/rest/FilesetOperations.java b/server/src/main/java/com/datastrato/gravitino/server/web/rest/FilesetOperations.java
index 49f245b072..1611422ae9 100644
--- a/server/src/main/java/com/datastrato/gravitino/server/web/rest/FilesetOperations.java
+++ b/server/src/main/java/com/datastrato/gravitino/server/web/rest/FilesetOperations.java
@@ -8,7 +8,7 @@ import com.codahale.metrics.annotation.ResponseMetered;
import com.codahale.metrics.annotation.Timed;
import com.datastrato.gravitino.NameIdentifier;
import com.datastrato.gravitino.Namespace;
-import com.datastrato.gravitino.catalog.FilesetOperationDispatcher;
+import com.datastrato.gravitino.catalog.FilesetDispatcher;
import com.datastrato.gravitino.dto.requests.FilesetCreateRequest;
import com.datastrato.gravitino.dto.requests.FilesetUpdateRequest;
import com.datastrato.gravitino.dto.requests.FilesetUpdatesRequest;
@@ -42,12 +42,12 @@ public class FilesetOperations {
private static final Logger LOG = LoggerFactory.getLogger(FilesetOperations.class);
- private final FilesetOperationDispatcher dispatcher;
+ private final FilesetDispatcher dispatcher;
@Context private HttpServletRequest httpRequest;
@Inject
- public FilesetOperations(FilesetOperationDispatcher dispatcher) {
+ public FilesetOperations(FilesetDispatcher dispatcher) {
this.dispatcher = dispatcher;
}
diff --git a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestFilesetOperations.java b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestFilesetOperations.java
index 0d1112cda0..f998b4ce47 100644
--- a/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestFilesetOperations.java
+++ b/server/src/test/java/com/datastrato/gravitino/server/web/rest/TestFilesetOperations.java
@@ -16,6 +16,7 @@ import com.datastrato.gravitino.Audit;
import com.datastrato.gravitino.Config;
import com.datastrato.gravitino.GravitinoEnv;
import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.FilesetDispatcher;
import com.datastrato.gravitino.catalog.FilesetOperationDispatcher;
import com.datastrato.gravitino.dto.file.FilesetDTO;
import com.datastrato.gravitino.dto.requests.FilesetCreateRequest;
@@ -94,7 +95,7 @@ public class TestFilesetOperations extends JerseyTest {
new AbstractBinder() {
@Override
protected void configure() {
- bind(dispatcher).to(FilesetOperationDispatcher.class).ranked(2);
+ bind(dispatcher).to(FilesetDispatcher.class).ranked(2);
bindFactory(MockServletRequestFactory.class).to(HttpServletRequest.class);
}
});