正在显示
2 个修改的文件
包含
12 行增加
和
1 行删除
cim-forward-route/src/main/java/com/crossoverjie/cim/route/service/impl/AccountServiceRedisImpl.java
| @@ -103,6 +103,7 @@ public class AccountServiceRedisImpl implements AccountService { | @@ -103,6 +103,7 @@ public class AccountServiceRedisImpl implements AccountService { | ||
| 103 | 103 | ||
| 104 | Map<Long, CIMServerResVO> routes = new HashMap<>(64); | 104 | Map<Long, CIMServerResVO> routes = new HashMap<>(64); |
| 105 | 105 | ||
| 106 | + | ||
| 106 | RedisConnection connection = redisTemplate.getConnectionFactory().getConnection(); | 107 | RedisConnection connection = redisTemplate.getConnectionFactory().getConnection(); |
| 107 | ScanOptions options = ScanOptions.scanOptions() | 108 | ScanOptions options = ScanOptions.scanOptions() |
| 108 | .match(ROUTE_PREFIX + "*") | 109 | .match(ROUTE_PREFIX + "*") |
| @@ -116,6 +117,11 @@ public class AccountServiceRedisImpl implements AccountService { | @@ -116,6 +117,11 @@ public class AccountServiceRedisImpl implements AccountService { | ||
| 116 | parseServerInfo(routes, key); | 117 | parseServerInfo(routes, key); |
| 117 | 118 | ||
| 118 | } | 119 | } |
| 120 | + try { | ||
| 121 | + scan.close(); | ||
| 122 | + } catch (IOException e) { | ||
| 123 | + LOGGER.error("IOException",e); | ||
| 124 | + } | ||
| 119 | 125 | ||
| 120 | return routes; | 126 | return routes; |
| 121 | } | 127 | } |
| @@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest; | @@ -13,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest; | ||
| 13 | import org.springframework.test.context.junit4.SpringRunner; | 13 | import org.springframework.test.context.junit4.SpringRunner; |
| 14 | 14 | ||
| 15 | import java.util.Map; | 15 | import java.util.Map; |
| 16 | +import java.util.concurrent.TimeUnit; | ||
| 16 | 17 | ||
| 17 | @SpringBootTest(classes = RouteApplication.class) | 18 | @SpringBootTest(classes = RouteApplication.class) |
| 18 | @RunWith(SpringRunner.class) | 19 | @RunWith(SpringRunner.class) |
| @@ -25,8 +26,12 @@ public class AccountServiceRedisImplTest { | @@ -25,8 +26,12 @@ public class AccountServiceRedisImplTest { | ||
| 25 | 26 | ||
| 26 | @Test | 27 | @Test |
| 27 | public void loadRouteRelated() throws Exception { | 28 | public void loadRouteRelated() throws Exception { |
| 29 | + for (int i = 0; i < 100; i++) { | ||
| 30 | + | ||
| 28 | Map<Long, CIMServerResVO> longCIMServerResVOMap = accountService.loadRouteRelated(); | 31 | Map<Long, CIMServerResVO> longCIMServerResVOMap = accountService.loadRouteRelated(); |
| 29 | - LOGGER.info("longCIMServerResVOMap={}" , JSON.toJSONString(longCIMServerResVOMap)); | 32 | + LOGGER.info("longCIMServerResVOMap={},cun={}" , JSON.toJSONString(longCIMServerResVOMap),i); |
| 33 | + } | ||
| 34 | + TimeUnit.SECONDS.sleep(10); | ||
| 30 | } | 35 | } |
| 31 | 36 | ||
| 32 | } | 37 | } |
-
请 注册 或 登录 后发表评论