Class PersistentDataStore
- java.lang.Object
-
- net.i2p.router.networkdb.kademlia.TransientDataStore
-
- net.i2p.router.networkdb.kademlia.PersistentDataStore
-
- All Implemented Interfaces:
DataStore
public 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. Public only for access to static methods by startup classes
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static String
DIR_PREFIX
static FileFilter
RI_FILTER
-
Fields inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore
_context, _log
-
-
Constructor Summary
Constructors Constructor Description PersistentDataStore(RouterContext ctx, String dbDir, KademliaNetworkDatabaseFacade facade)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DatabaseEntry
get(Hash key)
DatabaseEntry
get(Hash key, boolean persist)
Prepare for having only a partial set in memory and the rest on diskstatic File
getRouterInfoFile(RouterContext ctx, Hash hash)
The persistent RI file for a hash.(package private) static Hash
getRouterInfoHash(String filename)
Package private for installer BundleRouterInfosboolean
isInitialized()
boolean
put(Hash key, DatabaseEntry data)
boolean
put(Hash key, DatabaseEntry data, boolean persist)
for PersistentDataStore only - don't use hereDatabaseEntry
remove(Hash key)
DatabaseEntry
remove(Hash key, boolean persist)
for PersistentDataStore only - don't use herevoid
rescan()
void
restart()
void
stop()
-
Methods inherited from class net.i2p.router.networkdb.kademlia.TransientDataStore
countLeaseSets, getEntries, getKeys, getMapEntries, isKnown, size, toString
-
-
-
-
Field Detail
-
DIR_PREFIX
static final String DIR_PREFIX
- See Also:
- Constant Field Values
-
RI_FILTER
public static final FileFilter RI_FILTER
- Since:
- 0.9.34
-
-
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 interfaceDataStore
- Overrides:
isInitialized
in classTransientDataStore
-
stop
public void stop()
- Specified by:
stop
in interfaceDataStore
- Overrides:
stop
in classTransientDataStore
-
restart
public void restart()
- Specified by:
restart
in interfaceDataStore
- Overrides:
restart
in classTransientDataStore
-
rescan
public void rescan()
- Specified by:
rescan
in interfaceDataStore
- Overrides:
rescan
in classTransientDataStore
-
get
public DatabaseEntry get(Hash key)
- Specified by:
get
in interfaceDataStore
- Overrides:
get
in classTransientDataStore
-
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 interfaceDataStore
- Overrides:
get
in classTransientDataStore
- Parameters:
persist
- if false, call super only, don't access disk
-
remove
public DatabaseEntry remove(Hash key)
- Specified by:
remove
in interfaceDataStore
- Overrides:
remove
in classTransientDataStore
-
remove
public DatabaseEntry remove(Hash key, boolean persist)
Description copied from class:TransientDataStore
for PersistentDataStore only - don't use here- Specified by:
remove
in interfaceDataStore
- Overrides:
remove
in classTransientDataStore
-
put
public boolean put(Hash key, DatabaseEntry data)
- Specified by:
put
in interfaceDataStore
- Overrides:
put
in classTransientDataStore
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 interfaceDataStore
- Overrides:
put
in classTransientDataStore
-
getRouterInfoFile
public static File getRouterInfoFile(RouterContext ctx, Hash hash)
The persistent RI file for a hash. This is available before the netdb subsystem is running, so we can delete our old RI.- Returns:
- non-null, should be absolute, does not necessarily exist
- Since:
- 0.9.23
-
-