org.gudy.azureus2.pluginsimpl.local.ddb
Class DDBaseImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.ddb.DDBaseImpl
All Implemented Interfaces:
DistributedDatabase

public class DDBaseImpl
extends Object
implements DistributedDatabase

Author:
parg

Nested Class Summary
protected  class DDBaseImpl.dbEvent
           
protected  class DDBaseImpl.listenerMapper
           
 
Field Summary
protected static AEMonitor class_mon
           
 
Fields inherited from interface org.gudy.azureus2.plugins.ddb.DistributedDatabase
DHT_CVS, DHT_MAIN, DT_FREQUENCY, DT_NONE, DT_SIZE, OP_EXHAUSTIVE_READ, OP_NONE, OP_PRIORITY_HIGH
 
Constructor Summary
protected DDBaseImpl(AzureusCore _azureus_core)
           
protected DDBaseImpl(String _net, DHTPluginInterface _dht)
           
 
Method Summary
 void addListener(DistributedDatabaseListener l)
           
 void addTransferHandler(DistributedDatabaseTransferType type, DistributedDatabaseTransferHandler handler)
           
protected  DistributedDatabaseValue call(DDBaseContactImpl contact, DistributedDatabaseProgressListener listener, DistributedDatabaseTransferType type, DistributedDatabaseValue value, long timeout)
           
 DistributedDatabaseKey createKey(Object key)
           
 DistributedDatabaseKey createKey(Object key, String description)
           
 DistributedDatabaseValue createValue(Object value)
           
 void delete(DistributedDatabaseListener listener, DistributedDatabaseKey key)
           
 void delete(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseContact[] targets)
           
static List<DistributedDatabase> getDDBs(Download download)
           
static List<DistributedDatabase> getDDBs(String[] networks)
           
static List<DistributedDatabase> getDDBs(String[] networks, Map<String,Object> _options)
           
protected  DHTPluginInterface getDHT()
           
 DHTPluginInterface getDHTPlugin()
           
 DistributedDatabaseContact getLocalContact()
           
 String getNetwork()
           
static DDBaseImpl getSingleton(AzureusCore azureus_core)
           
 DistributedDatabaseTransferType getStandardTransferType(int standard_type)
           
 DDBaseTTTorrent getTTTorrent()
           
 List<DistributedDatabaseValue> getValues(DistributedDatabaseKey key)
          Get all locally held (direct+indirect) values for a key
protected  DHTPluginInterface grabDHT()
           
 DistributedDatabaseContact importContact(InetSocketAddress address)
           
 DistributedDatabaseContact importContact(InetSocketAddress address, byte version)
           
 DistributedDatabaseContact importContact(InetSocketAddress address, byte version, int preferred_dht)
           
 DistributedDatabaseContact importContact(Map<String,Object> map)
           
 boolean isAvailable()
           
 boolean isExtendedUseAllowed()
           
 boolean isInitialized()
           
protected  void log(String str)
           
protected  DistributedDatabaseValue read(DDBaseContactImpl contact, DistributedDatabaseProgressListener listener, DistributedDatabaseTransferType type, DistributedDatabaseKey key, long timeout)
           
 void read(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout)
           
 void read(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout, int options)
           
 void readKeyStats(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout)
           
 void removeListener(DistributedDatabaseListener l)
           
protected  void throwIfNotAvailable()
           
protected  void write(DDBaseContactImpl contact, DistributedDatabaseProgressListener listener, DistributedDatabaseTransferType type, DistributedDatabaseKey key, DistributedDatabaseValue value, long timeout)
           
 void write(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseValue value)
           
 void write(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseValue[] values)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

class_mon

protected static AEMonitor class_mon
Constructor Detail

DDBaseImpl

protected DDBaseImpl(AzureusCore _azureus_core)

DDBaseImpl

protected DDBaseImpl(String _net,
                     DHTPluginInterface _dht)
Method Detail

getSingleton

public static DDBaseImpl getSingleton(AzureusCore azureus_core)

getDDBs

public static List<DistributedDatabase> getDDBs(Download download)

getDDBs

public static List<DistributedDatabase> getDDBs(String[] networks)

getDDBs

public static List<DistributedDatabase> getDDBs(String[] networks,
                                                Map<String,Object> _options)

getNetwork

public String getNetwork()
Specified by:
getNetwork in interface DistributedDatabase

getDHTPlugin

public DHTPluginInterface getDHTPlugin()
Specified by:
getDHTPlugin in interface DistributedDatabase

getTTTorrent

public DDBaseTTTorrent getTTTorrent()

grabDHT

protected DHTPluginInterface grabDHT()

isAvailable

public boolean isAvailable()
Specified by:
isAvailable in interface DistributedDatabase

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface DistributedDatabase

isExtendedUseAllowed

public boolean isExtendedUseAllowed()
Specified by:
isExtendedUseAllowed in interface DistributedDatabase

getLocalContact

public DistributedDatabaseContact getLocalContact()
Specified by:
getLocalContact in interface DistributedDatabase

throwIfNotAvailable

protected void throwIfNotAvailable()
                            throws DistributedDatabaseException
Throws:
DistributedDatabaseException

getDHT

protected DHTPluginInterface getDHT()
                             throws DistributedDatabaseException
Throws:
DistributedDatabaseException

log

protected void log(String str)

createKey

public DistributedDatabaseKey createKey(Object key)
                                 throws DistributedDatabaseException
Specified by:
createKey in interface DistributedDatabase
Throws:
DistributedDatabaseException

createKey

public DistributedDatabaseKey createKey(Object key,
                                        String description)
                                 throws DistributedDatabaseException
Specified by:
createKey in interface DistributedDatabase
Throws:
DistributedDatabaseException

createValue

public DistributedDatabaseValue createValue(Object value)
                                     throws DistributedDatabaseException
Specified by:
createValue in interface DistributedDatabase
Throws:
DistributedDatabaseException

importContact

public DistributedDatabaseContact importContact(InetSocketAddress address)
                                         throws DistributedDatabaseException
Specified by:
importContact in interface DistributedDatabase
Throws:
DistributedDatabaseException

importContact

public DistributedDatabaseContact importContact(InetSocketAddress address,
                                                byte version)
                                         throws DistributedDatabaseException
Specified by:
importContact in interface DistributedDatabase
Throws:
DistributedDatabaseException

importContact

public DistributedDatabaseContact importContact(InetSocketAddress address,
                                                byte version,
                                                int preferred_dht)
                                         throws DistributedDatabaseException
Specified by:
importContact in interface DistributedDatabase
Throws:
DistributedDatabaseException

importContact

public DistributedDatabaseContact importContact(Map<String,Object> map)
                                         throws DistributedDatabaseException
Specified by:
importContact in interface DistributedDatabase
Throws:
DistributedDatabaseException

write

public void write(DistributedDatabaseListener listener,
                  DistributedDatabaseKey key,
                  DistributedDatabaseValue value)
           throws DistributedDatabaseException
Specified by:
write in interface DistributedDatabase
Throws:
DistributedDatabaseException

write

public void write(DistributedDatabaseListener listener,
                  DistributedDatabaseKey key,
                  DistributedDatabaseValue[] values)
           throws DistributedDatabaseException
Specified by:
write in interface DistributedDatabase
Throws:
DistributedDatabaseException

read

public void read(DistributedDatabaseListener listener,
                 DistributedDatabaseKey key,
                 long timeout)
          throws DistributedDatabaseException
Specified by:
read in interface DistributedDatabase
Throws:
DistributedDatabaseException

read

public void read(DistributedDatabaseListener listener,
                 DistributedDatabaseKey key,
                 long timeout,
                 int options)
          throws DistributedDatabaseException
Specified by:
read in interface DistributedDatabase
Throws:
DistributedDatabaseException

readKeyStats

public void readKeyStats(DistributedDatabaseListener listener,
                         DistributedDatabaseKey key,
                         long timeout)
                  throws DistributedDatabaseException
Specified by:
readKeyStats in interface DistributedDatabase
Throws:
DistributedDatabaseException

getValues

public List<DistributedDatabaseValue> getValues(DistributedDatabaseKey key)
                                         throws DistributedDatabaseException
Description copied from interface: DistributedDatabase
Get all locally held (direct+indirect) values for a key

Specified by:
getValues in interface DistributedDatabase
Returns:
Throws:
DistributedDatabaseException

delete

public void delete(DistributedDatabaseListener listener,
                   DistributedDatabaseKey key)
            throws DistributedDatabaseException
Specified by:
delete in interface DistributedDatabase
Throws:
DistributedDatabaseException

delete

public void delete(DistributedDatabaseListener listener,
                   DistributedDatabaseKey key,
                   DistributedDatabaseContact[] targets)
            throws DistributedDatabaseException
Specified by:
delete in interface DistributedDatabase
Throws:
DistributedDatabaseException

addTransferHandler

public void addTransferHandler(DistributedDatabaseTransferType type,
                               DistributedDatabaseTransferHandler handler)
                        throws DistributedDatabaseException
Specified by:
addTransferHandler in interface DistributedDatabase
Throws:
DistributedDatabaseException

getStandardTransferType

public DistributedDatabaseTransferType getStandardTransferType(int standard_type)
                                                        throws DistributedDatabaseException
Specified by:
getStandardTransferType in interface DistributedDatabase
Throws:
DistributedDatabaseException

read

protected DistributedDatabaseValue read(DDBaseContactImpl contact,
                                        DistributedDatabaseProgressListener listener,
                                        DistributedDatabaseTransferType type,
                                        DistributedDatabaseKey key,
                                        long timeout)
                                 throws DistributedDatabaseException
Throws:
DistributedDatabaseException

write

protected void write(DDBaseContactImpl contact,
                     DistributedDatabaseProgressListener listener,
                     DistributedDatabaseTransferType type,
                     DistributedDatabaseKey key,
                     DistributedDatabaseValue value,
                     long timeout)
              throws DistributedDatabaseException
Throws:
DistributedDatabaseException

call

protected DistributedDatabaseValue call(DDBaseContactImpl contact,
                                        DistributedDatabaseProgressListener listener,
                                        DistributedDatabaseTransferType type,
                                        DistributedDatabaseValue value,
                                        long timeout)
                                 throws DistributedDatabaseException
Throws:
DistributedDatabaseException

addListener

public void addListener(DistributedDatabaseListener l)
Specified by:
addListener in interface DistributedDatabase

removeListener

public void removeListener(DistributedDatabaseListener l)
Specified by:
removeListener in interface DistributedDatabase