@Test public void unregisterProducer() throws Exception { producerManager.registerProducer(group, clientInfo); HashMap<Channel, ClientChannelInfo> channelMap = producerManager.getGroupChannelTable().get(group); assertThat(channelMap).isNotNull(); assertThat(channelMap.get(channel)).isEqualTo(clientInfo); producerManager.unregisterProducer(group, clientInfo); channelMap = producerManager.getGroupChannelTable().get(group); assertThat(channelMap).isNull(); }
public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); 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); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager unregisterProducer lock timeout"); } } catch (InterruptedException e) { log.error("", e); } }
ProducerManager { public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); 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); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager unregisterProducer lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } }
ProducerManager { public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); 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); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager unregisterProducer lock timeout"); } } catch (InterruptedException e) { log.error("", e); } } ProducerManager(); }
ProducerManager { public void unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); 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); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager unregisterProducer 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 unregisterProducer(final String group, final ClientChannelInfo clientChannelInfo) { try { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { try { HashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null != channelTable && !channelTable.isEmpty()) { ClientChannelInfo old = channelTable.remove(clientChannelInfo.getChannel()); 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); } } } finally { this.groupChannelLock.unlock(); } } else { log.warn("ProducerManager unregisterProducer 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);  }