This is an automated email from the ASF dual-hosted git repository.

fanng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/main by this push:
     new b43277a9f0 [#10492] Improvment: Add events for enable / disable 
metalake and catalog (#10488)
b43277a9f0 is described below

commit b43277a9f030d8570752a7a8fbc096aafaacc345
Author: Abhijeet Singh <[email protected]>
AuthorDate: Thu Mar 26 14:23:22 2026 +0530

    [#10492] Improvment: Add events for enable / disable metalake and catalog 
(#10488)
    
    ### What changes were proposed in this pull request?
    
    Add event dispatching support for metalake and catalog enable/disable
    (in-use toggle) operations. Previously, MetalakeEventDispatcher and
    CatalogEventDispatcher had TODO placeholders for these operations and
    silently delegated without emitting any events.
    ### Why are the changes needed?
    
    we need to consume these events.
    
    Fix: #10492
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    (Please list the user-facing changes introduced by your change,
    including
      1. Change in user-facing APIs.
      2. Addition or removal of property keys.)
    
    ### How was this patch tested?
    
    we have a EventListenerPlugin I tested it by logging events and toggling
    in-use on and off in UI
    
    (Please test your changes, and provide instructions on how to test it:
    1. If you add a feature or fix a bug, add a test to cover your changes.
    2. If you fix a flaky test, repeat it for many times to prove it works.)
    
    ---------
    
    Co-authored-by: Abhijeet Singh <[email protected]>
---
 .../java/org/apache/gravitino/audit/AuditLog.java  | 28 ++++++++++
 .../gravitino/audit/v2/CompatibilityUtils.java     |  4 ++
 .../gravitino/listener/CatalogEventDispatcher.java | 28 ++++++++--
 .../listener/MetalakeEventDispatcher.java          | 28 ++++++++--
 .../listener/api/event/DisableCatalogEvent.java    | 43 +++++++++++++++
 .../api/event/DisableCatalogFailureEvent.java      | 43 +++++++++++++++
 .../listener/api/event/DisableCatalogPreEvent.java | 43 +++++++++++++++
 .../listener/api/event/DisableMetalakeEvent.java   | 43 +++++++++++++++
 .../api/event/DisableMetalakeFailureEvent.java     | 43 +++++++++++++++
 .../api/event/DisableMetalakePreEvent.java         | 43 +++++++++++++++
 .../listener/api/event/EnableCatalogEvent.java     | 43 +++++++++++++++
 .../api/event/EnableCatalogFailureEvent.java       | 43 +++++++++++++++
 .../listener/api/event/EnableCatalogPreEvent.java  | 43 +++++++++++++++
 .../listener/api/event/EnableMetalakeEvent.java    | 43 +++++++++++++++
 .../api/event/EnableMetalakeFailureEvent.java      | 43 +++++++++++++++
 .../listener/api/event/EnableMetalakePreEvent.java | 43 +++++++++++++++
 .../listener/api/event/OperationType.java          |  4 ++
 .../org/apache/gravitino/audit/TestOperation.java  | 46 ++++++++++++++++
 .../gravitino/audit/v2/TestCompatibilityUtils.java |  4 ++
 .../listener/api/event/TestCatalogEvent.java       | 64 ++++++++++++++++++++++
 .../listener/api/event/TestMetalakeEvent.java      | 64 ++++++++++++++++++++++
 21 files changed, 778 insertions(+), 8 deletions(-)

diff --git a/core/src/main/java/org/apache/gravitino/audit/AuditLog.java 
b/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
index 3ff613c37b..e1b77f5ecb 100644
--- a/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
+++ b/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
@@ -45,6 +45,10 @@ import 
org.apache.gravitino.listener.api.event.CreateTableEvent;
 import org.apache.gravitino.listener.api.event.CreateTableFailureEvent;
 import org.apache.gravitino.listener.api.event.CreateTopicEvent;
 import org.apache.gravitino.listener.api.event.CreateTopicFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogFailureEvent;
 import org.apache.gravitino.listener.api.event.DropFilesetEvent;
@@ -57,6 +61,10 @@ import 
org.apache.gravitino.listener.api.event.DropTableEvent;
 import org.apache.gravitino.listener.api.event.DropTableFailureEvent;
 import org.apache.gravitino.listener.api.event.DropTopicEvent;
 import org.apache.gravitino.listener.api.event.DropTopicFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.Event;
 import org.apache.gravitino.listener.api.event.EventSource;
 import org.apache.gravitino.listener.api.event.GetFileLocationEvent;
@@ -201,6 +209,10 @@ public interface AuditLog {
 
     LIST_METALAKE,
 
+    ENABLE_METALAKE,
+
+    DISABLE_METALAKE,
+
     CREATE_CATALOG,
 
     LOAD_CATALOG,
@@ -211,6 +223,10 @@ public interface AuditLog {
 
     LIST_CATALOG,
 
+    ENABLE_CATALOG,
+
+    DISABLE_CATALOG,
+
     CREATE_SCHEMA,
 
     ALTER_SCHEMA,
@@ -277,6 +293,12 @@ public interface AuditLog {
         return LOAD_METALAKE;
       } else if (event instanceof ListMetalakeEvent || event instanceof 
ListMetalakeFailureEvent) {
         return LIST_METALAKE;
+      } else if (event instanceof EnableMetalakeEvent
+          || event instanceof EnableMetalakeFailureEvent) {
+        return ENABLE_METALAKE;
+      } else if (event instanceof DisableMetalakeEvent
+          || event instanceof DisableMetalakeFailureEvent) {
+        return DISABLE_METALAKE;
       } else if (event instanceof CreateCatalogEvent
           || event instanceof CreateCatalogFailureEvent) {
         return CREATE_CATALOG;
@@ -288,6 +310,12 @@ public interface AuditLog {
         return LOAD_CATALOG;
       } else if (event instanceof ListCatalogEvent || event instanceof 
ListCatalogFailureEvent) {
         return LIST_CATALOG;
+      } else if (event instanceof EnableCatalogEvent
+          || event instanceof EnableCatalogFailureEvent) {
+        return ENABLE_CATALOG;
+      } else if (event instanceof DisableCatalogEvent
+          || event instanceof DisableCatalogFailureEvent) {
+        return DISABLE_CATALOG;
       } else if (event instanceof CreateSchemaEvent || event instanceof 
CreateSchemaFailureEvent) {
         return CREATE_SCHEMA;
       } else if (event instanceof AlterSchemaEvent || event instanceof 
AlterSchemaFailureEvent) {
diff --git 
a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java 
b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
index 6027809e4c..99c8911012 100644
--- a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
+++ b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
@@ -35,6 +35,8 @@ public class CompatibilityUtils {
           .put(OperationType.DROP_METALAKE, Operation.DROP_METALAKE)
           .put(OperationType.LOAD_METALAKE, Operation.LOAD_METALAKE)
           .put(OperationType.LIST_METALAKE, Operation.LIST_METALAKE)
+          .put(OperationType.ENABLE_METALAKE, Operation.ENABLE_METALAKE)
+          .put(OperationType.DISABLE_METALAKE, Operation.DISABLE_METALAKE)
 
           // Catalog operation
           .put(OperationType.CREATE_CATALOG, Operation.CREATE_CATALOG)
@@ -42,6 +44,8 @@ public class CompatibilityUtils {
           .put(OperationType.DROP_CATALOG, Operation.DROP_CATALOG)
           .put(OperationType.LOAD_CATALOG, Operation.LOAD_CATALOG)
           .put(OperationType.LIST_CATALOG, Operation.LIST_CATALOG)
+          .put(OperationType.ENABLE_CATALOG, Operation.ENABLE_CATALOG)
+          .put(OperationType.DISABLE_CATALOG, Operation.DISABLE_CATALOG)
 
           // Schema operation
           .put(OperationType.CREATE_SCHEMA, Operation.CREATE_SCHEMA)
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java 
b/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java
index 782ef7df4e..afaf131593 100644
--- 
a/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java
+++ 
b/core/src/main/java/org/apache/gravitino/listener/CatalogEventDispatcher.java
@@ -37,9 +37,15 @@ import 
org.apache.gravitino.listener.api.event.AlterCatalogPreEvent;
 import org.apache.gravitino.listener.api.event.CreateCatalogEvent;
 import org.apache.gravitino.listener.api.event.CreateCatalogFailureEvent;
 import org.apache.gravitino.listener.api.event.CreateCatalogPreEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogPreEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogFailureEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogPreEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogPreEvent;
 import org.apache.gravitino.listener.api.event.ListCatalogEvent;
 import org.apache.gravitino.listener.api.event.ListCatalogFailureEvent;
 import org.apache.gravitino.listener.api.event.ListCatalogPreEvent;
@@ -192,13 +198,27 @@ public class CatalogEventDispatcher implements 
CatalogDispatcher {
   @Override
   public void enableCatalog(NameIdentifier ident)
       throws NoSuchCatalogException, CatalogNotInUseException {
-    // todo: support enable catalog event
-    dispatcher.enableCatalog(ident);
+    eventBus.dispatchEvent(new 
EnableCatalogPreEvent(PrincipalUtils.getCurrentUserName(), ident));
+    try {
+      dispatcher.enableCatalog(ident);
+      eventBus.dispatchEvent(new 
EnableCatalogEvent(PrincipalUtils.getCurrentUserName(), ident));
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new EnableCatalogFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
   }
 
   @Override
   public void disableCatalog(NameIdentifier ident) throws 
NoSuchCatalogException {
-    // todo: support disable catalog event
-    dispatcher.disableCatalog(ident);
+    eventBus.dispatchEvent(new 
DisableCatalogPreEvent(PrincipalUtils.getCurrentUserName(), ident));
+    try {
+      dispatcher.disableCatalog(ident);
+      eventBus.dispatchEvent(new 
DisableCatalogEvent(PrincipalUtils.getCurrentUserName(), ident));
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new DisableCatalogFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
   }
 }
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/MetalakeEventDispatcher.java 
b/core/src/main/java/org/apache/gravitino/listener/MetalakeEventDispatcher.java
index 0ff109a483..02dbce3f6c 100644
--- 
a/core/src/main/java/org/apache/gravitino/listener/MetalakeEventDispatcher.java
+++ 
b/core/src/main/java/org/apache/gravitino/listener/MetalakeEventDispatcher.java
@@ -33,9 +33,15 @@ import 
org.apache.gravitino.listener.api.event.AlterMetalakePreEvent;
 import org.apache.gravitino.listener.api.event.CreateMetalakeEvent;
 import org.apache.gravitino.listener.api.event.CreateMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.CreateMetalakePreEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakePreEvent;
 import org.apache.gravitino.listener.api.event.DropMetalakeEvent;
 import org.apache.gravitino.listener.api.event.DropMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.DropMetalakePreEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakePreEvent;
 import org.apache.gravitino.listener.api.event.ListMetalakeEvent;
 import org.apache.gravitino.listener.api.event.ListMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.ListMetalakePreEvent;
@@ -161,13 +167,27 @@ public class MetalakeEventDispatcher implements 
MetalakeDispatcher {
 
   @Override
   public void enableMetalake(NameIdentifier ident) throws 
NoSuchMetalakeException {
-    // todo: support enable metalake event
-    dispatcher.enableMetalake(ident);
+    eventBus.dispatchEvent(new 
EnableMetalakePreEvent(PrincipalUtils.getCurrentUserName(), ident));
+    try {
+      dispatcher.enableMetalake(ident);
+      eventBus.dispatchEvent(new 
EnableMetalakeEvent(PrincipalUtils.getCurrentUserName(), ident));
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new EnableMetalakeFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
   }
 
   @Override
   public void disableMetalake(NameIdentifier ident) throws 
NoSuchMetalakeException {
-    // todo: support disable metalake event
-    dispatcher.disableMetalake(ident);
+    eventBus.dispatchEvent(new 
DisableMetalakePreEvent(PrincipalUtils.getCurrentUserName(), ident));
+    try {
+      dispatcher.disableMetalake(ident);
+      eventBus.dispatchEvent(new 
DisableMetalakeEvent(PrincipalUtils.getCurrentUserName(), ident));
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new DisableMetalakeFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
   }
 }
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogEvent.java
new file mode 100644
index 0000000000..7ffb8fea0b
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered upon successfully disabling a 
catalog. */
+@DeveloperApi
+public final class DisableCatalogEvent extends CatalogEvent {
+
+  /**
+   * Constructs an instance of {@code DisableCatalogEvent}.
+   *
+   * @param user The username of the individual who initiated the catalog 
disabling operation.
+   * @param identifier The identifier of the disabled catalog.
+   */
+  public DisableCatalogEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogFailureEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogFailureEvent.java
new file mode 100644
index 0000000000..2e8251435e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogFailureEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered when an attempt to disable a catalog 
fails. */
+@DeveloperApi
+public final class DisableCatalogFailureEvent extends CatalogFailureEvent {
+  /**
+   * Constructs an instance of {@code DisableCatalogFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the catalog 
disablement.
+   * @param identifier The identifier of the catalog that failed to be 
disabled.
+   * @param exception The exception that was encountered during the catalog 
disablement attempt.
+   */
+  public DisableCatalogFailureEvent(String user, NameIdentifier identifier, 
Exception exception) {
+    super(user, identifier, exception);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogPreEvent.java
new file mode 100644
index 0000000000..d71f85dd2e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableCatalogPreEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is generated before a catalog is disabled. */
+@DeveloperApi
+public final class DisableCatalogPreEvent extends CatalogPreEvent {
+
+  /**
+   * Constructs an instance of {@code DisableCatalogPreEvent}.
+   *
+   * @param user The username of the individual who initiated the disable 
catalog operation.
+   * @param identifier The identifier of the catalog to be disabled.
+   */
+  public DisableCatalogPreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeEvent.java
new file mode 100644
index 0000000000..47f95d9fa8
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered upon successfully disabling a 
metalake. */
+@DeveloperApi
+public final class DisableMetalakeEvent extends MetalakeEvent {
+
+  /**
+   * Constructs an instance of {@code DisableMetalakeEvent}.
+   *
+   * @param user The username of the individual who initiated the metalake 
disabling operation.
+   * @param identifier The identifier of the disabled metalake.
+   */
+  public DisableMetalakeEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeFailureEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeFailureEvent.java
new file mode 100644
index 0000000000..1cd1e8fbed
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakeFailureEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered when an attempt to disable a 
metalake fails. */
+@DeveloperApi
+public final class DisableMetalakeFailureEvent extends MetalakeFailureEvent {
+  /**
+   * Constructs an instance of {@code DisableMetalakeFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the metalake 
disablement.
+   * @param identifier The identifier of the metalake that failed to be 
disabled.
+   * @param exception The exception that was encountered during the metalake 
disablement attempt.
+   */
+  public DisableMetalakeFailureEvent(String user, NameIdentifier identifier, 
Exception exception) {
+    super(user, identifier, exception);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakePreEvent.java
new file mode 100644
index 0000000000..92982f59a0
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DisableMetalakePreEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event triggered before disabling a metalake. */
+@DeveloperApi
+public class DisableMetalakePreEvent extends MetalakePreEvent {
+
+  /**
+   * Constructs an instance of {@code DisableMetalakePreEvent}.
+   *
+   * @param user The username of the individual who initiated the disable 
metalake operation.
+   * @param identifier The identifier of the metalake to be disabled.
+   */
+  public DisableMetalakePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.DISABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogEvent.java
new file mode 100644
index 0000000000..5af3e97239
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered upon successfully enabling a 
catalog. */
+@DeveloperApi
+public final class EnableCatalogEvent extends CatalogEvent {
+
+  /**
+   * Constructs an instance of {@code EnableCatalogEvent}.
+   *
+   * @param user The username of the individual who initiated the catalog 
enabling operation.
+   * @param identifier The identifier of the enabled catalog.
+   */
+  public EnableCatalogEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogFailureEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogFailureEvent.java
new file mode 100644
index 0000000000..b96971dd46
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogFailureEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered when an attempt to enable a catalog 
fails. */
+@DeveloperApi
+public final class EnableCatalogFailureEvent extends CatalogFailureEvent {
+  /**
+   * Constructs an instance of {@code EnableCatalogFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the catalog 
enablement.
+   * @param identifier The identifier of the catalog that failed to be enabled.
+   * @param exception The exception that was encountered during the catalog 
enablement attempt.
+   */
+  public EnableCatalogFailureEvent(String user, NameIdentifier identifier, 
Exception exception) {
+    super(user, identifier, exception);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogPreEvent.java
new file mode 100644
index 0000000000..c3c25a4e45
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableCatalogPreEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is generated before a catalog is enabled. */
+@DeveloperApi
+public final class EnableCatalogPreEvent extends CatalogPreEvent {
+
+  /**
+   * Constructs an instance of {@code EnableCatalogPreEvent}.
+   *
+   * @param user The username of the individual who initiated the enable 
catalog operation.
+   * @param identifier The identifier of the catalog to be enabled.
+   */
+  public EnableCatalogPreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_CATALOG;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeEvent.java
new file mode 100644
index 0000000000..8690912edf
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered upon successfully enabling a 
metalake. */
+@DeveloperApi
+public final class EnableMetalakeEvent extends MetalakeEvent {
+
+  /**
+   * Constructs an instance of {@code EnableMetalakeEvent}.
+   *
+   * @param user The username of the individual who initiated the metalake 
enabling operation.
+   * @param identifier The identifier of the enabled metalake.
+   */
+  public EnableMetalakeEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeFailureEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeFailureEvent.java
new file mode 100644
index 0000000000..c691e4ae2f
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakeFailureEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered when an attempt to enable a metalake 
fails. */
+@DeveloperApi
+public final class EnableMetalakeFailureEvent extends MetalakeFailureEvent {
+  /**
+   * Constructs an instance of {@code EnableMetalakeFailureEvent}.
+   *
+   * @param user The username of the individual who initiated the metalake 
enablement.
+   * @param identifier The identifier of the metalake that failed to be 
enabled.
+   * @param exception The exception that was encountered during the metalake 
enablement attempt.
+   */
+  public EnableMetalakeFailureEvent(String user, NameIdentifier identifier, 
Exception exception) {
+    super(user, identifier, exception);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakePreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakePreEvent.java
new file mode 100644
index 0000000000..90e97a123e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/EnableMetalakePreEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event triggered before enabling a metalake. */
+@DeveloperApi
+public class EnableMetalakePreEvent extends MetalakePreEvent {
+
+  /**
+   * Constructs an instance of {@code EnableMetalakePreEvent}.
+   *
+   * @param user The username of the individual who initiated the enable 
metalake operation.
+   * @param identifier The identifier of the metalake to be enabled.
+   */
+  public EnableMetalakePreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  @Override
+  public OperationType operationType() {
+    return OperationType.ENABLE_METALAKE;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java 
b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java
index b2ea3c8b3c..948c50caa2 100644
--- 
a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java
@@ -69,6 +69,8 @@ public enum OperationType {
   ALTER_CATALOG,
   LOAD_CATALOG,
   LIST_CATALOG,
+  ENABLE_CATALOG,
+  DISABLE_CATALOG,
 
   // Partition event
   ADD_PARTITION,
@@ -92,6 +94,8 @@ public enum OperationType {
   LIST_METALAKE,
   DROP_METALAKE,
   LOAD_METALAKE,
+  ENABLE_METALAKE,
+  DISABLE_METALAKE,
 
   // View event
   CREATE_VIEW,
diff --git a/core/src/test/java/org/apache/gravitino/audit/TestOperation.java 
b/core/src/test/java/org/apache/gravitino/audit/TestOperation.java
index cd0bc9da91..3a9bedb983 100644
--- a/core/src/test/java/org/apache/gravitino/audit/TestOperation.java
+++ b/core/src/test/java/org/apache/gravitino/audit/TestOperation.java
@@ -54,6 +54,10 @@ import 
org.apache.gravitino.listener.api.event.CreateTableEvent;
 import org.apache.gravitino.listener.api.event.CreateTableFailureEvent;
 import org.apache.gravitino.listener.api.event.CreateTopicEvent;
 import org.apache.gravitino.listener.api.event.CreateTopicFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogEvent;
+import org.apache.gravitino.listener.api.event.DisableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.DisableMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogEvent;
 import org.apache.gravitino.listener.api.event.DropCatalogFailureEvent;
 import org.apache.gravitino.listener.api.event.DropFilesetEvent;
@@ -66,6 +70,10 @@ import 
org.apache.gravitino.listener.api.event.DropTableEvent;
 import org.apache.gravitino.listener.api.event.DropTableFailureEvent;
 import org.apache.gravitino.listener.api.event.DropTopicEvent;
 import org.apache.gravitino.listener.api.event.DropTopicFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogEvent;
+import org.apache.gravitino.listener.api.event.EnableCatalogFailureEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeEvent;
+import org.apache.gravitino.listener.api.event.EnableMetalakeFailureEvent;
 import org.apache.gravitino.listener.api.event.Event;
 import org.apache.gravitino.listener.api.event.GetFileLocationEvent;
 import org.apache.gravitino.listener.api.event.GetFileLocationFailureEvent;
@@ -483,6 +491,44 @@ public class TestOperation {
         AuditLog.Operation.fromEvent(loadTopicFailureEvent), 
AuditLog.Operation.LOAD_TOPIC);
   }
 
+  @Test
+  public void testEnableDisableOperation() {
+    Event enableMetalakeEvent = new EnableMetalakeEvent(USER, 
metalakeIdentifier);
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(enableMetalakeEvent), 
AuditLog.Operation.ENABLE_METALAKE);
+    Event enableMetalakeFailureEvent =
+        new EnableMetalakeFailureEvent(USER, metalakeIdentifier, new 
Exception());
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(enableMetalakeFailureEvent),
+        AuditLog.Operation.ENABLE_METALAKE);
+
+    Event disableMetalakeEvent = new DisableMetalakeEvent(USER, 
metalakeIdentifier);
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(disableMetalakeEvent), 
AuditLog.Operation.DISABLE_METALAKE);
+    Event disableMetalakeFailureEvent =
+        new DisableMetalakeFailureEvent(USER, metalakeIdentifier, new 
Exception());
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(disableMetalakeFailureEvent),
+        AuditLog.Operation.DISABLE_METALAKE);
+
+    Event enableCatalogEvent = new EnableCatalogEvent(USER, catalogIdentifier);
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(enableCatalogEvent), 
AuditLog.Operation.ENABLE_CATALOG);
+    Event enableCatalogFailureEvent =
+        new EnableCatalogFailureEvent(USER, catalogIdentifier, new 
Exception());
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(enableCatalogFailureEvent), 
AuditLog.Operation.ENABLE_CATALOG);
+
+    Event disableCatalogEvent = new DisableCatalogEvent(USER, 
catalogIdentifier);
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(disableCatalogEvent), 
AuditLog.Operation.DISABLE_CATALOG);
+    Event disableCatalogFailureEvent =
+        new DisableCatalogFailureEvent(USER, catalogIdentifier, new 
Exception());
+    Assertions.assertEquals(
+        AuditLog.Operation.fromEvent(disableCatalogFailureEvent),
+        AuditLog.Operation.DISABLE_CATALOG);
+  }
+
   @Test
   public void testExistsOperation() {
     Event partitionExistsEvent =
diff --git 
a/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java 
b/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java
index 3021fdd56c..5ddf3c834d 100644
--- 
a/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java
+++ 
b/core/src/test/java/org/apache/gravitino/audit/v2/TestCompatibilityUtils.java
@@ -38,11 +38,15 @@ public class TestCompatibilityUtils {
       {OperationType.DROP_METALAKE, Operation.DROP_METALAKE},
       {OperationType.LOAD_METALAKE, Operation.LOAD_METALAKE},
       {OperationType.LIST_METALAKE, Operation.LIST_METALAKE},
+      {OperationType.ENABLE_METALAKE, Operation.ENABLE_METALAKE},
+      {OperationType.DISABLE_METALAKE, Operation.DISABLE_METALAKE},
       {OperationType.CREATE_CATALOG, Operation.CREATE_CATALOG},
       {OperationType.ALTER_CATALOG, Operation.ALTER_CATALOG},
       {OperationType.DROP_CATALOG, Operation.DROP_CATALOG},
       {OperationType.LOAD_CATALOG, Operation.LOAD_CATALOG},
       {OperationType.LIST_CATALOG, Operation.LIST_CATALOG},
+      {OperationType.ENABLE_CATALOG, Operation.ENABLE_CATALOG},
+      {OperationType.DISABLE_CATALOG, Operation.DISABLE_CATALOG},
       {OperationType.CREATE_SCHEMA, Operation.CREATE_SCHEMA},
       {OperationType.ALTER_SCHEMA, Operation.ALTER_SCHEMA},
       {OperationType.DROP_SCHEMA, Operation.DROP_SCHEMA},
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestCatalogEvent.java
 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestCatalogEvent.java
index f334f8c166..0bbb7caff2 100644
--- 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestCatalogEvent.java
+++ 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestCatalogEvent.java
@@ -184,6 +184,40 @@ public class TestCatalogEvent {
     Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
+  @Test
+  void testEnableCatalogEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake", catalog.name());
+    dispatcher.enableCatalog(identifier);
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(EnableCatalogEvent.class, event.getClass());
+    Assertions.assertEquals(OperationType.ENABLE_CATALOG, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(EnableCatalogPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.ENABLE_CATALOG, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
+  }
+
+  @Test
+  void testDisableCatalogEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake", catalog.name());
+    dispatcher.disableCatalog(identifier);
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(DisableCatalogEvent.class, event.getClass());
+    Assertions.assertEquals(OperationType.DISABLE_CATALOG, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(DisableCatalogPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.DISABLE_CATALOG, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
+  }
+
   @Test
   void testCreateCatalogFailureEvent() {
     NameIdentifier identifier = NameIdentifier.of("metalake", catalog.name());
@@ -254,6 +288,36 @@ public class TestCatalogEvent {
     Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
   }
 
+  @Test
+  void testEnableCatalogFailureEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake", catalog.name());
+    Assertions.assertThrowsExactly(
+        GravitinoRuntimeException.class, () -> 
failureDispatcher.enableCatalog(identifier));
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(EnableCatalogFailureEvent.class, event.getClass());
+    Assertions.assertEquals(
+        GravitinoRuntimeException.class,
+        ((EnableCatalogFailureEvent) event).exception().getClass());
+    Assertions.assertEquals(OperationType.ENABLE_CATALOG, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+  }
+
+  @Test
+  void testDisableCatalogFailureEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake", catalog.name());
+    Assertions.assertThrowsExactly(
+        GravitinoRuntimeException.class, () -> 
failureDispatcher.disableCatalog(identifier));
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(DisableCatalogFailureEvent.class, 
event.getClass());
+    Assertions.assertEquals(
+        GravitinoRuntimeException.class,
+        ((DisableCatalogFailureEvent) event).exception().getClass());
+    Assertions.assertEquals(OperationType.DISABLE_CATALOG, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+  }
+
   @Test
   void testListCatalogFailureEvent() {
     Namespace namespace = Namespace.of("metalake", "catalog");
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestMetalakeEvent.java
 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestMetalakeEvent.java
index 0eafd111b9..1a45ed9363 100644
--- 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestMetalakeEvent.java
+++ 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestMetalakeEvent.java
@@ -160,6 +160,40 @@ public class TestMetalakeEvent {
     Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
+  @Test
+  void testEnableMetalakeEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake");
+    dispatcher.enableMetalake(identifier);
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(EnableMetalakeEvent.class, event.getClass());
+    Assertions.assertEquals(OperationType.ENABLE_METALAKE, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(EnableMetalakePreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.ENABLE_METALAKE, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
+  }
+
+  @Test
+  void testDisableMetalakeEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake");
+    dispatcher.disableMetalake(identifier);
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(DisableMetalakeEvent.class, event.getClass());
+    Assertions.assertEquals(OperationType.DISABLE_METALAKE, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(DisableMetalakePreEvent.class, 
preEvent.getClass());
+    Assertions.assertEquals(OperationType.DISABLE_METALAKE, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
+  }
+
   @Test
   void testCreateMetalakeFailureEvent() {
     NameIdentifier identifier = NameIdentifier.of(metalake.name());
@@ -227,6 +261,36 @@ public class TestMetalakeEvent {
     Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
   }
 
+  @Test
+  void testEnableMetalakeFailureEvent() {
+    NameIdentifier identifier = NameIdentifier.of(metalake.name());
+    Assertions.assertThrowsExactly(
+        GravitinoRuntimeException.class, () -> 
failureDispatcher.enableMetalake(identifier));
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(EnableMetalakeFailureEvent.class, 
event.getClass());
+    Assertions.assertEquals(
+        GravitinoRuntimeException.class,
+        ((EnableMetalakeFailureEvent) event).exception().getClass());
+    Assertions.assertEquals(OperationType.ENABLE_METALAKE, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+  }
+
+  @Test
+  void testDisableMetalakeFailureEvent() {
+    NameIdentifier identifier = NameIdentifier.of(metalake.name());
+    Assertions.assertThrowsExactly(
+        GravitinoRuntimeException.class, () -> 
failureDispatcher.disableMetalake(identifier));
+    Event event = dummyEventListener.popPostEvent();
+    Assertions.assertEquals(identifier, event.identifier());
+    Assertions.assertEquals(DisableMetalakeFailureEvent.class, 
event.getClass());
+    Assertions.assertEquals(
+        GravitinoRuntimeException.class,
+        ((DisableMetalakeFailureEvent) event).exception().getClass());
+    Assertions.assertEquals(OperationType.DISABLE_METALAKE, 
event.operationType());
+    Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+  }
+
   @Test
   void testListMetalakeFailureEvent() {
     Assertions.assertThrowsExactly(

Reply via email to