|
xrpld
|
#include <DatabaseNodeImp.h>


Public Member Functions | |
| DatabaseNodeImp ()=delete | |
| DatabaseNodeImp (DatabaseNodeImp const &)=delete | |
| DatabaseNodeImp & | operator= (DatabaseNodeImp const &)=delete |
| DatabaseNodeImp (Scheduler &scheduler, int readThreads, std::shared_ptr< Backend > backend, Section const &config, beast::Journal j) | |
| ~DatabaseNodeImp () override | |
| std::string | getName () const override |
| Retrieve the name associated with this backend. | |
| std::int32_t | getWriteLoad () const override |
| Retrieve the estimated number of pending write operations. | |
| void | importDatabase (Database &source) override |
| Import objects from another database. | |
| void | store (NodeObjectType type, Blob &&data, UInt256 const &hash, std::uint32_t) override |
| Store the object. | |
| bool | isSameDB (std::uint32_t, std::uint32_t) override |
| Check if two ledgers are in the same database. | |
| void | sync () override |
| void | asyncFetch (UInt256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override |
| Fetch an object without waiting. | |
| void | sweep () override |
| Remove expired entries from the positive and negative caches. | |
| std::shared_ptr< NodeObject > | fetchNodeObject (UInt256 const &hash, std::uint32_t ledgerSeq=0, FetchType fetchType=FetchType::Synchronous, bool duplicate=false) |
| Fetch a node object. | |
| 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 () |
| Close the read queue and wait for the read threads to exit. | |
| 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 | |
| std::shared_ptr< NodeObject > | fetchNodeObject (UInt256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override |
| void | forEach (std::function< void(std::shared_ptr< NodeObject >)> f) override |
| Visit every object in the database This is usually called during import. | |
| void | threadEntry () |
Private Attributes | |
| std::shared_ptr< TaggedCache< UInt256, NodeObject > > | cache_ |
| std::shared_ptr< Backend > | backend_ |
| 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 |
Definition at line 27 of file DatabaseNodeImp.h.
|
delete |
|
delete |
| xrpl::node_store::DatabaseNodeImp::DatabaseNodeImp | ( | Scheduler & | scheduler, |
| int | readThreads, | ||
| std::shared_ptr< Backend > | backend, | ||
| Section const & | config, | ||
| beast::Journal | j ) |
Definition at line 35 of file DatabaseNodeImp.h.
|
override |
Definition at line 75 of file DatabaseNodeImp.h.
|
delete |
|
overridevirtual |
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.
Implements xrpl::node_store::Database.
Definition at line 81 of file DatabaseNodeImp.h.
|
overridevirtual |
Retrieve the estimated number of pending write operations.
This is used for diagnostics.
Implements xrpl::node_store::Database.
Definition at line 87 of file DatabaseNodeImp.h.
|
overridevirtual |
Import objects from another database.
Implements xrpl::node_store::Database.
Definition at line 93 of file DatabaseNodeImp.h.
|
overridevirtual |
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. |
Implements xrpl::node_store::Database.
Definition at line 21 of file DatabaseNodeImp.cpp.
|
overridevirtual |
Check if two ledgers are in the same database.
If these two sequence numbers map to the same database, the result of a fetch with either sequence number would be identical.
| s1 | The first sequence number |
| s2 | The second sequence number |
Implements xrpl::node_store::Database.
Definition at line 102 of file DatabaseNodeImp.h.
|
overridevirtual |
Implements xrpl::node_store::Database.
Definition at line 109 of file DatabaseNodeImp.h.
|
overridevirtual |
Fetch an object without waiting.
Queue a read for the read threads, or complete it at once with no object when the queue is closed, so the caller always gets exactly one callback.
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 |
| hash | The key of the object to read. |
| ledgerSeq | The sequence of the ledger the object belongs to. |
| cb | The callback that receives the object, or nullptr if the object is not present or the database is stopping. |
Reimplemented from xrpl::node_store::Database.
Definition at line 37 of file DatabaseNodeImp.cpp.
|
overridevirtual |
Remove expired entries from the positive and negative caches.
Implements xrpl::node_store::Database.
Definition at line 55 of file DatabaseNodeImp.cpp.
|
overrideprivatevirtual |
Implements xrpl::node_store::Database.
Definition at line 62 of file DatabaseNodeImp.cpp.
|
overrideprivatevirtual |
Visit every object in the database This is usually called during import.
Implements xrpl::node_store::Database.
Definition at line 135 of file DatabaseNodeImp.h.
|
inherited |
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 263 of file libxrpl/nodestore/Database.cpp.
|
inherited |
Gather statistics pertaining to read and write activities.
| obj | Json object reference into which to place counters. |
Definition at line 174 of file Database.h.
|
inherited |
Definition at line 180 of file Database.h.
|
inherited |
Definition at line 186 of file Database.h.
|
inherited |
Definition at line 192 of file Database.h.
|
inherited |
Definition at line 198 of file Database.h.
|
inherited |
Definition at line 290 of file libxrpl/nodestore/Database.cpp.
|
inherited |
Returns the number of file descriptors the database expects to need.
Definition at line 210 of file Database.h.
|
virtualinherited |
Close the read queue and wait for the read threads to exit.
The call that closes the queue completes every read still queued with no object before it returns, so every caller gets exactly one callback. The callbacks run on the calling thread with readLock_ released, since a callback may post or wait on other reads. A concurrent second call waits only for the read threads, so it may return while the first call is still delivering those callbacks.
Definition at line 154 of file libxrpl/nodestore/Database.cpp.
|
inherited |
Definition at line 138 of file libxrpl/nodestore/Database.cpp.
|
nodiscardnoexceptinherited |
Definition at line 225 of file Database.h.
|
protectedinherited |
Definition at line 252 of file Database.h.
|
protectedinherited |
Definition at line 225 of file libxrpl/nodestore/Database.cpp.
|
protectedinherited |
Definition at line 264 of file Database.h.
|
privateinherited |
|
private |
Definition at line 126 of file DatabaseNodeImp.h.
|
private |
Definition at line 128 of file DatabaseNodeImp.h.
|
protectedinherited |
Definition at line 231 of file Database.h.
|
protectedinherited |
Definition at line 232 of file Database.h.
|
protectedinherited |
Definition at line 233 of file Database.h.
|
protectedinherited |
Definition at line 235 of file Database.h.
|
protectedinherited |
Definition at line 236 of file Database.h.
|
protectedinherited |
Definition at line 244 of file Database.h.
|
protectedinherited |
Definition at line 249 of file Database.h.
|
privateinherited |
Definition at line 272 of file Database.h.
|
privateinherited |
Definition at line 273 of file Database.h.
|
privateinherited |
Definition at line 274 of file Database.h.
|
privateinherited |
Definition at line 275 of file Database.h.
|
privateinherited |
Definition at line 276 of file Database.h.
|
mutableprivateinherited |
Definition at line 278 of file Database.h.
|
privateinherited |
Definition at line 279 of file Database.h.
|
privateinherited |
Definition at line 286 of file Database.h.
|
privateinherited |
Definition at line 288 of file Database.h.
|
privateinherited |
Definition at line 289 of file Database.h.
|
privateinherited |
Definition at line 290 of file Database.h.