lizhimins opened a new pull request, #7353:
URL: https://github.com/apache/rocketmq-dashboard/pull/7353
### Which Issue(s) This PR Fixes
No tracking issue. The design is normative in
`docs/studio-instance-model-spec.md`, which this PR
rewrites to match the code.
### Brief Description
Topic and group names are currently unique per Studio deployment
(`uk_topic_name (name)`), so two
environments that reuse the same resource names (dev / staging / prod) force
separate Studio
deployments even when they sit on different NameServer clusters.
This scopes uniqueness to the **NameServer domain**:
- `rmq_instance.nameserver_id` binds an APACHE instance to a
`rmq_nameserver` row at creation
(required, immutable afterwards, application-layer validated, no foreign
key). Cloud instances keep
deriving their domain from `cloud_instance_id`.
- `rmq_instance_topic.domain` / `rmq_instance_group.domain` hold
`ns:<nameserver_id>` or
`cloud:<cloudInstanceId>`, and the unique keys become `uk_topic_domain
(domain, cluster_id, name)`
/ `uk_group_domain (domain, cluster_id, name)`. A **slot** is `(domain,
cluster, name)` and belongs
to exactly one instance, so the same name can coexist across domains and
across the broker clusters
of one domain.
- `ResourceOwnershipGuard` turns slot based: `domainOf` resolves the domain
(409 for an open-source
instance that is not bound to a NameServer), `createTarget` picks the
cluster a creation should
target (the caller's own registration, else the instance default) so a
foreign registration on
another cluster no longer blocks a create, `checkSlot` resolves
configuration mutations to a single
physical target and rejects an ambiguous name, and `checkOwnerInDomain`
keeps name-routed operations
(sending messages, resetting offsets) on the caller's own registration. A
committed claim is still
never released by a remote-operation failure.
- `ResourceOwnershipSchemaMigration` upgrades an initialized database in
place: add the columns,
resolve every instance to a domain (registering a NameServer row for
endpoints the registry does not
know yet), backfill every resource row, then swap the unique keys —
creating `uk_*_domain` before
dropping `uk_*_name`. It refuses to start on a row whose owner cannot be
resolved or on a duplicated
slot, so nothing is silently discarded.
- `docs/studio-instance-model-spec.md` is rewritten from the
global-uniqueness wording to the domain
wording (hierarchy, slot rules, behaviour constraints, implementation map).
### How Did You Test This Change?
```
cd server && mvn -B -ntp test
# MySQL 8.0 started as in CONTRIBUTING.md (same env as
deploy/docker-compose.yml,
# server/src/main/resources/db/schema.sql loaded), mirroring the CI
backend-test job.
Tests run: 3838, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS Total time: 01:45 min
```
Ownership and migration coverage lives in `ResourceOwnershipGuardTest`,
`InstanceServiceTest`,
`MybatisPlusInstanceRepositoryTest`, `MetadataServiceTest`,
`LiteTopicServiceTest`,
`RocketMQAdminClientImplTest`, `RocketMQMessageProviderTest` and
`RocketMQLiteTopicProviderTest`
(test methods keep the `...Test` suffix).
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits (`feat:` / `fix:` /
`refactor:` / `chore:` / `docs:` / `perf:`)
- [x] Tests added or updated for non-trivial changes, test methods named
`...Test`
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
(no UI text in this PR)
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks)
- [x] New source files carry the ASF license header (no new source files)
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help)
--
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]