Skip to content

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

[#6742] feat(core): Support group failure event to Gravitino server (#6823)

Lord of Abyss06497e424ba4
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AccessControlEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AccessControlEventDispatcher.java
index 59d6cfb3bb..f9d478243b 100644
--- a/core/src/main/java/org/apache/gravitino/listener/api/event/AccessControlEventDispatcher.java
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AccessControlEventDispatcher.java
@@ -164,7 +164,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groupObject;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new AddGroupFailureEvent(initiator, metalake, e, group));
throw e;
}
}
@@ -181,7 +181,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return isExists;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new RemoveGroupFailureEvent(initiator, metalake, e, group));
throw e;
}
}
@@ -199,7 +199,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groupObject;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new GetGroupFailureEvent(initiator, metalake, e, group));
throw e;
}
}
@@ -216,7 +216,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groups;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new ListGroupsFailureEvent(initiator, metalake, e));
throw e;
}
}
@@ -233,7 +233,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groupNames;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new ListGroupNamesFailureEvent(initiator, metalake, e));
throw e;
}
}
@@ -271,7 +271,7 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groupObject;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(new GrantGroupRolesFailureEvent(initiator, metalake, e, group, roles));
throw e;
}
}
@@ -290,7 +290,8 @@ public class AccessControlEventDispatcher implements AccessControlDispatcher {
return groupObject;
} catch (Exception e) {
- // TODO: add failure event
+ eventBus.dispatchEvent(
+ new RevokeGroupRolesFailureEvent(initiator, metalake, e, group, roles));
throw e;
}
}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AddGroupFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AddGroupFailureEvent.java
new file mode 100644
index 0000000000..2ac21860d6
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AddGroupFailureEvent.java
@@ -0,0 +1,65 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to add a group to a metalake fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class AddGroupFailureEvent extends GroupFailureEvent {
+ private final String groupName;
+ /**
+ * Creates a new instance of {@code AddGroupFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake where the group addition was attempted
+ * @param exception the exception encountered during the operation
+ * @param groupName the name of the group that failed to be added
+ */
+ public AddGroupFailureEvent(
+ String initiator, String metalake, Exception exception, String groupName) {
+ super(initiator, NameIdentifierUtil.ofGroup(metalake, groupName), exception);
+
+ this.groupName = groupName;
+ }
+
+ /**
+ * Retrieves the name of the group that failed to be added.
+ *
+ * @return the group name involved in the failure event
+ */
+ public String groupName() {
+ return groupName;
+ }
+
+ /**
+ * Returns the operation type for this event.
+ *
+ * @return the operation type for this event.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ADD_GROUP;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupFailureEvent.java
new file mode 100644
index 0000000000..35e5ecb1f5
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetGroupFailureEvent.java
@@ -0,0 +1,66 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to retrieve a group from the metalake fails due to
+ * an exception.
+ */
+@DeveloperApi
+public class GetGroupFailureEvent extends GroupFailureEvent {
+ private final String groupName;
+
+ /**
+ * Creates a new instance of {@code GetGroupFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake from which the group retrieval was attempted
+ * @param exception the exception encountered during the operation
+ * @param groupName the name of the group that failed to be retrieved
+ */
+ public GetGroupFailureEvent(
+ String initiator, String metalake, Exception exception, String groupName) {
+ super(initiator, NameIdentifierUtil.ofGroup(metalake, groupName), exception);
+
+ this.groupName = groupName;
+ }
+
+ /**
+ * Retrieves the name of the group that failed to be retrieved.
+ *
+ * @return the group name involved in the failure event
+ */
+ public String groupName() {
+ return groupName;
+ }
+
+ /**
+ * Returns the operation type for this event.
+ *
+ * @return the operation type for this event.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.GET_GROUP;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GrantGroupRolesFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GrantGroupRolesFailureEvent.java
new file mode 100644
index 0000000000..21e8f03567
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GrantGroupRolesFailureEvent.java
@@ -0,0 +1,83 @@
+/*
+ * 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 java.util.List;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to grant roles to a group fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class GrantGroupRolesFailureEvent extends GroupFailureEvent {
+ private final String groupName;
+ private final List<String> roles;
+
+ /**
+ * Creates a new instance of {@code GrantGroupRolesFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake where the operation was attempted
+ * @param exception the exception encountered during the operation
+ * @param groupName the name of the group to which the roles were attempted to be granted
+ * @param roles the list of roles that were attempted to be granted to the group
+ */
+ public GrantGroupRolesFailureEvent(
+ String initiator,
+ String metalake,
+ Exception exception,
+ String groupName,
+ List<String> roles) {
+ super(initiator, NameIdentifierUtil.ofGroup(metalake, groupName), exception);
+
+ this.groupName = groupName;
+ this.roles = roles;
+ }
+
+ /**
+ * Retrieves the name of the group to which the roles were attempted to be granted.
+ *
+ * @return the group name involved in the failure event
+ */
+ public String groupName() {
+ return groupName;
+ }
+
+ /**
+ * Retrieves the list of roles that were attempted to be granted to the group.
+ *
+ * @return the list of roles involved in the failure event
+ */
+ public List<String> roles() {
+ return roles;
+ }
+
+ /**
+ * Returns the operation type of this event.
+ *
+ * @return the operation type.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.GRANT_GROUP_ROLES;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GroupFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GroupFailureEvent.java
new file mode 100644
index 0000000000..92ccbe1288
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GroupFailureEvent.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 when a group operation fails due to an exception. This event
+ * encapsulates the group operation's unique identifier, the initiating user, and the exception that
+ * led to the failure.
+ */
+@DeveloperApi
+public abstract class GroupFailureEvent extends FailureEvent {
+
+ /**
+ * Creates a new instance of {@code GroupFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param identifier the unique identifier for the group operation
+ * @param exception the exception encountered during the operation, detailing the cause of failure
+ */
+ public GroupFailureEvent(String initiator, NameIdentifier identifier, Exception exception) {
+ super(initiator, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupNamesFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupNamesFailureEvent.java
new file mode 100644
index 0000000000..752574bc62
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupNamesFailureEvent.java
@@ -0,0 +1,52 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to list group names from a metalake fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class ListGroupNamesFailureEvent extends GroupFailureEvent {
+
+ /**
+ * Creates a new instance of {@code ListGroupNamesFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake where the operation was attempted
+ * @param exception the exception encountered during the operation
+ */
+ public ListGroupNamesFailureEvent(String initiator, String metalake, Exception exception) {
+ super(initiator, NameIdentifierUtil.ofMetalake(metalake), exception);
+ }
+
+ /**
+ * Returns the operation type for this event.
+ *
+ * @return the operation type for this event.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_GROUP_NAMES;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupsFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupsFailureEvent.java
new file mode 100644
index 0000000000..9ea4d54aea
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListGroupsFailureEvent.java
@@ -0,0 +1,52 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to list groups from a metalake fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class ListGroupsFailureEvent extends GroupFailureEvent {
+
+ /**
+ * Creates a new instance of {@code ListGroupsFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake where the operation was attempted
+ * @param exception the exception encountered during the operation
+ */
+ public ListGroupsFailureEvent(String initiator, String metalake, Exception exception) {
+ super(initiator, NameIdentifierUtil.ofMetalake(metalake), exception);
+ }
+
+ /**
+ * Returns the operation type for this event.
+ *
+ * @return the operation type for this event.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_GROUPS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupFailureEvent.java
new file mode 100644
index 0000000000..195d58522c
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/RemoveGroupFailureEvent.java
@@ -0,0 +1,66 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to remove a group from a metalake fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class RemoveGroupFailureEvent extends GroupFailureEvent {
+ private final String groupName;
+
+ /**
+ * Creates a new instance of {@code RemoveGroupFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake from which the group removal was attempted
+ * @param exception the exception encountered during the operation
+ * @param groupName the name of the group that failed to be removed
+ */
+ public RemoveGroupFailureEvent(
+ String initiator, String metalake, Exception exception, String groupName) {
+ super(initiator, NameIdentifierUtil.ofGroup(metalake, groupName), exception);
+
+ this.groupName = groupName;
+ }
+
+ /**
+ * Retrieves the name of the group that failed to be removed.
+ *
+ * @return the group name involved in the failure event
+ */
+ public String groupName() {
+ return groupName;
+ }
+
+ /**
+ * Returns the operation type for this event.
+ *
+ * @return the operation type for this event.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.REMOVE_GROUP;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/RevokeGroupRolesFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/RevokeGroupRolesFailureEvent.java
new file mode 100644
index 0000000000..08f7f99662
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/RevokeGroupRolesFailureEvent.java
@@ -0,0 +1,83 @@
+/*
+ * 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 java.util.List;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/**
+ * Represents an event triggered when an attempt to revoke roles from a group fails due to an
+ * exception.
+ */
+@DeveloperApi
+public class RevokeGroupRolesFailureEvent extends GroupFailureEvent {
+ private final String groupName;
+ private final List<String> roles;
+
+ /**
+ * Creates a new instance of {@code RevokeGroupRolesFailureEvent}.
+ *
+ * @param initiator the user who initiated the operation
+ * @param metalake the name of the metalake where the operation was attempted
+ * @param exception the exception encountered during the operation
+ * @param groupName the name of the group from which the roles were attempted to be revoked
+ * @param roles the list of roles that were attempted to be revoked from the group
+ */
+ public RevokeGroupRolesFailureEvent(
+ String initiator,
+ String metalake,
+ Exception exception,
+ String groupName,
+ List<String> roles) {
+ super(initiator, NameIdentifierUtil.ofGroup(metalake, groupName), exception);
+
+ this.groupName = groupName;
+ this.roles = roles;
+ }
+
+ /**
+ * Retrieves the name of the group from which the roles were attempted to be revoked.
+ *
+ * @return the group name involved in the failure event
+ */
+ public String groupName() {
+ return groupName;
+ }
+
+ /**
+ * Retrieves the list of roles that were attempted to be revoked from the group.
+ *
+ * @return the list of roles involved in the failure event
+ */
+ public List<String> roles() {
+ return roles;
+ }
+
+ /**
+ * Returns the operation type of this event.
+ *
+ * @return the operation type.
+ */
+ @Override
+ public OperationType operationType() {
+ return OperationType.REVOKE_GROUP_ROLES;
+ }
+}
diff --git a/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java b/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
index 44d7ae1936..a8ba88e9d2 100644
--- a/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
+++ b/core/src/test/java/org/apache/gravitino/listener/api/event/TestGroupEvent.java
@@ -117,6 +117,23 @@ public class TestGroupEvent {
validateGroup(addGroupEvent.addedGroupInfo(), group);
}
+ @Test
+ void testAddGroupFailureEvent() {
+ Assertions.assertThrowsExactly(
+ GravitinoRuntimeException.class, () -> failureDispatcher.addGroup(METALAKE, groupName));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(AddGroupFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.ADD_GROUP, event.operationType());
+
+ AddGroupFailureEvent addGroupFailureEvent = (AddGroupFailureEvent) event;
+ Assertions.assertEquals(
+ NameIdentifierUtil.ofGroup(METALAKE, groupName), addGroupFailureEvent.identifier());
+ Assertions.assertEquals(groupName, addGroupFailureEvent.groupName());
+ }
+
@Test
void testGetGroupPreEventWithExistingGroup() {
dispatcher.getGroup(METALAKE, groupName);
@@ -174,6 +191,23 @@ public class TestGroupEvent {
NoSuchGroupException.class, () -> dispatcher.getGroup(METALAKE, inExistGroupName));
}
+ @Test
+ void testGetGroupFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class, () -> failureDispatcher.getGroup(METALAKE, groupName));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(GetGroupFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.GET_GROUP, event.operationType());
+
+ GetGroupFailureEvent getGroupFailureEvent = (GetGroupFailureEvent) event;
+ Assertions.assertEquals(
+ NameIdentifierUtil.ofGroup(METALAKE, groupName), getGroupFailureEvent.identifier());
+ Assertions.assertEquals(groupName, getGroupFailureEvent.groupName());
+ }
+
@Test
void testListGroupsPreEvent() {
dispatcher.listGroups(METALAKE);
@@ -202,6 +236,21 @@ public class TestGroupEvent {
Assertions.assertEquals(identifier, listGroupsEvent.identifier());
}
+ @Test
+ void testListGroupsFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class, () -> failureDispatcher.listGroups(METALAKE));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(ListGroupsFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.LIST_GROUPS, event.operationType());
+
+ ListGroupsFailureEvent listGroupsFailureEvent = (ListGroupsFailureEvent) event;
+ Assertions.assertEquals(identifier, listGroupsFailureEvent.identifier());
+ }
+
@Test
void testListGroupNamesPreEvent() {
dispatcher.listGroupNames(METALAKE);
@@ -230,6 +279,21 @@ public class TestGroupEvent {
Assertions.assertEquals(identifier, listGroupNamesEvent.identifier());
}
+ @Test
+ void testListGroupNamesFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class, () -> failureDispatcher.listGroupNames(METALAKE));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(ListGroupNamesFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.LIST_GROUP_NAMES, event.operationType());
+
+ ListGroupNamesFailureEvent listGroupNamesFailureEvent = (ListGroupNamesFailureEvent) event;
+ Assertions.assertEquals(identifier, listGroupNamesFailureEvent.identifier());
+ }
+
@Test
void testRemoveGroupPreEvent() {
dispatcher.removeGroup(METALAKE, groupName);
@@ -280,6 +344,23 @@ public class TestGroupEvent {
Assertions.assertEquals(inExistGroupName, removeGroupEvent.removedGroupName());
}
+ @Test
+ void testRemoveGroupFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class, () -> failureDispatcher.removeGroup(METALAKE, groupName));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(RemoveGroupFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.REMOVE_GROUP, event.operationType());
+
+ RemoveGroupFailureEvent removeGroupFailureEvent = (RemoveGroupFailureEvent) event;
+ Assertions.assertEquals(
+ NameIdentifierUtil.ofGroup(METALAKE, groupName), removeGroupFailureEvent.identifier());
+ Assertions.assertEquals(groupName, removeGroupFailureEvent.groupName());
+ }
+
@Test
void testGrantRolesToGroupPreEvent() {
dispatcher.grantRolesToGroup(METALAKE, grantedRoles, groupName);
@@ -316,6 +397,25 @@ public class TestGroupEvent {
validateGroup(groupInfo, group);
}
+ @Test
+ void testGrantRolesToGroupFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class,
+ () -> failureDispatcher.grantRolesToGroup(METALAKE, grantedRoles, groupName));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(GrantGroupRolesFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.GRANT_GROUP_ROLES, event.operationType());
+
+ GrantGroupRolesFailureEvent grantGroupRolesFailureEvent = (GrantGroupRolesFailureEvent) event;
+ Assertions.assertEquals(
+ NameIdentifierUtil.ofGroup(METALAKE, groupName), grantGroupRolesFailureEvent.identifier());
+ Assertions.assertEquals(groupName, grantGroupRolesFailureEvent.groupName());
+ Assertions.assertEquals(grantedRoles, grantGroupRolesFailureEvent.roles());
+ }
+
@Test
void testRevokeRolesFromGroupPreEvent() {
dispatcher.revokeRolesFromGroup(METALAKE, revokedRoles, otherGroupName);
@@ -353,6 +453,27 @@ public class TestGroupEvent {
validateGroup(groupInfo, otherGroup);
}
+ @Test
+ void testRevokeRolesFromGroupFailureEvent() {
+ Assertions.assertThrows(
+ GravitinoRuntimeException.class,
+ () -> failureDispatcher.revokeRolesFromGroup(METALAKE, revokedRoles, otherGroupName));
+
+ // validate event
+ Event event = dummyEventListener.popPostEvent();
+ Assertions.assertEquals(RevokeGroupRolesFailureEvent.class, event.getClass());
+ Assertions.assertEquals(OperationStatus.FAILURE, event.operationStatus());
+ Assertions.assertEquals(OperationType.REVOKE_GROUP_ROLES, event.operationType());
+
+ RevokeGroupRolesFailureEvent revokeGroupRolesFailureEvent =
+ (RevokeGroupRolesFailureEvent) event;
+ Assertions.assertEquals(
+ NameIdentifierUtil.ofGroup(METALAKE, otherGroupName),
+ revokeGroupRolesFailureEvent.identifier());
+ Assertions.assertEquals(otherGroupName, revokeGroupRolesFailureEvent.groupName());
+ Assertions.assertEquals(revokedRoles, revokeGroupRolesFailureEvent.roles());
+ }
+
private Group getMockGroup(String name, List<String> roles) {
Group mockGroup = mock(Group.class);
when(mockGroup.name()).thenReturn(name);
diff --git a/docs/gravitino-server-config.md b/docs/gravitino-server-config.md
index 7dfce90c7e..95d50c117e 100644
--- a/docs/gravitino-server-config.md
+++ b/docs/gravitino-server-config.md
@@ -130,7 +130,7 @@ Gravitino triggers a pre-event before the operation, a post-event after the comp
| tag operation | `ListTagsEvent`, `ListTagsInfoEvent`, `CreateTagEvent`, `GetTagEvent`, `AlterTagEvent`, `DeleteTagEvent`, `ListMetadataObjectsForTagEvent`, `ListTagsForMetadataObjectEvent`, `ListTagsInfoForMetadataObjectEvent`, `AssociateTagsForMetadataObjectEvent`, `GetTagForMetadataObjectEvent`, `ListTagsFailureEvent`, `ListTagInfoFailureEvent`, `CreateTagFailureEvent`, `GetTagFailureEvent`, `AlterTagFailureEvent`, `DeleteTagFailureEvent`, `ListMetadataObjectsForTagFailureEvent`, `ListTagsForMetadataObjectFailureEvent`, `ListTagsInfoForMetadataObjectFailureEvent`, `AssociateTagsForMetadataObjectFailureEvent`, `GetTagForMetadataObjectFailureEvent` | 0.9.0-incubating |
| model operation | `DeleteModelEvent`, `DeleteModelVersionEvent`, `GetModelEvent`, `GetModelVersionEvent`, `LinkModelVersionEvent`, `ListModelEvent`, `ListModelVersionsEvent`, `RegisterAndLinkModelEvent`, `RegisterModelEvent`, `DeleteModelFailureEvent`, `DeleteModelVersionFailureEvent`, `GetModelFailureEvent`, `GetModelVersionFailureEvent`, `LinkModelVersionFailureEvent`, `ListModelFailureEvent`, `ListModelVersionFailureEvent`, `RegisterAndLinkModelFailureEvent`, `RegisterModelFailureEvent` | 0.9.0-incubating |
| user operation | `AddUserEvent`, `GetUserEvent`, `ListUserNamesEvent`, `ListUsersEvent`, `RemoveUserEvent`, `GrantUserRolesEvent`, `RevokeUserRolesEvent`, `AddUserFailureEvent`, `GetUserFailureEvent`, `GrantUserRolesFailureEvent`, `ListUserNamesFailureEvent`, `ListUsersFailureEvent`, `RemoveUserFailureEvent`, `RevokeUserRolesFailureEvent` | 0.9.0-incubating |
-| group operation | `AddGroupEvent`, `GetGroupEvent`, `ListGroupNamesEvent`, `ListGroupsEvent`, `RemoveGroupEvent`, `GrantGroupRolesEvent`, `RevokeGroupRolesEvent` | 0.9.0-incubating |
+| group operation | `AddGroupEvent`, `GetGroupEvent`, `ListGroupNamesEvent`, `ListGroupsEvent`, `RemoveGroupEvent`, `GrantGroupRolesEvent`, `RevokeGroupRolesEvent`, `AddGroupFailureEvent`, `GetGroupFailureEvent`, `GrantGroupRolesFailureEvent`, `ListGroupNamesFailureEvent`, `ListGroupsFailureEvent`, `RemoveGroupFailureEvent`, `RevokeGroupRolesFailureEvent` | 0.9.0-incubating |