In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about the source code analysis of slot implementation in Sentinel. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
In the CtSph.entryWithPriority method, an instance of ProcessorSlotChain is assigned to each resource. By default, the corresponding slot chain is created through the DefaultSlotChainBuilder class. The construction process is as follows:
Public ProcessorSlotChain build () {ProcessorSlotChain chain = new DefaultProcessorSlotChain (); chain.addLast (new NodeSelectorSlot ()); chain.addLast (new ClusterBuilderSlot ()); chain.addLast (new LogSlot ()); chain.addLast (new StatisticSlot ()); chain.addLast (new SystemSlot ()); chain.addLast (new AuthoritySlot ()); chain.addLast (new FlowSlot ()); chain.addLast (new DegradeSlot ()); return chain;}
It contains 8 slot by default, as follows.
NodeSelectorSlot
Create different DefaultNode for different context of the same resource and store them in a slot-level map to store statistical data.
ClusterBuilderSlot
Maintain a separate ClusterNode instance for the same resource to hold statistics. At the same time, according to the different origin, create the corresponding StatisticNode.
StatisticSlot
The counter of default & cluster & statistic node is added to the entry/exit method to realize data statistics.
SystemSlot
Achieve global (java process level) flow control through the SystemRuleManager.checkSystem method, including: total number of qps; threads; total average response time; system average load (obtained through OperatingSystemMXBean); CPU utilization (obtained through OperatingSystemMXBean).
AuthoritySlot
Manage all AuthorityRule through AuthorityRuleManager, and implement blacklist and whitelist detection on resource-origin granularity.
FlowSlow
The core logic of flow control implementation relies on FlowRuleManager to manage all FlowRule collections and test whether rule is effective on the resource dimension. FlowRule inspection is divided into local check and cluster check, which relies on centralized services to manage resources to access token.
In local check mode, it is mainly divided into two steps: selecting the correct counting node (origin/cluster/default node); TrafficShapingController determines whether to release the current call by counting node statistics.
DegradeSlot
The DegradeRuleManager.checkDegrade method detects whether the DegradeRule is valid on the resource dimension. Currently, there are three downgrade strategies: average response time, anomaly rate, and number of exceptions.
After reading the above, do you have any further understanding of the source code analysis of the slot implementation in Sentinel? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 299
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.