Skip to content
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

Add basic interface and adaptations for Sentinel cluster flow control in sentinel-core #257

Merged
merged 3 commits into from
Nov 23, 2018

Conversation

sczyh30
Copy link
Member

@sczyh30 sczyh30 commented Nov 21, 2018

Describe what this PR does / why we need it

Add basic interface for Sentinel cluster flow control in sentinel-core, and update rules and checkers for FlowRule and ParamFlowRule to adapt to cluster flow control interface.

Does this pull request fix one issue?

Related to #200 (a sub-task of it)

Describe how you did it

  • Add basic interface and entity for Sentinel cluster flow control
  • Add a universal TokenService SPI interface for both local flow control and distributed flow control service
  • Add TokenResult entity to represent result of acquiring token
  • Add ClusterTokenClient as the SPI interface for client of Sentinel cluster flow control
  • Update flow / parameter flow rule and checker for cluster mode
    • Add new fields clusterMode and clusterConfig for cluster mode
    • Add ClusterFlowConfig and ParamFlowClusterConfig class for rule config in cluster mode
    • Update FlowRuleChecker and ParamFlowChecker to support cluster mode
  • Extract rule util classes for FlowRule and ParamFlowRule

Describe how to verify it

See test cases.

Special notes for reviews

NONE

- Add a universal `TokenService` SPI interface for both local flow control and distributed flow control
- Add TokenResult entity to represents result of acquiring token
- Add `ClusterTokenClient` as the SPI interface for client of Sentinel cluster flow control

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
- Add new field `clusterMode` and `clusterConfig` for cluster mode
- Add a `ClusterFlowConfig` class for specific items for cluster flow control
- Update FlowRuleChecker to support cluster mode
- Extract valid rule checking and rule map generating logic to FlowRuleUtil

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
@sczyh30 sczyh30 added the to-review To review label Nov 21, 2018
@sczyh30 sczyh30 force-pushed the feature/cluster-core branch 2 times, most recently from 55858cb to 1010836 Compare November 23, 2018 02:05
…util class

- Update ParamFlowRule to support cluster mode
- Add `ParamFlowClusterConfig` to provide cluster mode items for the rule
- Update ParamFlowChecker to support cluster flow mode
- Extract ParamFlowRuleUtil class
- Change type of `flowId` from Integer to Long

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
@sczyh30 sczyh30 force-pushed the feature/cluster-core branch from 11d07cc to f539b5b Compare November 23, 2018 02:14
@codecov-io
Copy link

codecov-io commented Nov 23, 2018

Codecov Report

Merging #257 into master will decrease coverage by 1.93%.
The diff coverage is 23.27%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #257      +/-   ##
============================================
- Coverage     52.59%   50.65%   -1.94%     
- Complexity      913      923      +10     
============================================
  Files           150      158       +8     
  Lines          5037     5249     +212     
  Branches        720      754      +34     
============================================
+ Hits           2649     2659      +10     
- Misses         2065     2253     +188     
- Partials        323      337      +14
Impacted Files Coverage Δ Complexity Δ
.../sentinel/slots/block/flow/FlowRuleComparator.java 57.14% <0%> (-22.86%) 5 <4> (ø)
...p/sentinel/slots/block/flow/ClusterFlowConfig.java 0% <0%> (ø) 0 <0> (?)
...a/csp/sentinel/cluster/log/ClusterStatLogUtil.java 0% <0%> (ø) 0 <0> (?)
.../com/alibaba/csp/sentinel/cluster/TokenResult.java 0% <0%> (ø) 0 <0> (?)
...slots/block/flow/param/ParamFlowClusterConfig.java 0% <0%> (ø) 0 <0> (?)
...ba/csp/sentinel/cluster/TokenServerDescriptor.java 0% <0%> (ø) 0 <0> (?)
...baba/csp/sentinel/cluster/TokenClientProvider.java 0% <0%> (ø) 0 <0> (?)
...libaba/csp/sentinel/slots/block/flow/FlowSlot.java 100% <100%> (ø) 8 <6> (ø) ⬇️
...l/slots/block/flow/param/ParamFlowRuleManager.java 76.19% <100%> (+4.76%) 7 <0> (-19) ⬇️
...csp/sentinel/slots/block/flow/FlowRuleChecker.java 56.6% <11.76%> (-21.18%) 16 <1> (+2)
... and 17 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7bf2a80...f539b5b. Read the comment docs.

Copy link
Contributor

@CarpenterLee CarpenterLee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sczyh30 sczyh30 merged commit c80bb5a into master Nov 23, 2018
@sczyh30 sczyh30 removed the to-review To review label Nov 23, 2018
@sczyh30 sczyh30 deleted the feature/cluster-core branch November 28, 2018 02:13
@sczyh30 sczyh30 added this to the 1.4.0 milestone Nov 30, 2018
Arlmls pushed a commit to Arlmls/Sentinel that referenced this pull request Jan 8, 2019
Add basic interface and adaptations for Sentinel cluster flow control in `sentinel-core` (alibaba#257)
CST11021 pushed a commit to CST11021/Sentinel that referenced this pull request Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants