Interface PeerRouter<LOCATOR,​HEADER extends P2PHeader<LOCATOR>,​MSG extends P2PMessage<LOCATOR,​HEADER,​?>>

  • Type Parameters:
    LOCATOR - The locator defines the type which identifies a source and a destination (or stop-overs) of a P2PMessage.
    HEADER - The P2PHeader defines the least required attributes of a P2PMessage.
    MSG - The (sub-)type of the P2PMessage being processed by the according Peer (sub-)type.
    All Known Subinterfaces:
    Peer<LOCATOR,​HEADER,​MSG,​ROUTER>, PeerProxy<LOCATOR,​HEADER,​MSG>
    All Known Implementing Classes:
    AbstractPeer

    public interface PeerRouter<LOCATOR,​HEADER extends P2PHeader<LOCATOR>,​MSG extends P2PMessage<LOCATOR,​HEADER,​?>>
    A PeerRouter defines functionality to route a P2PMessage.
    • Method Detail

      • getHopCount

        default int getHopCount​(LOCATOR aDestination)
                         throws IOException
        Determines the (nearest) hop count to the given peer.
        Parameters:
        aDestination - The unique ID of the peer for which to get the hop count.
        Returns:
        The according hop count or -1 if the targeted peer is unreachable.
        Throws:
        IOException - thrown in case I/O problems occurred while accessing the mesh.
      • getHopCount

        int getHopCount​(LOCATOR aLocator,
                        LOCATOR[] aHops)
                 throws IOException
        Determines the (nearest) hop count to the given peer.
        Parameters:
        aLocator - The unique ID of the peer for which to get the hop count.
        aHops - The trail of peers already passed (in order to avoid turning circles when determining the hop count).
        Returns:
        The according hop count or -1 if the targeted peer is unreachable.
        Throws:
        IOException - thrown in case I/O problems occurred while accessing the mesh.