FANNG1 commented on code in PR #4102:
URL: https://github.com/apache/gravitino/pull/4102#discussion_r1673217749


##########
core/src/main/java/com/datastrato/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 com.datastrato.gravitino.listener;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.PartitionDispatcher;
+import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
+import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
+import com.datastrato.gravitino.listener.api.event.AddPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.AddPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionNamesEvent;
+import 
com.datastrato.gravitino.listener.api.event.ListPartitionNamesFailureEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.info.PartitionInfo;
+import com.datastrato.gravitino.rel.partitions.Partition;
+import com.datastrato.gravitino.utils.PrincipalUtils;
+
+/**
+ * {@code PartitionEventDispatcher} is a decorator for {@link 
PartitionDispatcher} that not only
+ * delegates partition operations to the underlying partition dispatcher but 
also dispatches
+ * corresponding events to an {@link 
com.datastrato.gravitino.listener.EventBus} after each
+ * operation is completed. This allows for event-driven workflows or 
monitoring of partition
+ * operations.
+ */
+public class PartitionEventDispatcher implements PartitionDispatcher {
+  private final EventBus eventBus;
+  private final PartitionDispatcher dispatcher;
+
+  /**
+   * Constructs a PartitionEventDispatcher with a specified EventBus and 
PartitionDispatcher.
+   *
+   * @param eventBus The EventBus to which events will be dispatched.
+   * @param dispatcher The underlying {@link PartitionDispatcher} that will 
perform the actual
+   *     partition operations.
+   */
+  public PartitionEventDispatcher(EventBus eventBus, PartitionDispatcher 
dispatcher) {
+    this.eventBus = eventBus;
+    this.dispatcher = dispatcher;
+  }
+
+  @Override
+  public Partition addPartition(NameIdentifier ident, Partition partition)
+      throws NoSuchPartitionException, PartitionAlreadyExistsException {
+    try {
+      Partition newPartition = dispatcher.addPartition(ident, partition);
+      eventBus.dispatchEvent(
+          new AddPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(newPartition)));
+      return partition;
+    } catch (Exception e) {
+      PartitionInfo addPartitionRequest = new PartitionInfo(partition);
+      eventBus.dispatchEvent(
+          new AddPartitionFailureEvent(
+              PrincipalUtils.getCurrentUserName(), ident, e, 
addPartitionRequest));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition getPartition(NameIdentifier ident, String partitionName)
+      throws NoSuchPartitionException {
+    try {
+      Partition partition = dispatcher.getPartition(ident, partitionName);
+      eventBus.dispatchEvent(
+          new GetPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(partition)));
+      return partition;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new GetPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean dropPartition(NameIdentifier ident, String name) {
+    try {
+      boolean isExists = dispatcher.dropPartition(ident, name);
+      eventBus.dispatchEvent(
+          new DropPartitionEvent(PrincipalUtils.getCurrentUserName(), ident, 
isExists, name));
+      return isExists;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new DropPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition[] listPartitions(NameIdentifier ident) {
+    try {
+      Partition[] listPartitions = dispatcher.listPartitions(ident);
+      eventBus.dispatchEvent(new 
ListPartitionEvent(PrincipalUtils.getCurrentUserName(), ident));
+      return listPartitions;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new ListPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public String[] listPartitionNames(NameIdentifier ident) {
+    try {
+      String[] listPartitionNames = dispatcher.listPartitionNames(ident);
+      eventBus.dispatchEvent(
+          new ListPartitionNamesEvent(PrincipalUtils.getCurrentUserName(), 
ident));
+      return listPartitionNames;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new 
ListPartitionNamesFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean partitionExists(NameIdentifier ident, String name) {
+    try {
+      boolean isExists = dispatcher.partitionExists(ident, name);
+      eventBus.dispatchEvent(
+          new ExistPartitionEvent(PrincipalUtils.getCurrentUserName(), ident, 
isExists, name));
+      return isExists;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new ExistPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean purgePartition(NameIdentifier ident, String name) {

Review Comment:
   name -> partitionName



##########
core/src/main/java/com/datastrato/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 com.datastrato.gravitino.listener;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.PartitionDispatcher;
+import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
+import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
+import com.datastrato.gravitino.listener.api.event.AddPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.AddPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionNamesEvent;
+import 
com.datastrato.gravitino.listener.api.event.ListPartitionNamesFailureEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.info.PartitionInfo;
+import com.datastrato.gravitino.rel.partitions.Partition;
+import com.datastrato.gravitino.utils.PrincipalUtils;
+
+/**
+ * {@code PartitionEventDispatcher} is a decorator for {@link 
PartitionDispatcher} that not only
+ * delegates partition operations to the underlying partition dispatcher but 
also dispatches
+ * corresponding events to an {@link 
com.datastrato.gravitino.listener.EventBus} after each
+ * operation is completed. This allows for event-driven workflows or 
monitoring of partition
+ * operations.
+ */
+public class PartitionEventDispatcher implements PartitionDispatcher {
+  private final EventBus eventBus;
+  private final PartitionDispatcher dispatcher;
+
+  /**
+   * Constructs a PartitionEventDispatcher with a specified EventBus and 
PartitionDispatcher.
+   *
+   * @param eventBus The EventBus to which events will be dispatched.
+   * @param dispatcher The underlying {@link PartitionDispatcher} that will 
perform the actual
+   *     partition operations.
+   */
+  public PartitionEventDispatcher(EventBus eventBus, PartitionDispatcher 
dispatcher) {
+    this.eventBus = eventBus;
+    this.dispatcher = dispatcher;
+  }
+
+  @Override
+  public Partition addPartition(NameIdentifier ident, Partition partition)
+      throws NoSuchPartitionException, PartitionAlreadyExistsException {
+    try {
+      Partition newPartition = dispatcher.addPartition(ident, partition);
+      eventBus.dispatchEvent(
+          new AddPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(newPartition)));
+      return partition;
+    } catch (Exception e) {
+      PartitionInfo addPartitionRequest = new PartitionInfo(partition);
+      eventBus.dispatchEvent(
+          new AddPartitionFailureEvent(
+              PrincipalUtils.getCurrentUserName(), ident, e, 
addPartitionRequest));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition getPartition(NameIdentifier ident, String partitionName)
+      throws NoSuchPartitionException {
+    try {
+      Partition partition = dispatcher.getPartition(ident, partitionName);
+      eventBus.dispatchEvent(
+          new GetPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(partition)));
+      return partition;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new GetPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));

Review Comment:
   could you add `partitionName` to `GetPartitionFailureEvent`?



##########
core/src/test/java/com/datastrato/gravitino/listener/api/event/TestPartitionEvent.java:
##########
@@ -0,0 +1,235 @@
+/*
+ * 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 com.datastrato.gravitino.listener.api.event;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.PartitionDispatcher;
+import com.datastrato.gravitino.exceptions.GravitinoRuntimeException;
+import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
+import com.datastrato.gravitino.listener.DummyEventListener;
+import com.datastrato.gravitino.listener.EventBus;
+import com.datastrato.gravitino.listener.PartitionEventDispatcher;
+import com.datastrato.gravitino.listener.api.info.PartitionInfo;
+import com.datastrato.gravitino.rel.partitions.Partition;
+import com.google.common.collect.ImmutableMap;
+import java.util.Arrays;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.api.TestInstance.Lifecycle;
+
+@TestInstance(Lifecycle.PER_CLASS)
+public class TestPartitionEvent {
+  private PartitionDispatcher dispatcher;
+  private PartitionDispatcher failureDispatcher;
+  private DummyEventListener dummyEventListener;
+  private Partition partition;
+
+  @BeforeAll
+  void init() {
+    this.partition = mockPartition();
+    this.dummyEventListener = new DummyEventListener();
+    EventBus eventBus = new EventBus(Arrays.asList(dummyEventListener));
+    PartitionDispatcher partitionDispatcher = mockPartitionDispatcher();
+    this.dispatcher = new PartitionEventDispatcher(eventBus, 
partitionDispatcher);
+    PartitionDispatcher partitionExceptionDispatcher = 
mockExceptionPartitionDispatcher();
+    this.failureDispatcher = new PartitionEventDispatcher(eventBus, 
partitionExceptionDispatcher);
+  }
+
+  @Test
+  void testAddPartitionEvent() {
+    NameIdentifier identifier = NameIdentifier.of("metalake", 
partition.name());

Review Comment:
   should be `NameIdentifier.of("metalake","catalog","schema","table")`, not 
include `partition.name()`



##########
core/src/main/java/com/datastrato/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 com.datastrato.gravitino.listener;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.PartitionDispatcher;
+import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
+import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
+import com.datastrato.gravitino.listener.api.event.AddPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.AddPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionNamesEvent;
+import 
com.datastrato.gravitino.listener.api.event.ListPartitionNamesFailureEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.info.PartitionInfo;
+import com.datastrato.gravitino.rel.partitions.Partition;
+import com.datastrato.gravitino.utils.PrincipalUtils;
+
+/**
+ * {@code PartitionEventDispatcher} is a decorator for {@link 
PartitionDispatcher} that not only
+ * delegates partition operations to the underlying partition dispatcher but 
also dispatches
+ * corresponding events to an {@link 
com.datastrato.gravitino.listener.EventBus} after each
+ * operation is completed. This allows for event-driven workflows or 
monitoring of partition
+ * operations.
+ */
+public class PartitionEventDispatcher implements PartitionDispatcher {
+  private final EventBus eventBus;
+  private final PartitionDispatcher dispatcher;
+
+  /**
+   * Constructs a PartitionEventDispatcher with a specified EventBus and 
PartitionDispatcher.
+   *
+   * @param eventBus The EventBus to which events will be dispatched.
+   * @param dispatcher The underlying {@link PartitionDispatcher} that will 
perform the actual
+   *     partition operations.
+   */
+  public PartitionEventDispatcher(EventBus eventBus, PartitionDispatcher 
dispatcher) {
+    this.eventBus = eventBus;
+    this.dispatcher = dispatcher;
+  }
+
+  @Override
+  public Partition addPartition(NameIdentifier ident, Partition partition)
+      throws NoSuchPartitionException, PartitionAlreadyExistsException {
+    try {
+      Partition newPartition = dispatcher.addPartition(ident, partition);
+      eventBus.dispatchEvent(
+          new AddPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(newPartition)));
+      return partition;
+    } catch (Exception e) {
+      PartitionInfo addPartitionRequest = new PartitionInfo(partition);
+      eventBus.dispatchEvent(
+          new AddPartitionFailureEvent(
+              PrincipalUtils.getCurrentUserName(), ident, e, 
addPartitionRequest));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition getPartition(NameIdentifier ident, String partitionName)
+      throws NoSuchPartitionException {
+    try {
+      Partition partition = dispatcher.getPartition(ident, partitionName);
+      eventBus.dispatchEvent(
+          new GetPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(partition)));
+      return partition;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new GetPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean dropPartition(NameIdentifier ident, String name) {

Review Comment:
   rename `name` to `partitionName` and add it to `DropPartitionFailureEvent`?



##########
core/src/main/java/com/datastrato/gravitino/listener/PartitionEventDispatcher.java:
##########
@@ -0,0 +1,169 @@
+/*
+ * 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 com.datastrato.gravitino.listener;
+
+import com.datastrato.gravitino.NameIdentifier;
+import com.datastrato.gravitino.catalog.PartitionDispatcher;
+import com.datastrato.gravitino.exceptions.NoSuchPartitionException;
+import com.datastrato.gravitino.exceptions.PartitionAlreadyExistsException;
+import com.datastrato.gravitino.listener.api.event.AddPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.AddPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.DropPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ExistPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.GetPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.event.ListPartitionNamesEvent;
+import 
com.datastrato.gravitino.listener.api.event.ListPartitionNamesFailureEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionEvent;
+import com.datastrato.gravitino.listener.api.event.PurgePartitionFailureEvent;
+import com.datastrato.gravitino.listener.api.info.PartitionInfo;
+import com.datastrato.gravitino.rel.partitions.Partition;
+import com.datastrato.gravitino.utils.PrincipalUtils;
+
+/**
+ * {@code PartitionEventDispatcher} is a decorator for {@link 
PartitionDispatcher} that not only
+ * delegates partition operations to the underlying partition dispatcher but 
also dispatches
+ * corresponding events to an {@link 
com.datastrato.gravitino.listener.EventBus} after each
+ * operation is completed. This allows for event-driven workflows or 
monitoring of partition
+ * operations.
+ */
+public class PartitionEventDispatcher implements PartitionDispatcher {
+  private final EventBus eventBus;
+  private final PartitionDispatcher dispatcher;
+
+  /**
+   * Constructs a PartitionEventDispatcher with a specified EventBus and 
PartitionDispatcher.
+   *
+   * @param eventBus The EventBus to which events will be dispatched.
+   * @param dispatcher The underlying {@link PartitionDispatcher} that will 
perform the actual
+   *     partition operations.
+   */
+  public PartitionEventDispatcher(EventBus eventBus, PartitionDispatcher 
dispatcher) {
+    this.eventBus = eventBus;
+    this.dispatcher = dispatcher;
+  }
+
+  @Override
+  public Partition addPartition(NameIdentifier ident, Partition partition)
+      throws NoSuchPartitionException, PartitionAlreadyExistsException {
+    try {
+      Partition newPartition = dispatcher.addPartition(ident, partition);
+      eventBus.dispatchEvent(
+          new AddPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(newPartition)));
+      return partition;
+    } catch (Exception e) {
+      PartitionInfo addPartitionRequest = new PartitionInfo(partition);
+      eventBus.dispatchEvent(
+          new AddPartitionFailureEvent(
+              PrincipalUtils.getCurrentUserName(), ident, e, 
addPartitionRequest));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition getPartition(NameIdentifier ident, String partitionName)
+      throws NoSuchPartitionException {
+    try {
+      Partition partition = dispatcher.getPartition(ident, partitionName);
+      eventBus.dispatchEvent(
+          new GetPartitionEvent(
+              PrincipalUtils.getCurrentUserName(), ident, new 
PartitionInfo(partition)));
+      return partition;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new GetPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean dropPartition(NameIdentifier ident, String name) {
+    try {
+      boolean isExists = dispatcher.dropPartition(ident, name);
+      eventBus.dispatchEvent(
+          new DropPartitionEvent(PrincipalUtils.getCurrentUserName(), ident, 
isExists, name));
+      return isExists;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new DropPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public Partition[] listPartitions(NameIdentifier ident) {
+    try {
+      Partition[] listPartitions = dispatcher.listPartitions(ident);
+      eventBus.dispatchEvent(new 
ListPartitionEvent(PrincipalUtils.getCurrentUserName(), ident));
+      return listPartitions;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new ListPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public String[] listPartitionNames(NameIdentifier ident) {
+    try {
+      String[] listPartitionNames = dispatcher.listPartitionNames(ident);
+      eventBus.dispatchEvent(
+          new ListPartitionNamesEvent(PrincipalUtils.getCurrentUserName(), 
ident));
+      return listPartitionNames;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new 
ListPartitionNamesFailureEvent(PrincipalUtils.getCurrentUserName(), ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean partitionExists(NameIdentifier ident, String name) {
+    try {
+      boolean isExists = dispatcher.partitionExists(ident, name);
+      eventBus.dispatchEvent(
+          new ExistPartitionEvent(PrincipalUtils.getCurrentUserName(), ident, 
isExists, name));
+      return isExists;
+    } catch (Exception e) {
+      eventBus.dispatchEvent(
+          new ExistPartitionFailureEvent(PrincipalUtils.getCurrentUserName(), 
ident, e));
+      throw e;
+    }
+  }
+
+  @Override
+  public boolean purgePartition(NameIdentifier ident, String name) {

Review Comment:
   add partitionName to failure event



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to