20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/nodestore/impl/DatabaseRotatingImp.h>
22 #include <ripple/protocol/HashPrefix.h>
48 , writableBackend_(
std::move(writableBackend))
49 , archiveBackend_(
std::move(archiveBackend))
88 auto const backend = [&] {
99 auto const backend = [&] {
115 pCache_->canonicalize_replace_cache(hash, nObj);
117 auto const backend = [&] {
121 backend->store(nObj);
134 nodeObject =
pCache_->fetch(hash);
135 if (nodeObject ||
nCache_->touch_if_exists(hash))
170 status = backend->fetch(hash.
data(), &nodeObject);
183 fetchSz_ += nodeObject->getData().size();
188 JLOG(
j_.
fatal()) <<
"Corrupt NodeObject #" << hash;
191 JLOG(
j_.
warn()) <<
"Unknown status=" << status;
199 auto nodeObject{
pCache_->fetch(hash)};
200 if (!nodeObject && !
nCache_->touch_if_exists(hash))
202 auto [writable, archive] = [&] {
210 nodeObject = fetch(writable);
214 nodeObject = fetch(archive);
224 writable->store(nodeObject);
232 nodeObject =
pCache_->fetch(hash);
242 pCache_->canonicalize_replace_client(hash, nodeObject);
245 JLOG(
j_.
trace()) <<
"HOS: " << hash <<
" fetch: in shard db";
256 auto [writable, archive] = [&] {
262 writable->for_each(f);
265 archive->for_each(f);
Holds a collection of configuration values.
void rotateWithLock(std::function< std::unique_ptr< NodeStore::Backend >(std::string const &writableBackendName)> const &f) override
Rotates the backends.
std::shared_ptr< Backend > archiveBackend_
Persistency layer for NodeObject.
Stream trace() const
Severity stream access functions.
void sweep() override
Remove expired entries from the positive and negative caches.
void tune(int size, std::chrono::seconds age) override
Set the maximum number of entries and maximum cache age for both caches.
NodeObjectType
The types of node objects.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
DatabaseRotatingImp()=delete
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport) override
std::atomic< std::uint32_t > fetchSz_
Contains information about a fetch operation.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
std::string getName() const override
Retrieve the name associated with this backend.
std::atomic< std::uint32_t > fetchHitCount_
void setParent(Stoppable &parent)
Set the parent of this Stoppable.
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
Provides an interface for starting and stopping.
void importInternal(Backend &dstBackend, Database &srcDB)
void Rethrow()
Rethrow the exception currently being handled.
constexpr std::chrono::seconds cacheTargetAge
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Store a ledger from a different database.
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
void import(Database &source) override
Import objects from another database.
void storeStats(std::uint64_t count, std::uint64_t sz)
Status
Return codes from Backend operations.
bool asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::shared_ptr< NodeObject > &nodeObject) override
Fetch an object without waiting.
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.
virtual bool asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::shared_ptr< NodeObject > &nodeObject)=0
Fetch an object without waiting.
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
A simple object that the Ledger uses to store entries.
Maintains a cache of keys with no associated data.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
std::shared_ptr< Backend > writableBackend_
std::shared_ptr< KeyCache< uint256 > > nCache_
std::shared_ptr< TaggedCache< uint256, NodeObject > > pCache_