20 #ifndef RIPPLE_NODESTORE_DATABASESHARDIMP_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASESHARDIMP_H_INCLUDED
23 #include <ripple/nodestore/DatabaseShard.h>
24 #include <ripple/nodestore/impl/Shard.h>
25 #include <ripple/nodestore/impl/TaskQueue.h>
27 #include <boost/asio/basic_waitable_timer.hpp>
54 [[nodiscard]] boost::optional<std::uint32_t>
114 boost::filesystem::path
const&
249 Throw<std::runtime_error>(
"Shard store import not supported");
254 boost::optional<std::uint32_t>
265 boost::optional<uint256>
const& expectedHash);
316 boost::optional<PathDesignation>
322 boost::filesystem::path
std::uint32_t earliestShardIndex_
std::uint32_t ledgersPerShard_
std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const override
Calculates the last ledger sequence for a given shard index.
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::uint32_t earliestShardIndex() const override
boost::optional< std::uint32_t > prepareLedger(std::uint32_t validLedgerSeq) override
Prepare to store a new ledger in the shard being acquired.
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Store a ledger from a different database.
Persistency layer for NodeObject.
std::string getName() const override
Retrieve the name associated with this backend.
void removePreShard(std::uint32_t shardIndex) override
Remove a previously prepared shard index for import.
NodeObjectType
The types of node objects.
std::unique_ptr< TaskQueue > taskQueue_
void setStored(std::shared_ptr< Ledger const > const &ledger) override
Notifies the database that the given ledger has been fully acquired and stored.
void updateStatus(std::lock_guard< std::mutex > const &)
boost::optional< std::uint32_t > secondLatestShardIndex_
Contains information about a fetch operation.
void finalizeShard(std::shared_ptr< Shard > &shard, bool writeSQLite, boost::optional< uint256 > const &expectedHash)
DatabaseShardImp & operator=(DatabaseShardImp const &)=delete
const std::uint32_t openFinalLimit_
void sweep() override
Remove expired entries from the positive and negative caches.
std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const override
Calculates the first ledger sequence for a given shard index.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq, FetchReport &fetchReport) override
std::uint64_t avgShardFileSz_
std::string getPreShards() override
Get shard indexes being imported.
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
Provides an interface for starting and stopping.
boost::filesystem::path chooseHistoricalPath(std::lock_guard< std::mutex > const &) const
bool sufficientStorage(std::uint32_t numShards, PathDesignation pathDesignation, std::lock_guard< std::mutex > const &) const
std::string getCompleteShards() override
Query which complete shards are stored.
std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const override
Calculates the shard index for a given ledger sequence.
bool isSameDB(std::uint32_t s1, std::uint32_t s2) override
std::uint32_t ledgersPerShard() const override
boost::filesystem::path dir_
void removeFailedShard(std::shared_ptr< Shard > &shard)
A collection of historical shards.
bool importShard(std::uint32_t shardIndex, boost::filesystem::path const &srcDir) override
Import a shard into the shard database.
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq) override
Store the object.
bool checkHistoricalPaths() const
bool initConfig(std::lock_guard< std::mutex > const &)
boost::optional< std::uint32_t > latestShardIndex_
A generic endpoint for log messages.
constexpr std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq, std::uint32_t ledgersPerShard=DatabaseShard::ledgersPerShardDefault)
std::uint32_t earliestLedgerSeq() const
std::uint32_t acquireIndex_
Scheduling for asynchronous backend activity.
std::set< std::uint32_t > preparedIndexes_
bool init() override
Initialize the database.
std::vector< boost::filesystem::path > historicalPaths_
boost::filesystem::path const & getRootDir() const override
Returns the root database directory.
boost::optional< std::uint32_t > findAcquireIndex(std::uint32_t validLedgerSeq, std::lock_guard< std::mutex > const &)
static constexpr auto importMarker_
static constexpr std::uint32_t ledgersPerShardDefault
The number of ledgers in a shard.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::uint32_t maxHistoricalShards_
std::shared_ptr< Ledger > fetchLedger(uint256 const &hash, std::uint32_t ledgerSeq) override
Fetch a ledger from the shard store.
std::uint32_t numHistoricalShards(std::lock_guard< std::mutex > const &lock) const
void relocateOutdatedShards(std::lock_guard< std::mutex > const &lock)
void onChildrenStopped() override
Override called when all children have stopped.
std::uint32_t shardBoundaryIndex() const
bool prepareShards(std::vector< std::uint32_t > const &shardIndexes) override
Prepare one or more shard indexes to be imported into the database.
bool setStoredInShard(std::shared_ptr< Shard > &shard, std::shared_ptr< Ledger const > const &ledger)
std::unordered_map< std::uint32_t, std::shared_ptr< Shard > > shards_
DatabaseShardImp()=delete
boost::optional< PathDesignation > prepareForNewShard(std::uint32_t shardIndex, std::uint32_t numHistoricalShards, std::lock_guard< std::mutex > const &lock)
void onStop() override
Override called when the stop notification is issued.
std::unique_ptr< nudb::context > ctx_