|
| 1 | +package com.codingapi.ribbon.loadbalancer; |
| 2 | + |
| 3 | +import org.slf4j.Logger; |
| 4 | +import org.slf4j.LoggerFactory; |
| 5 | + |
| 6 | +import com.netflix.client.config.IClientConfig; |
| 7 | +import com.netflix.loadbalancer.IPing; |
| 8 | +import com.netflix.loadbalancer.IRule; |
| 9 | +import com.netflix.loadbalancer.Server; |
| 10 | +import com.netflix.loadbalancer.ServerList; |
| 11 | +import com.netflix.loadbalancer.ServerListFilter; |
| 12 | +import com.netflix.loadbalancer.ServerListUpdater; |
| 13 | +import com.netflix.loadbalancer.ZoneAwareLoadBalancer; |
| 14 | + |
| 15 | +/** |
| 16 | + * created by foxdd 2017-12-05 |
| 17 | + */ |
| 18 | +public class LcnZoneAwareLoadBalancerProxy<T extends Server> extends ZoneAwareLoadBalancer<T> { |
| 19 | + |
| 20 | + private Logger logger = LoggerFactory.getLogger(LcnZoneAwareLoadBalancerProxy.class); |
| 21 | + |
| 22 | + LcnLoadBalancerRule lcnLoadBalancerRule = new LcnLoadBalancerRule(); |
| 23 | + |
| 24 | + public LcnZoneAwareLoadBalancerProxy(IClientConfig clientConfig, IRule rule, |
| 25 | + IPing ping, ServerList<T> serverList, ServerListFilter<T> filter, |
| 26 | + ServerListUpdater serverListUpdater) { |
| 27 | + super(clientConfig, rule, ping, serverList, filter, serverListUpdater); |
| 28 | + } |
| 29 | + |
| 30 | + @Override |
| 31 | + public Server chooseServer(Object key){ |
| 32 | + logger.info("enter chooseServer method, key:" + key); |
| 33 | + return lcnLoadBalancerRule.proxy(super.chooseServer(key)); |
| 34 | + } |
| 35 | + |
| 36 | +} |
0 commit comments