rippled
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | Static Private Member Functions | List of all members
ripple::NodeStore::NuDBBackend Class Reference
Inheritance diagram for ripple::NodeStore::NuDBBackend:
Inheritance graph
[legend]
Collaboration diagram for ripple::NodeStore::NuDBBackend:
Collaboration graph
[legend]

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 (void const *key, std::shared_ptr< NodeObject > *pno) override
 Fetch a single object.
 
std::pair< std::vector< std::shared_ptr< NodeObject > >, StatusfetchBatch (std::vector< uint256 const * > const &hashes) override
 Fetch a batch synchronously.
 
void do_insert (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 for_each (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 appnum = 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 23 of file NuDBFactory.cpp.

Constructor & Destructor Documentation

◆ NuDBBackend() [1/2]

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

Definition at line 41 of file NuDBFactory.cpp.

◆ NuDBBackend() [2/2]

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

Definition at line 60 of file NuDBFactory.cpp.

◆ ~NuDBBackend()

ripple::NodeStore::NuDBBackend::~NuDBBackend ( )
override

Definition at line 81 of file NuDBFactory.cpp.

Member Function Documentation

◆ getName()

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

Get the human-readable name of this backend.

This is used for diagnostic output.

Implements ripple::NodeStore::Backend.

Definition at line 96 of file NuDBFactory.cpp.

◆ getBlockSize()

std::optional< std::size_t > ripple::NodeStore::NuDBBackend::getBlockSize ( ) const
overridevirtual

Get the block size for backends that support it.

Reimplemented from ripple::NodeStore::Backend.

Definition at line 102 of file NuDBFactory.cpp.

◆ open() [1/2]

void ripple::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 ripple::NodeStore::Backend.

Definition at line 108 of file NuDBFactory.cpp.

◆ isOpen()

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

Returns true is the database is open.

Implements ripple::NodeStore::Backend.

Definition at line 156 of file NuDBFactory.cpp.

◆ open() [2/2]

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

Open the backend.

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

Implements ripple::NodeStore::Backend.

Definition at line 162 of file NuDBFactory.cpp.

◆ close()

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

Close the backend.

This allows the caller to catch exceptions.

Implements ripple::NodeStore::Backend.

Definition at line 168 of file NuDBFactory.cpp.

◆ fetch()

Status ripple::NodeStore::NuDBBackend::fetch ( void const *  key,
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
keyA pointer to the key data.
pObject[out] The created object if successful.
Returns
The result of the operation.

Implements ripple::NodeStore::Backend.

Definition at line 194 of file NuDBFactory.cpp.

◆ fetchBatch()

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

Fetch a batch synchronously.

Implements ripple::NodeStore::Backend.

Definition at line 222 of file NuDBFactory.cpp.

◆ do_insert()

void ripple::NodeStore::NuDBBackend::do_insert ( std::shared_ptr< NodeObject > const &  no)

Definition at line 240 of file NuDBFactory.cpp.

◆ store()

void ripple::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 ripple::NodeStore::Backend.

Definition at line 252 of file NuDBFactory.cpp.

◆ storeBatch()

void ripple::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 ripple::NodeStore::Backend.

Definition at line 264 of file NuDBFactory.cpp.

◆ sync()

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

Implements ripple::NodeStore::Backend.

Definition at line 277 of file NuDBFactory.cpp.

◆ for_each()

void ripple::NodeStore::NuDBBackend::for_each ( 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 ripple::NodeStore::Backend.

Definition at line 282 of file NuDBFactory.cpp.

◆ getWriteLoad()

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

Estimate the number of write operations pending.

Implements ripple::NodeStore::Backend.

Definition at line 319 of file NuDBFactory.cpp.

◆ setDeletePath()

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

Remove contents on disk upon destruction.

Implements ripple::NodeStore::Backend.

Definition at line 325 of file NuDBFactory.cpp.

◆ verify()

void ripple::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 ripple::NodeStore::Backend.

Definition at line 331 of file NuDBFactory.cpp.

◆ fdRequired()

int ripple::NodeStore::NuDBBackend::fdRequired ( ) const
overridevirtual

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

Implements ripple::NodeStore::Backend.

Definition at line 350 of file NuDBFactory.cpp.

◆ parseBlockSize()

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

Definition at line 357 of file NuDBFactory.cpp.

Member Data Documentation

◆ appnum

constexpr std::uint64_t ripple::NodeStore::NuDBBackend::appnum = 1
staticconstexpr

Definition at line 30 of file NuDBFactory.cpp.

◆ j_

beast::Journal const ripple::NodeStore::NuDBBackend::j_

Definition at line 32 of file NuDBFactory.cpp.

◆ keyBytes_

size_t const ripple::NodeStore::NuDBBackend::keyBytes_

Definition at line 33 of file NuDBFactory.cpp.

◆ burstSize_

std::size_t const ripple::NodeStore::NuDBBackend::burstSize_

Definition at line 34 of file NuDBFactory.cpp.

◆ name_

std::string const ripple::NodeStore::NuDBBackend::name_

Definition at line 35 of file NuDBFactory.cpp.

◆ blockSize_

std::size_t const ripple::NodeStore::NuDBBackend::blockSize_

Definition at line 36 of file NuDBFactory.cpp.

◆ db_

nudb::store ripple::NodeStore::NuDBBackend::db_

Definition at line 37 of file NuDBFactory.cpp.

◆ deletePath_

std::atomic<bool> ripple::NodeStore::NuDBBackend::deletePath_

Definition at line 38 of file NuDBFactory.cpp.

◆ scheduler_

Scheduler& ripple::NodeStore::NuDBBackend::scheduler_

Definition at line 39 of file NuDBFactory.cpp.