@Test public void testRegisterProducer() throws Exception { producerManager.registerProducer(group, clientInfo); Map<Channel, ClientChannelInfo> channelMap = producerManager.getGroupChannelTable().get(group); Channel channel1 = producerManager.findChannel("clientId"); assertThat(channelMap).isNotNull(); assertThat(channel1).isNotNull(); assertThat(channelMap.get(channel)).isEqualTo(clientInfo); assertThat(channel1).isEqualTo(channel); }
public synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) { ClientChannelInfo clientChannelInfoFound = null; ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null == channelTable) { channelTable = new ConcurrentHashMap<>(); this.groupChannelTable.put(group, channelTable); } clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel()); if (null == clientChannelInfoFound) { channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo); clientChannelTable.put(clientChannelInfo.getClientId(), clientChannelInfo.getChannel()); log.info("new producer connected, group: {} channel: {}", group, clientChannelInfo.toString()); } if (clientChannelInfoFound != null) { clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis()); } }
ProducerManager { public synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) { ClientChannelInfo clientChannelInfoFound = null; ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null == channelTable) { channelTable = new ConcurrentHashMap<>(); this.groupChannelTable.put(group, channelTable); } clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel()); if (null == clientChannelInfoFound) { channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo); clientChannelTable.put(clientChannelInfo.getClientId(), clientChannelInfo.getChannel()); log.info("new producer connected, group: {} channel: {}", group, clientChannelInfo.toString()); } if (clientChannelInfoFound != null) { clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis()); } } }
ProducerManager { public synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) { ClientChannelInfo clientChannelInfoFound = null; ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null == channelTable) { channelTable = new ConcurrentHashMap<>(); this.groupChannelTable.put(group, channelTable); } clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel()); if (null == clientChannelInfoFound) { channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo); clientChannelTable.put(clientChannelInfo.getClientId(), clientChannelInfo.getChannel()); log.info("new producer connected, group: {} channel: {}", group, clientChannelInfo.toString()); } if (clientChannelInfoFound != null) { clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis()); } } ProducerManager(); }
ProducerManager { public synchronized void registerProducer(final String group, final ClientChannelInfo clientChannelInfo) { ClientChannelInfo clientChannelInfoFound = null; ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null == channelTable) { channelTable = new ConcurrentHashMap<>(); this.groupChannelTable.put(group, channelTable); } clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel()); if (null == clientChannelInfoFound) { channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo); clientChannelTable.put(clientChannelInfo.getClientId(), clientChannelInfo.getChannel()); log.info("new producer connected, group: {} channel: {}", group, clientChannelInfo.toString()); } if (clientChannelInfoFound != null) { clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis()); } } 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 registerProducer(final String group, final ClientChannelInfo clientChannelInfo) { ClientChannelInfo clientChannelInfoFound = null; ConcurrentHashMap<Channel, ClientChannelInfo> channelTable = this.groupChannelTable.get(group); if (null == channelTable) { channelTable = new ConcurrentHashMap<>(); this.groupChannelTable.put(group, channelTable); } clientChannelInfoFound = channelTable.get(clientChannelInfo.getChannel()); if (null == clientChannelInfoFound) { channelTable.put(clientChannelInfo.getChannel(), clientChannelInfo); clientChannelTable.put(clientChannelInfo.getClientId(), clientChannelInfo.getChannel()); log.info("new producer connected, group: {} channel: {}", group, clientChannelInfo.toString()); } if (clientChannelInfoFound != null) { clientChannelInfoFound.setLastUpdateTimestamp(System.currentTimeMillis()); } } 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);  }