20 #include <ripple/app/ledger/Ledger.h>
21 #include <ripple/nodestore/impl/DatabaseNodeImp.h>
22 #include <ripple/protocol/HashPrefix.h>
59 callback(obj->getType() ==
hotDUMMY ?
nullptr : obj);
85 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash <<
": record not "
86 << (
cache_ ?
"cached" :
"found");
97 <<
"fetchNodeObject " << hash
98 <<
": Exception fetching from backend: " << e.
what();
108 cache_->canonicalize_replace_client(hash, nodeObject);
122 JLOG(
j_.
fatal()) <<
"fetchNodeObject " << hash
123 <<
": nodestore data is corrupted";
127 <<
"fetchNodeObject " << hash
128 <<
": backend returns unknown result " << status;
134 JLOG(
j_.
trace()) <<
"fetchNodeObject " << hash
135 <<
": record found in cache";
136 if (nodeObject->getType() ==
hotDUMMY)
151 auto const before = steady_clock::now();
155 uint64_t fetches = 0;
156 for (
size_t i = 0; i < hashes.
size(); ++i)
158 auto const& hash = hashes[i];
170 results[i] = nObj->getType() ==
hotDUMMY ? nullptr : nObj;
176 JLOG(
j_.
debug()) <<
"fetchBatch - cache hits = "
177 << (hashes.
size() - cacheMisses.
size())
178 <<
" - cache misses = " << cacheMisses.
size();
179 auto dbResults =
backend_->fetchBatch(cacheMisses).first;
181 for (
size_t i = 0; i < dbResults.size(); ++i)
183 auto nObj = std::move(dbResults[i]);
184 size_t index = indexMap[cacheMisses[i]];
185 auto const& hash = hashes[index];
191 cache_->canonicalize_replace_client(hash, nObj);
197 <<
"record not found in db or cache. hash = " <<
strHex(hash);
206 results[index] = std::move(nObj);
209 auto fetchDurationUs =
210 std::chrono::duration_cast<std::chrono::microseconds>(
211 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.
virtual void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback)
Fetch an object without waiting.
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)
void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override
Fetch an object without waiting.