In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the role of AvailabilityFilteringRule in Ribbon, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
The version of Ribbon is 2.3.0.release.
Figure 1
AvailabilityFilteringRule inherits PredicateBasedRule because of the use of AbstractServerPredicate.
The choose method follows List-1, which is selected in turn to determine whether the condition is satisfied or not. If it is satisfied, the choose method selection of the parent class will be called for more than 10 times.
List-1
Public Server choose (Object key) {int count = 0; for (Server server = this.roundRobinRule.choose (key); count++ = (Integer) this.activeConnectionsLimit.get ();}
If it is not satisfied after 10 times in List-1, call the choose method of the parent class to take a look at the choose implementation of PredicateBasedRule, as shown in List-3
List-3
Public Server choose (Object key) {ILoadBalancer lb = this.getLoadBalancer (); Optional server = this.getPredicate (). ChooseRoundRobinAfterFiltering (lb.getAllServers (), key); return server.isPresent ()? (Server) server.get (): null;}
How is it implemented in chooseRoundRobinAfterFiltering, such as List-4
Get all service instances
Traverse the list of services to filter out those that do not meet the criteria
In the list of services that meet the conditions, use the RoundRibbon algorithm to select the services
List-4
Public Optional chooseRoundRobinAfterFiltering (List servers, Object loadBalancerKey) {List eligible = this.getEligibleServers (servers, loadBalancerKey); return eligible.size () = 0? Optional.absent (): Optional.of (eligible.get (this.incrementAndGetModulo (eligible.size ();} public List getEligibleServers (List servers, Object loadBalancerKey) {if (loadBalancerKey = = null) {return ImmutableList.copyOf (Iterables.filter (servers, this.getServerOnlyPredicate ());} else {List results = Lists.newArrayList (); Iterator var4 = servers.iterator () While (var4.hasNext ()) {Server server = (Server) var4.next (); if (this.apply (new PredicateKey (loadBalancerKey, server)) {results.add (server);}} return results;}}
AvailabilityFilteringRule selects the services that meet the conditions on the basis of RoundRibbon. If it has not been obtained for 10 times, the RoundRibbon algorithm is used to select the services in the list of services that meet the conditions.
This is what the role of AvailabilityFilteringRule in Ribbon is, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
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: 0
*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