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 c1b988520 [#5550] feat(core): add partition pre event to Gravitino 
event (#5590)
c1b988520 is described below

commit c1b988520e9a933e1784c8bda098060c543b096f
Author: Qiang-Liu <[email protected]>
AuthorDate: Mon Nov 25 16:46:20 2024 +0800

    [#5550] feat(core): add partition pre event to Gravitino event (#5590)
    
    ### What changes were proposed in this pull request?
    
    1. add corresponding PartitionPreEvent
    2. generate pre-event in PartitionEventDispatcher
    3. add test in TestPartitionEvent
    4. add document in gravitino-server-config.md
    
    ### Why are the changes needed?
    
    Fix: #5550
    
    ### Does this PR introduce _any_ user-facing change?
    
    NO
    
    ### How was this patch tested?
    
    UT
---
 .../listener/PartitionEventDispatcher.java         | 18 +++++++
 .../listener/api/event/AddPartitionPreEvent.java   | 57 ++++++++++++++++++++++
 .../listener/api/event/DropPartitionPreEvent.java  | 47 ++++++++++++++++++
 .../listener/api/event/GetPartitionPreEvent.java   | 48 ++++++++++++++++++
 .../api/event/ListPartitionNamesPreEvent.java      | 41 ++++++++++++++++
 .../listener/api/event/ListPartitionPreEvent.java  | 40 +++++++++++++++
 .../listener/api/event/PartitionPreEvent.java      | 31 ++++++++++++
 .../listener/api/event/PurgePartitionPreEvent.java | 47 ++++++++++++++++++
 .../listener/api/event/TestPartitionEvent.java     | 37 ++++++++++++++
 docs/gravitino-server-config.md                    |  1 +
 10 files changed, 367 insertions(+)

diff --git 
a/core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java
 
b/core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java
index 31e51de8c..d439b41a5 100644
--- 
a/core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java
+++ 
b/core/src/main/java/org/apache/gravitino/listener/PartitionEventDispatcher.java
@@ -25,18 +25,24 @@ import 
org.apache.gravitino.exceptions.NoSuchPartitionException;
 import org.apache.gravitino.exceptions.PartitionAlreadyExistsException;
 import org.apache.gravitino.listener.api.event.AddPartitionEvent;
 import org.apache.gravitino.listener.api.event.AddPartitionFailureEvent;
+import org.apache.gravitino.listener.api.event.AddPartitionPreEvent;
 import org.apache.gravitino.listener.api.event.DropPartitionEvent;
 import org.apache.gravitino.listener.api.event.DropPartitionFailureEvent;
+import org.apache.gravitino.listener.api.event.DropPartitionPreEvent;
 import org.apache.gravitino.listener.api.event.GetPartitionEvent;
 import org.apache.gravitino.listener.api.event.GetPartitionFailureEvent;
+import org.apache.gravitino.listener.api.event.GetPartitionPreEvent;
 import org.apache.gravitino.listener.api.event.ListPartitionEvent;
 import org.apache.gravitino.listener.api.event.ListPartitionFailureEvent;
 import org.apache.gravitino.listener.api.event.ListPartitionNamesEvent;
 import org.apache.gravitino.listener.api.event.ListPartitionNamesFailureEvent;
+import org.apache.gravitino.listener.api.event.ListPartitionNamesPreEvent;
+import org.apache.gravitino.listener.api.event.ListPartitionPreEvent;
 import org.apache.gravitino.listener.api.event.PartitionExistsEvent;
 import org.apache.gravitino.listener.api.event.PartitionExistsFailureEvent;
 import org.apache.gravitino.listener.api.event.PurgePartitionEvent;
 import org.apache.gravitino.listener.api.event.PurgePartitionFailureEvent;
+import org.apache.gravitino.listener.api.event.PurgePartitionPreEvent;
 import org.apache.gravitino.listener.api.info.partitions.PartitionInfo;
 import org.apache.gravitino.rel.partitions.Partition;
 import org.apache.gravitino.utils.PrincipalUtils;
@@ -66,6 +72,9 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
   @Override
   public Partition addPartition(NameIdentifier ident, Partition partition)
       throws NoSuchPartitionException, PartitionAlreadyExistsException {
+    eventBus.dispatchEvent(
+        new AddPartitionPreEvent(
+            PrincipalUtils.getCurrentUserName(), ident, 
PartitionInfo.of(partition)));
     try {
       Partition newPartition = dispatcher.addPartition(ident, partition);
       eventBus.dispatchEvent(
@@ -84,6 +93,8 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
   @Override
   public Partition getPartition(NameIdentifier ident, String partitionName)
       throws NoSuchPartitionException {
+    eventBus.dispatchEvent(
+        new GetPartitionPreEvent(PrincipalUtils.getCurrentUserName(), ident, 
partitionName));
     try {
       Partition partition = dispatcher.getPartition(ident, partitionName);
       eventBus.dispatchEvent(
@@ -100,6 +111,8 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
 
   @Override
   public boolean dropPartition(NameIdentifier ident, String partitionName) {
+    eventBus.dispatchEvent(
+        new DropPartitionPreEvent(PrincipalUtils.getCurrentUserName(), ident, 
partitionName));
     try {
       boolean isExists = dispatcher.dropPartition(ident, partitionName);
       eventBus.dispatchEvent(
@@ -116,6 +129,7 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
 
   @Override
   public Partition[] listPartitions(NameIdentifier ident) {
+    eventBus.dispatchEvent(new 
ListPartitionPreEvent(PrincipalUtils.getCurrentUserName(), ident));
     try {
       Partition[] listPartitions = dispatcher.listPartitions(ident);
       eventBus.dispatchEvent(new 
ListPartitionEvent(PrincipalUtils.getCurrentUserName(), ident));
@@ -129,6 +143,8 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
 
   @Override
   public String[] listPartitionNames(NameIdentifier ident) {
+    eventBus.dispatchEvent(
+        new ListPartitionNamesPreEvent(PrincipalUtils.getCurrentUserName(), 
ident));
     try {
       String[] listPartitionNames = dispatcher.listPartitionNames(ident);
       eventBus.dispatchEvent(
@@ -159,6 +175,8 @@ public class PartitionEventDispatcher implements 
PartitionDispatcher {
 
   @Override
   public boolean purgePartition(NameIdentifier ident, String partitionName) {
+    eventBus.dispatchEvent(
+        new PurgePartitionPreEvent(PrincipalUtils.getCurrentUserName(), ident, 
partitionName));
     try {
       boolean isExists = dispatcher.purgePartition(ident, partitionName);
       eventBus.dispatchEvent(
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/AddPartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AddPartitionPreEvent.java
new file mode 100644
index 000000000..cf0c43e8a
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/AddPartitionPreEvent.java
@@ -0,0 +1,57 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.info.TableInfo;
+import org.apache.gravitino.listener.api.info.partitions.PartitionInfo;
+
+/** Represents an event triggered before creating a partition. */
+@DeveloperApi
+public class AddPartitionPreEvent extends PartitionPreEvent {
+
+  private final PartitionInfo createPartitionRequest;
+
+  public AddPartitionPreEvent(
+      String user, NameIdentifier identifier, PartitionInfo 
createPartitionRequest) {
+    super(user, identifier);
+    this.createPartitionRequest = createPartitionRequest;
+  }
+
+  /**
+   * Retrieves the create partition request.
+   *
+   * @return A {@link TableInfo} instance encapsulating the comprehensive 
details of create
+   *     partition request.
+   */
+  public PartitionInfo createdPartitionRequest() {
+    return createPartitionRequest;
+  }
+
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.ADD_PARTITION;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/DropPartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DropPartitionPreEvent.java
new file mode 100644
index 000000000..da677287e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/DropPartitionPreEvent.java
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event that is triggered before dropping a partition. */
+@DeveloperApi
+public class DropPartitionPreEvent extends PartitionPreEvent {
+  private final String partitionName;
+
+  public DropPartitionPreEvent(String user, NameIdentifier identifier, String 
partitionName) {
+    super(user, identifier);
+    this.partitionName = partitionName;
+  }
+
+  public String partitionName() {
+    return partitionName;
+  }
+
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.DROP_PARTITION;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/GetPartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/GetPartitionPreEvent.java
new file mode 100644
index 000000000..f373dfe6e
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/GetPartitionPreEvent.java
@@ -0,0 +1,48 @@
+/*
+ *  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 before getting a partition. */
+@DeveloperApi
+public class GetPartitionPreEvent extends PartitionPreEvent {
+
+  private final String partitionName;
+
+  public GetPartitionPreEvent(String user, NameIdentifier identifier, String 
partitionName) {
+    super(user, identifier);
+    this.partitionName = partitionName;
+  }
+
+  public String partitionName() {
+    return partitionName;
+  }
+
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.LOAD_PARTITION;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionNamesPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionNamesPreEvent.java
new file mode 100644
index 000000000..c81db0ca1
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionNamesPreEvent.java
@@ -0,0 +1,41 @@
+/*
+ *  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 before listing of partition name 
within a namespace. */
+@DeveloperApi
+public class ListPartitionNamesPreEvent extends PartitionPreEvent {
+
+  public ListPartitionNamesPreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.LIST_PARTITION_NAMES;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionPreEvent.java
new file mode 100644
index 000000000..36b87e628
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/ListPartitionPreEvent.java
@@ -0,0 +1,40 @@
+/*
+ *  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 before listing of partition within a 
namespace. */
+@DeveloperApi
+public class ListPartitionPreEvent extends PartitionPreEvent {
+
+  public ListPartitionPreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.LIST_PARTITION;
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/PartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PartitionPreEvent.java
new file mode 100644
index 000000000..3178530a6
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PartitionPreEvent.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents a pre-event for partition operations. */
+@DeveloperApi
+public abstract class PartitionPreEvent extends PreEvent {
+
+  protected PartitionPreEvent(String user, NameIdentifier identifier) {
+    super(user, identifier);
+  }
+}
diff --git 
a/core/src/main/java/org/apache/gravitino/listener/api/event/PurgePartitionPreEvent.java
 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PurgePartitionPreEvent.java
new file mode 100644
index 000000000..5b9f96fcc
--- /dev/null
+++ 
b/core/src/main/java/org/apache/gravitino/listener/api/event/PurgePartitionPreEvent.java
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.gravitino.listener.api.event;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+
+/** Represents an event triggered before purging a partition. */
+@DeveloperApi
+public class PurgePartitionPreEvent extends PartitionPreEvent {
+
+  private final String partitionName;
+
+  public PurgePartitionPreEvent(String user, NameIdentifier identifier, String 
partitionName) {
+    super(user, identifier);
+    this.partitionName = partitionName;
+  }
+
+  public String partitionName() {
+    return partitionName;
+  }
+  /**
+   * Returns the type of operation.
+   *
+   * @return the operation type.
+   */
+  @Override
+  public OperationType operationType() {
+    return OperationType.PURGE_PARTITION;
+  }
+}
diff --git 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestPartitionEvent.java
 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestPartitionEvent.java
index e8d616365..6a5b38993 100644
--- 
a/core/src/test/java/org/apache/gravitino/listener/api/event/TestPartitionEvent.java
+++ 
b/core/src/test/java/org/apache/gravitino/listener/api/event/TestPartitionEvent.java
@@ -117,6 +117,14 @@ public class TestPartitionEvent {
     checkPartitionInfo(partitionInfo, partition);
     Assertions.assertEquals(OperationType.ADD_PARTITION, 
event.operationType());
     Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(AddPartitionPreEvent.class, preEvent.getClass());
+    partitionInfo = ((AddPartitionPreEvent) 
preEvent).createdPartitionRequest();
+    checkPartitionInfo(partitionInfo, partition);
+    Assertions.assertEquals(OperationType.ADD_PARTITION, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
   @Test
@@ -129,6 +137,12 @@ public class TestPartitionEvent {
     Assertions.assertEquals(false, ((DropPartitionEvent) event).isExists());
     Assertions.assertEquals(OperationType.DROP_PARTITION, 
event.operationType());
     Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(DropPartitionPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.DROP_PARTITION, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
   @Test
@@ -153,6 +167,12 @@ public class TestPartitionEvent {
     Assertions.assertEquals(identifier, ((ListPartitionEvent) 
event).identifier());
     Assertions.assertEquals(OperationType.LIST_PARTITION, 
event.operationType());
     Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(ListPartitionPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.LIST_PARTITION, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
   @Test
@@ -165,6 +185,12 @@ public class TestPartitionEvent {
     Assertions.assertEquals(identifier, ((ListPartitionNamesEvent) 
event).identifier());
     Assertions.assertEquals(OperationType.LIST_PARTITION_NAMES, 
event.operationType());
     Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(ListPartitionNamesPreEvent.class, 
preEvent.getClass());
+    Assertions.assertEquals(OperationType.LIST_PARTITION_NAMES, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
   @Test
@@ -177,6 +203,12 @@ public class TestPartitionEvent {
     Assertions.assertEquals(identifier, ((PurgePartitionEvent) 
event).identifier());
     Assertions.assertEquals(OperationType.PURGE_PARTITION, 
event.operationType());
     Assertions.assertEquals(OperationStatus.SUCCESS, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(PurgePartitionPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(OperationType.PURGE_PARTITION, 
preEvent.operationType());
+    Assertions.assertEquals(OperationStatus.UNPROCESSED, 
preEvent.operationStatus());
   }
 
   @Test
@@ -209,6 +241,11 @@ public class TestPartitionEvent {
     Assertions.assertEquals(identifier, event.identifier());
     Assertions.assertEquals(OperationType.DROP_PARTITION, 
event.operationType());
     Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+
+    PreEvent preEvent = dummyEventListener.popPreEvent();
+    Assertions.assertEquals(identifier, preEvent.identifier());
+    Assertions.assertEquals(DropPartitionPreEvent.class, preEvent.getClass());
+    Assertions.assertEquals(partition.name(), ((DropPartitionPreEvent) 
preEvent).partitionName());
   }
 
   @Test
diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.md
index 9049be5b8..4bbf03d25 100644
--- a/docs/gravitino-server-config.md
+++ b/docs/gravitino-server-config.md
@@ -136,6 +136,7 @@ Gravitino triggers a pre-event before the operation, a 
post-event after the comp
 | Gravitino server schema operation   | `CreateSchemaPreEvent`, 
`AlterSchemaPreEvent`, `DropSchemaPreEvent`, `LoadSchemaPreEvent`, 
`ListSchemaPreEvent`                                                            
                                | 0.8.0-incubating  |
 | Gravitino server catalog operation  | `CreateCatalogPreEvent`, 
`AlterCatalogPreEvent`, `DropCatalogPreEvent`, `LoadCatalogPreEvent`, 
`ListCatalogPreEvent`                                                           
                            | 0.8.0-incubating  |
 | Gravitino server metalake operation | `CreateMetalakePreEvent`, 
`AlterMetalakePreEvent`,`DropMetalakePreEvent`,`LoadMetalakePreEvent`,`ListMetalakePreEvent`
                                                                                
     | 0.8.0-incubating |
+| Gravitino server partition operation| `AddPartitionPreEvent`, 
`DropPartitionPreEvent`, `GetPartitionPreEvent`, 
`PurgePartitionPreEvent`,`ListPartitionPreEvent`,`ListPartitionNamesPreEvent`   
                                                  | 0.8.0-incubating |
 
 #### Event listener plugin
 

Reply via email to