Class AbstractP2PTail<LOCATOR>

java.lang.Object
org.refcodes.p2p.AbstractP2PTail<LOCATOR>
Type Parameters:
LOCATOR - Defines the type of the locators identifying a peer.
All Implemented Interfaces:
org.refcodes.mixin.SourceAccessor<LOCATOR>, HopsAccessor<LOCATOR>, P2PTail<LOCATOR>

public class AbstractP2PTail<LOCATOR> extends Object implements P2PTail<LOCATOR>
Abstract implementation of a P2PTail.
  • Field Details

    • _hops

      protected LOCATOR[] _hops
  • Constructor Details

    • AbstractP2PTail

      public AbstractP2PTail()
      Constructs the tail. The source is added upon transmission as first stop-over.
  • Method Details

    • getSource

      public LOCATOR getSource()
      Specified by:
      getSource in interface org.refcodes.mixin.SourceAccessor<LOCATOR>
    • getHops

      public LOCATOR[] getHops()
      Retrieves the trail of peers already passed.
      Specified by:
      getHops in interface HopsAccessor<LOCATOR>
      Specified by:
      getHops in interface P2PTail<LOCATOR>
      Returns:
      The trail of peers already passed (in order to avoid turning circles when determining the hop count).
    • appendHop

      public void appendHop(LOCATOR aLocator)
      Adds a stop-over peer, being the peer which received the message for dispatching to the next peer. The stop-over will be prepended to the trail of peers.
      Specified by:
      appendHop in interface P2PTail<LOCATOR>
      Parameters:
      aLocator - the stop-over peer while dispatching the message.
    • toString

      public String toString()
      Overrides:
      toString in class Object