com.aelitis.azureus.core.dht.impl
Class DHTImpl

java.lang.Object
  extended by com.aelitis.azureus.core.dht.impl.DHTImpl
All Implemented Interfaces:
DHT, AERunStateHandler.RunStateChangeListener

public class DHTImpl
extends java.lang.Object
implements DHT, AERunStateHandler.RunStateChangeListener

Author:
parg

Field Summary
 
Fields inherited from interface com.aelitis.azureus.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_CVS, NW_MAIN, NW_MAIN_V6, 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
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
 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 method
 void 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 key
 DHTLogger 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 state
 void integrate(boolean full_wait)
          Integrate the node into the DHT Can be invoked more than once if additional state is imported
 boolean 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 interface AERunStateHandler.RunStateChangeListener

isSleeping

public boolean isSleeping()
Specified by:
isSleeping in interface DHT

setSuspended

public void setSuspended(boolean susp)
Specified by:
setSuspended in interface DHT

getProp

protected int getProp(java.lang.String name,
                      int def)

getIntProperty

public int getIntProperty(java.lang.String name)
Specified by:
getIntProperty in interface DHT

isDiversified

public boolean isDiversified(byte[] key)
Specified by:
isDiversified in interface DHT

put

public void put(byte[] key,
                java.lang.String description,
                byte[] value,
                short flags,
                DHTOperationListener listener)
Specified by:
put in interface DHT

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

Specified by:
put in interface DHT

put

public void put(byte[] key,
                java.lang.String description,
                byte[] value,
                short flags,
                byte life_hours,
                boolean high_priority,
                DHTOperationListener listener)
Specified by:
put in interface DHT

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)
Specified by:
put in interface DHT

getLocalValue

public DHTTransportValue getLocalValue(byte[] key)
Description copied from interface: DHT
Returns value if originated from here for key

Specified by:
getLocalValue in interface DHT
Returns:

getStoredValues

public java.util.List<DHTTransportValue> getStoredValues(byte[] key)
Specified by:
getStoredValues in interface DHT

get

public void get(byte[] key,
                java.lang.String description,
                short flags,
                int max_values,
                long timeout,
                boolean exhaustive,
                boolean high_priority,
                DHTOperationListener listener)
Specified by:
get in interface DHT

remove

public byte[] remove(byte[] key,
                     java.lang.String description,
                     DHTOperationListener listener)
Specified by:
remove in interface DHT

remove

public byte[] remove(DHTTransportContact[] contacts,
                     byte[] key,
                     java.lang.String description,
                     DHTOperationListener listener)
Specified by:
remove in interface DHT

getTransport

public DHTTransport getTransport()
Specified by:
getTransport in interface DHT

getRouter

public DHTRouter getRouter()
Specified by:
getRouter in interface DHT

getControl

public DHTControl getControl()
Specified by:
getControl in interface DHT

getDataBase

public DHTDB getDataBase()
Specified by:
getDataBase in interface DHT

getNATPuncher

public DHTNATPuncher getNATPuncher()
Specified by:
getNATPuncher in interface DHT

getSpeedTester

public DHTSpeedTester getSpeedTester()

getStorageAdapter

public DHTStorageAdapter getStorageAdapter()
Specified by:
getStorageAdapter in interface DHT

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

Specified by:
integrate in interface DHT

destroy

public void destroy()
Specified by:
destroy in interface DHT

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 interface DHT
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 interface DHT
Throws:
java.io.IOException

setLogging

public void setLogging(boolean on)
Specified by:
setLogging in interface DHT

getLogger

public DHTLogger getLogger()
Specified by:
getLogger in interface DHT

print

public void print(boolean full)
Specified by:
print in interface DHT

addListener

public void addListener(DHTListener listener)
Specified by:
addListener in interface DHT

removeListener

public void removeListener(DHTListener listener)
Specified by:
removeListener in interface DHT