xrpld
Loading...
Searching...
No Matches
xrpl::NodeStore::NuDBBackend Class Reference
Inheritance diagram for xrpl::NodeStore::NuDBBackend:
Collaboration diagram for xrpl::NodeStore::NuDBBackend:

Public Member Functions

 NuDBBackend (size_t keyBytes, Section const &keyValues, std::size_t burstSize, Scheduler &scheduler, beast::Journal journal)
 NuDBBackend (size_t keyBytes, Section const &keyValues, std::size_t burstSize, Scheduler &scheduler, nudb::context &context, beast::Journal journal)
 ~NuDBBackend () override
std::string getName () override
 Get the human-readable name of this backend.
std::optional< std::size_tgetBlockSize () const override
 Get the block size for backends that support it.
void open (bool createIfMissing, uint64_t appType, uint64_t uid, uint64_t salt) override
 Open the backend.
bool isOpen () override
 Returns true is the database is open.
void open (bool createIfMissing) override
 Open the backend.
void close () override
 Close the backend.
Status fetch (uint256 const &hash, std::shared_ptr< NodeObject > *pno) override
 Fetch a single object.
void doInsert (std::shared_ptr< NodeObject > const &no)
void store (std::shared_ptr< NodeObject > const &no) override
 Store a single object.
void storeBatch (Batch const &batch) override
 Store a group of objects.
void sync () override
void forEach (std::function< void(std::shared_ptr< NodeObject >)> f) override
 Visit every object in the database This is usually called during import.
int getWriteLoad () override
 Estimate the number of write operations pending.
void setDeletePath () override
 Remove contents on disk upon destruction.
void verify () override
 Perform consistency checks on database.
int fdRequired () const override
 Returns the number of file descriptors the backend expects to need.

Public Attributes

beast::Journal const j
size_t const keyBytes
std::size_t const burstSize
std::string const name
std::size_t const blockSize
nudb::store db
std::atomic< bool > deletePath
Schedulerscheduler

Static Public Attributes

static constexpr std::uint64_t kAppNum = 1

Static Private Member Functions

static std::size_t parseBlockSize (std::string const &name, Section const &keyValues, beast::Journal journal)

Detailed Description

Definition at line 49 of file NuDBFactory.cpp.

Constructor & Destructor Documentation

◆ NuDBBackend() [1/2]

xrpl::NodeStore::NuDBBackend::NuDBBackend ( size_t keyBytes,
Section const & keyValues,
std::size_t burstSize,
Scheduler & scheduler,
beast::Journal journal )

Definition at line 67 of file NuDBFactory.cpp.

◆ NuDBBackend() [2/2]

xrpl::NodeStore::NuDBBackend::NuDBBackend ( size_t keyBytes,
Section const & keyValues,
std::size_t burstSize,
Scheduler & scheduler,
nudb::context & context,
beast::Journal journal )

Definition at line 85 of file NuDBFactory.cpp.

◆ ~NuDBBackend()

xrpl::NodeStore::NuDBBackend::~NuDBBackend ( )
override

Definition at line 105 of file NuDBFactory.cpp.

Member Function Documentation

◆ getName()

std::string xrpl::NodeStore::NuDBBackend::getName ( )
overridevirtual

Get the human-readable name of this backend.

This is used for diagnostic output.

Implements xrpl::NodeStore::Backend.

Definition at line 120 of file NuDBFactory.cpp.

◆ getBlockSize()

std::optional< std::size_t > xrpl::NodeStore::NuDBBackend::getBlockSize ( ) const
nodiscardoverridevirtual

Get the block size for backends that support it.

Reimplemented from xrpl::NodeStore::Backend.

Definition at line 126 of file NuDBFactory.cpp.

◆ open() [1/2]

void xrpl::NodeStore::NuDBBackend::open ( bool createIfMissing,
uint64_t appType,
uint64_t uid,
uint64_t salt )
overridevirtual

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 from xrpl::NodeStore::Backend.

Definition at line 132 of file NuDBFactory.cpp.

◆ isOpen()

bool xrpl::NodeStore::NuDBBackend::isOpen ( )
overridevirtual

Returns true is the database is open.

Implements xrpl::NodeStore::Backend.

Definition at line 170 of file NuDBFactory.cpp.

◆ open() [2/2]

void xrpl::NodeStore::NuDBBackend::open ( bool createIfMissing)
overridevirtual

Open the backend.

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

Implements xrpl::NodeStore::Backend.

Definition at line 176 of file NuDBFactory.cpp.

◆ close()

void xrpl::NodeStore::NuDBBackend::close ( )
overridevirtual

Close the backend.

This allows the caller to catch exceptions.

Implements xrpl::NodeStore::Backend.

Definition at line 182 of file NuDBFactory.cpp.

◆ fetch()

Status xrpl::NodeStore::NuDBBackend::fetch ( uint256 const & hash,
std::shared_ptr< NodeObject > * pObject )
overridevirtual

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
hashThe hash of the object.
pObject[out] The created object if successful.
Returns
The result of the operation.

Implements xrpl::NodeStore::Backend.

Definition at line 208 of file NuDBFactory.cpp.

◆ doInsert()

void xrpl::NodeStore::NuDBBackend::doInsert ( std::shared_ptr< NodeObject > const & no)

Definition at line 236 of file NuDBFactory.cpp.

◆ store()

void xrpl::NodeStore::NuDBBackend::store ( std::shared_ptr< NodeObject > const & object)
overridevirtual

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.

Implements xrpl::NodeStore::Backend.

Definition at line 248 of file NuDBFactory.cpp.

◆ storeBatch()

void xrpl::NodeStore::NuDBBackend::storeBatch ( Batch const & batch)
overridevirtual

Store a group of objects.

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

Implements xrpl::NodeStore::Backend.

Definition at line 260 of file NuDBFactory.cpp.

◆ sync()

void xrpl::NodeStore::NuDBBackend::sync ( )
overridevirtual

Implements xrpl::NodeStore::Backend.

Definition at line 273 of file NuDBFactory.cpp.

◆ forEach()

void xrpl::NodeStore::NuDBBackend::forEach ( std::function< void(std::shared_ptr< NodeObject >)> f)
overridevirtual

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

Implements xrpl::NodeStore::Backend.

Definition at line 278 of file NuDBFactory.cpp.

◆ getWriteLoad()

int xrpl::NodeStore::NuDBBackend::getWriteLoad ( )
overridevirtual

Estimate the number of write operations pending.

Implements xrpl::NodeStore::Backend.

Definition at line 315 of file NuDBFactory.cpp.

◆ setDeletePath()

void xrpl::NodeStore::NuDBBackend::setDeletePath ( )
overridevirtual

Remove contents on disk upon destruction.

Implements xrpl::NodeStore::Backend.

Definition at line 321 of file NuDBFactory.cpp.

◆ verify()

void xrpl::NodeStore::NuDBBackend::verify ( )
overridevirtual

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 from xrpl::NodeStore::Backend.

Definition at line 327 of file NuDBFactory.cpp.

◆ fdRequired()

int xrpl::NodeStore::NuDBBackend::fdRequired ( ) const
nodiscardoverridevirtual

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

Implements xrpl::NodeStore::Backend.

Definition at line 346 of file NuDBFactory.cpp.

◆ parseBlockSize()

std::size_t xrpl::NodeStore::NuDBBackend::parseBlockSize ( std::string const & name,
Section const & keyValues,
beast::Journal journal )
staticprivate

Definition at line 353 of file NuDBFactory.cpp.

Member Data Documentation

◆ kAppNum

std::uint64_t xrpl::NodeStore::NuDBBackend::kAppNum = 1
staticconstexpr

Definition at line 56 of file NuDBFactory.cpp.

◆ j

beast::Journal const xrpl::NodeStore::NuDBBackend::j

Definition at line 58 of file NuDBFactory.cpp.

◆ keyBytes

size_t const xrpl::NodeStore::NuDBBackend::keyBytes

Definition at line 59 of file NuDBFactory.cpp.

◆ burstSize

std::size_t const xrpl::NodeStore::NuDBBackend::burstSize

Definition at line 60 of file NuDBFactory.cpp.

◆ name

std::string const xrpl::NodeStore::NuDBBackend::name

Definition at line 61 of file NuDBFactory.cpp.

◆ blockSize

std::size_t const xrpl::NodeStore::NuDBBackend::blockSize

Definition at line 62 of file NuDBFactory.cpp.

◆ db

nudb::store xrpl::NodeStore::NuDBBackend::db

Definition at line 63 of file NuDBFactory.cpp.

◆ deletePath

std::atomic<bool> xrpl::NodeStore::NuDBBackend::deletePath

Definition at line 64 of file NuDBFactory.cpp.

◆ scheduler

Scheduler& xrpl::NodeStore::NuDBBackend::scheduler

Definition at line 65 of file NuDBFactory.cpp.