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

com.github.ltsopensource.core.loadbalance.RandomLoadBalance Maven / Gradle / Ivy

package com.github.ltsopensource.core.loadbalance;

import com.github.ltsopensource.core.commons.concurrent.ThreadLocalRandom;

import java.util.List;

/**
 * 随机负载均衡算法
 * Robert HG ([email protected]) on 3/25/15.
 */
public class RandomLoadBalance extends AbstractLoadBalance {

    @Override
    protected  S doSelect(List shards, String seed) {
        return shards.get(ThreadLocalRandom.current().nextInt(shards.size()));
    }
}