作者 crossoverJie

:fire: Removing code or files.

package com.crossoverjie.cim.common.route.algorithm.loop;
import com.crossoverjie.cim.common.enums.StatusEnum;
import com.crossoverjie.cim.common.exception.CIMException;
import com.crossoverjie.cim.common.route.algorithm.RouteHandle;
import java.util.List;
... ... @@ -18,7 +20,7 @@ public class LoopHandle implements RouteHandle {
@Override
public String routeServer(List<String> values,String key) {
if (values.size() == 0) {
throw new RuntimeException("CIM 服务器可用服务列表为空");
throw new CIMException(StatusEnum.SERVER_NOT_AVAILABLE) ;
}
Long position = index.incrementAndGet() % values.size();
if (position < 0) {
... ...
... ... @@ -72,21 +72,4 @@ public class ServerCache {
}
/**
* 选取服务器
*
* @return
*/
public String selectServer() {
List<String> all = getAll();
if (all.size() == 0) {
throw new RuntimeException("CIM 服务器可用服务列表为空");
}
Long position = index.incrementAndGet() % all.size();
if (position < 0) {
position = 0L;
}
return all.get(position.intValue());
}
}
... ...