com.alibaba.schedulerx.worker.route.RoundRobinRouter Maven / Gradle / Ivy
package com.alibaba.schedulerx.worker.route;
import java.util.List;
import java.util.Map;
/**
* @author dingxuan
*/
public class RoundRobinRouter extends Router {
@Override
public void init(String strategyContent) {
}
@Override
public String route(long appGroupId, long jobId, List workerList, Map> targetWorkerAddsMap, long loopCount, String masterWorkerIdAddr) {
int size = workerList.size();
int index = 0;
if (size == 0) {
return null;
} else if (loopCount >= size) {
index = new Long(loopCount % size).intValue();
}
return workerList.get(index);
}
}