|
rippled
|
Persistency layer for NodeObject. More...
#include <Database.h>


Public Member Functions | |
| Database ()=delete | |
| Database (Scheduler &scheduler, int readThreads, Section const &config, beast::Journal j) | |
| Construct the node store. | |
| virtual | ~Database () |
| Destroy the node store. | |
| virtual std::string | getName () const =0 |
| Retrieve the name associated with this backend. | |
| virtual void | importDatabase (Database &source)=0 |
| Import objects from another database. | |
| virtual std::int32_t | getWriteLoad () const =0 |
| Retrieve the estimated number of pending write operations. | |
| virtual void | store (NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq)=0 |
| Store the object. | |
| virtual bool | isSameDB (std::uint32_t s1, std::uint32_t s2)=0 |
| virtual void | sync ()=0 |
| std::shared_ptr< NodeObject > | fetchNodeObject (uint256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::synchronous, bool duplicate=false) |
| Fetch a node object. | |
| virtual void | asyncFetch (uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) |
| Fetch an object without waiting. | |
| std::uint64_t | getStoreCount () const |
| Gather statistics pertaining to read and write activities. | |
| std::uint32_t | getFetchTotalCount () const |
| std::uint32_t | getFetchHitCount () const |
| std::uint64_t | getStoreSize () const |
| std::uint32_t | getFetchSize () const |
| void | getCountsJson (Json::Value &obj) |
| int | fdRequired () const |
| Returns the number of file descriptors the database expects to need. | |
| virtual void | stop () |
| bool | isStopping () const |
| std::uint32_t | earliestLedgerSeq () const noexcept |
Protected Member Functions | |
| void | storeStats (std::uint64_t count, std::uint64_t sz) |
| void | importInternal (Backend &dstBackend, Database &srcDB) |
| void | updateFetchMetrics (uint64_t fetches, uint64_t hits, uint64_t duration) |
Protected Attributes | |
| beast::Journal const | j_ |
| Scheduler & | scheduler_ |
| int | fdRequired_ {0} |
| std::atomic< std::uint32_t > | fetchHitCount_ {0} |
| std::atomic< std::uint32_t > | fetchSz_ {0} |
| std::uint32_t const | earliestLedgerSeq_ |
| int const | requestBundle_ |
Private Member Functions | |
| virtual std::shared_ptr< NodeObject > | fetchNodeObject (uint256 const &hash, std::uint32_t ledgerSeq, FetchReport &fetchReport, bool duplicate)=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. | |
| void | threadEntry () |
Private Attributes | |
| std::atomic< std::uint64_t > | storeCount_ {0} |
| std::atomic< std::uint64_t > | storeSz_ {0} |
| std::atomic< std::uint64_t > | fetchTotalCount_ {0} |
| std::atomic< std::uint64_t > | fetchDurationUs_ {0} |
| std::atomic< std::uint64_t > | storeDurationUs_ {0} |
| std::mutex | readLock_ |
| std::condition_variable | readCondVar_ |
| std::map< uint256, std::vector< std::pair< std::uint32_t, std::function< void(std::shared_ptr< NodeObject > const &)> > > > | read_ |
| std::atomic< bool > | readStopping_ = false |
| std::atomic< int > | readThreads_ = 0 |
| std::atomic< int > | runningThreads_ = 0 |
Persistency layer for NodeObject.
A Node is a ledger object which is uniquely identified by a key, which is the 256-bit hash of the body of the node. The payload is a variable length block of serialized data.
All ledger data is stored as node objects and as such, needs to be persisted between launches. Furthermore, since the set of node objects will in general be larger than the amount of available memory, purged node objects which are later accessed must be retrieved from the node store.
Definition at line 30 of file Database.h.
|
delete |
| xrpl::NodeStore::Database::Database | ( | Scheduler & | scheduler, |
| int | readThreads, | ||
| Section const & | config, | ||
| beast::Journal | j | ||
| ) |
Construct the node store.
| scheduler | The scheduler to use for performing asynchronous tasks. |
| readThreads | The number of asynchronous read threads to create. |
| config | The configuration settings |
| journal | Destination for logging output. |
Definition at line 13 of file Database.cpp.
|
virtual |
Destroy the node store.
All pending operations are completed, pending writes flushed, and files closed before this returns.
Definition at line 100 of file Database.cpp.
|
pure virtual |
Retrieve the name associated with this backend.
This is used for diagnostics and may not reflect the actual path or paths used by the underlying backend.
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
pure virtual |
Import objects from another database.
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
pure virtual |
Retrieve the estimated number of pending write operations.
This is used for diagnostics.
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
pure virtual |
Store the object.
The caller's Blob parameter is overwritten.
| type | The type of object. |
| data | The payload of the object. The caller's variable is overwritten. |
| hash | The 256-bit hash of the payload data. |
| ledgerSeq | The sequence of the ledger the object belongs to. |
true if the object was stored? Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
pure virtual |
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
pure virtual |
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
| std::shared_ptr< NodeObject > xrpl::NodeStore::Database::fetchNodeObject | ( | uint256 const & | hash, |
| std::uint32_t | ledgerSeq = 0, |
||
| FetchType | fetchType = FetchType::synchronous, |
||
| bool | duplicate = false |
||
| ) |
Fetch a node object.
If the object is known to be not in the database, isn't found in the database during the fetch, or failed to load correctly during the fetch, nullptr is returned.
| hash | The key of the object to retrieve. |
| ledgerSeq | The sequence of the ledger where the object is stored. |
| fetchType | the type of fetch, synchronous or asynchronous. |
Definition at line 202 of file Database.cpp.
|
virtual |
Fetch an object without waiting.
If I/O is required to determine whether or not the object is present, false is returned. Otherwise, true is returned and object is set to refer to the object, or nullptr if the object is not present. If I/O is required, the I/O is scheduled and true is returned
| hash | The key of the object to retrieve |
| ledgerSeq | The sequence of the ledger where the object is stored. |
| callback | Callback function when read completes |
Reimplemented in xrpl::NodeStore::DatabaseNodeImp.
Definition at line 149 of file Database.cpp.
| std::uint64_t xrpl::NodeStore::Database::getStoreCount | ( | ) | const |
Gather statistics pertaining to read and write activities.
| obj | Json object reference into which to place counters. |
Definition at line 141 of file Database.h.
| std::uint32_t xrpl::NodeStore::Database::getFetchTotalCount | ( | ) | const |
Definition at line 147 of file Database.h.
| std::uint32_t xrpl::NodeStore::Database::getFetchHitCount | ( | ) | const |
Definition at line 153 of file Database.h.
| std::uint64_t xrpl::NodeStore::Database::getStoreSize | ( | ) | const |
Definition at line 159 of file Database.h.
| std::uint32_t xrpl::NodeStore::Database::getFetchSize | ( | ) | const |
Definition at line 165 of file Database.h.
| void xrpl::NodeStore::Database::getCountsJson | ( | Json::Value & | obj | ) |
Definition at line 225 of file Database.cpp.
| int xrpl::NodeStore::Database::fdRequired | ( | ) | const |
Returns the number of file descriptors the database expects to need.
Definition at line 175 of file Database.h.
|
virtual |
Definition at line 118 of file Database.cpp.
| bool xrpl::NodeStore::Database::isStopping | ( | ) | const |
Definition at line 112 of file Database.cpp.
|
noexcept |
Definition at line 189 of file Database.h.
|
protected |
Definition at line 216 of file Database.h.
Definition at line 164 of file Database.cpp.
|
protected |
Definition at line 228 of file Database.h.
|
privatepure virtual |
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
privatepure virtual |
Visit every object in the database This is usually called during import.
Implemented in xrpl::NodeStore::DatabaseNodeImp, and xrpl::NodeStore::DatabaseRotatingImp.
|
private |
|
protected |
Definition at line 195 of file Database.h.
|
protected |
Definition at line 196 of file Database.h.
|
protected |
Definition at line 197 of file Database.h.
|
protected |
Definition at line 199 of file Database.h.
|
protected |
Definition at line 200 of file Database.h.
|
protected |
Definition at line 208 of file Database.h.
|
protected |
Definition at line 213 of file Database.h.
|
private |
Definition at line 236 of file Database.h.
|
private |
Definition at line 237 of file Database.h.
|
private |
Definition at line 238 of file Database.h.
|
private |
Definition at line 239 of file Database.h.
|
private |
Definition at line 240 of file Database.h.
|
mutableprivate |
Definition at line 242 of file Database.h.
|
private |
Definition at line 243 of file Database.h.
|
private |
Definition at line 247 of file Database.h.
|
private |
Definition at line 249 of file Database.h.
|
private |
Definition at line 250 of file Database.h.
|
private |
Definition at line 251 of file Database.h.