正在显示
1 个修改的文件
包含
4 行增加
和
2 行删除
| 1 | package com.crossoverjie.cim.common.route.algorithm.random; | 1 | package com.crossoverjie.cim.common.route.algorithm.random; |
| 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 | -import java.util.concurrent.ThreadLocalRandom; | ||
| 5 | 6 | ||
| 6 | import java.util.List; | 7 | import java.util.List; |
| 8 | +import java.util.concurrent.ThreadLocalRandom; | ||
| 7 | 9 | ||
| 8 | /** | 10 | /** |
| 9 | * Function: 路由策略, 随机 | 11 | * Function: 路由策略, 随机 |
| @@ -18,7 +20,7 @@ public class RandomHandle implements RouteHandle { | @@ -18,7 +20,7 @@ public class RandomHandle implements RouteHandle { | ||
| 18 | public String routeServer(List<String> values, String key) { | 20 | public String routeServer(List<String> values, String key) { |
| 19 | int size = values.size(); | 21 | int size = values.size(); |
| 20 | if (size == 0) { | 22 | if (size == 0) { |
| 21 | - throw new RuntimeException("CIM 服务器可用服务列表为空"); | 23 | + throw new CIMException(StatusEnum.SERVER_NOT_AVAILABLE) ; |
| 22 | } | 24 | } |
| 23 | int offset = ThreadLocalRandom.current().nextInt(size); | 25 | int offset = ThreadLocalRandom.current().nextInt(size); |
| 24 | 26 |
-
请 注册 或 登录 后发表评论