1#include <xrpl/nodestore/detail/DatabaseRotatingImp.h>
3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/Log.h>
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/basics/contract.h>
7#include <xrpl/beast/utility/Journal.h>
8#include <xrpl/config/BasicConfig.h>
9#include <xrpl/nodestore/Backend.h>
10#include <xrpl/nodestore/Database.h>
11#include <xrpl/nodestore/DatabaseRotating.h>
12#include <xrpl/nodestore/NodeObject.h>
13#include <xrpl/nodestore/Scheduler.h>
14#include <xrpl/nodestore/Types.h>
49 std::string const newWritableBackendName = newBackend->getName();
67 f(newWritableBackendName, newArchiveBackendName);
87 auto const backend = [&] {
107 auto const backend = [&] {
112 backend->store(nObj);
134 status = backend->fetch(hash, &nodeObject);
138 JLOG(
j_.fatal()) <<
"Exception, " << e.
what();
148 JLOG(
j_.fatal()) <<
"Corrupt NodeObject #" << hash;
151 JLOG(
j_.warn()) <<
"Unknown status=" <<
static_cast<int>(status);
161 auto [writable, archive] = [&] {
167 nodeObject = fetch(writable);
171 nodeObject = fetch(archive);
182 writable->store(nodeObject);
195 auto [writable, archive] = [&] {
201 writable->forEach(f);
A generic endpoint for log messages.
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
std::shared_ptr< Backend > archiveBackend_
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
void importDatabase(Database &source) override
Import objects from another database.
void sweep() override
Remove expired entries from the positive and negative caches.
std::shared_ptr< Backend > writableBackend_
void rotate(std::unique_ptr< NodeStore::Backend > &&newBackend, std::function< void(std::string const &writableName, std::string const &archiveName)> const &f) override
Rotates the backends.
std::string getName() const override
Retrieve the name associated with this backend.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
DatabaseRotatingImp()=delete
DatabaseRotating(Scheduler &scheduler, int readThreads, Section const &config, beast::Journal journal)
Persistency layer for NodeObject.
void storeStats(std::uint64_t count, std::uint64_t sz)
void importInternal(Backend &dstBackend, Database &srcDB)
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
Status
Return codes from Backend operations.
NodeObjectType
The types of node objects.
XRPL_NO_SANITIZE_ADDRESS void rethrow()
Rethrow the exception currently being handled.
std::vector< unsigned char > Blob
Storage for linear binary data.
Contains information about a fetch operation.