NIWSRoundRobinRule.java 863 字节
Newer Older
1 2
package com.netflix.niws.client;

3
import com.netflix.loadbalancer.BaseLoadBalancer;
4 5 6 7 8 9 10 11 12 13 14 15 16 17
import com.netflix.loadbalancer.RoundRobinRule;
import com.netflix.loadbalancer.Server;

/**
 * This class essentially contains the RoundRobinRule class defined in the loadbalancer package
 * @author stonse
 *
 */
public class NIWSRoundRobinRule extends AbstractNIWSLoadBalancerRule{

    RoundRobinRule rule = new RoundRobinRule();
    
    @Override
    public void initWithNiwsConfig(
18
            IClientConfig clientConfig) {
19 20 21 22
       rule = new RoundRobinRule();        
    }

    @Override
23
    public Server choose(BaseLoadBalancer lb, Object key) {       
24 25 26 27 28 29 30 31
        if (rule!=null){
            return rule.choose(lb, key);
        }else{
            throw new IllegalArgumentException("This class has not been initialized with the RoundRobinRule class");
        }
    }

}