- All Known Implementing Classes:
PersistentDataStore, TransientDataStore
public interface DataStore
Interface for database storage operations in the network database.
Provides methods for storing, retrieving, and managing database entries including RouterInfo and LeaseSet objects with optional persistence control.
Method Summary
All MethodsModifier and TypeMethodDescriptionintCount the number of LeaseSet entries in the store.booleanforcePut(Hash key, DatabaseEntry data) Unconditionally store, bypass all newer/older checks.Retrieve the database entry for the given key.Retrieve the database entry for the given key with optional persistence control.All entries in the data store.getKeys()All keys stored in the data store.All map entries in the data store.booleanCheck if the data store has been initialized.booleanCheck if the given key exists in the data store.booleanput(Hash key, DatabaseEntry data) Store a database entry with the given key.booleanput(Hash key, DatabaseEntry data, boolean persist) Store a database entry with the given key and persistence control.Remove the entry for the given key.Remove the entry for the given key with optional persistence control.voidrescan()Rescan the storage for any changes.intsize()Total number of entries in the store, RouterInfos and LeaseSets together.voidstop()Stop the data store and release resources.
Method Details
isInitialized
boolean isInitialized()Check if the data store has been initialized.- Returns:
- true if the store is ready for operations
isKnown
Check if the given key exists in the data store.- Parameters:
key- the hash key to look up- Returns:
- true if the key is known and stored
get
Retrieve the database entry for the given key.- Parameters:
key- the hash key to look up- Returns:
- the database entry, or null if not found
get
Retrieve the database entry for the given key with optional persistence control.- Parameters:
key- the hash key to look uppersist- if true, keep the entry in persistent storage- Returns:
- the database entry, or null if not found
put
Store a database entry with the given key.- Parameters:
key- the hash key to store underdata- the database entry to store- Returns:
- true if the store was successful
put
Store a database entry with the given key and persistence control.- Parameters:
key- the hash key to store underdata- the database entry to storepersist- if true, keep the entry in persistent storage- Returns:
- true if the store was successful
forcePut
Unconditionally store, bypass all newer/older checks.- Parameters:
key- non-nulldata- non-null- Returns:
- true if the entry was stored in the Kademlia structure
remove
Remove the entry for the given key.- Parameters:
key- the hash key to remove- Returns:
- the removed database entry, or null if not found
remove
Remove the entry for the given key with optional persistence control.- Parameters:
key- the hash key to removepersist- if true, also remove from persistent storage- Returns:
- the removed database entry, or null if not found
getKeys
getEntries
Collection<DatabaseEntry> getEntries()All entries in the data store.- Returns:
- every entry currently held, as a live collection
getMapEntries
Set<Map.Entry<Hash, DatabaseEntry>> getMapEntries()All map entries in the data store.- Returns:
- the map entries
stop
void stop()Stop the data store and release resources.rescan
void rescan()Rescan the storage for any changes.countLeaseSets
int countLeaseSets()Count the number of LeaseSet entries in the store.- Returns:
- the number of LeaseSets stored
size
int size()Total number of entries in the store, RouterInfos and LeaseSets together.- Returns:
- total size (RI and LS)