From 2bead5411782127b4dfaef5449119bf9d40f8cbf Mon Sep 17 00:00:00 2001 From: talent-tan Date: Wed, 20 Feb 2019 22:29:26 +0800 Subject: [PATCH] https://github.com/tywo45/t-io/issues/14 --- src/core/src/main/java/org/tio/core/Tio.java | 72 +------------------- 1 file changed, 3 insertions(+), 69 deletions(-) diff --git a/src/core/src/main/java/org/tio/core/Tio.java b/src/core/src/main/java/org/tio/core/Tio.java index eb0b9802..5fb219a0 100644 --- a/src/core/src/main/java/org/tio/core/Tio.java +++ b/src/core/src/main/java/org/tio/core/Tio.java @@ -513,8 +513,6 @@ public static Page getPageOfAll(GroupContext groupContext, Integer pageIn * @author tanyaowu */ public static Page getPageOfConnecteds(ClientGroupContext clientGroupContext, Integer pageIndex, Integer pageSize) { - // SetWithLock setWithLock = Tio.getAllConnectedsChannelContexts(clientGroupContext); - // return PageUtils.fromSetWithLock(setWithLock, pageIndex, pageSize); return getPageOfConnecteds(clientGroupContext, pageIndex, pageSize, null); } @@ -542,8 +540,6 @@ public static Page getPageOfConnecteds(ClientGroupContext clientGroupCont * @author tanyaowu */ public static Page getPageOfGroup(GroupContext groupContext, String group, Integer pageIndex, Integer pageSize) { - // SetWithLock setWithLock = Tio.getChannelContextsByGroup(groupContext, group); - // return PageUtils.fromSetWithLock(setWithLock, pageIndex, pageSize); return getPageOfGroup(groupContext, group, pageIndex, pageSize, null); } @@ -589,27 +585,6 @@ public static boolean isInGroup(String group, ChannelContext channelContext) { return false; } return set.getObj().contains(group); - // - // MapWithLock> mapWithLock = - // channelContext.groupContext.groups.getChannelmap(); - // ReadLock lock = mapWithLock.readLock(); - // lock.lock(); - // try { - // Map> m = mapWithLock.getObj(); - // if (m == null || m.size() == 0) { - // return false; - // } - // SetWithLock set = m.get(channelContext); - // if (set == null) { - // return false; - // } - // return set.getObj().contains(group); - // } catch (Throwable e) { - // log.error(e.toString(), e); - // return false; - // } finally { - // lock.unlock(); - // } } /** @@ -770,13 +745,13 @@ public static Boolean send(ChannelContext channelContext, Packet packet) { */ private static Boolean send(final ChannelContext channelContext, final Packet packet, CountDownLatch countDownLatch, PacketSendMode packetSendMode) { try { - if (packet == null) { + if (packet == null || channelContext == null) { if (countDownLatch != null) { countDownLatch.countDown(); } return false; } - + if (channelContext.isVirtual) { if (countDownLatch != null) { countDownLatch.countDown(); @@ -784,14 +759,11 @@ private static Boolean send(final ChannelContext channelContext, final Packet pa return true; } - if (channelContext == null || channelContext.isClosed || channelContext.isRemoved) { + if (channelContext.isClosed || channelContext.isRemoved) { if (countDownLatch != null) { countDownLatch.countDown(); } if (channelContext != null) { - // log.error("can't send data, {}, isClosed:{}, isRemoved:{}, stack:{} ", channelContext, channelContext.isClosed, channelContext.isRemoved, - // ThreadUtils.stackTrace()); - log.info("can't send data, {}, isClosed:{}, isRemoved:{}", channelContext, channelContext.isClosed, channelContext.isRemoved); } return false; @@ -825,10 +797,7 @@ private static Boolean send(final ChannelContext channelContext, final Packet pa if (isSingleBlock) { long timeout = 10; try { - // channelContext.traceBlockPacket(SynPacketAction.BEFORE_WAIT, packet, countDownLatch, null); Boolean awaitFlag = countDownLatch.await(timeout, TimeUnit.SECONDS); - // channelContext.traceBlockPacket(SynPacketAction.AFTER__WAIT, packet, countDownLatch, null); - if (!awaitFlag) { log.error("{}, 阻塞发送超时, timeout:{}s, packet:{}", channelContext, timeout, packet.logstr()); } @@ -1014,9 +983,6 @@ private static Boolean sendToGroup(GroupContext groupContext, String group, Pack TioClusterConfig tioClusterConfig = groupContext.getTioClusterConfig(); if (tioClusterConfig.isCluster4group()) { - // TioClusterVo tioClusterVo = new TioClusterVo(packet); - // tioClusterVo.setGroup(group); - // tioClusterConfig.publish(tioClusterVo); notifyClusterForGroup(groupContext, group, packet); } } @@ -1107,10 +1073,6 @@ private static Boolean sendToIp(GroupContext groupContext, String ip, Packet pac TioClusterConfig tioClusterConfig = groupContext.getTioClusterConfig(); if (tioClusterConfig.isCluster4ip()) { - // TioClusterVo tioClusterVo = new TioClusterVo(packet); - // tioClusterVo.setIp(ip); - // tioClusterConfig.publish(tioClusterVo); - notifyClusterForIp(groupContext, ip, packet); } } @@ -1140,17 +1102,6 @@ public static void sendToSet(GroupContext groupContext, SetWithLock setWithLock, Packet packet, ChannelContextFilter channelContextFilter, boolean isBlock) { - // if (isBlock) - // { - // try - // { - // org.tio.core.GroupContext.SYN_SEND_SEMAPHORE.acquire(); - // } catch (InterruptedException e) - // { - // log.error(e.toString(), e); - // } - // } - boolean releasedLock = false; Lock lock = setWithLock.readLock(); lock.lock(); @@ -1160,10 +1111,6 @@ private static Boolean sendToSet(GroupContext groupContext, SetWithLock