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>
52 boost::optional<std::uint32_t>
67 boost::filesystem::path
const& srcDir)
override;
116 boost::filesystem::path
const&
254 Throw<std::runtime_error>(
"Shard store import not supported");
259 boost::optional<std::uint32_t>
268 ShardInfo& shardInfo,
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
ShardInfo(std::shared_ptr< Shard > shard_, State state_)
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
Copies a ledger stored in a different database to this one.
Persistency layer for NodeObject.
std::shared_ptr< NodeObject > fetch(uint256 const &hash, std::uint32_t seq) override
Fetch an object.
std::uint32_t seqToShardIndex(std::uint32_t seq) const override
Calculates the shard index for a given ledger sequence.
std::string getName() const override
Retrieve the name associated with this backend.
std::pair< std::shared_ptr< PCache >, std::shared_ptr< NCache > > getCache(std::uint32_t seq)
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.
bool prepareShard(std::uint32_t shardIndex) override
Prepare a shard index to be imported into the database.
std::uint64_t available() const
void tune(int size, std::chrono::seconds age) override
Set the maximum number of entries and maximum cache age for both caches.
bool asyncFetch(uint256 const &hash, std::uint32_t seq, std::shared_ptr< NodeObject > &object) override
Fetch an object without waiting.
DatabaseShardImp & operator=(DatabaseShardImp const &)=delete
void sweep() override
Remove expired entries from the positive and negative caches.
int getDesiredAsyncReadCount(std::uint32_t seq) override
Get the maximum number of async reads the node store prefers.
std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const override
Calculates the first ledger sequence for a given shard index.
float getCacheHitRate() override
Get the positive cache hits to total attempts ratio.
std::uint64_t avgShardFileSz_
std::shared_ptr< NodeObject > fetchFrom(uint256 const &hash, std::uint32_t seq) override
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.
std::shared_ptr< Shard > shard
bool initConfig(std::lock_guard< std::mutex > &)
std::string getCompleteShards() override
Query which complete shards are stored.
std::uint32_t ledgersPerShard() const override
std::map< std::uint32_t, ShardInfo > shards_
~DatabaseShardImp() override
boost::filesystem::path dir_
void updateStatus(std::lock_guard< std::mutex > &)
constexpr std::uint32_t seqToShardIndex(std::uint32_t seq, std::uint32_t ledgersPerShard=DatabaseShard::ledgersPerShardDefault)
A collection of historical shards.
bool importShard(std::uint32_t shardIndex, boost::filesystem::path const &srcDir) override
Import a shard into the shard database.
const std::uint32_t earliestShardIndex_
A generic endpoint for log messages.
std::uint32_t earliestLedgerSeq() const
std::uint32_t acquireIndex_
Scheduling for asynchronous backend activity.
boost::optional< std::uint32_t > findAcquireIndex(std::uint32_t validLedgerSeq, std::lock_guard< std::mutex > &)
bool init() override
Initialize the database.
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t seq) override
Store the object.
boost::filesystem::path const & getRootDir() const override
Returns the root database directory.
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::shared_ptr< Ledger > fetchLedger(uint256 const &hash, std::uint32_t seq) override
Fetch a ledger from the shard store.
void validate() override
Verifies shard store data is valid.
DatabaseShardImp()=delete
void finalizeShard(ShardInfo &shardInfo, bool writeSQLite, std::lock_guard< std::mutex > &)
void onStop() override
Override called when the stop notification is issued.
std::unique_ptr< nudb::context > ctx_
bool storeLedgerInShard(std::shared_ptr< Shard > &shard, std::shared_ptr< Ledger const > const &ledger)