|
@@ -96,10 +96,6 @@ public class AcceptanceInboundHandlerAdapter extends ChannelInboundHandlerAdapt
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
protected void receiveMsg(String msg, String deviceId, Channel channel) {
|
|
|
manageChannel(channel, deviceId);
|
|
|
kafkaSendThreadPool.execute(() -> sendKakfaMsg(msg, deviceId));
|
|
@@ -118,8 +114,8 @@ public class AcceptanceInboundHandlerAdapter extends ChannelInboundHandlerAdapt
|
|
|
channelDeviceMap.put(channel, deviceId);
|
|
|
String addressStr = ConnectMsg.ipToLong(ip);
|
|
|
ConnectMsg cMsg = new ConnectMsg(ip, socketkey);
|
|
|
- Jedis jedis = jedisPool.getResource();
|
|
|
- try {
|
|
|
+
|
|
|
+ try (Jedis jedis = jedisPool.getResource()){
|
|
|
jedis.select(REDIS_INDEX_LINK);
|
|
|
String insertKey = PREFIX_LINK + addressStr;
|
|
|
String selectKey = PREFIX_DEVICE + deviceId;
|
|
@@ -128,9 +124,7 @@ public class AcceptanceInboundHandlerAdapter extends ChannelInboundHandlerAdapt
|
|
|
jedis.sadd(insertBackupKey, deviceId);
|
|
|
jedis.set(selectKey, StringUtil.convert2String(cMsg));
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- jedis.close();
|
|
|
+ logger.error(e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -305,7 +299,7 @@ public class AcceptanceInboundHandlerAdapter extends ChannelInboundHandlerAdapt
|
|
|
@Override
|
|
|
protected void initChannel(SocketChannel ch) throws Exception {
|
|
|
ch.pipeline().addLast("idleStateHandler", new IdleStateHandler(10, 0, 0, TimeUnit.MINUTES));
|
|
|
- ch.pipeline().addLast(this);
|
|
|
+ ch.pipeline().addLast(AcceptanceInboundHandlerAdapter.this);
|
|
|
}
|
|
|
}).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true);
|
|
|
|
|
@@ -316,7 +310,7 @@ public class AcceptanceInboundHandlerAdapter extends ChannelInboundHandlerAdapt
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage());
|
|
|
} finally {
|
|
|
- cleanRedisLinkData();
|
|
|
+ // cleanRedisLinkData();
|
|
|
workerGroup.shutdownGracefully();
|
|
|
bossGroup.shutdownGracefully();
|
|
|
}
|