Class DHTRouterImpl

  • All Implemented Interfaces:
    DHTRouter

    public class DHTRouterImpl
    extends java.lang.Object
    implements DHTRouter
    • Constructor Detail

    • Method Detail

      • notifyLocationChanged

        protected void notifyLocationChanged​(DHTRouterContact contact)
      • notifyNowFailing

        protected void notifyNowFailing​(DHTRouterContact contact)
      • notifyDead

        protected void notifyDead()
      • addObserver

        public boolean addObserver​(DHTRouterObserver rto)
        Description copied from interface: DHTRouter
        Adds a routing table observer if it is not already observing.
        Specified by:
        addObserver in interface DHTRouter
        Parameters:
        rto - the observer to add
        Returns:
        true if now observing, false otherwise
      • containsObserver

        public boolean containsObserver​(DHTRouterObserver rto)
        Description copied from interface: DHTRouter
        Returns whether the given observer is already observing.
        Specified by:
        containsObserver in interface DHTRouter
        Parameters:
        rto - the observer to query as observing
        Returns:
        true if observing, false otherwise
      • removeObserver

        public boolean removeObserver​(DHTRouterObserver rto)
        Description copied from interface: DHTRouter
        Removes the observer if it is already observing.
        Specified by:
        removeObserver in interface DHTRouter
        Parameters:
        rto - the observer to remove
        Returns:
        true if no longer observing, false otherwise
      • getK

        public int getK()
        Specified by:
        getK in interface DHTRouter
      • getID

        public byte[] getID()
        Specified by:
        getID in interface DHTRouter
      • isID

        public boolean isID​(byte[] id)
        Specified by:
        isID in interface DHTRouter
      • setSleeping

        public void setSleeping​(boolean _sleeping)
        Specified by:
        setSleeping in interface DHTRouter
      • setSuspended

        public void setSuspended​(boolean _suspended)
        Specified by:
        setSuspended in interface DHTRouter
      • contactKnown

        public void contactKnown​(byte[] node_id,
                                 DHTRouterContactAttachment attachment,
                                 boolean force)
        Description copied from interface: DHTRouter
        Adds a contact to the router. The contact is not known to be alive (e.g. we've been returned the contact by someone but we've not either got a reply from it, nor has it invoked us.
        Specified by:
        contactKnown in interface DHTRouter
      • contactDead

        public DHTRouterContact contactDead​(byte[] node_id,
                                            boolean force)
        Description copied from interface: DHTRouter
        Informs the router that an attempt to interact with the contact failed
        Specified by:
        contactDead in interface DHTRouter
        Returns:
      • contactRemoved

        public void contactRemoved​(byte[] node_id)
      • findClosestContacts

        public java.util.List findClosestContacts​(byte[] node_id,
                                                  int num_to_return,
                                                  boolean live_only)
        Description copied from interface: DHTRouter
        Returns num_to_return or a few more closest contacts, unordered
        Specified by:
        findClosestContacts in interface DHTRouter
      • findClosestContacts

        protected void findClosestContacts​(byte[] node_id,
                                           int num_to_return,
                                           int depth,
                                           DHTRouterNodeImpl current_node,
                                           boolean live_only,
                                           java.util.List res)
      • findContactSupport

        protected java.lang.Object[] findContactSupport​(byte[] node_id)
      • getNodeCount

        protected long getNodeCount()
      • getContactCount

        protected long getContactCount()
      • findBestContacts

        public java.util.List findBestContacts​(int max)
        Description copied from interface: DHTRouter
        returns a list of best contacts in terms of uptime, best first
        Specified by:
        findBestContacts in interface DHTRouter
        Returns:
      • getAllContacts

        public java.util.List getAllContacts()
        Description copied from interface: DHTRouter
        Returns a list of DHTRouterContact objects
        Specified by:
        getAllContacts in interface DHTRouter
        Returns:
      • findAllContacts

        protected void findAllContacts​(java.util.Set set,
                                       DHTRouterNodeImpl node)
      • findAllContacts

        protected void findAllContacts​(java.util.List list,
                                       DHTRouterNodeImpl node)
      • seed

        public void seed()
        Description copied from interface: DHTRouter
        Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets)
        Specified by:
        seed in interface DHTRouter
      • seedSupport

        protected void seedSupport()
      • refreshNodes

        protected void refreshNodes​(java.util.List nodes_to_refresh,
                                    DHTRouterNodeImpl node,
                                    byte[] path,
                                    boolean seeding,
                                    long max_permitted_idle)
      • refreshNode

        protected void refreshNode​(java.util.List nodes_to_refresh,
                                   DHTRouterNodeImpl node,
                                   byte[] path)
      • recordLookup

        public void recordLookup​(byte[] node_id)
        Specified by:
        recordLookup in interface DHTRouter
      • requestPing

        public boolean requestPing​(byte[] node_id)
        Specified by:
        requestPing in interface DHTRouter
      • dispatchPings

        protected void dispatchPings()
      • pingeroonies

        protected void pingeroonies()
      • dispatchNodeAdds

        protected void dispatchNodeAdds()
      • requestLookup

        protected void requestLookup​(byte[] id,
                                     java.lang.String description)
      • getStatsSupport

        protected void getStatsSupport​(long[] stats_array,
                                       DHTRouterNodeImpl node)
      • getStatsSupport

        protected long[] getStatsSupport()
      • log

        protected void log​(java.lang.String str)
      • print

        public void print()
        Specified by:
        print in interface DHTRouter
      • destroy

        public void destroy()
        Specified by:
        destroy in interface DHTRouter