com.aelitis.azureus.core.dht.router
Class DHTRouterWrapper

java.lang.Object
  extended by com.aelitis.azureus.core.dht.router.DHTRouterWrapper
All Implemented Interfaces:
DHTRouter

public class DHTRouterWrapper
extends Object
implements DHTRouter


Constructor Summary
DHTRouterWrapper(DHTRouter _delegate)
           
 
Method Summary
 boolean addObserver(DHTRouterObserver rto)
          Adds a routing table observer if it is not already observing.
 void contactAlive(byte[] node_id, DHTRouterContactAttachment attachment)
          Adds a contact to the router and marks it as "known to be alive"
 DHTRouterContact contactDead(byte[] node_id, boolean force)
          Informs the router that an attempt to interact with the contact failed
 void contactKnown(byte[] node_id, DHTRouterContactAttachment attachment, boolean force)
          Adds a contact to the router.
 boolean containsObserver(DHTRouterObserver rto)
          Returns whether the given observer is already observing.
 void destroy()
           
 List<DHTRouterContact> findBestContacts(int max)
          returns a list of best contacts in terms of uptime, best first
 List<DHTRouterContact> findClosestContacts(byte[] node_id, int num_to_return, boolean live_only)
          Returns num_to_return or a few more closest contacts, unordered
 DHTRouterContact findContact(byte[] node_id)
           
 List<DHTRouterContact> getAllContacts()
          Returns a list of DHTRouterContact objects
protected  DHTRouter getDelegate()
           
 byte[] getID()
           
 int getK()
           
 DHTRouterContact getLocalContact()
           
 DHTRouterStats getStats()
           
 boolean isID(byte[] node_id)
           
 void print()
           
 void recordLookup(byte[] node_id)
           
 void refreshIdleLeaves(long idle_max)
           
 byte[] refreshRandom()
           
 boolean removeObserver(DHTRouterObserver rto)
          Removes the observer if it is already observing.
 boolean requestPing(byte[] node_id)
           
 void seed()
          Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets)
 void setAdapter(DHTRouterAdapter _adapter)
           
 void setSleeping(boolean sleeping)
           
 void setSuspended(boolean susp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DHTRouterWrapper

public DHTRouterWrapper(DHTRouter _delegate)
Method Detail

getDelegate

protected DHTRouter getDelegate()

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[] node_id)
Specified by:
isID in interface DHTRouter

getLocalContact

public DHTRouterContact getLocalContact()
Specified by:
getLocalContact in interface DHTRouter

setAdapter

public void setAdapter(DHTRouterAdapter _adapter)
Specified by:
setAdapter in interface DHTRouter

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

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

contactAlive

public void contactAlive(byte[] node_id,
                         DHTRouterContactAttachment attachment)
Description copied from interface: DHTRouter
Adds a contact to the router and marks it as "known to be alive"

Specified by:
contactAlive 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:

findContact

public DHTRouterContact findContact(byte[] node_id)
Specified by:
findContact in interface DHTRouter

findClosestContacts

public List<DHTRouterContact> 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

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

refreshIdleLeaves

public void refreshIdleLeaves(long idle_max)
Specified by:
refreshIdleLeaves in interface DHTRouter

refreshRandom

public byte[] refreshRandom()
Specified by:
refreshRandom in interface DHTRouter

findBestContacts

public List<DHTRouterContact> 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 List<DHTRouterContact> getAllContacts()
Description copied from interface: DHTRouter
Returns a list of DHTRouterContact objects

Specified by:
getAllContacts in interface DHTRouter
Returns:

getStats

public DHTRouterStats getStats()
Specified by:
getStats in interface DHTRouter

setSleeping

public void setSleeping(boolean sleeping)
Specified by:
setSleeping in interface DHTRouter

setSuspended

public void setSuspended(boolean susp)
Specified by:
setSuspended in interface DHTRouter

destroy

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

print

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

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