20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/nodestore/impl/DatabaseNodeImp.h>
22 #include <ripple/protocol/HashPrefix.h>
58 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash <<
": record not "
59 << (
cache_ ?
"cached" :
"found");
70 <<
"fetchNodeObject " << hash
71 <<
": Exception fetching from backend: " << e.
what();
79 cache_->canonicalize_replace_client(hash, nodeObject);
84 JLOG(
j_.
fatal()) <<
"fetchNodeObject " << hash
85 <<
": nodestore data is corrupted";
89 <<
"fetchNodeObject " << hash
90 <<
": backend returns unknown result " << status;
96 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash
97 <<
": record found in cache";
111 auto const before = steady_clock::now();
115 uint64_t fetches = 0;
116 for (
size_t i = 0; i < hashes.
size(); ++i)
118 auto const& hash = hashes[i];
136 JLOG(
j_.
debug()) <<
"fetchBatch - cache hits = "
137 << (hashes.
size() - cacheMisses.
size())
138 <<
" - cache misses = " << cacheMisses.
size();
139 auto dbResults =
backend_->fetchBatch(cacheMisses).first;
141 for (
size_t i = 0; i < dbResults.size(); ++i)
143 auto nObj = dbResults[i];
144 size_t index = indexMap[cacheMisses[i]];
145 results[index] = nObj;
146 auto const& hash = hashes[index];
152 cache_->canonicalize_replace_client(hash, nObj);
158 <<
"record not found in db or cache. hash = " <<
strHex(hash);
162 auto fetchDurationUs =
163 std::chrono::duration_cast<std::chrono::microseconds>(
164 steady_clock::now() - before)
std::shared_ptr< Backend > backend_
Stream trace() const
Severity stream access functions.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
NodeObjectType
The types of node objects.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
Contains information about a fetch operation.
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
Store the object.
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)