/** * cleanup any edge peers when trying to forward an SRDI query so we are guaranteed to the best of * our knowledge that the peer is a rendezvous. This is not perfect, as it may take time for the * peerview to converge but at least we can remove any peers that is not a rendezvous. */ protected Vector cleanupAnyEdges(String src, Vector results) { Vector clean = new Vector(results.size()); PeerID pid = null; // put the peerview as a vector of PIDs Vector rpvId = srdi.getGlobalPeerView(); // remove any peers not in the current peerview // these peers may be gone or have become edges for (int i = 0; i < results.size(); i++) { pid = (PeerID) results.elementAt(i); // eliminate the src of the query so we don't resend // the query to whom send it to us if (src.equals(pid.toString())) { continue; } // remove the local also, so we don't send to ourself if (localPeerId.equals(pid)) { continue; } if (rpvId.contains(pid)) { // ok that's a good RDV to the best if (LOG.isEnabledFor(Level.DEBUG)) { LOG.debug("valid rdv for SRDI forward " + pid); } clean.add(pid); } else { // cleanup our SRDI cache for that peer srdiIndex.remove(pid); } } return clean; }
/** * return the global peerview * * @return Vector of RDV member of the peerview */ protected Vector getGlobalPeerView() { return srdi.getGlobalPeerView(); }