Add view CRUD event dispatching, hooks, audit mapping, and tests#11028
Open
raushanprabhakar1 wants to merge 3 commits into
Open
Add view CRUD event dispatching, hooks, audit mapping, and tests#11028raushanprabhakar1 wants to merge 3 commits into
raushanprabhakar1 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR brings view CRUD operations in line with existing table behavior by adding an event + hook dispatch chain for views and ensuring audit log classification recognizes the new view events.
Changes:
- Added
ViewInfoplus pre/success/failure view event types and aViewEventDispatcherto emit them on theEventBus. - Added
ViewHookDispatcherto apply ownership and authorization-related hooks for view create/rename/drop. - Wired the view dispatcher chain in
GravitinoEnvand updatedAuditLog.Operation.fromEvent+ tests to cover audit mapping for view events.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| core/src/test/java/org/apache/gravitino/listener/api/event/TestViewEvent.java | New unit tests validating view pre/post/failure event emission. |
| core/src/test/java/org/apache/gravitino/audit/TestOperation.java | Extends audit-mapping tests to cover view operations. |
| core/src/main/java/org/apache/gravitino/listener/ViewEventDispatcher.java | New dispatcher that emits view CRUD events around view operations. |
| core/src/main/java/org/apache/gravitino/listener/api/info/ViewInfo.java | New listener-facing view info DTO used in view events. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ViewPreEvent.java | Base pre-event type for view operations. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ViewFailureEvent.java | Base failure-event type for view operations. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ViewEvent.java | Base success-event type for view operations. |
| core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewPreEvent.java | Pre-event for load-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewFailureEvent.java | Failure-event for load-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/LoadViewEvent.java | Success-event for load-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ListViewPreEvent.java | Pre-event for list-views. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ListViewFailureEvent.java | Failure-event for list-views. |
| core/src/main/java/org/apache/gravitino/listener/api/event/ListViewEvent.java | Success-event for list-views. |
| core/src/main/java/org/apache/gravitino/listener/api/event/DropViewPreEvent.java | Pre-event for drop-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/DropViewFailureEvent.java | Failure-event for drop-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/DropViewEvent.java | Success-event for drop-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewPreEvent.java | Pre-event for create-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewFailureEvent.java | Failure-event for create-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/CreateViewEvent.java | Success-event for create-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewPreEvent.java | Pre-event for alter-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewFailureEvent.java | Failure-event for alter-view. |
| core/src/main/java/org/apache/gravitino/listener/api/event/AlterViewEvent.java | Success-event for alter-view. |
| core/src/main/java/org/apache/gravitino/hook/ViewHookDispatcher.java | New hook dispatcher for ownership and privilege rename/cleanup on view ops. |
| core/src/main/java/org/apache/gravitino/GravitinoEnv.java | Wires the view dispatcher chain (hook → event → normalize → operation). |
| core/src/main/java/org/apache/gravitino/audit/AuditLog.java | Maps view events to concrete audit operations instead of UNKNOWN. |
Code Coverage Report
Files
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Author
|
Hi @mchades requesting a review from you, Thanks |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
ViewInfoand view event types (pre/success/failure) for list, load, create, alter, and drop, aligned with existingOperationTypeview entries.ViewEventDispatcherto emit those events on theEventBus, andViewHookDispatcherfor ownership on create, privilege rename on view rename, and privilege cleanup on drop (mirroring table behavior).GravitinoEnvso the view stack isViewHookDispatcher→ViewEventDispatcher→ViewNormalizeDispatcher→ViewOperationDispatcher.AuditLog.Operation.fromEventso audit logs are notUNKNOWN_OPERATIONfor view ops.TestViewEventand extendTestOperationfor audit mapping.Why are the changes needed?
View operations did not go through the same listener and hook chain as tables, so
EventListenerPluginimplementations could not observe view CRUD and audit could not classify view events. This addresses the subtask for table-style view event hooks.Fix: #11002
Does this PR introduce any user-facing change?
Yes. Event listeners and audit integrations now receive view CRUD events (and related audit operation types). No REST or client API surface changes;
viewExistsremains without dedicated events, consistent withtableExists.How was this patch tested?
./gradlew :core:spotlessApply :core:test --tests org.apache.gravitino.listener.api.event.TestViewEvent --tests org.apache.gravitino.audit.TestOperation -PskipITs