-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#5900] feat(tag): support tag pre-event to Gravitino server #5980
Draft
amazingLychee
wants to merge
15
commits into
apache:main
Choose a base branch
from
amazingLychee:issue-5900
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
555756e
add TagPreEvent
amazingLychee 90300bb
feat: Add pre-event logic for listTags method
amazingLychee 36da9d7
feat: Add pre-event logic for listTagsInfo method
amazingLychee 8cf9289
feat: Add pre-event logic for getTag method
amazingLychee f5e310e
feat: Add pre-event logic for createTag method
amazingLychee b7f5894
feat: Add pre-event logic for alterTag method
amazingLychee 8557203
feat: Add pre-event logic for deleteTag method
amazingLychee bf2d861
feat: Add pre-event logic for listMetadataObjectsForTag method
amazingLychee 050c17b
feat: Add pre-event logic for listTagsForMetadataObject method
amazingLychee 816fdcb
feat: Add pre-event logic for listTagsInfoForMetadataObject method
amazingLychee f0a0bc9
feat: Add pre-event logic for associateTagsForMetadataObject method
amazingLychee 867b2c3
feat: Add pre-event logic for getTagForMetadataObject method
amazingLychee 08ffb23
feat: Add tag event in OperationType
amazingLychee f944fec
feat: Modify Tag PreEvent
amazingLychee cbc6a05
Merge branch 'main' into issue-5900
amazingLychee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
63 changes: 63 additions & 0 deletions
63
core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.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,63 @@ | ||
/* | ||
* 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.tag.TagChange; | ||
|
||
/** Represents an event triggered before altering a tag. */ | ||
@DeveloperApi | ||
public class AlterTagPreEvent extends TagPreEvent { | ||
|
||
private final TagChange[] changes; | ||
|
||
/** | ||
* Constructs a new AlterTagPreEvent instance. | ||
* | ||
* @param user The user responsible for the operation. | ||
* @param metalake The namespace of the tag. | ||
* @param tagName The name of the tag being altered. | ||
* @param changes The changes being applied to the tag. | ||
*/ | ||
public AlterTagPreEvent(String user, String metalake, String tagName, TagChange[] changes) { | ||
super(user, NameIdentifier.of(metalake, tagName)); | ||
this.changes = changes; | ||
} | ||
|
||
/** | ||
* Returns the changes being applied to the tag. | ||
* | ||
* @return An array of {@link TagChange}. | ||
*/ | ||
public TagChange[] getChanges() { | ||
return changes; | ||
} | ||
|
||
/** | ||
* Returns the operation type for this event. | ||
* | ||
* @return The operation type {@link OperationType#ALTER_TAG}. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ALTER_TAG; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
.../java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.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,78 @@ | ||
/* | ||
* 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 before associating tags with a specific metadata object. */ | ||
@DeveloperApi | ||
public class AssociateTagsForMetadataObjectPreEvent extends TagPreEvent { | ||
private final String[] tagsToAdd; | ||
private final String[] tagsToRemove; | ||
|
||
/** | ||
* Constructs the pre-event with user, metalake, metadata object, tags to add, and tags to remove. | ||
* | ||
* @param user The user initiating the operation. | ||
* @param metalake The metalake environment name. | ||
* @param metadataObject The metadata object for which tags will be associated. | ||
* @param tagsToAdd Tags to be added to the metadata object. | ||
* @param tagsToRemove Tags to be removed from the metadata object. | ||
*/ | ||
public AssociateTagsForMetadataObjectPreEvent( | ||
String user, | ||
String metalake, | ||
MetadataObject metadataObject, | ||
String[] tagsToAdd, | ||
String[] tagsToRemove) { | ||
super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); | ||
this.tagsToAdd = tagsToAdd; | ||
this.tagsToRemove = tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the tags to be added. | ||
* | ||
* @return Array of tag names to be added. | ||
*/ | ||
public String[] getTagsToAdd() { | ||
return tagsToAdd; | ||
} | ||
|
||
/** | ||
* Returns the tags to be removed. | ||
* | ||
* @return Array of tag names to be removed. | ||
*/ | ||
public String[] getTagsToRemove() { | ||
return tagsToRemove; | ||
} | ||
|
||
/** | ||
* Returns the operation type for this event. | ||
* | ||
* @return The operation type, which is ASSOCIATE_TAGS_FOR_METADATA_OBJECT. | ||
*/ | ||
@Override | ||
public OperationType operationType() { | ||
return OperationType.ASSOCIATE_TAGS_FOR_METADATA_OBJECT; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.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,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.listener.api.info.TagInfo; | ||
import org.apache.gravitino.utils.NameIdentifierUtil; | ||
import org.apache.gravitino.annotation.DeveloperApi; | ||
|
||
@DeveloperApi | ||
public class CreateTagPreEvent extends TagPreEvent { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add javadoc |
||
private final TagInfo tagInfo; | ||
|
||
public CreateTagPreEvent(String user, String metalake, TagInfo tagInfo) { | ||
super(user, NameIdentifierUtil.ofTag(metalake, tagInfo.name())); | ||
this.tagInfo = tagInfo; | ||
} | ||
|
||
public TagInfo tagInfo() { | ||
return tagInfo; | ||
} | ||
|
||
@Override | ||
public OperationType operationType() { | ||
return OperationType.CREATE_TAG; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagPreEvent.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,36 @@ | ||
/* | ||
* 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 deleting a tag. */ | ||
@DeveloperApi | ||
public class DeleteTagPreEvent extends TagPreEvent { | ||
|
||
public DeleteTagPreEvent(String user, String metalake, String tagName) { | ||
super(user, NameIdentifier.of(metalake, tagName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
@Override | ||
public OperationType operationType() { | ||
return OperationType.DELETE_TAG; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
NameIdentifierUtil.ofTag(metalake, name)