com.aelitis.azureus.plugins.dht.impl
Class DHTPluginStorageManager
java.lang.Object
  
com.aelitis.azureus.plugins.dht.impl.DHTPluginStorageManager
- All Implemented Interfaces: 
 - DHTStorageAdapter
 
public class DHTPluginStorageManager
- extends Object
- implements DHTStorageAdapter
  
- Author:
 
  - parg
 
 
 
 
| 
Method Summary | 
protected  DHTStorageBlock[] | 
buildKeyBlockDetails(ByteArrayHashMap map)
 
            | 
protected  DHTPluginStorageManager.diversification | 
createDiversification(HashWrapper wrapper,
                      byte type)
 
            | 
 byte[][] | 
createNewDiversification(String description,
                         DHTTransportContact cause,
                         byte[] key,
                         boolean put_operation,
                         byte diversification_type,
                         boolean exhaustive,
                         int max_depth)
 
            | 
protected  void | 
deleteStorageKey(DHTPluginStorageManager.storageKey key)
 
            | 
 DHTStorageKeyStats | 
deserialiseStats(DataInputStream is)
 
            | 
protected  void | 
divAdded(DHTPluginStorageManager.diversification div)
 
            | 
static byte[] | 
diversifyKey(byte[] key_in,
             int offset)
 
            | 
static HashWrapper | 
diversifyKey(HashWrapper key_in,
             int offset)
 
            | 
static byte[] | 
diversifyKeyLocal(byte[] key_in,
                  int offset)
 
            | 
protected  void | 
divRemoved(DHTPluginStorageManager.diversification div)
 
            | 
 void | 
exportContacts(DHT dht)
 
            | 
protected  byte[][] | 
followDivChain(HashWrapper wrapper,
               boolean put_operation,
               boolean exhaustive,
               int max_depth)
 
            | 
protected  List | 
followDivChainSupport(List list_in,
                      boolean put_operation,
                      int depth,
                      boolean exhaustive,
                      List keys_done,
                      int max_depth)
 
            | 
protected static String | 
formatExpiry(long l)
 
            | 
 DHTStorageBlock[] | 
getDirectKeyBlocks()
 
            | 
 byte[][] | 
getExistingDiversification(byte[] key,
                           boolean put_operation,
                           boolean exhaustive,
                           int max_depth)
 
            | 
 DHTStorageBlock | 
getKeyBlockDetails(byte[] key)
 
            | 
 int | 
getKeyCount()
 
            | 
 byte[] | 
getKeyForKeyBlock(byte[] request)
 
            | 
protected  String | 
getMostRecentAddress()
 
            | 
 int | 
getNetwork()
 
            | 
 int | 
getNextValueVersions(int num)
 
            | 
 int | 
getRemoteFreqDivCount()
 
            | 
 int | 
getRemoteSizeDivCount()
 
            | 
 byte[] | 
getStorageForKey(String key)
 
            | 
protected  DHTPluginStorageManager.storageKey | 
getStorageKey(HashWrapper key)
 
            | 
 void | 
importContacts(DHT dht)
 
            | 
 boolean | 
isDiversified(byte[] key)
 
            | 
protected  boolean | 
isRecentAddress(String address)
 
            | 
 DHTStorageBlock | 
keyBlockRequest(DHTTransportContact originating_contact,
                byte[] request,
                byte[] signature)
 
            | 
 DHTStorageKey | 
keyCreated(HashWrapper key,
           boolean local)
 
          Create a new storage key for a given key | 
 void | 
keyDeleted(DHTStorageKey key)
 
            | 
 void | 
keyRead(DHTStorageKey key,
        DHTTransportContact contact)
 
            | 
protected  void | 
localContactChanged(DHTTransportContact contact)
 
            | 
protected  DHTPluginStorageManager.diversification | 
lookupDiversification(HashWrapper wrapper)
 
            | 
protected  void | 
purgeDirectKeyBlocks()
 
            | 
protected  void | 
readDiversifications()
 
            | 
protected  void | 
readKeyBlocks()
 
            | 
protected  Map | 
readMapFromFile(String file_prefix)
 
            | 
protected  void | 
readRecentAddresses()
 
            | 
protected  void | 
readVersionData()
 
            | 
protected  void | 
recordCurrentAddress(String address)
 
            | 
 void | 
serialiseStats(DHTPluginStorageManager.storageKey key,
               DataOutputStream dos)
 
            | 
 void | 
setStorageForKey(String key,
                 byte[] data)
 
            | 
protected  boolean | 
suspendDivs()
 
            | 
 void | 
valueAdded(DHTStorageKey key,
           DHTTransportValue value)
 
            | 
 void | 
valueDeleted(DHTStorageKey key,
             DHTTransportValue value)
 
            | 
 void | 
valueUpdated(DHTStorageKey key,
             DHTTransportValue old_value,
             DHTTransportValue new_value)
 
            | 
static boolean | 
verifyKeyBlock(byte[] request,
               byte[] signature)
 
            | 
protected  boolean | 
verifyKeyBlock(DHTPluginStorageManager.keyBlock kb,
               DHTTransportContact originator)
 
            | 
protected  void | 
writeDiversifications()
 
            | 
protected  void | 
writeKeyBlocks()
 
            | 
protected  void | 
writeMapToFile(Map map,
               String file_prefix)
 
            | 
protected  void | 
writeRecentAddresses()
 
            | 
protected  void | 
writeVersionData()
 
            | 
 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
LOCAL_DIVERSIFICATION_SIZE_LIMIT
public static final int LOCAL_DIVERSIFICATION_SIZE_LIMIT
- See Also:
 - Constant Field Values
 
LOCAL_DIVERSIFICATION_ENTRIES_LIMIT
public static final int LOCAL_DIVERSIFICATION_ENTRIES_LIMIT
- See Also:
 - Constant Field Values
 
LOCAL_DIVERSIFICATION_READS_PER_MIN_SAMPLES
public static final int LOCAL_DIVERSIFICATION_READS_PER_MIN_SAMPLES
- See Also:
 - Constant Field Values
 
LOCAL_DIVERSIFICATION_READS_PER_MIN
public static final int LOCAL_DIVERSIFICATION_READS_PER_MIN
- See Also:
 - Constant Field Values
 
MAX_STORAGE_KEYS
public static final int MAX_STORAGE_KEYS
- See Also:
 - Constant Field Values
 
DHTPluginStorageManager
public DHTPluginStorageManager(int _network,
                               DHTLogger _log,
                               File _data_dir)
getNetwork
public int getNetwork()
- Specified by:
 getNetwork in interface DHTStorageAdapter
 
 
importContacts
public void importContacts(DHT dht)
 
 
exportContacts
public void exportContacts(DHT dht)
 
 
readRecentAddresses
protected void readRecentAddresses()
 
 
writeRecentAddresses
protected void writeRecentAddresses()
 
 
recordCurrentAddress
protected void recordCurrentAddress(String address)
 
 
getMostRecentAddress
protected String getMostRecentAddress()
 
 
isRecentAddress
protected boolean isRecentAddress(String address)
 
 
localContactChanged
protected void localContactChanged(DHTTransportContact contact)
 
 
readMapFromFile
protected Map readMapFromFile(String file_prefix)
 
 
writeMapToFile
protected void writeMapToFile(Map map,
                              String file_prefix)
 
 
readVersionData
protected void readVersionData()
 
 
writeVersionData
protected void writeVersionData()
 
 
getNextValueVersions
public int getNextValueVersions(int num)
- Specified by:
 getNextValueVersions in interface DHTStorageAdapter
 
 
keyCreated
public DHTStorageKey keyCreated(HashWrapper key,
                                boolean local)
- Description copied from interface: 
DHTStorageAdapter 
- Create a new storage key for a given key
- Specified by:
 keyCreated in interface DHTStorageAdapter
 
- Returns:
 - null if the key shouldn't be allocated (e.g.out of space)
 
 
 
keyDeleted
public void keyDeleted(DHTStorageKey key)
- Specified by:
 keyDeleted in interface DHTStorageAdapter
 
 
getKeyCount
public int getKeyCount()
- Specified by:
 getKeyCount in interface DHTStorageAdapter
 
 
keyRead
public void keyRead(DHTStorageKey key,
                    DHTTransportContact contact)
- Specified by:
 keyRead in interface DHTStorageAdapter
 
 
serialiseStats
public void serialiseStats(DHTPluginStorageManager.storageKey key,
                           DataOutputStream dos)
                    throws IOException
 
- Throws:
 IOException
 
deserialiseStats
public DHTStorageKeyStats deserialiseStats(DataInputStream is)
                                    throws IOException
- Specified by:
 deserialiseStats in interface DHTStorageAdapter
 
- Throws:
 IOException
 
valueAdded
public void valueAdded(DHTStorageKey key,
                       DHTTransportValue value)
- Specified by:
 valueAdded in interface DHTStorageAdapter
 
 
valueUpdated
public void valueUpdated(DHTStorageKey key,
                         DHTTransportValue old_value,
                         DHTTransportValue new_value)
- Specified by:
 valueUpdated in interface DHTStorageAdapter
 
 
valueDeleted
public void valueDeleted(DHTStorageKey key,
                         DHTTransportValue value)
- Specified by:
 valueDeleted in interface DHTStorageAdapter
 
 
isDiversified
public boolean isDiversified(byte[] key)
- Specified by:
 isDiversified in interface DHTStorageAdapter
 
 
getExistingDiversification
public byte[][] getExistingDiversification(byte[] key,
                                           boolean put_operation,
                                           boolean exhaustive,
                                           int max_depth)
- Specified by:
 getExistingDiversification in interface DHTStorageAdapter
 
 
createNewDiversification
public byte[][] createNewDiversification(String description,
                                         DHTTransportContact cause,
                                         byte[] key,
                                         boolean put_operation,
                                         byte diversification_type,
                                         boolean exhaustive,
                                         int max_depth)
- Specified by:
 createNewDiversification in interface DHTStorageAdapter
 
 
followDivChain
protected byte[][] followDivChain(HashWrapper wrapper,
                                  boolean put_operation,
                                  boolean exhaustive,
                                  int max_depth)
 
 
followDivChainSupport
protected List followDivChainSupport(List list_in,
                                     boolean put_operation,
                                     int depth,
                                     boolean exhaustive,
                                     List keys_done,
                                     int max_depth)
 
 
getStorageKey
protected DHTPluginStorageManager.storageKey getStorageKey(HashWrapper key)
 
 
deleteStorageKey
protected void deleteStorageKey(DHTPluginStorageManager.storageKey key)
 
 
suspendDivs
protected boolean suspendDivs()
 
 
readDiversifications
protected void readDiversifications()
 
 
writeDiversifications
protected void writeDiversifications()
 
 
lookupDiversification
protected DHTPluginStorageManager.diversification lookupDiversification(HashWrapper wrapper)
 
 
createDiversification
protected DHTPluginStorageManager.diversification createDiversification(HashWrapper wrapper,
                                                                        byte type)
 
 
divAdded
protected void divAdded(DHTPluginStorageManager.diversification div)
 
 
divRemoved
protected void divRemoved(DHTPluginStorageManager.diversification div)
 
 
getRemoteFreqDivCount
public int getRemoteFreqDivCount()
- Specified by:
 getRemoteFreqDivCount in interface DHTStorageAdapter
 
 
getRemoteSizeDivCount
public int getRemoteSizeDivCount()
- Specified by:
 getRemoteSizeDivCount in interface DHTStorageAdapter
 
 
formatExpiry
protected static String formatExpiry(long l)
 
 
readKeyBlocks
protected void readKeyBlocks()
 
 
buildKeyBlockDetails
protected DHTStorageBlock[] buildKeyBlockDetails(ByteArrayHashMap map)
 
 
writeKeyBlocks
protected void writeKeyBlocks()
 
 
keyBlockRequest
public DHTStorageBlock keyBlockRequest(DHTTransportContact originating_contact,
                                       byte[] request,
                                       byte[] signature)
- Specified by:
 keyBlockRequest in interface DHTStorageAdapter
 
 
verifyKeyBlock
protected boolean verifyKeyBlock(DHTPluginStorageManager.keyBlock kb,
                                 DHTTransportContact originator)
 
 
verifyKeyBlock
public static boolean verifyKeyBlock(byte[] request,
                                     byte[] signature)
 
 
getKeyBlockDetails
public DHTStorageBlock getKeyBlockDetails(byte[] key)
- Specified by:
 getKeyBlockDetails in interface DHTStorageAdapter
 
 
getDirectKeyBlocks
public DHTStorageBlock[] getDirectKeyBlocks()
- Specified by:
 getDirectKeyBlocks in interface DHTStorageAdapter
 
 
getKeyForKeyBlock
public byte[] getKeyForKeyBlock(byte[] request)
- Specified by:
 getKeyForKeyBlock in interface DHTStorageAdapter
 
 
purgeDirectKeyBlocks
protected void purgeDirectKeyBlocks()
 
 
setStorageForKey
public void setStorageForKey(String key,
                             byte[] data)
- Specified by:
 setStorageForKey in interface DHTStorageAdapter
 
 
getStorageForKey
public byte[] getStorageForKey(String key)
- Specified by:
 getStorageForKey in interface DHTStorageAdapter
 
 
diversifyKey
public static HashWrapper diversifyKey(HashWrapper key_in,
                                       int offset)
 
 
diversifyKey
public static byte[] diversifyKey(byte[] key_in,
                                  int offset)
 
 
diversifyKeyLocal
public static byte[] diversifyKeyLocal(byte[] key_in,
                                       int offset)