Package com.biglybt.pifimpl.local.ddb
Class DDBaseImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.ddb.DDBaseImpl
-
- All Implemented Interfaces:
DistributedDatabase
public class DDBaseImpl extends java.lang.Object implements DistributedDatabase
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
DDBaseImpl.dbEvent
protected class
DDBaseImpl.listenerMapper
-
Field Summary
Fields Modifier and Type Field Description protected static AEMonitor
class_mon
private Core
core
private static java.util.Map<DHTPluginInterface,DistributedDatabase>
dht_pi_map
private DHTPluginInterface
dht_use_accessor
private CopyOnWriteList<DistributedDatabaseListener>
listeners
private java.lang.String
network
private static boolean
prefer_i2p
private static DDBaseImpl
singleton
private DDBaseTTTorrent
torrent_transfer
private java.util.Map<HashWrapper,DistributedDatabaseTransferHandler>
transfer_map
-
Fields inherited from interface com.biglybt.pif.ddb.DistributedDatabase
DHT_AZ_BIGLYBT, DHT_AZ_CVS, DHT_AZ_MAIN, DHT_CVS, DHT_MAIN, DT_FREQUENCY, DT_NONE, DT_SIZE, OP_EXHAUSTIVE_READ, OP_NONE, OP_PRIORITY_HIGH
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DDBaseImpl(Core _core)
protected
DDBaseImpl(java.lang.String _net, DHTPluginInterface _dht)
-
Method Summary
-
-
-
Field Detail
-
singleton
private static DDBaseImpl singleton
-
class_mon
protected static AEMonitor class_mon
-
transfer_map
private java.util.Map<HashWrapper,DistributedDatabaseTransferHandler> transfer_map
-
prefer_i2p
private static boolean prefer_i2p
-
dht_pi_map
private static java.util.Map<DHTPluginInterface,DistributedDatabase> dht_pi_map
-
core
private final Core core
-
torrent_transfer
private final DDBaseTTTorrent torrent_transfer
-
network
private final java.lang.String network
-
dht_use_accessor
private DHTPluginInterface dht_use_accessor
-
listeners
private CopyOnWriteList<DistributedDatabaseListener> listeners
-
-
Constructor Detail
-
DDBaseImpl
protected DDBaseImpl(Core _core)
-
DDBaseImpl
protected DDBaseImpl(java.lang.String _net, DHTPluginInterface _dht)
-
-
Method Detail
-
getSingleton
public static DDBaseImpl getSingleton(Core core)
-
getDDBs
public static java.util.List<DistributedDatabase> getDDBs(Download download)
-
getDDBs
public static java.util.List<DistributedDatabase> getDDBs(java.lang.String[] networks)
-
getDDBs
public static java.util.List<DistributedDatabase> getDDBs(java.lang.String[] networks, java.util.Map<java.lang.String,java.lang.Object> _options)
-
getNetwork
public java.lang.String getNetwork()
- Specified by:
getNetwork
in interfaceDistributedDatabase
-
getDHTPlugin
public DHTPluginInterface getDHTPlugin()
- Specified by:
getDHTPlugin
in interfaceDistributedDatabase
-
getTTTorrent
public DDBaseTTTorrent getTTTorrent()
-
grabDHT
protected DHTPluginInterface grabDHT()
-
isAvailable
public boolean isAvailable()
- Specified by:
isAvailable
in interfaceDistributedDatabase
-
isInitialized
public boolean isInitialized()
- Specified by:
isInitialized
in interfaceDistributedDatabase
-
isExtendedUseAllowed
public boolean isExtendedUseAllowed()
- Specified by:
isExtendedUseAllowed
in interfaceDistributedDatabase
-
isTorrentXferEnabled
protected boolean isTorrentXferEnabled()
-
getLocalContact
public DistributedDatabaseContact getLocalContact()
- Specified by:
getLocalContact
in interfaceDistributedDatabase
-
throwIfNotAvailable
protected void throwIfNotAvailable() throws DistributedDatabaseException
- Throws:
DistributedDatabaseException
-
getDHT
protected DHTPluginInterface getDHT() throws DistributedDatabaseException
- Throws:
DistributedDatabaseException
-
log
protected void log(java.lang.String str)
-
createKey
public DistributedDatabaseKey createKey(java.lang.Object key) throws DistributedDatabaseException
- Specified by:
createKey
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
createKey
public DistributedDatabaseKey createKey(java.lang.Object key, java.lang.String description) throws DistributedDatabaseException
- Specified by:
createKey
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
createValue
public DistributedDatabaseValue createValue(java.lang.Object value) throws DistributedDatabaseException
- Specified by:
createValue
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
importContact
public DistributedDatabaseContact importContact(java.net.InetSocketAddress address) throws DistributedDatabaseException
- Specified by:
importContact
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
importContact
public DistributedDatabaseContact importContact(java.net.InetSocketAddress address, byte version) throws DistributedDatabaseException
- Specified by:
importContact
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
importContact
public DistributedDatabaseContact importContact(java.net.InetSocketAddress address, byte version, int preferred_dht) throws DistributedDatabaseException
- Specified by:
importContact
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
importContact
public DistributedDatabaseContact importContact(java.util.Map<java.lang.String,java.lang.Object> map) throws DistributedDatabaseException
- Specified by:
importContact
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
write
public void write(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseValue value) throws DistributedDatabaseException
- Specified by:
write
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
write
public void write(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseValue[] values) throws DistributedDatabaseException
- Specified by:
write
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
read
public void read(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout) throws DistributedDatabaseException
- Specified by:
read
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
read
public void read(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout, int options) throws DistributedDatabaseException
- Specified by:
read
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
readKeyStats
public void readKeyStats(DistributedDatabaseListener listener, DistributedDatabaseKey key, long timeout) throws DistributedDatabaseException
- Specified by:
readKeyStats
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
getValues
public java.util.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 interfaceDistributedDatabase
- Returns:
- Throws:
DistributedDatabaseException
-
delete
public void delete(DistributedDatabaseListener listener, DistributedDatabaseKey key) throws DistributedDatabaseException
- Specified by:
delete
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
delete
public void delete(DistributedDatabaseListener listener, DistributedDatabaseKey key, DistributedDatabaseContact[] targets) throws DistributedDatabaseException
- Specified by:
delete
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
addTransferHandler
public void addTransferHandler(DistributedDatabaseTransferType type, DistributedDatabaseTransferHandler handler) throws DistributedDatabaseException
- Specified by:
addTransferHandler
in interfaceDistributedDatabase
- Throws:
DistributedDatabaseException
-
getStandardTransferType
public DistributedDatabaseTransferType getStandardTransferType(int standard_type) throws DistributedDatabaseException
- Specified by:
getStandardTransferType
in interfaceDistributedDatabase
- 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 interfaceDistributedDatabase
-
removeListener
public void removeListener(DistributedDatabaseListener l)
- Specified by:
removeListener
in interfaceDistributedDatabase
-
-