Package com.biglybt.core.dht.impl
Class DHTImpl
java.lang.Object
com.biglybt.core.dht.impl.DHTImpl
- All Implemented Interfaces:
DHT
,AERunStateHandler.RunStateChangeListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DHTControl
private final CopyOnWriteList
<DHTListener> private final DHTLogger
private DHTNATPuncherAdapter
private DHTNATPuncher
private final Properties
private boolean
private boolean
private DHTSpeedTester
(package private) final DHTStorageAdapter
Fields inherited from interface com.biglybt.core.dht.DHT
DT_FREQUENCY, DT_NONE, DT_SIZE, DT_STRINGS, FLAG_ANON, FLAG_BRIDGED, FLAG_DOWNLOADING, FLAG_HIGH_PRIORITY, FLAG_LOOKUP_FOR_STORE, FLAG_MULTI_VALUE, FLAG_NONE, FLAG_OBFUSCATE_LOOKUP, FLAG_PRECIOUS, FLAG_PUT_AND_FORGET, FLAG_SEEDING, FLAG_SINGLE_VALUE, FLAG_STATS, MAX_VALUE_SIZE, NW_AZ_CVS, NW_AZ_MAIN, NW_AZ_MAIN_V6, NW_BIGLYBT_MAIN, NW_MAIN, PR_CACHE_AT_CLOSEST_N, PR_CACHE_REPUBLISH_INTERVAL, PR_CONTACTS_PER_NODE, PR_ENABLE_RANDOM_LOOKUP, PR_ENCODE_KEYS, PR_LOOKUP_CONCURRENCY, PR_MAX_REPLACEMENTS_PER_NODE, PR_NODE_SPLIT_FACTOR, PR_ORIGINAL_REPUBLISH_INTERVAL, PR_SEARCH_CONCURRENCY, REP_FACT_DEFAULT, REP_FACT_NONE
-
Constructor Summary
ConstructorsConstructorDescriptionDHTImpl
(DHTTransport _transport, DHTRouter _router, DHTDB _database, Properties _properties, DHTStorageAdapter _storage_adapter, DHTLogger _logger) DHTImpl
(DHTTransport _transport, Properties _properties, DHTStorageAdapter _storage_adapter, DHTNATPuncherAdapter _nat_adapter, DHTLogger _logger) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(DHTListener listener) void
destroy()
void
exportState
(DataOutputStream os, int max) externalises information that allows the DHT to be recreated at a later date and populated via the import methodvoid
get
(byte[] key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener listener) int
getIntProperty
(String name) getLocalValue
(byte[] key) Returns value if originated from here for keyprotected int
getStoredValues
(byte[] key) void
populate the DHT with previously exported statevoid
integrate
(boolean full_wait) Integrate the node into the DHT Can be invoked more than once if additional state is importedboolean
isDiversified
(byte[] key) boolean
void
print
(boolean full) void
put
(byte[] key, String description, byte[] value, short flags, boolean high_priority, DHTOperationListener listener) default is HIGH PRIORITY.void
put
(byte[] key, String description, byte[] value, short flags, byte life_hours, boolean high_priority, DHTOperationListener listener) void
put
(byte[] key, String description, byte[] value, short flags, byte life_hours, byte replication_control, boolean high_priority, DHTOperationListener listener) void
put
(byte[] key, String description, byte[] value, short flags, DHTOperationListener listener) byte[]
remove
(byte[] key, String description, short flags, DHTOperationListener listener) byte[]
remove
(byte[] key, String description, DHTOperationListener listener) byte[]
remove
(DHTTransportContact[] contacts, byte[] key, String description, DHTOperationListener listener) void
removeListener
(DHTListener listener) void
runStateChanged
(long run_state) void
setLogging
(boolean on) void
setSuspended
(boolean susp)
-
Field Details
-
storage_adapter
-
nat_adapter
-
control
-
nat_puncher
-
speed_tester
-
properties
-
logger
-
listeners
-
runstate_startup
private boolean runstate_startup -
sleeping
private boolean sleeping
-
-
Constructor Details
-
DHTImpl
public DHTImpl(DHTTransport _transport, Properties _properties, DHTStorageAdapter _storage_adapter, DHTNATPuncherAdapter _nat_adapter, DHTLogger _logger) -
DHTImpl
public DHTImpl(DHTTransport _transport, DHTRouter _router, DHTDB _database, Properties _properties, DHTStorageAdapter _storage_adapter, DHTLogger _logger)
-
-
Method Details
-
runStateChanged
public void runStateChanged(long run_state) - Specified by:
runStateChanged
in interfaceAERunStateHandler.RunStateChangeListener
-
isSleeping
public boolean isSleeping()- Specified by:
isSleeping
in interfaceDHT
-
setSuspended
public void setSuspended(boolean susp) - Specified by:
setSuspended
in interfaceDHT
-
getProp
-
getIntProperty
- Specified by:
getIntProperty
in interfaceDHT
-
isDiversified
public boolean isDiversified(byte[] key) - Specified by:
isDiversified
in interfaceDHT
-
put
public void put(byte[] key, String description, byte[] value, short flags, DHTOperationListener listener) -
put
public void put(byte[] key, String description, byte[] value, short flags, boolean high_priority, DHTOperationListener listener) Description copied from interface:DHT
default is HIGH PRIORITY. if you change to low priority then do so consistently as operations can get out of order otherwise -
put
public void put(byte[] key, String description, byte[] value, short flags, byte life_hours, boolean high_priority, DHTOperationListener listener) -
put
public void put(byte[] key, String description, byte[] value, short flags, byte life_hours, byte replication_control, boolean high_priority, DHTOperationListener listener) -
getLocalValue
Description copied from interface:DHT
Returns value if originated from here for key- Specified by:
getLocalValue
in interfaceDHT
- Parameters:
key
-- Returns:
-
getStoredValues
- Specified by:
getStoredValues
in interfaceDHT
-
get
public void get(byte[] key, String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener listener) -
remove
-
remove
-
remove
public byte[] remove(DHTTransportContact[] contacts, byte[] key, String description, DHTOperationListener listener) -
getTransport
- Specified by:
getTransport
in interfaceDHT
-
getRouter
-
getControl
- Specified by:
getControl
in interfaceDHT
-
getDataBase
- Specified by:
getDataBase
in interfaceDHT
-
getNATPuncher
- Specified by:
getNATPuncher
in interfaceDHT
-
getSpeedTester
-
getStorageAdapter
- Specified by:
getStorageAdapter
in interfaceDHT
-
integrate
public void integrate(boolean full_wait) Description copied from interface:DHT
Integrate the node into the DHT Can be invoked more than once if additional state is imported -
destroy
public void destroy() -
exportState
Description copied from interface:DHT
externalises information that allows the DHT to be recreated at a later date and populated via the import method- Specified by:
exportState
in interfaceDHT
- Parameters:
os
-max
- maximum to export, 0 -> all- Throws:
IOException
-
importState
Description copied from interface:DHT
populate the DHT with previously exported state- Specified by:
importState
in interfaceDHT
- Parameters:
is
-- Throws:
IOException
-
setLogging
public void setLogging(boolean on) - Specified by:
setLogging
in interfaceDHT
-
getLogger
-
print
public void print(boolean full) -
addListener
- Specified by:
addListener
in interfaceDHT
-
removeListener
- Specified by:
removeListener
in interfaceDHT
-