protected void removeRequest(PeerNATTraversal request, int outcome) { synchronized (initiators) { LinkedList requests = (LinkedList) initiators.get(request.getInitiator()); if (requests != null) { requests.remove(request); } pending_requests.remove(request); if (active_requests.remove(request)) { usage_average.addValue(request.getTimeUsed()); if (outcome == OUTCOME_SUCCESS) { success_count++; } else { InetSocketAddress target = request.getTarget(); negative_result_bloom.add(target.toString().getBytes()); if (outcome == OUTCOME_FAILED_NO_REND) { failed_no_rendezvous++; } } } } }
public void unregister(PeerNATInitiator initiator) { List to_cancel; synchronized (initiators) { LinkedList requests = (LinkedList) initiators.remove(initiator); if (requests == null) { Debug.out("initiator not present"); return; } else { to_cancel = requests; } } Iterator it = to_cancel.iterator(); while (it.hasNext()) { PeerNATTraversal traversal = (PeerNATTraversal) it.next(); traversal.cancel(); } }
public List getTraversals(PeerNATInitiator initiator) { List result = new ArrayList(); synchronized (initiators) { LinkedList requests = (LinkedList) initiators.get(initiator); if (requests != null) { Iterator it = requests.iterator(); while (it.hasNext()) { PeerNATTraversal x = (PeerNATTraversal) it.next(); result.add(x.getTarget()); } } } return (result); }