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

Type Parameters:
LOCATOR - Defines the type of the locators identifying a peer.
HEADER - The P2PHeader defines the static attributes addressed for the target of the P2PMessage (a header might be signed as it is not modified during dispatch).
TAIL - The P2PTail describes the dynamic attributes required during dispatch of a P2PMessage (a tail is modified during dispatch by having the visited hops appended).
MSG - The (sub-)type of the P2PMessage being processed by the according Peer (sub-)type.
All Known Subinterfaces:
Peer<LOCATOR,HEADER,TAIL,MSG,ROUTER>, PeerProxy<LOCATOR,HEADER,TAIL,MSG>
All Known Implementing Classes:
AbstractPeer

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

    Modifier and Type
    Method
    Description
    default int
    getHopCount(LOCATOR aDestination)
    Determines the (nearest) hop count to the given peer.
    int
    getHopCount(LOCATOR aLocator, LOCATOR[] aHops)
    Determines the (nearest) hop count to the given peer.
    void
    sendMessage(MSG aMessage)
    Passes a message to the given peer.
  • Method Details

    • 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.
    • sendMessage

      void sendMessage(MSG aMessage) throws NoSuchDestinationException, IOException
      Passes a message to the given peer.
      Parameters:
      aMessage - The message to be passed.
      Throws:
      NoSuchDestinationException - thrown in case there is none such destination peer.
      IOException - thrown in case I/O problems occurred while accessing the mesh.