DHTImplpublic class DHTImpl extends Object implements com.aelitis.azureus.core.dht.DHT
Fields Summary |
---|
private com.aelitis.azureus.core.dht.DHTStorageAdapter | storage_adapter | private com.aelitis.azureus.core.dht.nat.DHTNATPuncherAdapter | nat_adapter | private DHTControl | control | private com.aelitis.azureus.core.dht.nat.DHTNATPuncher | nat_puncher | private com.aelitis.azureus.core.dht.speed.DHTSpeedTester | speed_tester | private Properties | properties | private com.aelitis.azureus.core.dht.DHTLogger | logger |
Constructors Summary |
---|
public DHTImpl(DHTTransport _transport, Properties _properties, com.aelitis.azureus.core.dht.DHTStorageAdapter _storage_adapter, com.aelitis.azureus.core.dht.nat.DHTNATPuncherAdapter _nat_adapter, com.aelitis.azureus.core.dht.DHTLogger _logger)
properties = _properties;
storage_adapter = _storage_adapter;
nat_adapter = _nat_adapter;
logger = _logger;
DHTNetworkPositionManager.initialise( storage_adapter );
DHTLog.setLogger( logger );
int K = getProp( PR_CONTACTS_PER_NODE, DHTControl.K_DEFAULT );
int B = getProp( PR_NODE_SPLIT_FACTOR, DHTControl.B_DEFAULT );
int max_r = getProp( PR_MAX_REPLACEMENTS_PER_NODE, DHTControl.MAX_REP_PER_NODE_DEFAULT );
int s_conc = getProp( PR_SEARCH_CONCURRENCY, DHTControl.SEARCH_CONCURRENCY_DEFAULT );
int l_conc = getProp( PR_LOOKUP_CONCURRENCY, DHTControl.LOOKUP_CONCURRENCY_DEFAULT );
int o_rep = getProp( PR_ORIGINAL_REPUBLISH_INTERVAL, DHTControl.ORIGINAL_REPUBLISH_INTERVAL_DEFAULT );
int c_rep = getProp( PR_CACHE_REPUBLISH_INTERVAL, DHTControl.CACHE_REPUBLISH_INTERVAL_DEFAULT );
int c_n = getProp( PR_CACHE_AT_CLOSEST_N, DHTControl.CACHE_AT_CLOSEST_N_DEFAULT );
control = DHTControlFactory.create(
new DHTControlAdapter()
{
public DHTStorageAdapter
getStorageAdapter()
{
return( storage_adapter );
}
public boolean
isDiversified(
byte[] key )
{
if ( storage_adapter == null ){
return( false );
}
return( storage_adapter.isDiversified( key ));
}
public byte[][]
diversify(
DHTTransportContact cause,
boolean put_operation,
boolean existing,
byte[] key,
byte type,
boolean exhaustive )
{
boolean valid;
if ( existing ){
valid = type == DHT.DT_FREQUENCY ||
type == DHT.DT_SIZE ||
type == DHT.DT_NONE;
}else{
valid = type == DHT.DT_FREQUENCY ||
type == DHT.DT_SIZE;
}
if ( storage_adapter != null && valid ){
if ( existing ){
return( storage_adapter.getExistingDiversification( key, put_operation, exhaustive ));
}else{
return( storage_adapter.createNewDiversification( cause, key, put_operation, type, exhaustive ));
}
}else{
if ( !valid ){
Debug.out( "Invalid diversification received: type = " + type );
}
if ( existing ){
return( new byte[][]{ key });
}else{
return( new byte[0][] );
}
}
}
},
_transport,
K, B, max_r,
s_conc, l_conc,
o_rep, c_rep, c_n,
logger );
if ( nat_adapter != null ){
nat_puncher = DHTNATPuncherFactory.create( nat_adapter, this );
}
speed_tester = DHTSpeedTesterFactory.create( this );
|
Methods Summary |
---|
public void | destroy()
if ( nat_puncher != null ){
nat_puncher.destroy();
}
DHTNetworkPositionManager.destroy( storage_adapter );
| public void | exportState(java.io.DataOutputStream os, int max)
control.exportState( os, max );
| public void | get(byte[] key, java.lang.String description, byte flags, int max_values, long timeout, boolean exhaustive, boolean high_priority, com.aelitis.azureus.core.dht.DHTOperationListener listener)
control.get( key, description, flags, max_values, timeout, exhaustive, high_priority, listener );
| public DHTControl | getControl()
return( control );
| public com.aelitis.azureus.core.dht.db.DHTDB | getDataBase()
return( control.getDataBase());
| public int | getIntProperty(java.lang.String name)
return(((Integer)properties.get(name)).intValue());
| public DHTTransportValue | getLocalValue(byte[] key)
return( control.getLocalValue( key ));
| public com.aelitis.azureus.core.dht.DHTLogger | getLogger()
return( logger );
| public com.aelitis.azureus.core.dht.nat.DHTNATPuncher | getNATPuncher()
return( nat_puncher );
| protected int | getProp(java.lang.String name, int def)
Integer x = (Integer)properties.get(name);
if ( x == null ){
properties.put( name, new Integer( def ));
return( def );
}
return( x.intValue());
| public com.aelitis.azureus.core.dht.router.DHTRouter | getRouter()
return( control.getRouter());
| public com.aelitis.azureus.core.dht.speed.DHTSpeedTester | getSpeedTester()
return( speed_tester );
| public com.aelitis.azureus.core.dht.DHTStorageAdapter | getStorageAdapter()
return( storage_adapter );
| public DHTTransport | getTransport()
return( control.getTransport());
| public void | importState(java.io.DataInputStream is)
control.importState( is );
| public void | integrate(boolean full_wait)
control.seed( full_wait );
if ( nat_puncher!= null ){
nat_puncher.start();
}
| public boolean | isDiversified(byte[] key)
return( control.isDiversified( key ));
| public void | print()
control.print();
| public void | put(byte[] key, java.lang.String description, byte[] value, byte flags, com.aelitis.azureus.core.dht.DHTOperationListener listener)
control.put( key, description, value, flags, listener );
| public byte[] | remove(byte[] key, java.lang.String description, com.aelitis.azureus.core.dht.DHTOperationListener listener)
return( control.remove( key, description, listener ));
| public void | setLogging(boolean on)
DHTLog.setLogging( on );
|
|