@Test public void doChannelCloseEvent() throws Exception { producerManager.registerProducer(group, clientInfo); assertThat(producerManager.getGroupChannelTable().get(group).get(channel)).isNotNull(); producerManager.doChannelCloseEvent("127.0.0.1", channel); assertThat(producerManager.getGroupChannelTable().get(group).get(channel)).isNull(); }
public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable.entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { log.info( "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } }
ProducerManager { public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable.entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { log.info( "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } } }
ProducerManager { public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable.entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { log.info( "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } } ProducerManager(); }
ProducerManager { public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable.entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { log.info( "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } } ProducerManager(); HashMap<String, HashMap<Channel, ClientChannelInfo>> getGroupChannelTable(); void scanNotActiveChannel(); void doChannelCloseEvent(final String remoteAddr, final Channel channel); void registerProducer(final String group, final ClientChannelInfo clientChannelInfo); void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo); Channel getAvaliableChannel(String groupId); }
ProducerManager { public void doChannelCloseEvent(final String remoteAddr, final Channel channel) { if (channel != null) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { for (final Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry : this.groupChannelTable.entrySet()) { final String group = entry.getKey(); final HashMap<Channel, ClientChannelInfo> clientChannelInfoTable = entry.getValue(); final ClientChannelInfo clientChannelInfo = clientChannelInfoTable.remove(channel); if (clientChannelInfo != null) { log.info( "NETTY EVENT: remove channel[{}][{}] from ProducerManager groupChannelTable, producer group: {}", clientChannelInfo.toString(), remoteAddr, group); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager doChannelCloseEvent lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } } ProducerManager(); HashMap<String, HashMap<Channel, ClientChannelInfo>> getGroupChannelTable(); void scanNotActiveChannel(); void doChannelCloseEvent(final String remoteAddr, final Channel channel); void registerProducer(final String group, final ClientChannelInfo clientChannelInfo); void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo); Channel getAvaliableChannel(String groupId);  }