@Test public void unregisterProducer() throws Exception { producerManager.registerProducer(group, clientInfo); Map<Channel, ClientChannelInfo> channelMap = producerManager.getGroupChannelTable().get(group); assertThat(channelMap).isNotNull(); assertThat(channelMap.get(channel)).isEqualTo(clientInfo); Channel channel1 = producerManager.findChannel("clientId"); assertThat(channel1).isNotNull(); assertThat(channel1).isEqualTo(channel); producerManager.unregisterProducer(group, clientInfo); channelMap = producerManager.getGroupChannelTable().get(group); channel1 = producerManager.findChannel("clientId"); assertThat(channelMap).isNull(); assertThat(channel1).isNull(); }
public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); clientChannelTable.remove(clientChannelInfo.getClientId()); if (old != null) { log.info("unregister a producer[{}] from groupChannelTable {}", group, clientChannelInfo.toString()); } if (channelTable.isEmpty()) { this.groupChannelTable.remove(group); log.info("unregister a producer group[{}] from groupChannelTable", group); } } }
ProducerManager { public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); clientChannelTable.remove(clientChannelInfo.getClientId()); if (old != null) { log.info("unregister a producer[{}] from groupChannelTable {}", group, clientChannelInfo.toString()); } if (channelTable.isEmpty()) { this.groupChannelTable.remove(group); log.info("unregister a producer group[{}] from groupChannelTable", group); } } } }
ProducerManager { public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); clientChannelTable.remove(clientChannelInfo.getClientId()); if (old != null) { log.info("unregister a producer[{}] from groupChannelTable {}", group, clientChannelInfo.toString()); } if (channelTable.isEmpty()) { this.groupChannelTable.remove(group); log.info("unregister a producer group[{}] from groupChannelTable", group); } } } ProducerManager(); }
ProducerManager { public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); clientChannelTable.remove(clientChannelInfo.getClientId()); if (old != null) { log.info("unregister a producer[{}] from groupChannelTable {}", group, clientChannelInfo.toString()); } if (channelTable.isEmpty()) { this.groupChannelTable.remove(group); log.info("unregister a producer group[{}] from groupChannelTable", group); } } } ProducerManager(); ConcurrentHashMap<String, ConcurrentHashMap<Channel, ClientChannelInfo>> getGroupChannelTable(); void scanNotActiveChannel(); synchronized void doChannelCloseEvent(final String remoteAddr, final Channel channel); synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo); synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo); Channel getAvaliableChannel(String groupId); Channel findChannel(String clientId); }
ProducerManager { public synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); clientChannelTable.remove(clientChannelInfo.getClientId()); if (old != null) { log.info("unregister a producer[{}] from groupChannelTable {}", group, clientChannelInfo.toString()); } if (channelTable.isEmpty()) { this.groupChannelTable.remove(group); log.info("unregister a producer group[{}] from groupChannelTable", group); } } } ProducerManager(); ConcurrentHashMap<String, ConcurrentHashMap<Channel, ClientChannelInfo>> getGroupChannelTable(); void scanNotActiveChannel(); synchronized void doChannelCloseEvent(final String remoteAddr, final Channel channel); synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo); synchronized void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo); Channel getAvaliableChannel(String groupId); Channel findChannel(String clientId);  }