In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to understand ServerList in Ribbon. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
ServerList is the object of the deposit service instance.
ServerList
Public interface ServerList {public List getInitialListOfServers (); / * * Return updated list of servers. This is called say every 30 secs * (configurable) by the Loadbalancer's Ping cycle * * / public List getUpdatedListOfServers ();}
StaticServerList
Maintain the list of services through static configuration.
Public class StaticServerList implements ServerList {private final List servers; public StaticServerList (T... Servers) {this.servers = Arrays.asList (servers);} @ Override public List getInitialListOfServers () {return servers;} @ Override public List getUpdatedListOfServers () {return servers;}}
AbstractServerList
ServerList interceptor, used by LoadBalancer.
Public abstract class AbstractServerList implements ServerList, IClientConfigAware {/ * * Get a ServerListFilter instance. It uses {@ link ClientFactory#instantiateInstanceWithClientConfig (String, IClientConfig)} * which in turn uses reflection to initialize the filter instance. * The filter class name is determined by the value of {@ link CommonClientConfigKey#NIWSServerListFilterClassName} * in the {@ link IClientConfig}. The default implementation is {@ link ZoneAffinityServerListFilter}. * / public AbstractServerListFilter getFilterImpl (IClientConfig niwsClientConfig) throws ClientException {try {String niwsServerListFilterClassName = niwsClientConfig .getProperty (CommonClientConfigKey.NIWSServerListFilterClassName, ZoneAffinityServerListFilter.class.getName ()) .toString (); AbstractServerListFilter abstractNIWSServerListFilter = (AbstractServerListFilter) ClientFactory.instantiateInstanceWithClientConfig (niwsServerListFilterClassName, niwsClientConfig) Return abstractNIWSServerListFilter;} catch (Throwable e) {throw new ClientException (ClientException.ErrorType.CONFIGURATION, "Unable to get an instance of CommonClientConfigKey.NIWSServerListFilterClassName. Configured class: "+ niwsClientConfig .getProperty (CommonClientConfigKey.NIWSServerListFilterClassName), e);}
ConfigurationBasedServerList
Through the configuration file parameter listOfservers, to achieve ServerList. Multiple are separated by commas.
Public class ConfigurationBasedServerList extends AbstractServerList {private IClientConfig clientConfig; @ Override public List getInitialListOfServers () {return getUpdatedListOfServers ();} @ Override public List getUpdatedListOfServers () {String listOfServers = clientConfig.get (CommonClientConfigKey.ListOfServers); return derive (listOfServers);} @ Override public void initWithNiwsConfig (IClientConfig clientConfig) {this.clientConfig = clientConfig;} protected List derive (String value) {List list = Lists.newArrayList () If (! Strings.isNullOrEmpty (value)) {for (Strings: value.split (",")) {list.add (new Server (s.trim ());}} return list;}}
DiscoveryEnabledNIWSServerList
Through the service discovery of Eureka, the ServerList.
Public class DiscoveryEnabledNIWSServerList extends AbstractServerList {@ Override public List getInitialListOfServers () {return obtainServersViaDiscovery ();} @ Override public List getUpdatedListOfServers () {return obtainServersViaDiscovery ();} private List obtainServersViaDiscovery () {List serverList = new ArrayList (); if (eurekaClientProvider = = null | | eurekaClientProvider.get () = = null) {logger.warn ("EurekaClient has not been initialized yet, returning an empty list") Return new ArrayList ();} EurekaClient eurekaClient = eurekaClientProvider.get (); if (vipAddresseswritten null) {for (String vipAddress: vipAddresses.split (",")) {/ / if targetRegion is null, it will be interpreted as the same region of client List listOfInstanceInfo = eurekaClient.getInstancesByVipAddress (vipAddress, isSecure, targetRegion) For (InstanceInfo ii: listOfInstanceInfo) {if (ii.getStatus (). Equals (InstanceStatus.UP)) {if (shouldUseOverridePort) {if (logger.isDebugEnabled ()) {logger.debug ("Overriding port on client name:" + clientName + "to" + overridePort) } / / copy is necessary since the InstanceInfo builder just uses the original reference, / / and we don't want to corrupt the global eureka copy of the object which may be / / used by other clients in our system InstanceInfo copy = new InstanceInfo (ii) If (isSecure) {ii = new InstanceInfo.Builder (copy) .setSecurePort (overridePort). Build ();} else {ii = new InstanceInfo.Builder (copy) .setPort (overridePort). Build () }} DiscoveryEnabledServer des = new DiscoveryEnabledServer (ii, isSecure, shouldUseIpAddr); des.setZone (DiscoveryClient.getZone (ii)); serverList.add (des) }} if (serverList.size () > 0 & & prioritizeVipAddressBasedServers) {break; / / if the current vipAddress has servers, we dont use subsequent vipAddress based servers} return serverList;}} after reading the above, do you have any further understanding of how to understand ServerList in Ribbon? 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: 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
Step 1: declare: `step 2: TouchAction ta = new TouchAction (drive)
© 2024 shulou.com SLNews company. All rights reserved.