All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.region.loadbalancer.policy.RandomPolicy Maven / Gradle / Ivy

package com.region.loadbalancer.policy;

import com.region.loadbalancer.group.Server;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

/**
 * Random Strategy
 *
 * @author liujieyu
 * @date 2023/5/27 14:59
 * @desciption
 */
public class RandomPolicy implements BalancerPolicy{

    private ThreadLocalRandom random = ThreadLocalRandom.current();

    @Override
    public Server choose(List servers) {
        return servers.get(random.nextInt(servers.size()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy