NIWSRoundRobinRule.java 866 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package com.netflix.niws.client;

import com.netflix.loadbalancer.NFLoadBalancer;
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(
            NiwsClientConfig niwsClientConfig) {
       rule = new RoundRobinRule();        
    }

    @Override
    public Server choose(NFLoadBalancer lb, Object key) {       
        if (rule!=null){
            return rule.choose(lb, key);
        }else{
            throw new IllegalArgumentException("This class has not been initialized with the RoundRobinRule class");
        }
    }

}