Class DHTRouterImpl
java.lang.Object
com.biglybt.core.dht.router.impl.DHTRouterImpl
- All Implemented Interfaces:
DHTRouter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DHTRouterAdapterprivate intprivate static final AEMonitorprivate intprivate booleanprivate intprivate DHTRouterContactImplprivate DHTLoggerprivate intprivate final CopyOnWriteList<DHTRouterObserver> private List<DHTRouterContactImpl> private List<DHTRouterContactImpl> private Randomprivate static longprivate final BloomFilterprivate DHTRouterNodeImplprivate byte[]private static final intprivate static final int(package private) intprivate booleanprivate DHTRouterNodeImplprivate intprivate static final intprivate final DHTRouterStatsImpl(package private) booleanprivate final AEMonitorprivate static final intprivate TimerEventPeriodic -
Constructor Summary
ConstructorsConstructorDescriptionDHTRouterImpl(int _K, int _B, int _max_rep_per_node, byte[] _router_node_id, DHTRouterContactAttachment _attachment, DHTLogger _logger) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContact(byte[] node_id, DHTRouterContactAttachment attachment, boolean known_to_be_alive) private DHTRouterContactaddContactSupport(byte[] node_id, DHTRouterContactAttachment attachment, boolean known_to_be_alive) booleanAdds a routing table observer if it is not already observing.voidcontactAlive(byte[] node_id, DHTRouterContactAttachment attachment) Adds a contact to the router and marks it as "known to be alive"contactDead(byte[] node_id, boolean force) Informs the router that an attempt to interact with the contact failedprivate voidcontactDeadSupport(DHTRouterNodeImpl node, DHTRouterContactImpl contact, boolean force) voidcontactKnown(byte[] node_id, DHTRouterContactAttachment attachment, boolean force) Adds a contact to the router.voidcontactRemoved(byte[] node_id) booleanReturns whether the given observer is already observing.voiddestroy()protected voidprotected voidprotected voidfindAllContacts(List list, DHTRouterNodeImpl node) protected voidfindAllContacts(Set set, DHTRouterNodeImpl node) findBestContacts(int max) returns a list of best contacts in terms of uptime, best firstfindClosestContacts(byte[] node_id, int num_to_return, boolean live_only) Returns num_to_return or a few more closest contacts, unorderedprotected voidfindClosestContacts(byte[] node_id, int num_to_return, int depth, DHTRouterNodeImpl current_node, boolean live_only, List res) findContact(byte[] node_id) protected Object[]findContactSupport(byte[] node_id) protected DHTRouterNodeImplfindNode(byte[] node_id) Returns a list of DHTRouterContact objectsprotected longprotected longbyte[]getID()intgetK()protected longprotected longprotected DHTRouterNodeImplgetStats()protected long[]protected voidgetStatsSupport(long[] stats_array, DHTRouterNodeImpl node) booleanisID(byte[] id) protected voidprotected voidnotifyAdded(DHTRouterContact contact) protected voidprotected voidnotifyLocationChanged(DHTRouterContact contact) protected voidnotifyNowAlive(DHTRouterContact contact) protected voidnotifyNowFailing(DHTRouterContact contact) protected voidnotifyRemoved(DHTRouterContact contact) protected voidvoidprint()voidrecordLookup(byte[] node_id) voidrefreshIdleLeaves(long idle_max) protected voidrefreshNode(List nodes_to_refresh, DHTRouterNodeImpl node, byte[] path) protected voidrefreshNodes(List nodes_to_refresh, DHTRouterNodeImpl node, byte[] path, boolean seeding, long max_permitted_idle) byte[]booleanRemoves the observer if it is already observing.protected voidrequestLookup(byte[] id, String description) protected voidrequestNodeAdd(DHTRouterContactImpl contact) booleanrequestPing(byte[] node_id) protected voidrequestPing(DHTRouterContactImpl contact) voidseed()Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets)protected voidvoidsetAdapter(DHTRouterAdapter _adapter) voidsetSleeping(boolean _sleeping) voidsetSuspended(boolean _suspended)
-
Field Details
-
SMALLEST_SUBTREE_MAX_EXCESS
private static final int SMALLEST_SUBTREE_MAX_EXCESS- See Also:
-
is_bootstrap_proxy
private boolean is_bootstrap_proxy -
K
private int K -
B
private int B -
max_rep_per_node
private int max_rep_per_node -
logger
-
smallest_subtree_max
private int smallest_subtree_max -
adapter
-
local_contact
-
router_node_id
private byte[] router_node_id -
root
-
smallest_subtree
-
consecutive_dead
private int consecutive_dead -
random_seed
private static long random_seed -
random
-
outstanding_pings
-
outstanding_adds
-
stats
-
this_mon
-
class_mon
-
observers
-
sleeping
private boolean sleeping -
suspended
boolean suspended -
recent_contact_bloom
-
timer_event
-
seed_in_ticks
volatile int seed_in_ticks -
TICK_PERIOD
private static final int TICK_PERIOD- See Also:
-
SEED_DELAY_PERIOD
private static final int SEED_DELAY_PERIOD- See Also:
-
SEED_DELAY_TICKS
private static final int SEED_DELAY_TICKS- See Also:
-
-
Constructor Details
-
DHTRouterImpl
public DHTRouterImpl(int _K, int _B, int _max_rep_per_node, byte[] _router_node_id, DHTRouterContactAttachment _attachment, DHTLogger _logger)
-
-
Method Details
-
notifyAdded
-
notifyRemoved
-
notifyLocationChanged
-
notifyNowAlive
-
notifyNowFailing
-
notifyDead
protected void notifyDead() -
addObserver
Description copied from interface:DHTRouterAdds a routing table observer if it is not already observing.- Specified by:
addObserverin interfaceDHTRouter- Parameters:
rto- the observer to add- Returns:
trueif now observing,falseotherwise
-
containsObserver
Description copied from interface:DHTRouterReturns whether the given observer is already observing.- Specified by:
containsObserverin interfaceDHTRouter- Parameters:
rto- the observer to query as observing- Returns:
trueif observing,falseotherwise
-
removeObserver
Description copied from interface:DHTRouterRemoves the observer if it is already observing.- Specified by:
removeObserverin interfaceDHTRouter- Parameters:
rto- the observer to remove- Returns:
trueif no longer observing,falseotherwise
-
getStats
-
getK
-
getID
-
isID
-
getLocalContact
- Specified by:
getLocalContactin interfaceDHTRouter
-
setAdapter
- Specified by:
setAdapterin interfaceDHTRouter
-
setSleeping
public void setSleeping(boolean _sleeping) - Specified by:
setSleepingin interfaceDHTRouter
-
setSuspended
public void setSuspended(boolean _suspended) - Specified by:
setSuspendedin interfaceDHTRouter
-
contactKnown
Description copied from interface:DHTRouterAdds 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:
contactKnownin interfaceDHTRouter- Parameters:
node_id-attachment-
-
contactAlive
Description copied from interface:DHTRouterAdds a contact to the router and marks it as "known to be alive"- Specified by:
contactAlivein interfaceDHTRouter- Parameters:
node_id-attachment-
-
contactDead
Description copied from interface:DHTRouterInforms the router that an attempt to interact with the contact failed- Specified by:
contactDeadin interfaceDHTRouter- Parameters:
node_id-- Returns:
-
contactDeadSupport
private void contactDeadSupport(DHTRouterNodeImpl node, DHTRouterContactImpl contact, boolean force) -
contactRemoved
public void contactRemoved(byte[] node_id) -
addContact
public void addContact(byte[] node_id, DHTRouterContactAttachment attachment, boolean known_to_be_alive) -
addContactSupport
private DHTRouterContact addContactSupport(byte[] node_id, DHTRouterContactAttachment attachment, boolean known_to_be_alive) -
findClosestContacts
Description copied from interface:DHTRouterReturns num_to_return or a few more closest contacts, unordered- Specified by:
findClosestContactsin interfaceDHTRouter
-
findClosestContacts
protected void findClosestContacts(byte[] node_id, int num_to_return, int depth, DHTRouterNodeImpl current_node, boolean live_only, List res) -
findContact
- Specified by:
findContactin interfaceDHTRouter
-
findNode
-
findContactSupport
-
getNodeCount
protected long getNodeCount() -
getNodeCount
-
getContactCount
protected long getContactCount() -
getContactCount
-
findBestContacts
Description copied from interface:DHTRouterreturns a list of best contacts in terms of uptime, best first- Specified by:
findBestContactsin interfaceDHTRouter- Parameters:
max-- Returns:
-
getAllContacts
Description copied from interface:DHTRouterReturns a list of DHTRouterContact objects- Specified by:
getAllContactsin interfaceDHTRouter- Returns:
-
findAllContacts
-
findAllContacts
-
seed
-
seedSupport
protected void seedSupport() -
refreshNodes
protected void refreshNodes(List nodes_to_refresh, DHTRouterNodeImpl node, byte[] path, boolean seeding, long max_permitted_idle) -
refreshNode
-
getSmallestSubtree
-
recordLookup
public void recordLookup(byte[] node_id) - Specified by:
recordLookupin interfaceDHTRouter
-
refreshIdleLeaves
public void refreshIdleLeaves(long idle_max) - Specified by:
refreshIdleLeavesin interfaceDHTRouter
-
requestPing
public boolean requestPing(byte[] node_id) - Specified by:
requestPingin interfaceDHTRouter
-
requestPing
-
dispatchPings
protected void dispatchPings() -
pingeroonies
protected void pingeroonies() -
requestNodeAdd
-
dispatchNodeAdds
protected void dispatchNodeAdds() -
refreshRandom
public byte[] refreshRandom()- Specified by:
refreshRandomin interfaceDHTRouter
-
requestLookup
-
getStatsSupport
-
getStatsSupport
protected long[] getStatsSupport() -
log
-
print
-
destroy
-