[feat](fe) Add ClusterGuard SPI interface for cluster-level policy enforcement#62031
Open
morningman wants to merge 3 commits intoapache:masterfrom
Open
[feat](fe) Add ClusterGuard SPI interface for cluster-level policy enforcement#62031morningman wants to merge 3 commits intoapache:masterfrom
morningman wants to merge 3 commits intoapache:masterfrom
Conversation
…forcement ### What problem does this PR solve? Issue Number: N/A Problem Summary: Add a ClusterGuard SPI (Service Provider Interface) abstraction in fe-core to decouple cluster-level policy enforcement (e.g., node limits, time validity checks) from business logic. The open-source fe-core depends only on the interface, while commercial implementations can be plugged in at runtime via Java ServiceLoader without any compile-time dependency on fe-core. Key changes: - Add `ClusterGuard` interface with `onStartup`, `checkTimeValidity`, `checkNodeLimit` and `getGuardInfo` methods - Add `ClusterGuardFactory` using Java ServiceLoader to discover implementations at runtime - Add `NoOpClusterGuard` as the open-source no-op default implementation - Add `ClusterGuardException` for guard-related error reporting - Add `ClusterGuardAction` HTTP API at `/api/cluster_guard/` for status query - Integrate `ClusterGuardFactory.getGuard()` into `DorisFE.java` (startup) and `SystemInfoService.java` (addBackend/dropBackend) ### Release note None ### Check List (For Author) - Test: No need to test (internal SPI wiring, no behavior change in open-source build) - Behavior changed: No - Does this need documentation: No Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
### What problem does this PR solve?
Issue Number: N/A
Problem Summary:
Add unit tests for the ClusterGuard SPI abstraction added in fe-core:
- NoOpClusterGuardTest: verifies all no-op methods pass without exception and getGuardInfo returns "{}"
- ClusterGuardExceptionTest: verifies message/cause constructors and checked-exception contract
- ClusterGuardFactoryTest: verifies singleton behavior, fallback to NoOpClusterGuard when no SPI provider is found, and correctness of custom guard injection
### Release note
None
### Check List (For Author)
- Test: Unit Test
- Behavior changed: No
- Does this need documentation: No
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
run buildall |
Cast to Object before instanceof RuntimeException check to avoid incompatible-types compile error — ClusterGuardException is statically known to be a checked exception so the compiler rejects the direct cast. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
run feut |
Contributor
FE UT Coverage ReportIncrement line coverage |
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 problem does this PR solve?
Issue Number: N/A
Problem Summary:
Add a ClusterGuard SPI (Service Provider Interface) abstraction in fe-core to
decouple cluster-level policy enforcement (e.g., node limits, time validity checks)
from business logic. The open-source fe-core depends only on the interface, while
commercial implementations can be plugged in at runtime via Java ServiceLoader
without any compile-time dependency on fe-core.
Key changes:
ClusterGuardinterface withonStartup,checkTimeValidity,checkNodeLimitandgetGuardInfomethodsClusterGuardFactoryusing Java ServiceLoader to discover implementations at runtimeNoOpClusterGuardas the open-source no-op default implementationClusterGuardExceptionfor guard-related error reportingClusterGuardActionHTTP API at/api/cluster_guard/for status queryClusterGuardFactory.getGuard()intoDorisFE.java(startup) andSystemInfoService.java(addBackend/dropBackend)Release note
None
Check List (For Author)
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com