Package com.biglybt.core.dht.impl
Class DHTImpl
- java.lang.Object
-
- com.biglybt.core.dht.impl.DHTImpl
-
- All Implemented Interfaces:
DHT
,AERunStateHandler.RunStateChangeListener
public class DHTImpl extends java.lang.Object implements DHT, AERunStateHandler.RunStateChangeListener
-
-
Field Summary
Fields Modifier and Type Field Description private DHTControl
control
private CopyOnWriteList<DHTListener>
listeners
private DHTLogger
logger
private DHTNATPuncherAdapter
nat_adapter
private DHTNATPuncher
nat_puncher
private java.util.Properties
properties
private boolean
runstate_startup
private boolean
sleeping
private DHTSpeedTester
speed_tester
(package private) DHTStorageAdapter
storage_adapter
-
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
Constructors Constructor Description DHTImpl(DHTTransport _transport, DHTRouter _router, DHTDB _database, java.util.Properties _properties, DHTStorageAdapter _storage_adapter, DHTLogger _logger)
DHTImpl(DHTTransport _transport, java.util.Properties _properties, DHTStorageAdapter _storage_adapter, DHTNATPuncherAdapter _nat_adapter, DHTLogger _logger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(DHTListener listener)
void
destroy()
void
exportState(java.io.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, java.lang.String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener listener)
DHTControl
getControl()
DHTDB
getDataBase()
int
getIntProperty(java.lang.String name)
DHTTransportValue
getLocalValue(byte[] key)
Returns value if originated from here for keyDHTLogger
getLogger()
DHTNATPuncher
getNATPuncher()
protected int
getProp(java.lang.String name, int def)
DHTRouter
getRouter()
DHTSpeedTester
getSpeedTester()
DHTStorageAdapter
getStorageAdapter()
java.util.List<DHTTransportValue>
getStoredValues(byte[] key)
DHTTransport
getTransport()
void
importState(java.io.DataInputStream is)
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
isSleeping()
void
print(boolean full)
void
put(byte[] key, java.lang.String description, byte[] value, short flags, boolean high_priority, DHTOperationListener listener)
default is HIGH PRIORITY.void
put(byte[] key, java.lang.String description, byte[] value, short flags, byte life_hours, boolean high_priority, DHTOperationListener listener)
void
put(byte[] key, java.lang.String description, byte[] value, short flags, byte life_hours, byte replication_control, boolean high_priority, DHTOperationListener listener)
void
put(byte[] key, java.lang.String description, byte[] value, short flags, DHTOperationListener listener)
byte[]
remove(byte[] key, java.lang.String description, DHTOperationListener listener)
byte[]
remove(DHTTransportContact[] contacts, byte[] key, java.lang.String description, DHTOperationListener listener)
void
removeListener(DHTListener listener)
void
runStateChanged(long run_state)
void
setLogging(boolean on)
void
setSuspended(boolean susp)
-
-
-
Field Detail
-
storage_adapter
final DHTStorageAdapter storage_adapter
-
nat_adapter
private DHTNATPuncherAdapter nat_adapter
-
control
private final DHTControl control
-
nat_puncher
private DHTNATPuncher nat_puncher
-
speed_tester
private DHTSpeedTester speed_tester
-
properties
private final java.util.Properties properties
-
logger
private final DHTLogger logger
-
listeners
private final CopyOnWriteList<DHTListener> listeners
-
runstate_startup
private boolean runstate_startup
-
sleeping
private boolean sleeping
-
-
Constructor Detail
-
DHTImpl
public DHTImpl(DHTTransport _transport, java.util.Properties _properties, DHTStorageAdapter _storage_adapter, DHTNATPuncherAdapter _nat_adapter, DHTLogger _logger)
-
DHTImpl
public DHTImpl(DHTTransport _transport, DHTRouter _router, DHTDB _database, java.util.Properties _properties, DHTStorageAdapter _storage_adapter, DHTLogger _logger)
-
-
Method Detail
-
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
protected int getProp(java.lang.String name, int def)
-
getIntProperty
public int getIntProperty(java.lang.String name)
- Specified by:
getIntProperty
in interfaceDHT
-
isDiversified
public boolean isDiversified(byte[] key)
- Specified by:
isDiversified
in interfaceDHT
-
put
public void put(byte[] key, java.lang.String description, byte[] value, short flags, DHTOperationListener listener)
-
put
public void put(byte[] key, java.lang.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, java.lang.String description, byte[] value, short flags, byte life_hours, boolean high_priority, DHTOperationListener listener)
-
put
public void put(byte[] key, java.lang.String description, byte[] value, short flags, byte life_hours, byte replication_control, boolean high_priority, DHTOperationListener listener)
-
getLocalValue
public DHTTransportValue getLocalValue(byte[] key)
Description copied from interface:DHT
Returns value if originated from here for key- Specified by:
getLocalValue
in interfaceDHT
- Returns:
-
getStoredValues
public java.util.List<DHTTransportValue> getStoredValues(byte[] key)
- Specified by:
getStoredValues
in interfaceDHT
-
get
public void get(byte[] key, java.lang.String description, short flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, DHTOperationListener listener)
-
remove
public byte[] remove(byte[] key, java.lang.String description, DHTOperationListener listener)
-
remove
public byte[] remove(DHTTransportContact[] contacts, byte[] key, java.lang.String description, DHTOperationListener listener)
-
getTransport
public DHTTransport getTransport()
- Specified by:
getTransport
in interfaceDHT
-
getControl
public DHTControl getControl()
- Specified by:
getControl
in interfaceDHT
-
getDataBase
public DHTDB getDataBase()
- Specified by:
getDataBase
in interfaceDHT
-
getNATPuncher
public DHTNATPuncher getNATPuncher()
- Specified by:
getNATPuncher
in interfaceDHT
-
getSpeedTester
public DHTSpeedTester getSpeedTester()
-
getStorageAdapter
public DHTStorageAdapter 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
-
exportState
public void exportState(java.io.DataOutputStream os, int max) throws java.io.IOException
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
max
- maximum to export, 0 -> all- Throws:
java.io.IOException
-
importState
public void importState(java.io.DataInputStream is) throws java.io.IOException
Description copied from interface:DHT
populate the DHT with previously exported state- Specified by:
importState
in interfaceDHT
- Throws:
java.io.IOException
-
setLogging
public void setLogging(boolean on)
- Specified by:
setLogging
in interfaceDHT
-
addListener
public void addListener(DHTListener listener)
- Specified by:
addListener
in interfaceDHT
-
removeListener
public void removeListener(DHTListener listener)
- Specified by:
removeListener
in interfaceDHT
-
-