提交 ea09ce09 编写于 作者: E Eason Chen 提交者: Hu Zongtang

[issue #670]change the way to create newGroupChannelTable (#1412)

* change the way to create newGroupChannelTable
上级 34b902fe
...@@ -53,7 +53,15 @@ public class ProducerManager { ...@@ -53,7 +53,15 @@ public class ProducerManager {
try { try {
if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) { if (this.groupChannelLock.tryLock(LOCK_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
try { 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 { } finally {
groupChannelLock.unlock(); groupChannelLock.unlock();
} }
......
...@@ -87,4 +87,12 @@ public class ProducerManagerTest { ...@@ -87,4 +87,12 @@ public class ProducerManagerTest {
assertThat(channelMap).isNull(); 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);
}
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册