Class DHTControlImpl
java.lang.Object
com.biglybt.core.dht.control.impl.DHTControlImpl
- All Implemented Interfaces:
DHTControl
,DHTTransportRequestHandler
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
protected static class
protected static class
private static class
protected class
protected static class
protected class
protected static class
protected static class
protected static class
(package private) static class
protected static class
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final List
<DHTControlActivity> (package private) final AEMonitor
(package private) final DHTControlAdapter
private final int
private final int
private long
private int
(package private) final DHTDB
private static final boolean
private final boolean
private final boolean
protected final AEMonitor
static int
(package private) final ThreadPool
private static final int
private final ThreadPool
private static final int
private final Map
<HashWrapper, Object> private static final int
(package private) final ThreadPool
(package private) final ThreadPool
(package private) final int
private long
(package private) long
private long
(package private) final ListenerManager
<DHTControlListener> (package private) DHTTransportContact
private long
private static final int
private final Map
<HashWrapper, Long> (package private) final DHTLogger
private final int
private final int
private byte[]
private final int
private static final int
private byte[]
private long
private static final int
(package private) DHTRouter
private int
private long
(package private) final int
(package private) boolean
private boolean
(package private) MessageDigest
private final Map
<InetAddress, Integer> private static final int
private final Map
<HashWrapper, byte[]> private static final int
(package private) byte[]
protected final AEMonitor
private final DHTControlStatsImpl
private boolean
private final DHTTransport
Fields inherited from interface com.biglybt.core.dht.control.DHTControl
B_DEFAULT, CACHE_AT_CLOSEST_N_DEFAULT, CACHE_REPUBLISH_INTERVAL_DEFAULT, ENABLE_RANDOM_DEFAULT, ENCODE_KEYS_DEFAULT, K_DEFAULT, LOOKUP_CONCURRENCY_DEFAULT, MAX_REP_PER_NODE_DEFAULT, ORIGINAL_REPUBLISH_INTERVAL_DEFAULT, SEARCH_CONCURRENCY_DEFAULT
-
Constructor Summary
ConstructorsConstructorDescriptionDHTControlImpl
(DHTControlAdapter _adapter, DHTTransport _transport, int _K, int _B, int _max_rep_per_node, int _search_concurrency, int _lookup_concurrency, int _original_republish_interval, int _cache_republish_interval, int _cache_at_closest_n, boolean _encode_keys, boolean _enable_random_poking, DHTLogger _logger) DHTControlImpl
(DHTControlAdapter _adapter, DHTTransport _transport, DHTRouter _router, DHTDB _database, int _K, int _B, int _max_rep_per_node, int _search_concurrency, int _lookup_concurrency, int _original_republish_interval, int _cache_republish_interval, int _cache_at_closest_n, boolean _encode_keys, boolean _enable_random_poking, DHTLogger _logger) -
Method Summary
Modifier and TypeMethodDescriptionvoid
int
compareDistances
(byte[] n1, byte[] n2) -ve -> n1 invalid input: '<' n2protected static int
compareDistances2
(byte[] n1, byte[] n2) int
computeAndCompareDistances
(byte[] t1, byte[] t2, byte[] pivot) protected static int
computeAndCompareDistances2
(byte[] t1, byte[] t2, byte[] pivot) byte[]
computeDistance
(byte[] n1, byte[] n2) protected static byte[]
computeDistance2
(byte[] n1, byte[] n2) void
contactImported
(DHTTransportContact contact, boolean is_bootstrap) Mechanism for reporting that a contact has been importedvoid
contactRemoved
(DHTTransportContact contact) protected void
createRouter
(DHTTransportContact _local_contact) void
destroy()
protected byte[]
encodeKey
(byte[] key) protected void
estimateDHTSize
(byte[] id, List<DHTTransportContact> contacts, int contacts_to_use) void
exportState
(DataOutputStream daos, int max) findNodeRequest
(DHTTransportContact originating_contact, byte[] id) private DHTTransportContact[]
findNodeRequest
(DHTTransportContact originating_contact, byte[] id, boolean already_logged) findValueRequest
(DHTTransportContact originating_contact, byte[] key, int max_values, short flags) private int
generateSpoofID
(DHTTransportContact contact) private byte[]
generateSpoofID2
(DHTTransportContact contact) void
get
(byte[] unencoded_key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener get_listener) getClosestContactsList
(byte[] id, int num_to_return, boolean live_only) protected Set
<DHTTransportContact> getClosestContactsSet
(byte[] id, int num_to_return, boolean live_only) getClosestKContactsList
(byte[] id, boolean live_only) int
getLocalValue
(byte[] unencoded_key) protected int
byte[]
getObfuscatedKey
(byte[] plain_key) protected byte[]
getObfuscatedValue
(byte[] plain_key) protected DHTTransportValue
getObfuscatedValue
(DHTTransportValue basis, byte[] plain_key) int
long
getStats()
getStoredValues
(byte[] unencoded_key) protected DHTControlImpl.DhtTaskSet
getSupport
(byte[] initial_encoded_key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTControlImpl.DHTOperationListenerDemuxer get_listener) int
protected BigInteger
IDToBigInteger
(byte[] data) void
importState
(DataInputStream dais) boolean
isDiversified
(byte[] unencoded_key) protected boolean
isIDInClosestContacts
(byte[] test_id, byte[] target_id, int num_to_consider, boolean live_only) boolean
isSeeded()
void
keyBlockRequest
(DHTTransportContact originating_contact, byte[] request, byte[] sig) protected void
logDiversification
(DHTTransportContact contact, byte[][] keys, byte[][] div) boolean
lookup
(byte[] unencoded_key, String description, long timeout, DHTOperationListener lookup_listener) protected DHTControlImpl.DhtTask
lookup
(ThreadPool thread_pool, boolean high_priority, byte[] _lookup_id, String description, short flags, boolean value_search, long timeout, int concurrency, int max_values, int search_accuracy, DHTControlImpl.lookupResultHandler handler) The lookup method returns up to K closest nodes to the targetboolean
lookupEncoded
(byte[] encoded_key, String description, long timeout, boolean high_priority, DHTOperationListener lookup_listener) protected void
nodeAddedToRouter
(DHTRouterContact new_contact) void
pingAll()
void
pingRequest
(DHTTransportContact originating_contact) protected void
poke()
void
print
(boolean full) void
put
(byte[] _unencoded_key, String _description, byte[] _value, short _flags, byte _life_hours, byte _replication_control, boolean _high_priority, DHTOperationListener _listener) protected void
put
(ThreadPool thread_pool, boolean high_priority, byte[][] initial_encoded_keys, String description, DHTTransportValue[][] initial_value_sets, short flags, List<DHTTransportContact> contacts, long timeout, DHTControlImpl.DHTOperationListenerDemuxer listener, boolean consider_diversification, Set things_written, int put_level, boolean immediate) protected void
put
(ThreadPool thread_pool, boolean high_priority, byte[] initial_encoded_key, String description, DHTTransportValue[] values, short flags, long timeout, boolean original_mappings, Set things_written, int put_level, DHTControlImpl.DHTOperationListenerDemuxer listener) protected void
put
(ThreadPool thread_pool, boolean high_priority, byte[] initial_encoded_key, String description, DHTTransportValue value, short flags, long timeout, boolean original_mappings, Set things_written, int put_level, DHTControlImpl.DHTOperationListenerDemuxer listener) void
putDirectEncodedKeys
(byte[][] encoded_keys, String description, DHTTransportValue[][] value_sets, DHTTransportContact contact, DHTOperationListener listener) void
putDirectEncodedKeys
(byte[][] encoded_keys, String description, DHTTransportValue[][] value_sets, List<DHTTransportContact> contacts) void
putEncodedKey
(byte[] encoded_key, String description, DHTTransportValue value, long timeout, boolean original_mappings) queryStoreRequest
(DHTTransportContact originating_contact, int header_len, List<Object[]> keys) byte[]
remove
(byte[] unencoded_key, String description, short flags, DHTOperationListener listener) byte[]
remove
(byte[] unencoded_key, String description, DHTOperationListener listener) byte[]
remove
(DHTTransportContact[] contacts, byte[] unencoded_key, String description, DHTOperationListener listener) void
protected void
requestPing
(DHTRouterContact contact) void
seed
(boolean full_wait) void
Manually mark things as seededvoid
setSleeping
(boolean asleep) void
setSuspended
(boolean susp) void
setTransportEstimatedDHTSize
(int size) statsRequest
(DHTTransportContact contact) storeRequest
(DHTTransportContact originating_contact, byte[][] keys, DHTTransportValue[][] value_sets) boolean
verifyContact
(DHTTransportContact c, boolean direct)
-
Field Details
-
DISABLE_REPLICATE_ON_JOIN
private static final boolean DISABLE_REPLICATE_ON_JOIN- See Also:
-
EXTERNAL_LOOKUP_CONCURRENCY
public static int EXTERNAL_LOOKUP_CONCURRENCY -
EXTERNAL_PUT_CONCURRENCY
private static final int EXTERNAL_PUT_CONCURRENCY- See Also:
-
EXTERNAL_SLEEPING_PUT_CONCURRENCY
private static final int EXTERNAL_SLEEPING_PUT_CONCURRENCY- See Also:
-
RANDOM_QUERY_PERIOD
private static final int RANDOM_QUERY_PERIOD- See Also:
-
INTEGRATION_TIME_MAX
private static final int INTEGRATION_TIME_MAX- See Also:
-
adapter
-
transport
-
local_contact
DHTTransportContact local_contact -
router
DHTRouter router -
database
-
stats
-
logger
-
node_id_byte_count
private final int node_id_byte_count -
search_concurrency
final int search_concurrency -
lookup_concurrency
private final int lookup_concurrency -
cache_at_closest_n
private final int cache_at_closest_n -
K
final int K -
B
private final int B -
max_rep_per_node
private final int max_rep_per_node -
encode_keys
private final boolean encode_keys -
enable_random_poking
private final boolean enable_random_poking -
router_start_time
private long router_start_time -
router_count
private int router_count -
internal_lookup_pool
-
external_lookup_pool
-
internal_put_pool
-
external_put_pool
-
imported_state
-
seeded
volatile boolean seeded -
last_lookup
long last_lookup -
listeners
-
activities
-
activity_mon
-
estimate_mon
-
last_dht_estimate_time
private long last_dht_estimate_time -
local_dht_estimate
private long local_dht_estimate -
combined_dht_estimate
private long combined_dht_estimate -
combined_dht_estimate_mag
private int combined_dht_estimate_mag -
LOCAL_ESTIMATE_HISTORY
private static final int LOCAL_ESTIMATE_HISTORY- See Also:
-
local_estimate_values
-
REMOTE_ESTIMATE_HISTORY
private static final int REMOTE_ESTIMATE_HISTORY- See Also:
-
remote_estimate_values
-
spoof_mon
-
spoof_digest
MessageDigest spoof_digest -
spoof_key
byte[] spoof_key -
SPOOF_GEN_HISTORY_SIZE
private static final int SPOOF_GEN_HISTORY_SIZE- See Also:
-
spoof_gen_history
-
spoof_gen_history2
-
SPOOF_ID2_SIZE
private static final int SPOOF_ID2_SIZE- See Also:
-
last_node_add_check
private long last_node_add_check -
node_add_check_uninteresting_limit
private byte[] node_add_check_uninteresting_limit -
rbs_time
private long rbs_time -
rbs_id
private byte[] rbs_id -
sleeping
private boolean sleeping -
suspended
private boolean suspended
-
-
Constructor Details
-
DHTControlImpl
public DHTControlImpl(DHTControlAdapter _adapter, DHTTransport _transport, int _K, int _B, int _max_rep_per_node, int _search_concurrency, int _lookup_concurrency, int _original_republish_interval, int _cache_republish_interval, int _cache_at_closest_n, boolean _encode_keys, boolean _enable_random_poking, DHTLogger _logger) -
DHTControlImpl
public DHTControlImpl(DHTControlAdapter _adapter, DHTTransport _transport, DHTRouter _router, DHTDB _database, int _K, int _B, int _max_rep_per_node, int _search_concurrency, int _lookup_concurrency, int _original_republish_interval, int _cache_republish_interval, int _cache_at_closest_n, boolean _encode_keys, boolean _enable_random_poking, DHTLogger _logger)
-
-
Method Details
-
createRouter
-
getRouterUptime
public long getRouterUptime() -
getRouterCount
public int getRouterCount() -
setSleeping
public void setSleeping(boolean asleep) - Specified by:
setSleeping
in interfaceDHTControl
-
setSuspended
public void setSuspended(boolean susp) - Specified by:
setSuspended
in interfaceDHTControl
-
getStats
- Specified by:
getStats
in interfaceDHTControl
-
getTransport
- Specified by:
getTransport
in interfaceDHTControl
-
getRouter
- Specified by:
getRouter
in interfaceDHTControl
-
getDataBase
- Specified by:
getDataBase
in interfaceDHTControl
-
contactImported
Description copied from interface:DHTTransportRequestHandler
Mechanism for reporting that a contact has been imported- Specified by:
contactImported
in interfaceDHTTransportRequestHandler
- Parameters:
contact
-
-
contactRemoved
- Specified by:
contactRemoved
in interfaceDHTTransportRequestHandler
-
exportState
- Specified by:
exportState
in interfaceDHTControl
- Throws:
IOException
-
importState
- Specified by:
importState
in interfaceDHTControl
- Throws:
IOException
-
seed
public void seed(boolean full_wait) - Specified by:
seed
in interfaceDHTControl
-
isSeeded
public boolean isSeeded()- Specified by:
isSeeded
in interfaceDHTControl
-
setSeeded
public void setSeeded()Description copied from interface:DHTControl
Manually mark things as seeded- Specified by:
setSeeded
in interfaceDHTControl
-
poke
protected void poke() -
put
public void put(byte[] _unencoded_key, String _description, byte[] _value, short _flags, byte _life_hours, byte _replication_control, boolean _high_priority, DHTOperationListener _listener) - Specified by:
put
in interfaceDHTControl
-
putEncodedKey
public void putEncodedKey(byte[] encoded_key, String description, DHTTransportValue value, long timeout, boolean original_mappings) - Specified by:
putEncodedKey
in interfaceDHTControl
-
put
protected void put(ThreadPool thread_pool, boolean high_priority, byte[] initial_encoded_key, String description, DHTTransportValue value, short flags, long timeout, boolean original_mappings, Set things_written, int put_level, DHTControlImpl.DHTOperationListenerDemuxer listener) -
put
protected void put(ThreadPool thread_pool, boolean high_priority, byte[] initial_encoded_key, String description, DHTTransportValue[] values, short flags, long timeout, boolean original_mappings, Set things_written, int put_level, DHTControlImpl.DHTOperationListenerDemuxer listener) -
putDirectEncodedKeys
public void putDirectEncodedKeys(byte[][] encoded_keys, String description, DHTTransportValue[][] value_sets, List<DHTTransportContact> contacts) - Specified by:
putDirectEncodedKeys
in interfaceDHTControl
-
putDirectEncodedKeys
public void putDirectEncodedKeys(byte[][] encoded_keys, String description, DHTTransportValue[][] value_sets, DHTTransportContact contact, DHTOperationListener listener) - Specified by:
putDirectEncodedKeys
in interfaceDHTControl
-
getObfuscatedKey
public byte[] getObfuscatedKey(byte[] plain_key) - Specified by:
getObfuscatedKey
in interfaceDHTControl
-
getObfuscatedValue
protected byte[] getObfuscatedValue(byte[] plain_key) -
getObfuscatedValue
-
put
protected void put(ThreadPool thread_pool, boolean high_priority, byte[][] initial_encoded_keys, String description, DHTTransportValue[][] initial_value_sets, short flags, List<DHTTransportContact> contacts, long timeout, DHTControlImpl.DHTOperationListenerDemuxer listener, boolean consider_diversification, Set things_written, int put_level, boolean immediate) -
getMaxDivDepth
protected int getMaxDivDepth() -
logDiversification
-
getLocalValue
- Specified by:
getLocalValue
in interfaceDHTControl
-
getStoredValues
- Specified by:
getStoredValues
in interfaceDHTControl
-
get
public void get(byte[] unencoded_key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener get_listener) - Specified by:
get
in interfaceDHTControl
-
isDiversified
public boolean isDiversified(byte[] unencoded_key) - Specified by:
isDiversified
in interfaceDHTControl
-
lookup
public boolean lookup(byte[] unencoded_key, String description, long timeout, DHTOperationListener lookup_listener) - Specified by:
lookup
in interfaceDHTControl
-
lookupEncoded
public boolean lookupEncoded(byte[] encoded_key, String description, long timeout, boolean high_priority, DHTOperationListener lookup_listener) - Specified by:
lookupEncoded
in interfaceDHTControl
-
getSupport
protected DHTControlImpl.DhtTaskSet getSupport(byte[] initial_encoded_key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTControlImpl.DHTOperationListenerDemuxer get_listener) -
remove
- Specified by:
remove
in interfaceDHTControl
-
remove
public byte[] remove(byte[] unencoded_key, String description, short flags, DHTOperationListener listener) - Specified by:
remove
in interfaceDHTControl
-
remove
public byte[] remove(DHTTransportContact[] contacts, byte[] unencoded_key, String description, DHTOperationListener listener) - Specified by:
remove
in interfaceDHTControl
-
lookup
protected DHTControlImpl.DhtTask lookup(ThreadPool thread_pool, boolean high_priority, byte[] _lookup_id, String description, short flags, boolean value_search, long timeout, int concurrency, int max_values, int search_accuracy, DHTControlImpl.lookupResultHandler handler) The lookup method returns up to K closest nodes to the target -
pingRequest
- Specified by:
pingRequest
in interfaceDHTTransportRequestHandler
-
keyBlockRequest
- Specified by:
keyBlockRequest
in interfaceDHTTransportRequestHandler
-
storeRequest
public DHTTransportStoreReply storeRequest(DHTTransportContact originating_contact, byte[][] keys, DHTTransportValue[][] value_sets) - Specified by:
storeRequest
in interfaceDHTTransportRequestHandler
-
queryStoreRequest
public DHTTransportQueryStoreReply queryStoreRequest(DHTTransportContact originating_contact, int header_len, List<Object[]> keys) - Specified by:
queryStoreRequest
in interfaceDHTTransportRequestHandler
-
findNodeRequest
- Specified by:
findNodeRequest
in interfaceDHTTransportRequestHandler
-
findNodeRequest
private DHTTransportContact[] findNodeRequest(DHTTransportContact originating_contact, byte[] id, boolean already_logged) -
findValueRequest
public DHTTransportFindValueReply findValueRequest(DHTTransportContact originating_contact, byte[] key, int max_values, short flags) - Specified by:
findValueRequest
in interfaceDHTTransportRequestHandler
-
statsRequest
- Specified by:
statsRequest
in interfaceDHTTransportRequestHandler
-
requestPing
-
nodeAddedToRouter
-
getClosestContactsSet
protected Set<DHTTransportContact> getClosestContactsSet(byte[] id, int num_to_return, boolean live_only) -
getClosestKContactsList
- Specified by:
getClosestKContactsList
in interfaceDHTControl
-
getClosestContactsList
public List<DHTTransportContact> getClosestContactsList(byte[] id, int num_to_return, boolean live_only) - Specified by:
getClosestContactsList
in interfaceDHTControl
-
isIDInClosestContacts
protected boolean isIDInClosestContacts(byte[] test_id, byte[] target_id, int num_to_consider, boolean live_only) -
encodeKey
protected byte[] encodeKey(byte[] key) -
computeAndCompareDistances
public int computeAndCompareDistances(byte[] t1, byte[] t2, byte[] pivot) - Specified by:
computeAndCompareDistances
in interfaceDHTControl
-
computeAndCompareDistances2
protected static int computeAndCompareDistances2(byte[] t1, byte[] t2, byte[] pivot) -
computeDistance
public byte[] computeDistance(byte[] n1, byte[] n2) - Specified by:
computeDistance
in interfaceDHTControl
-
computeDistance2
protected static byte[] computeDistance2(byte[] n1, byte[] n2) -
compareDistances
public int compareDistances(byte[] n1, byte[] n2) -ve -> n1 invalid input: '<' n2- Specified by:
compareDistances
in interfaceDHTControl
-
compareDistances2
protected static int compareDistances2(byte[] n1, byte[] n2) -
addListener
- Specified by:
addListener
in interfaceDHTControl
-
removeListener
- Specified by:
removeListener
in interfaceDHTControl
-
getActivities
- Specified by:
getActivities
in interfaceDHTControl
-
setTransportEstimatedDHTSize
public void setTransportEstimatedDHTSize(int size) - Specified by:
setTransportEstimatedDHTSize
in interfaceDHTTransportRequestHandler
-
getTransportEstimatedDHTSize
public int getTransportEstimatedDHTSize()- Specified by:
getTransportEstimatedDHTSize
in interfaceDHTTransportRequestHandler
-
getEstimatedDHTSize
public int getEstimatedDHTSize() -
estimateDHTSize
-
IDToBigInteger
-
generateSpoofID
-
generateSpoofID2
-
verifyContact
- Specified by:
verifyContact
in interfaceDHTControl
-
getContacts
- Specified by:
getContacts
in interfaceDHTControl
-
pingAll
public void pingAll()- Specified by:
pingAll
in interfaceDHTControl
-
destroy
public void destroy()- Specified by:
destroy
in interfaceDHTControl
-
print
public void print(boolean full) - Specified by:
print
in interfaceDHTControl
-