20 #ifndef RIPPLE_NODESTORE_DATABASE_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASE_H_INCLUDED
23 #include <ripple/basics/KeyCache.h>
24 #include <ripple/basics/TaggedCache.h>
25 #include <ripple/core/Stoppable.h>
26 #include <ripple/nodestore/Backend.h>
27 #include <ripple/nodestore/NodeObject.h>
28 #include <ripple/nodestore/Scheduler.h>
29 #include <ripple/nodestore/impl/Tuning.h>
30 #include <ripple/protocol/SystemParameters.h>
std::uint32_t getFetchSize() const
Holds a collection of configuration values.
virtual std::int32_t getWriteLoad() const =0
Retrieve the estimated number of pending write operations.
std::map< uint256, std::tuple< std::uint32_t, std::weak_ptr< TaggedCache< uint256, NodeObject > >, std::weak_ptr< KeyCache< uint256 > > > > read_
Persistency layer for NodeObject.
std::shared_ptr< NodeObject > doFetch(uint256 const &hash, std::uint32_t seq, TaggedCache< uint256, NodeObject > &pCache, KeyCache< uint256 > &nCache, bool isAsync)
virtual std::shared_ptr< NodeObject > fetchFrom(uint256 const &hash, std::uint32_t seq)=0
NodeObjectType
The types of node objects.
std::atomic< std::uint32_t > fetchSz_
virtual float getCacheHitRate()=0
Get the positive cache hits to total attempts ratio.
std::atomic< std::uint32_t > fetchHitCount_
void onChildrenStopped() override
Override called when all children have stopped.
virtual std::string getName() const =0
Retrieve the name associated with this backend.
virtual void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t seq)=0
Store the object.
Provides an interface for starting and stopping.
void importInternal(Backend &dstBackend, Database &srcDB)
std::uint32_t getStoreSize() const
virtual std::shared_ptr< NodeObject > fetch(uint256 const &hash, std::uint32_t seq)=0
Fetch an object.
std::condition_variable readCondVar_
void waitReads()
Wait for all currently pending async reads to complete.
std::uint32_t getStoreCount() const
Gather statistics pertaining to read and write activities.
void storeStats(size_t sz)
A generic endpoint for log messages.
std::uint32_t earliestLedgerSeq() const
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.
std::shared_ptr< NodeObject > fetchInternal(uint256 const &hash, std::shared_ptr< Backend > backend)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void onStop() override
Override called when the stop notification is issued.
virtual bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger)=0
Copies a ledger stored in a different database to this one.
std::condition_variable readGenCondVar_
std::atomic< std::uint32_t > storeCount_
std::vector< std::thread > readThreads_
virtual bool asyncFetch(uint256 const &hash, std::uint32_t seq, std::shared_ptr< NodeObject > &object)=0
Fetch an object without waiting.
const std::uint32_t earliestLedgerSeq_
std::atomic< std::uint32_t > fetchTotalCount_
std::uint32_t getFetchHitCount() const
std::atomic< std::uint32_t > storeSz_
std::uint32_t getFetchTotalCount() const
virtual void tune(int size, std::chrono::seconds age)=0
Set the maximum number of entries and maximum cache age for both caches.
virtual int getDesiredAsyncReadCount(std::uint32_t seq)=0
Get the maximum number of async reads the node store prefers.
int fdRequired() const
Returns the number of file descriptors the database expects to need.
A backend used for the NodeStore.