com.aelitis.azureus.core.dht.control.impl
Class DHTControlImpl
java.lang.Object
com.aelitis.azureus.core.dht.control.impl.DHTControlImpl
- All Implemented Interfaces:
- DHTControl, DHTTransportRequestHandler
public class DHTControlImpl
- extends Object
- implements DHTControl, DHTTransportRequestHandler
- Author:
- parg
Constructor Summary |
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)
|
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)
|
Method Summary |
void |
addListener(DHTControlListener l)
|
int |
compareDistances(byte[] n1,
byte[] n2)
-ve -> n1 < n2 |
protected 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 imported |
void |
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)
|
DHTTransportContact[] |
findNodeRequest(DHTTransportContact originating_contact,
byte[] id)
|
DHTTransportFindValueReply |
findValueRequest(DHTTransportContact originating_contact,
byte[] key,
int max_values,
short flags)
|
void |
get(byte[] unencoded_key,
String description,
short flags,
int max_values,
long timeout,
boolean exhaustive,
boolean high_priority,
DHTOperationListener get_listener)
|
DHTControlActivity[] |
getActivities()
|
List<DHTTransportContact> |
getClosestContactsList(byte[] id,
int num_to_return,
boolean live_only)
|
protected Set<DHTTransportContact> |
getClosestContactsSet(byte[] id,
int num_to_return,
boolean live_only)
|
List<DHTTransportContact> |
getClosestKContactsList(byte[] id,
boolean live_only)
|
List |
getContacts()
|
DHTDB |
getDataBase()
|
int |
getEstimatedDHTSize()
|
DHTTransportValue |
getLocalValue(byte[] unencoded_key)
|
protected int |
getMaxDivDepth()
|
byte[] |
getObfuscatedKey(byte[] plain_key)
|
protected byte[] |
getObfuscatedValue(byte[] plain_key)
|
protected DHTTransportValue |
getObfuscatedValue(DHTTransportValue basis,
byte[] plain_key)
|
DHTRouter |
getRouter()
|
int |
getRouterCount()
|
long |
getRouterUptime()
|
DHTControlStats |
getStats()
|
List<DHTTransportValue> |
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)
|
DHTTransport |
getTransport()
|
int |
getTransportEstimatedDHTSize()
|
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,
com.aelitis.azureus.core.dht.control.impl.DHTControlImpl.lookupResultHandler handler)
The lookup method returns up to K closest nodes to the target |
boolean |
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 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 contacts)
|
void |
putEncodedKey(byte[] encoded_key,
String description,
DHTTransportValue value,
long timeout,
boolean original_mappings)
|
DHTTransportQueryStoreReply |
queryStoreRequest(DHTTransportContact originating_contact,
int header_len,
List<Object[]> keys)
|
byte[] |
remove(byte[] unencoded_key,
String description,
DHTOperationListener listener)
|
byte[] |
remove(DHTTransportContact[] contacts,
byte[] unencoded_key,
String description,
DHTOperationListener listener)
|
void |
removeListener(DHTControlListener l)
|
protected void |
requestPing(DHTRouterContact contact)
|
void |
seed(boolean full_wait)
|
void |
setSeeded()
Manually mark things as seeded |
void |
setSleeping(boolean asleep)
|
void |
setSuspended(boolean susp)
|
void |
setTransportEstimatedDHTSize(int size)
|
DHTTransportFullStats |
statsRequest(DHTTransportContact contact)
|
DHTTransportStoreReply |
storeRequest(DHTTransportContact originating_contact,
byte[][] keys,
DHTTransportValue[][] value_sets)
|
boolean |
verifyContact(DHTTransportContact c,
boolean direct)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EXTERNAL_LOOKUP_CONCURRENCY
public static int EXTERNAL_LOOKUP_CONCURRENCY
estimate_mon
protected final AEMonitor estimate_mon
spoof_mon
protected final AEMonitor spoof_mon
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)
createRouter
protected void createRouter(DHTTransportContact _local_contact)
getRouterUptime
public long getRouterUptime()
getRouterCount
public int getRouterCount()
setSleeping
public void setSleeping(boolean asleep)
- Specified by:
setSleeping
in interface DHTControl
setSuspended
public void setSuspended(boolean susp)
- Specified by:
setSuspended
in interface DHTControl
getStats
public DHTControlStats getStats()
- Specified by:
getStats
in interface DHTControl
getTransport
public DHTTransport getTransport()
- Specified by:
getTransport
in interface DHTControl
getRouter
public DHTRouter getRouter()
- Specified by:
getRouter
in interface DHTControl
getDataBase
public DHTDB getDataBase()
- Specified by:
getDataBase
in interface DHTControl
contactImported
public void contactImported(DHTTransportContact contact,
boolean is_bootstrap)
- Description copied from interface:
DHTTransportRequestHandler
- Mechanism for reporting that a contact has been imported
- Specified by:
contactImported
in interface DHTTransportRequestHandler
contactRemoved
public void contactRemoved(DHTTransportContact contact)
- Specified by:
contactRemoved
in interface DHTTransportRequestHandler
exportState
public void exportState(DataOutputStream daos,
int max)
throws IOException
- Specified by:
exportState
in interface DHTControl
- Throws:
IOException
importState
public void importState(DataInputStream dais)
throws IOException
- Specified by:
importState
in interface DHTControl
- Throws:
IOException
seed
public void seed(boolean full_wait)
- Specified by:
seed
in interface DHTControl
isSeeded
public boolean isSeeded()
- Specified by:
isSeeded
in interface DHTControl
setSeeded
public void setSeeded()
- Description copied from interface:
DHTControl
- Manually mark things as seeded
- Specified by:
setSeeded
in interface DHTControl
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 interface DHTControl
putEncodedKey
public void putEncodedKey(byte[] encoded_key,
String description,
DHTTransportValue value,
long timeout,
boolean original_mappings)
- Specified by:
putEncodedKey
in interface DHTControl
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 contacts)
- Specified by:
putDirectEncodedKeys
in interface DHTControl
putDirectEncodedKeys
public void putDirectEncodedKeys(byte[][] encoded_keys,
String description,
DHTTransportValue[][] value_sets,
DHTTransportContact contact,
DHTOperationListener listener)
- Specified by:
putDirectEncodedKeys
in interface DHTControl
getObfuscatedKey
public byte[] getObfuscatedKey(byte[] plain_key)
- Specified by:
getObfuscatedKey
in interface DHTControl
getObfuscatedValue
protected byte[] getObfuscatedValue(byte[] plain_key)
getObfuscatedValue
protected DHTTransportValue getObfuscatedValue(DHTTransportValue basis,
byte[] plain_key)
put
protected void put(ThreadPool thread_pool,
boolean high_priority,
byte[][] initial_encoded_keys,
String description,
DHTTransportValue[][] initial_value_sets,
short flags,
List contacts,
long timeout,
DHTControlImpl.DHTOperationListenerDemuxer listener,
boolean consider_diversification,
Set things_written,
int put_level,
boolean immediate)
getMaxDivDepth
protected int getMaxDivDepth()
logDiversification
protected void logDiversification(DHTTransportContact contact,
byte[][] keys,
byte[][] div)
getLocalValue
public DHTTransportValue getLocalValue(byte[] unencoded_key)
- Specified by:
getLocalValue
in interface DHTControl
getStoredValues
public List<DHTTransportValue> getStoredValues(byte[] unencoded_key)
- Specified by:
getStoredValues
in interface DHTControl
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 interface DHTControl
isDiversified
public boolean isDiversified(byte[] unencoded_key)
- Specified by:
isDiversified
in interface DHTControl
lookup
public boolean lookup(byte[] unencoded_key,
String description,
long timeout,
DHTOperationListener lookup_listener)
- Specified by:
lookup
in interface DHTControl
lookupEncoded
public boolean lookupEncoded(byte[] encoded_key,
String description,
long timeout,
boolean high_priority,
DHTOperationListener lookup_listener)
- Specified by:
lookupEncoded
in interface DHTControl
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
public byte[] remove(byte[] unencoded_key,
String description,
DHTOperationListener listener)
- Specified by:
remove
in interface DHTControl
remove
public byte[] remove(DHTTransportContact[] contacts,
byte[] unencoded_key,
String description,
DHTOperationListener listener)
- Specified by:
remove
in interface DHTControl
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,
com.aelitis.azureus.core.dht.control.impl.DHTControlImpl.lookupResultHandler handler)
- The lookup method returns up to K closest nodes to the target
- Parameters:
lookup_id
-
- Returns:
pingRequest
public void pingRequest(DHTTransportContact originating_contact)
- Specified by:
pingRequest
in interface DHTTransportRequestHandler
keyBlockRequest
public void keyBlockRequest(DHTTransportContact originating_contact,
byte[] request,
byte[] sig)
- Specified by:
keyBlockRequest
in interface DHTTransportRequestHandler
storeRequest
public DHTTransportStoreReply storeRequest(DHTTransportContact originating_contact,
byte[][] keys,
DHTTransportValue[][] value_sets)
- Specified by:
storeRequest
in interface DHTTransportRequestHandler
queryStoreRequest
public DHTTransportQueryStoreReply queryStoreRequest(DHTTransportContact originating_contact,
int header_len,
List<Object[]> keys)
- Specified by:
queryStoreRequest
in interface DHTTransportRequestHandler
findNodeRequest
public DHTTransportContact[] findNodeRequest(DHTTransportContact originating_contact,
byte[] id)
- Specified by:
findNodeRequest
in interface DHTTransportRequestHandler
findValueRequest
public DHTTransportFindValueReply findValueRequest(DHTTransportContact originating_contact,
byte[] key,
int max_values,
short flags)
- Specified by:
findValueRequest
in interface DHTTransportRequestHandler
statsRequest
public DHTTransportFullStats statsRequest(DHTTransportContact contact)
- Specified by:
statsRequest
in interface DHTTransportRequestHandler
requestPing
protected void requestPing(DHTRouterContact contact)
nodeAddedToRouter
protected void nodeAddedToRouter(DHTRouterContact new_contact)
getClosestContactsSet
protected Set<DHTTransportContact> getClosestContactsSet(byte[] id,
int num_to_return,
boolean live_only)
getClosestKContactsList
public List<DHTTransportContact> getClosestKContactsList(byte[] id,
boolean live_only)
- Specified by:
getClosestKContactsList
in interface DHTControl
getClosestContactsList
public List<DHTTransportContact> getClosestContactsList(byte[] id,
int num_to_return,
boolean live_only)
- Specified by:
getClosestContactsList
in interface DHTControl
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 interface DHTControl
computeAndCompareDistances2
protected static int computeAndCompareDistances2(byte[] t1,
byte[] t2,
byte[] pivot)
computeDistance
public byte[] computeDistance(byte[] n1,
byte[] n2)
- Specified by:
computeDistance
in interface DHTControl
computeDistance2
protected static byte[] computeDistance2(byte[] n1,
byte[] n2)
compareDistances
public int compareDistances(byte[] n1,
byte[] n2)
- -ve -> n1 < n2
- Specified by:
compareDistances
in interface DHTControl
- Parameters:
n1
- n2
-
- Returns:
compareDistances2
protected static int compareDistances2(byte[] n1,
byte[] n2)
addListener
public void addListener(DHTControlListener l)
- Specified by:
addListener
in interface DHTControl
removeListener
public void removeListener(DHTControlListener l)
- Specified by:
removeListener
in interface DHTControl
getActivities
public DHTControlActivity[] getActivities()
- Specified by:
getActivities
in interface DHTControl
setTransportEstimatedDHTSize
public void setTransportEstimatedDHTSize(int size)
- Specified by:
setTransportEstimatedDHTSize
in interface DHTTransportRequestHandler
getTransportEstimatedDHTSize
public int getTransportEstimatedDHTSize()
- Specified by:
getTransportEstimatedDHTSize
in interface DHTTransportRequestHandler
getEstimatedDHTSize
public int getEstimatedDHTSize()
estimateDHTSize
protected void estimateDHTSize(byte[] id,
List<DHTTransportContact> contacts,
int contacts_to_use)
IDToBigInteger
protected BigInteger IDToBigInteger(byte[] data)
verifyContact
public boolean verifyContact(DHTTransportContact c,
boolean direct)
- Specified by:
verifyContact
in interface DHTControl
getContacts
public List getContacts()
- Specified by:
getContacts
in interface DHTControl
pingAll
public void pingAll()
- Specified by:
pingAll
in interface DHTControl
destroy
public void destroy()
- Specified by:
destroy
in interface DHTControl
print
public void print(boolean full)
- Specified by:
print
in interface DHTControl