jerryshao opened a new pull request, #14281: URL: https://github.com/apache/gravitino/pull/14281
### What changes were proposed in this pull request? Add the Domain entity and its metadata storage in `core/`, following the Domain design in #13867. This PR is stacked on #13881 (Domain API) and stays a draft until #13881 merges. Only the last commit belongs to this PR: https://github.com/jerryshao/gravitino/compare/13877-domain-api...13882-domain-storage - `Entity.EntityType.DOMAIN`, the domain namespace `<metalake>.system.domain`, `NameIdentifierUtil.ofDomain` / `checkDomain`, and the `MetadataObject.Type.DOMAIN` ↔ `EntityType.DOMAIN` mapping in `MetadataObjectUtil`. - `DomainEntity`, which holds the stored data of a domain. It does not implement `Domain`; the domain manager (#13884) serves the API. - The `domain_meta` table for H2, MySQL and PostgreSQL, in the 2.0.0 schemas and the 1.3.0 → 2.0.0 upgrade scripts. Names are unique per metalake across both domain levels. - The backing tag is stored on the domain row as `backing_tag_id` and `backing_tag_value` (NULL binds the tag without a value), with an index on `(metalake_id, backing_tag_id, backing_tag_value, deleted_at)` for the reverse lookup. - The binding is by tag ID. Reads take the tag name from the live tag, so a renamed tag keeps backing the domain. - A deleted tag leaves its ID on the row, and `backingTag()` reads as empty. A new tag with the same name does not match. - Locking reads do not join the tag table. - `DomainPO`, `DomainMetaMapper` with its SQL providers, and `DomainMetaService`: - insert (with overwrite), get, batch get and list; - version-checked update and delete, where the update returns the domain as stored; - garbage collection. Deleting a domain also removes its owner and the privileges granted on it. - Wiring: `JDBCBackend`, entity ID resolution, owners, live-endpoint locking, the orphaned-relation collector, metadata object name lookup and the metalake delete. Per the design, `DOMAIN` is not a taggable type and domains are not in the entity cache. Two things are left to later subtasks: - The sub-domain relation (#13883) and the manager (#13884), including `MetadataObjectUtil.checkMetadataObject` for `DOMAIN`. - Entity change-log entries for domain drops and renames, which keep peers' authorization name-to-ID cache fresh. They belong to the authorization subtask. ### Why are the changes needed? This is the first of three core subtasks of the Domain epic (#13864). The next ones add the sub-domain relation (#13883) and the domain manager (#13884). Fix: #13882 ### Does this PR introduce _any_ user-facing change? It adds the `domain_meta` table to the 2.0.0 schema and upgrade scripts. Nothing calls the new storage yet, so behavior does not change. ### How was this patch tested? - New tests: `TestDomainEntity`, `TestDomainPO` and `TestDomainMetaService`. The domain cases are added to `TestNameIdentifierUtil`, `TestMetadataObjectUtil` and `TestOrphanedMetadataObjectRelationService`. - Ran `./gradlew compileJava compileTestJava spotlessCheck -PskipITs` and `./gradlew :core:coreUnitTest :core:coreH2Test -PskipITs`. The H2 lane includes `TestSQLScripts`. - In those lanes, the new and changed main code reaches 97% line coverage. - The MySQL and PostgreSQL lanes were not run locally; CI runs them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
