|
rippled
|
A collection of historical shards. More...


Public Member Functions | |
| DatabaseShard (std::string const &name, Stoppable &parent, Scheduler &scheduler, int readThreads, Section const &config, beast::Journal journal) | |
| Construct a shard store. More... | |
| virtual bool | init ()=0 |
| Initialize the database. More... | |
| virtual boost::optional< std::uint32_t > | prepareLedger (std::uint32_t validLedgerSeq)=0 |
| Prepare to store a new ledger in the shard being acquired. More... | |
| virtual bool | prepareShards (std::vector< std::uint32_t > const &shardIndexes)=0 |
| Prepare one or more shard indexes to be imported into the database. More... | |
| virtual void | removePreShard (std::uint32_t shardIndex)=0 |
| Remove a previously prepared shard index for import. More... | |
| virtual std::string | getPreShards ()=0 |
| Get shard indexes being imported. More... | |
| virtual bool | importShard (std::uint32_t shardIndex, boost::filesystem::path const &srcDir)=0 |
| Import a shard into the shard database. More... | |
| virtual std::shared_ptr< Ledger > | fetchLedger (uint256 const &hash, std::uint32_t seq)=0 |
| Fetch a ledger from the shard store. More... | |
| virtual void | setStored (std::shared_ptr< Ledger const > const &ledger)=0 |
| Notifies the database that the given ledger has been fully acquired and stored. More... | |
| virtual std::string | getCompleteShards ()=0 |
| Query which complete shards are stored. More... | |
| virtual std::uint32_t | ledgersPerShard () const =0 |
| virtual std::uint32_t | earliestShardIndex () const =0 |
| virtual std::uint32_t | seqToShardIndex (std::uint32_t seq) const =0 |
| Calculates the shard index for a given ledger sequence. More... | |
| virtual std::uint32_t | firstLedgerSeq (std::uint32_t shardIndex) const =0 |
| Calculates the first ledger sequence for a given shard index. More... | |
| virtual std::uint32_t | lastLedgerSeq (std::uint32_t shardIndex) const =0 |
| Calculates the last ledger sequence for a given shard index. More... | |
| virtual boost::filesystem::path const & | getRootDir () const =0 |
| Returns the root database directory. More... | |
| virtual std::string | getName () const =0 |
| Retrieve the name associated with this backend. More... | |
| virtual void | import (Database &source)=0 |
| Import objects from another database. More... | |
| virtual std::int32_t | getWriteLoad () const =0 |
| Retrieve the estimated number of pending write operations. More... | |
| virtual void | store (NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq)=0 |
| Store the object. More... | |
| 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) |
| Fetch a node object. More... | |
| void | asyncFetch (uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) |
| Fetch an object without waiting. More... | |
| virtual bool | storeLedger (std::shared_ptr< Ledger const > const &srcLedger)=0 |
| Store a ledger from a different database. More... | |
| virtual void | sweep ()=0 |
| Remove expired entries from the positive and negative caches. More... | |
| virtual Backend & | getBackend ()=0 |
| std::uint64_t | getStoreCount () const |
| Gather statistics pertaining to read and write activities. More... | |
| 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. More... | |
| void | onStop () override |
| Override called when the stop notification is issued. More... | |
| void | onChildrenStopped () override |
| Override called when all children have stopped. More... | |
| std::uint32_t | earliestLedgerSeq () const |
| RootStoppable & | getRoot () |
| void | setParent (Stoppable &parent) |
| Set the parent of this Stoppable. More... | |
| bool | isStopping () const |
Returns true if the stoppable should stop. More... | |
| bool | isStopped () const |
Returns true if the requested stop has completed. More... | |
| bool | areChildrenStopped () const |
Returns true if all children have stopped. More... | |
| JobCounter & | jobCounter () |
| bool | alertable_sleep_until (std::chrono::system_clock::time_point const &t) |
| Sleep or wake up on stop. More... | |
Static Public Attributes | |
| static constexpr std::uint32_t | ledgersPerShardDefault {16384u} |
| The number of ledgers in a shard. More... | |
Protected Member Functions | |
| void | asyncFetch (uint256 const &hash, std::uint32_t ledgerSeq) |
| bool | storeLedger (Ledger const &srcLedger, std::shared_ptr< Backend > dstBackend) |
| void | stopReadThreads () |
| 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) |
| void | stopped () |
| Called by derived classes to indicate that the stoppable has stopped. More... | |
Protected Attributes | |
| const beast::Journal | j_ |
| Scheduler & | scheduler_ |
| int | fdRequired_ {0} |
| std::atomic< std::uint32_t > | fetchHitCount_ {0} |
| std::atomic< std::uint32_t > | fetchSz_ {0} |
Private Types | |
| using | Children = beast::LockFreeStack< Child > |
Private Member Functions | |
| virtual std::shared_ptr< NodeObject > | fetchNodeObject (uint256 const &hash, std::uint32_t ledgerSeq, FetchReport &fetchReport)=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. More... | |
| void | threadEntry () |
| virtual void | onPrepare () |
| Override called during preparation. More... | |
| virtual void | onStart () |
| Override called during start. More... | |
| void | prepareRecursive () |
| void | startRecursive () |
| void | stopAsyncRecursive (beast::Journal j) |
| void | stopRecursive (beast::Journal j) |
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_ |
| uint256 | readLastHash_ |
| std::vector< std::thread > | readThreads_ |
| bool | readShut_ {false} |
| const std::uint32_t | earliestLedgerSeq_ |
| std::string | m_name |
| RootStoppable & | m_root |
| Child | m_child |
| std::atomic< bool > | m_stopped {false} |
| std::atomic< bool > | m_childrenStopped {false} |
| Children | m_children |
| std::condition_variable | m_cv |
| std::mutex | m_mut |
| bool | m_is_stopping = false |
| bool | hasParent_ {false} |
A collection of historical shards.
Definition at line 37 of file DatabaseShard.h.
|
privateinherited |
Definition at line 319 of file Stoppable.h.
| ripple::NodeStore::DatabaseShard::DatabaseShard | ( | std::string const & | name, |
| Stoppable & | parent, | ||
| Scheduler & | scheduler, | ||
| int | readThreads, | ||
| Section const & | config, | ||
| beast::Journal | journal | ||
| ) |
Construct a shard store.
| name | The Stoppable name for this Database |
| parent | The parent Stoppable |
| scheduler | The scheduler to use for performing asynchronous tasks |
| readThreads | The number of asynchronous read threads to create |
| config | The shard configuration section for the database |
| journal | Destination for logging output |
Definition at line 49 of file DatabaseShard.h.
|
pure virtual |
Initialize the database.
true if the database initialized without error Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Prepare to store a new ledger in the shard being acquired.
| validLedgerSeq | The sequence of the maximum valid ledgers |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Prepare one or more shard indexes to be imported into the database.
| shardIndexes | Shard indexes to be prepared for import |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Remove a previously prepared shard index for import.
| shardIndex | Shard index to be removed from import |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Get shard indexes being imported.
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Import a shard into the shard database.
| shardIndex | Shard index to import |
| srcDir | The directory to import from |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Fetch a ledger from the shard store.
| hash | The key of the ledger to retrieve |
| seq | The sequence of the ledger |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Notifies the database that the given ledger has been fully acquired and stored.
| ledger | The stored ledger to be marked as complete |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Query which complete shards are stored.
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Calculates the shard index for a given ledger sequence.
| seq | ledger sequence |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Calculates the first ledger sequence for a given shard index.
| shardIndex | The shard index considered |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Calculates the last ledger sequence for a given shard index.
| shardIndex | The shard index considered |
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtual |
Returns the root database directory.
Implemented in ripple::NodeStore::DatabaseShardImp.
|
pure virtualinherited |
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 ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
pure virtualinherited |
Import objects from another database.
Implemented in ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
pure virtualinherited |
Retrieve the estimated number of pending write operations.
This is used for diagnostics.
Implemented in ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
pure virtualinherited |
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 ripple::NodeStore::DatabaseRotatingImp, and ripple::NodeStore::DatabaseShardImp.
|
pure virtualinherited |
|
pure virtualinherited |
|
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 145 of file Database.cpp.
|
privatepure virtualinherited |
Implemented in ripple::NodeStore::DatabaseRotatingImp, and ripple::NodeStore::DatabaseShardImp.
|
inherited |
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, used by the shard store. |
| callback | Callback function when read completes |
Definition at line 94 of file Database.cpp.
|
protectedinherited |
|
pure virtualinherited |
Store a ledger from a different database.
| srcLedger | The ledger to store. |
Implemented in ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
protectedinherited |
Definition at line 170 of file Database.cpp.
|
pure virtualinherited |
Remove expired entries from the positive and negative caches.
Implemented in ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
pure virtualinherited |
|
inherited |
Gather statistics pertaining to read and write activities.
| obj | Json object reference into which to place counters. |
Definition at line 189 of file Database.h.
|
inherited |
Definition at line 195 of file Database.h.
|
inherited |
Definition at line 201 of file Database.h.
|
inherited |
Definition at line 207 of file Database.h.
|
inherited |
Definition at line 213 of file Database.h.
|
inherited |
Definition at line 319 of file Database.cpp.
|
inherited |
Returns the number of file descriptors the database expects to need.
Definition at line 223 of file Database.h.
|
overridevirtualinherited |
Override called when the stop notification is issued.
The call is made on an unspecified, implementation-specific thread. onStop and onChildrenStopped will never be called concurrently, across all Stoppable objects descended from the same root, inclusive of the root.
It is safe to call isStopping, isStopped, and areChildrenStopped from within this function; The values returned will always be valid and never change during the callback.
The default implementation simply calls stopped(). This is applicable when the Stoppable has a trivial stop operation (or no stop operation), and we are merely using the Stoppable API to position it as a dependency of some parent service.
Thread safety: May not block for long periods. Guaranteed only to be called once. Must be safe to call from any thread at any time.
Reimplemented from ripple::Stoppable.
Reimplemented in ripple::NodeStore::DatabaseShardImp.
Definition at line 64 of file Database.cpp.
|
overridevirtualinherited |
Override called when all children have stopped.
The call is made on an unspecified, implementation-specific thread. onStop and onChildrenStopped will never be called concurrently, across all Stoppable objects descended from the same root, inclusive of the root.
It is safe to call isStopping, isStopped, and areChildrenStopped from within this function; The values returned will always be valid and never change during the callback.
The default implementation does nothing.
Thread safety: May not block for long periods. Guaranteed only to be called once. Must be safe to call from any thread at any time.
Reimplemented from ripple::Stoppable.
Reimplemented in ripple::NodeStore::DatabaseShardImp.
Definition at line 72 of file Database.cpp.
|
inherited |
Definition at line 237 of file Database.h.
|
protectedinherited |
Definition at line 78 of file Database.cpp.
|
protectedinherited |
Definition at line 254 of file Database.h.
|
protectedinherited |
Definition at line 106 of file Database.cpp.
|
protectedinherited |
Definition at line 274 of file Database.h.
|
privatepure virtualinherited |
Visit every object in the database This is usually called during import.
Implemented in ripple::NodeStore::DatabaseShardImp, ripple::NodeStore::DatabaseNodeImp, and ripple::NodeStore::DatabaseRotatingImp.
|
privateinherited |
Definition at line 270 of file Database.cpp.
|
inherited |
Definition at line 214 of file Stoppable.h.
|
inherited |
Set the parent of this Stoppable.
Definition at line 43 of file Stoppable.cpp.
|
inherited |
Returns true if the stoppable should stop.
Definition at line 54 of file Stoppable.cpp.
|
inherited |
Returns true if the requested stop has completed.
Definition at line 60 of file Stoppable.cpp.
|
inherited |
Returns true if all children have stopped.
Definition at line 66 of file Stoppable.cpp.
|
inherited |
Definition at line 420 of file Stoppable.h.
|
inherited |
Sleep or wake up on stop.
true if we are stopping Definition at line 440 of file Stoppable.h.
|
protectedinherited |
Called by derived classes to indicate that the stoppable has stopped.
Definition at line 72 of file Stoppable.cpp.
|
privatevirtualinherited |
Override called during preparation.
Since all other Stoppable objects in the tree have already been constructed, this provides an opportunity to perform initialization which depends on calling into other Stoppable objects. This call is made on the same thread that called prepare(). The default implementation does nothing. Guaranteed to only be called once.
Reimplemented in ripple::OverlayImpl, ripple::test::Stoppable_test::Root, ripple::test::Stoppable_test::C, ripple::test::Stoppable_test::I, ripple::test::Stoppable_test::B, ripple::test::Stoppable_test::H, ripple::test::Stoppable_test::G, ripple::test::Stoppable_test::A, ripple::PeerFinder::ManagerImp, ripple::test::Stoppable_test::F, ripple::test::Stoppable_test::E, ripple::test::Stoppable_test::J, ripple::PerfLog_test::PerfLogParent, and ripple::test::Stoppable_test::D.
Definition at line 80 of file Stoppable.cpp.
|
privatevirtualinherited |
Override called during start.
Reimplemented in ripple::ApplicationImp, ripple::OverlayImpl, ripple::test::Stoppable_test::Root, ripple::test::Stoppable_test::C, ripple::test::Stoppable_test::I, ripple::test::Stoppable_test::B, ripple::test::Stoppable_test::H, ripple::GRPCServer, ripple::test::Stoppable_test::G, ripple::SHAMapStoreImp, ripple::test::Stoppable_test::A, ripple::perf::PerfLogImp, ripple::test::Stoppable_test::F, ripple::test::Stoppable_test::E, ripple::test::Stoppable_test::J, ripple::detail::LedgerCleanerImp, ripple::LoadManager, ripple::PerfLog_test::PerfLogParent, and ripple::test::Stoppable_test::D.
Definition at line 85 of file Stoppable.cpp.
|
privateinherited |
Definition at line 103 of file Stoppable.cpp.
|
privateinherited |
Definition at line 113 of file Stoppable.cpp.
|
privateinherited |
Definition at line 123 of file Stoppable.cpp.
|
privateinherited |
Definition at line 134 of file Stoppable.cpp.
|
staticconstexpr |
The number of ledgers in a shard.
Definition at line 179 of file DatabaseShard.h.
|
protectedinherited |
Definition at line 243 of file Database.h.
|
protectedinherited |
Definition at line 244 of file Database.h.
|
protectedinherited |
Definition at line 245 of file Database.h.
|
protectedinherited |
Definition at line 247 of file Database.h.
|
protectedinherited |
Definition at line 248 of file Database.h.
|
privateinherited |
Definition at line 282 of file Database.h.
|
privateinherited |
Definition at line 283 of file Database.h.
|
privateinherited |
Definition at line 284 of file Database.h.
|
privateinherited |
Definition at line 285 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 297 of file Database.h.
|
privateinherited |
Definition at line 300 of file Database.h.
|
privateinherited |
Definition at line 302 of file Database.h.
|
privateinherited |
Definition at line 303 of file Database.h.
|
privateinherited |
Definition at line 307 of file Database.h.
|
privateinherited |
Definition at line 339 of file Stoppable.h.
|
privateinherited |
Definition at line 340 of file Stoppable.h.
|
privateinherited |
Definition at line 341 of file Stoppable.h.
|
privateinherited |
Definition at line 343 of file Stoppable.h.
|
privateinherited |
Definition at line 344 of file Stoppable.h.
|
privateinherited |
Definition at line 345 of file Stoppable.h.
|
privateinherited |
Definition at line 346 of file Stoppable.h.
|
privateinherited |
Definition at line 347 of file Stoppable.h.
|
privateinherited |
Definition at line 348 of file Stoppable.h.
|
privateinherited |
Definition at line 349 of file Stoppable.h.
1.8.17