xrpld
Loading...
Searching...
No Matches
xrpl::node_store::NuDBBackend Class Reference
Inheritance diagram for xrpl::node_store::NuDBBackend:
Collaboration diagram for xrpl::node_store::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 libxrpl/nodestore/backend/NuDBFactory.cpp.

Constructor & Destructor Documentation

◆ NuDBBackend() [1/2]

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

Definition at line 67 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ NuDBBackend() [2/2]

xrpl::node_store::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 libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ ~NuDBBackend()

xrpl::node_store::NuDBBackend::~NuDBBackend ( )
override

Definition at line 105 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

Member Function Documentation

◆ getName()

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

Get the human-readable name of this backend.

This is used for diagnostic output.

Implements xrpl::node_store::Backend.

Definition at line 120 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ getBlockSize()

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

Get the block size for backends that support it.

Reimplemented from xrpl::node_store::Backend.

Definition at line 126 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ open() [1/2]

void xrpl::node_store::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::node_store::Backend.

Definition at line 132 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ isOpen()

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

Returns true is the database is open.

Implements xrpl::node_store::Backend.

Definition at line 170 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ open() [2/2]

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

Open the backend.

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

Implements xrpl::node_store::Backend.

Definition at line 176 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ close()

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

Close the backend.

This allows the caller to catch exceptions.

Implements xrpl::node_store::Backend.

Definition at line 182 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ fetch()

Status xrpl::node_store::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::node_store::Backend.

Definition at line 209 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ doInsert()

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

Definition at line 237 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ store()

void xrpl::node_store::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::node_store::Backend.

Definition at line 249 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ storeBatch()

void xrpl::node_store::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::node_store::Backend.

Definition at line 261 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ sync()

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

◆ forEach()

void xrpl::node_store::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::node_store::Backend.

Definition at line 279 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ getWriteLoad()

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

Estimate the number of write operations pending.

Implements xrpl::node_store::Backend.

Definition at line 316 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ setDeletePath()

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

Remove contents on disk upon destruction.

Implements xrpl::node_store::Backend.

Definition at line 322 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ verify()

void xrpl::node_store::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::node_store::Backend.

Definition at line 328 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ fdRequired()

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

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

Implements xrpl::node_store::Backend.

Definition at line 347 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ parseBlockSize()

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

Definition at line 354 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

Member Data Documentation

◆ kAppNum

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

Definition at line 56 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ j

beast::Journal const xrpl::node_store::NuDBBackend::j

Definition at line 58 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ keyBytes

size_t const xrpl::node_store::NuDBBackend::keyBytes

Definition at line 59 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ burstSize

std::size_t const xrpl::node_store::NuDBBackend::burstSize

Definition at line 60 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ name

std::string const xrpl::node_store::NuDBBackend::name

Definition at line 61 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ blockSize

std::size_t const xrpl::node_store::NuDBBackend::blockSize

Definition at line 62 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ db

nudb::store xrpl::node_store::NuDBBackend::db

Definition at line 63 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ deletePath

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

Definition at line 64 of file libxrpl/nodestore/backend/NuDBFactory.cpp.

◆ scheduler

Scheduler& xrpl::node_store::NuDBBackend::scheduler

Definition at line 65 of file libxrpl/nodestore/backend/NuDBFactory.cpp.