rippled
Classes | Public Member Functions | List of all members
ripple::NodeStore::Backend Class Referenceabstract

A backend used for the NodeStore. More...

Inheritance diagram for ripple::NodeStore::Backend:
Inheritance graph
[legend]

Classes

struct  Counters
 

Public Member Functions

virtual ~Backend ()=default
 Destroy the backend. More...
 
virtual std::string getName ()=0
 Get the human-readable name of this backend. More...
 
virtual void open (bool createIfMissing=true)=0
 Open the backend. More...
 
virtual bool isOpen ()=0
 Returns true is the database is open. More...
 
virtual void open (bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt)
 Open the backend. More...
 
virtual void close ()=0
 Close the backend. More...
 
virtual Status fetch (void const *key, std::shared_ptr< NodeObject > *pObject)=0
 Fetch a single object. More...
 
virtual std::pair< std::vector< std::shared_ptr< NodeObject > >, StatusfetchBatch (std::vector< uint256 const * > const &hashes)=0
 Fetch a batch synchronously. More...
 
virtual void store (std::shared_ptr< NodeObject > const &object)=0
 Store a single object. More...
 
virtual void storeBatch (Batch const &batch)=0
 Store a group of objects. More...
 
virtual void sync ()=0
 
virtual void for_each (std::function< void(std::shared_ptr< NodeObject >)> f)=0
 Visit every object in the database This is usually called during import. More...
 
virtual int getWriteLoad ()=0
 Estimate the number of write operations pending. More...
 
virtual void setDeletePath ()=0
 Remove contents on disk upon destruction. More...
 
virtual void verify ()
 Perform consistency checks on database. More...
 
virtual int fdRequired () const =0
 Returns the number of file descriptors the backend expects to need. More...
 
virtual std::optional< Counters< std::uint64_t > > counters () const
 Returns read and write stats. More...
 

Detailed Description

A backend used for the NodeStore.

The NodeStore uses a swappable backend so that other database systems can be tried. Different databases may offer various features such as improved performance, fault tolerant or distributed storage, or all in-memory operation.

A given instance of a backend is fixed to a particular key size.

Definition at line 39 of file Backend.h.

Constructor & Destructor Documentation

◆ ~Backend()

virtual ripple::NodeStore::Backend::~Backend ( )
virtualdefault

Destroy the backend.

All open files are closed and flushed. If there are batched writes or other tasks scheduled, they will be completed before this call returns.

Member Function Documentation

◆ getName()

virtual std::string ripple::NodeStore::Backend::getName ( )
pure virtual

Get the human-readable name of this backend.

This is used for diagnostic output.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ open() [1/2]

virtual void ripple::NodeStore::Backend::open ( bool  createIfMissing = true)
pure virtual

Open the backend.

Parameters
createIfMissingCreate the database files if necessary. This allows the caller to catch exceptions.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ isOpen()

virtual bool ripple::NodeStore::Backend::isOpen ( )
pure virtual

Returns true is the database is open.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ open() [2/2]

virtual void ripple::NodeStore::Backend::open ( bool  createIfMissing,
uint64_t  appType,
uint64_t  uid,
uint64_t  salt 
)
virtual

Open the backend.

Parameters
createIfMissingCreate the database files if necessary.
appTypeDeterministic appType used to create a backend.
uidDeterministic uid used to create a backend.
saltDeterministic salt used to create a backend.
Exceptions
std::runtime_erroris function is called not for NuDB backend.

Reimplemented in ripple::NodeStore::NuDBBackend.

Definition at line 99 of file Backend.h.

◆ close()

virtual void ripple::NodeStore::Backend::close ( )
pure virtual

Close the backend.

This allows the caller to catch exceptions.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ fetch()

virtual Status ripple::NodeStore::Backend::fetch ( void const *  key,
std::shared_ptr< NodeObject > *  pObject 
)
pure virtual

Fetch a single object.

If the object is not found or an error is encountered, the result will indicate the condition.

Note
This will be called concurrently.
Parameters
keyA pointer to the key data.
pObject[out] The created object if successful.
Returns
The result of the operation.

Implemented in ripple::NodeStore::MemoryBackend, ripple::NodeStore::NuDBBackend, and ripple::NodeStore::NullBackend.

◆ fetchBatch()

virtual std::pair<std::vector<std::shared_ptr<NodeObject> >, Status> ripple::NodeStore::Backend::fetchBatch ( std::vector< uint256 const * > const &  hashes)
pure virtual

◆ store()

virtual void ripple::NodeStore::Backend::store ( std::shared_ptr< NodeObject > const &  object)
pure virtual

Store a single object.

Depending on the implementation this may happen immediately or deferred using a scheduled task.

Note
This will be called concurrently.
Parameters
objectThe object to store.

Implemented in ripple::NodeStore::MemoryBackend, ripple::NodeStore::NullBackend, and ripple::NodeStore::NuDBBackend.

◆ storeBatch()

virtual void ripple::NodeStore::Backend::storeBatch ( Batch const &  batch)
pure virtual

Store a group of objects.

Note
This function will not be called concurrently with itself or store.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ sync()

virtual void ripple::NodeStore::Backend::sync ( )
pure virtual

◆ for_each()

virtual void ripple::NodeStore::Backend::for_each ( std::function< void(std::shared_ptr< NodeObject >)>  f)
pure virtual

Visit every object in the database This is usually called during import.

Note
This routine will not be called concurrently with itself or other methods.
See also
import

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ getWriteLoad()

virtual int ripple::NodeStore::Backend::getWriteLoad ( )
pure virtual

Estimate the number of write operations pending.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ setDeletePath()

virtual void ripple::NodeStore::Backend::setDeletePath ( )
pure virtual

Remove contents on disk upon destruction.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ verify()

virtual void ripple::NodeStore::Backend::verify ( )
virtual

Perform consistency checks on database.

This method is implemented only by NuDBBackend. It is not yet called anywhere, but it might be a good idea to one day call it at startup to avert a crash.

Reimplemented in ripple::NodeStore::NuDBBackend.

Definition at line 170 of file Backend.h.

◆ fdRequired()

virtual int ripple::NodeStore::Backend::fdRequired ( ) const
pure virtual

Returns the number of file descriptors the backend expects to need.

Implemented in ripple::NodeStore::NuDBBackend, ripple::NodeStore::MemoryBackend, and ripple::NodeStore::NullBackend.

◆ counters()

virtual std::optional<Counters<std::uint64_t> > ripple::NodeStore::Backend::counters ( ) const
virtual

Returns read and write stats.

Note
The Counters struct is specific to and only used by CassandraBackend.

Definition at line 184 of file Backend.h.