作者 crossoverJie

:fire: Removing code or files.

1 package com.crossoverjie.cim.common.route.algorithm.loop; 1 package com.crossoverjie.cim.common.route.algorithm.loop;
2 2
  3 +import com.crossoverjie.cim.common.enums.StatusEnum;
  4 +import com.crossoverjie.cim.common.exception.CIMException;
3 import com.crossoverjie.cim.common.route.algorithm.RouteHandle; 5 import com.crossoverjie.cim.common.route.algorithm.RouteHandle;
4 6
5 import java.util.List; 7 import java.util.List;
@@ -18,7 +20,7 @@ public class LoopHandle implements RouteHandle { @@ -18,7 +20,7 @@ public class LoopHandle implements RouteHandle {
18 @Override 20 @Override
19 public String routeServer(List<String> values,String key) { 21 public String routeServer(List<String> values,String key) {
20 if (values.size() == 0) { 22 if (values.size() == 0) {
21 - throw new RuntimeException("CIM 服务器可用服务列表为空"); 23 + throw new CIMException(StatusEnum.SERVER_NOT_AVAILABLE) ;
22 } 24 }
23 Long position = index.incrementAndGet() % values.size(); 25 Long position = index.incrementAndGet() % values.size();
24 if (position < 0) { 26 if (position < 0) {
@@ -72,21 +72,4 @@ public class ServerCache { @@ -72,21 +72,4 @@ public class ServerCache {
72 72
73 } 73 }
74 74
75 - /**  
76 - * 选取服务器  
77 - *  
78 - * @return  
79 - */  
80 - public String selectServer() {  
81 - List<String> all = getAll();  
82 - if (all.size() == 0) {  
83 - throw new RuntimeException("CIM 服务器可用服务列表为空");  
84 - }  
85 - Long position = index.incrementAndGet() % all.size();  
86 - if (position < 0) {  
87 - position = 0L;  
88 - }  
89 -  
90 - return all.get(position.intValue());  
91 - }  
92 } 75 }