20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/nodestore/impl/DatabaseNodeImp.h>
22 #include <ripple/protocol/HashPrefix.h>
57 <<
"DatabaseNodeImp::fetchNodeObject - record not in cache";
76 fetchSz_ += nodeObject->getData().size();
78 cache_->canonicalize_replace_client(hash, nodeObject);
84 JLOG(
j_.
fatal()) <<
"Corrupt NodeObject #" << hash;
87 JLOG(
j_.
warn()) <<
"Unknown status=" << status;
94 <<
"DatabaseNodeImp::fetchNodeObject - record in cache";
108 auto const before = steady_clock::now();
112 uint64_t fetches = 0;
113 for (
size_t i = 0; i < hashes.
size(); ++i)
115 auto const& hash = hashes[i];
133 JLOG(
j_.
debug()) <<
"DatabaseNodeImp::fetchBatch - cache hits = "
134 << (hashes.
size() - cacheMisses.
size())
135 <<
" - cache misses = " << cacheMisses.
size();
136 auto dbResults =
backend_->fetchBatch(cacheMisses).first;
138 for (
size_t i = 0; i < dbResults.size(); ++i)
140 auto nObj = dbResults[i];
141 size_t index = indexMap[cacheMisses[i]];
142 results[index] = nObj;
143 auto const& hash = hashes[index];
149 cache_->canonicalize_replace_client(hash, nObj);
154 <<
"DatabaseNodeImp::fetchBatch - "
155 <<
"record not found in db or cache. hash = " <<
strHex(hash);
159 auto fetchDurationUs =
160 std::chrono::duration_cast<std::chrono::microseconds>(
161 steady_clock::now() - before)
std::shared_ptr< Backend > backend_
Stream trace() const
Severity stream access functions.
NodeObjectType
The types of node objects.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
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.
std::atomic< std::uint32_t > fetchHitCount_
void updateFetchMetrics(uint64_t fetches, uint64_t hits, uint64_t duration)
Integers of any length that is a multiple of 32-bits.
void Rethrow()
Rethrow the exception currently being handled.
std::shared_ptr< TaggedCache< uint256, NodeObject > > cache_
void storeStats(std::uint64_t count, std::uint64_t sz)
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Status
Return codes from Backend operations.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void sweep() override
Remove expired entries from the positive and negative caches.
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::vector< uint256 > const &hashes)
std::string strHex(FwdIt begin, FwdIt end)