forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#5902] feat: Add tag failure event to Gravitino server (apache…
…#5944) ### What changes were proposed in this pull request? Add tag failure event to Gravitino server ### Why are the changes needed? Subtask: apache#5902 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Unit tests.
- Loading branch information
1 parent
e54c6d5
commit 266cb2e
Showing
23 changed files
with
1,178 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagFailureEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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.tag.TagChange; | ||
import org.apache.gravitino.utils.NameIdentifierUtil; | ||
|
||
/** | ||
* Represents an event triggered when an attempt to alter a tag in the database fails due to an | ||
* exception. | ||
*/ | ||
@DeveloperApi | ||
public class AlterTagFailureEvent extends TagFailureEvent { | ||
private final TagChange[] changes; | ||
|
||
/** | ||
* Constructs a new AlterTagFailureEvent. | ||
* | ||
* @param user the user who attempted to alter the tag | ||
* @param metalake the metalake identifier | ||
* @param name the name of the tag | ||
* @param changes the changes attempted to be made to the tag | ||
* @param exception the exception that caused the failure | ||
*/ | ||
public AlterTagFailureEvent( | ||
String user, String metalake, String name, TagChange[] changes, Exception exception) { | ||
super(user, NameIdentifierUtil.ofTag(metalake, name), exception); | ||
this.changes = changes; | ||
} | ||
|
||
/** | ||
* Returns the changes attempted to be made to the tag. | ||
* | ||
* @return the changes attempted to be made to the tag | ||
*/ | ||
public TagChange[] changes() { | ||
return changes; | ||
} | ||
|
||
/** | ||
* Returns the type of operation. | ||
* | ||
* @return the operation type. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ALTER_TAG; | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
...a/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectFailureEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* 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.MetadataObject; | ||
import org.apache.gravitino.annotation.DeveloperApi; | ||
import org.apache.gravitino.utils.MetadataObjectUtil; | ||
|
||
/** | ||
* Represents an event triggered when an attempt to associate tags for a metadata object fails due | ||
* to an exception. | ||
*/ | ||
@DeveloperApi | ||
public class AssociateTagsForMetadataObjectFailureEvent extends TagFailureEvent { | ||
private final String[] tagsToAdd; | ||
private final String[] tagsToRemove; | ||
|
||
/** | ||
* Constructs a new {@code AssociateTagsForMetadataObjectFailureEvent} instance. | ||
* | ||
* @param user The user who initiated the operation. | ||
* @param metalake The metalake name where the metadata object resides. | ||
* @param metadataObject The metadata object for which tags are being associated. | ||
* @param tagsToAdd The tags to add. | ||
* @param tagsToRemove The tags to remove. | ||
* @param exception The exception encountered during the operation, providing insights into the | ||
* reasons behind the failure. | ||
*/ | ||
public AssociateTagsForMetadataObjectFailureEvent( | ||
String user, | ||
String metalake, | ||
MetadataObject metadataObject, | ||
String[] tagsToAdd, | ||
String[] tagsToRemove, | ||
Exception exception) { | ||
super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject), exception); | ||
this.tagsToAdd = tagsToAdd; | ||
this.tagsToRemove = tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the tags to add. | ||
* | ||
* @return The tags to add. | ||
*/ | ||
public String[] tagsToAdd() { | ||
return tagsToAdd; | ||
} | ||
|
||
/** | ||
* Returns the tags to remove. | ||
* | ||
* @return The tags to remove. | ||
*/ | ||
public String[] tagsToRemove() { | ||
return tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the type of operation. | ||
* | ||
* @return the operation type. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ASSOCIATE_TAGS_FOR_METADATA_OBJECT; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagFailureEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.listener.api.info.TagInfo; | ||
import org.apache.gravitino.utils.NameIdentifierUtil; | ||
|
||
/** | ||
* Represents an event triggered when an attempt to create a tag in the database fails due to an | ||
* exception. | ||
*/ | ||
@DeveloperApi | ||
public class CreateTagFailureEvent extends TagFailureEvent { | ||
private final TagInfo tagInfo; | ||
/** | ||
* Constructs a new {@code CreateTagFailureEvent} instance. | ||
* | ||
* @param user The user who initiated the tag creation operation. | ||
* @param metalake The metalake name where the tag resides. | ||
* @param tagInfo The information about the tag to be created. | ||
* @param exception The exception encountered during the tag creation operation, providing | ||
* insights into the reasons behind the operation's failure. | ||
*/ | ||
public CreateTagFailureEvent(String user, String metalake, TagInfo tagInfo, Exception exception) { | ||
super(user, NameIdentifierUtil.ofTag(metalake, tagInfo.name()), exception); | ||
this.tagInfo = tagInfo; | ||
} | ||
|
||
/** | ||
* Returns the information about the tag. | ||
* | ||
* @return the tag information | ||
*/ | ||
public TagInfo tagInfo() { | ||
return tagInfo; | ||
} | ||
|
||
/** | ||
* Returns the type of operation. | ||
* | ||
* @return the operation type. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.CREATE_TAG; | ||
} | ||
} |
Oops, something went wrong.