1 5 package com.tc.net.groups; 6 7 import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap; 8 9 import com.tc.net.protocol.tcm.ChannelID; 10 11 import java.util.Map ; 12 13 18 public class NodeIDChannelIDConverter { 19 20 private static final Map map = new ConcurrentReaderHashMap(); 21 22 private static int nextChannelID = -100; 23 24 public static ChannelID getChannelIDFor(NodeID nodeID) { 25 ChannelID cid = (ChannelID) map.get(nodeID); 26 if (cid != null) return cid; 27 synchronized (map) { 28 if (!map.containsKey(nodeID)) { 29 map.put(nodeID, (cid = new ChannelID(nextChannelID--))); 30 } 31 } 32 return cid; 33 } 34 35 } 36 | Popular Tags |