mirror of
https://github.com/apache/rocketmq.git
synced 2026-10-29 17:25:35 +08:00
* change the way to create newGroupChannelTable
This commit is contained in:
@@ -53,7 +53,15 @@ public class ProducerManager {
|
||||
try {
|
||||
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
|
||||
try {
|
||||
newGroupChannelTable.putAll(groupChannelTable);
|
||||
Iterator<Map.Entry<String, HashMap<Channel, ClientChannelInfo>>> iter = groupChannelTable.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry<String, HashMap<Channel, ClientChannelInfo>> entry = iter.next();
|
||||
String key = entry.getKey();
|
||||
HashMap<Channel, ClientChannelInfo> val = entry.getValue();
|
||||
HashMap<Channel, ClientChannelInfo> tmp = new HashMap<Channel, ClientChannelInfo>();
|
||||
tmp.putAll(val);
|
||||
newGroupChannelTable.put(key, tmp);
|
||||
}
|
||||
} finally {
|
||||
groupChannelLock.unlock();
|
||||
}
|
||||
|
||||
@@ -87,4 +87,12 @@ public class ProducerManagerTest {
|
||||
assertThat(channelMap).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetGroupChannelTable() throws Exception {
|
||||
producerManager.registerProducer(group, clientInfo);
|
||||
HashMap<Channel, ClientChannelInfo> oldMap = producerManager.getGroupChannelTable().get(group);
|
||||
|
||||
producerManager.unregisterProducer(group, clientInfo);
|
||||
assertThat(oldMap.size()).isNotEqualTo(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user