public Conversation insertNewConversation(long rmt_ip, int lcl_port, int rmt_port) { gc(); Conversation conv = new Conversation(rmt_ip, lcl_port, rmt_port); modLong.setLong(rmt_ip); modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF)); ModInteger mInt = new ModInteger(); mInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF)); HashMap portsMap = (HashMap) hostsMap.get(modLong); if (portsMap == null) { ModLong mLong = new ModLong(); mLong.setLong(rmt_ip); portsMap = new HashMap(); hostsMap.put(mLong, portsMap); } portsMap.put(mInt, conv); allConversations.add(conv); hasChanged = true; return conv; }
public void updateStatus(InputStream in) throws IOException { DataInputStream din = new DataInputStream(in); Set curSet = new HashSet(ipToHost.keySet()); int count = din.readInt(); for (int i = 0; i < count; i++) { long ip = din.readLong(); tmpLong.setLong(ip); Host host = (Host) ipToHost.get(tmpLong); if (host == null) { addHost(ip, Util.getInetAddress(ip)); host = (Host) ipToHost.get(tmpLong); } curSet.remove(tmpLong); host.readHost(din); host.updateData(); } Iterator it = curSet.iterator(); while (it.hasNext()) { Long elem = (Long) it.next(); removeHost(elem.longValue()); } hostsHolder.revalidate(); hostsHolder.repaint(); }
public Conversation findConversation(long rmt_ip, int lcl_port, int rmt_port) { modLong.setLong(rmt_ip); modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF)); Conversation conv = null; HashMap portsMap = (HashMap) hostsMap.get(modLong); if (portsMap != null) { conv = (Conversation) portsMap.get(modInt); } if (conv != null) { return conv; } return insertNewConversation(rmt_ip, lcl_port, rmt_port); }
public Conversation removeConversation(long rmt_ip, int lcl_port, int rmt_port) { modLong.setLong(rmt_ip); modInt.setInt((lcl_port << 16) | (rmt_port & 0xFFFF)); HashMap portsMap = (HashMap) hostsMap.get(modLong); Conversation conv = null; if (portsMap != null) { conv = (Conversation) portsMap.remove(modInt); if (conv != null) { if (portsMap.size() == 0) { hostsMap.remove(modLong); } } } allConversations.remove(conv); return conv; }