20 #ifndef RIPPLE_NODESTORE_DATABASE_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASE_H_INCLUDED
23 #include <ripple/basics/TaggedCache.h>
24 #include <ripple/nodestore/Backend.h>
25 #include <ripple/nodestore/NodeObject.h>
26 #include <ripple/nodestore/Scheduler.h>
27 #include <ripple/protocol/SystemParameters.h>
145 bool duplicate =
false);
std::uint32_t getFetchSize() const
Holds a collection of configuration values.
std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const noexcept
Calculates the last ledger sequence for a given shard index.
virtual std::int32_t getWriteLoad() const =0
Retrieve the estimated number of pending write operations.
std::uint64_t getStoreCount() const
Gather statistics pertaining to read and write activities.
std::atomic< std::uint64_t > fetchDurationUs_
Persistency layer for NodeObject.
const std::uint32_t ledgersPerShard_
NodeObjectType
The types of node objects.
std::map< uint256, std::vector< std::pair< std::uint32_t, std::function< void(std::shared_ptr< NodeObject > const &)> > > > read_
std::atomic< std::uint64_t > fetchTotalCount_
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::atomic< std::uint32_t > fetchSz_
Contains information about a fetch operation.
virtual void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq)=0
Store the object.
std::atomic< bool > readStopping_
std::atomic< int > readThreads_
std::atomic< std::uint32_t > fetchHitCount_
std::atomic< std::uint64_t > storeCount_
void updateFetchMetrics(uint64_t fetches, uint64_t hits, uint64_t duration)
virtual std::string getName() const =0
Retrieve the name associated with this backend.
std::uint64_t getStoreSize() const
std::atomic< std::uint64_t > storeSz_
std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const noexcept
Calculates the first ledger sequence for a given shard index.
void importInternal(Backend &dstBackend, Database &srcDB)
std::condition_variable readCondVar_
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
virtual ~Database()
Destroy the node store.
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.
virtual void sweep()=0
Remove expired entries from the positive and negative caches.
void storeStats(std::uint64_t count, std::uint64_t sz)
virtual std::optional< Backend::Counters< std::uint64_t > > getCounters() const
Retrieve backend read and write stats.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger)=0
Store a ledger from a different database.
std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept
Calculates the shard index for a given ledger sequence.
std::atomic< std::uint64_t > storeDurationUs_
std::uint32_t earliestShardIndex() const noexcept
void getCountsJson(Json::Value &obj)
const std::uint32_t earliestLedgerSeq_
std::uint32_t getFetchHitCount() const
const std::uint32_t earliestShardIndex_
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::atomic< int > runningThreads_
std::uint32_t getFetchTotalCount() const
std::uint32_t earliestLedgerSeq() const noexcept
virtual bool isSameDB(std::uint32_t s1, std::uint32_t s2)=0
std::uint32_t maxLedgers(std::uint32_t shardIndex) const noexcept
Calculates the maximum ledgers for a given shard index.
virtual void importDatabase(Database &source)=0
Import objects from another database.
std::uint32_t ledgersPerShard() const noexcept
int fdRequired() const
Returns the number of file descriptors the database expects to need.
A backend used for the NodeStore.