net.i2p.router.networkdb.kademlia
Class PersistentDataStore

java.lang.Object
  extended by net.i2p.router.networkdb.kademlia.TransientDataStore
      extended by net.i2p.router.networkdb.kademlia.PersistentDataStore
All Implemented Interfaces:
DataStore

 class PersistentDataStore
extends TransientDataStore

Write out keys to disk when we get them and periodically read ones we don't know about into memory, with newly read routers are also added to the routing table.


Nested Class Summary
(package private) static class PersistentDataStore.RouterInfoFilter
           
 
Field Summary
(package private) static String B64
           
(package private) static String DIR_PREFIX
           
 
Fields inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore
_context, _log
 
Constructor Summary
PersistentDataStore(RouterContext ctx, String dbDir, KademliaNetworkDatabaseFacade facade)
           
 
Method Summary
 DatabaseEntry get(Hash key)
           
 DatabaseEntry get(Hash key, boolean persist)
          Prepare for having only a partial set in memory and the rest on disk
(package private) static Hash getRouterInfoHash(String filename)
           
 boolean isInitialized()
           
 boolean put(Hash key, DatabaseEntry data)
           
 boolean put(Hash key, DatabaseEntry data, boolean persist)
          for PersistentDataStore only - don't use here
 DatabaseEntry remove(Hash key)
           
 DatabaseEntry remove(Hash key, boolean persist)
          for PersistentDataStore only - don't use here
 void rescan()
           
 void restart()
           
 void stop()
           
 
Methods inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore
countLeaseSets, getEntries, getKeys, getMapEntries, isKnown, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DIR_PREFIX

static final String DIR_PREFIX
See Also:
Constant Field Values

B64

static final String B64
See Also:
Constant Field Values
Constructor Detail

PersistentDataStore

public PersistentDataStore(RouterContext ctx,
                           String dbDir,
                           KademliaNetworkDatabaseFacade facade)
                    throws IOException
Parameters:
dbDir - relative path
Throws:
IOException
Method Detail

isInitialized

public boolean isInitialized()
Specified by:
isInitialized in interface DataStore
Overrides:
isInitialized in class TransientDataStore

stop

public void stop()
Specified by:
stop in interface DataStore
Overrides:
stop in class TransientDataStore

restart

public void restart()
Specified by:
restart in interface DataStore
Overrides:
restart in class TransientDataStore

rescan

public void rescan()
Specified by:
rescan in interface DataStore
Overrides:
rescan in class TransientDataStore

get

public DatabaseEntry get(Hash key)
Specified by:
get in interface DataStore
Overrides:
get in class TransientDataStore

get

public DatabaseEntry get(Hash key,
                         boolean persist)
Prepare for having only a partial set in memory and the rest on disk

Specified by:
get in interface DataStore
Overrides:
get in class TransientDataStore
Parameters:
persist - if false, call super only, don't access disk

remove

public DatabaseEntry remove(Hash key)
Specified by:
remove in interface DataStore
Overrides:
remove in class TransientDataStore

remove

public DatabaseEntry remove(Hash key,
                            boolean persist)
Description copied from class: TransientDataStore
for PersistentDataStore only - don't use here

Specified by:
remove in interface DataStore
Overrides:
remove in class TransientDataStore

put

public boolean put(Hash key,
                   DatabaseEntry data)
Specified by:
put in interface DataStore
Overrides:
put in class TransientDataStore
data - must be validated before here
Returns:
success

put

public boolean put(Hash key,
                   DatabaseEntry data,
                   boolean persist)
Description copied from class: TransientDataStore
for PersistentDataStore only - don't use here

Specified by:
put in interface DataStore
Overrides:
put in class TransientDataStore

getRouterInfoHash

static Hash getRouterInfoHash(String filename)