20 #ifndef RIPPLE_NODESTORE_SHARD_H_INCLUDED
21 #define RIPPLE_NODESTORE_SHARD_H_INCLUDED
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/basics/BasicConfig.h>
25 #include <ripple/basics/RangeSet.h>
26 #include <ripple/core/DatabaseCon.h>
27 #include <ripple/nodestore/NodeObject.h>
28 #include <ripple/nodestore/Scheduler.h>
30 #include <boost/filesystem.hpp>
31 #include <nudb/nudb.hpp>
69 boost::filesystem::path
const& dir,
108 [[nodiscard]] boost::optional<std::uint32_t>
130 [[nodiscard]] StoreLedgerResult
150 [[nodiscard]] boost::filesystem::path
const&
156 [[nodiscard]] std::chrono::steady_clock::time_point
188 bool const writeSQLite,
189 boost::optional<uint256>
const& referenceHash);
219 other.counter_ =
nullptr;
234 operator bool()
const
271 boost::filesystem::path
const dir_;
const boost::filesystem::path dir_
static constexpr State acquire
std::unique_ptr< DatabaseCon > lgrSQLiteDB_
std::atomic< bool > removeOnDestroy_
StoreLedgerResult storeLedger(std::shared_ptr< Ledger const > const &srcLedger, std::shared_ptr< Ledger const > const &next)
static constexpr State finalizing
Shard(Application &app, DatabaseShard const &db, std::uint32_t index, boost::filesystem::path const &dir, beast::Journal j)
boost::filesystem::path const & getDir() const
Count(std::atomic< std::uint32_t > *counter)
std::pair< std::uint64_t, std::uint32_t > getFileInfo() const
Returns a pair where the first item describes the storage space utilized and the second item is the n...
Contains information about a fetch operation.
bool isOpen() const
Returns true if the database are open.
void stop()
Notify shard to prepare for shutdown.
static const uint256 finalKey
const std::uint32_t lastSeq_
static constexpr State complete
RangeSet< std::uint32_t > storedSeqs
std::shared_ptr< NodeObject > verifyFetch(uint256 const &hash) const
bool tryClose()
Try to close databases if not in use.
void removeOnDestroy()
Enables removal of the shard directory on destruction.
std::unique_ptr< Backend > backend_
bool isLegacy() const
Returns true if shard is older, without final key data.
static constexpr std::uint32_t version
bool storeSQLite(std::shared_ptr< Ledger const > const &ledger)
bool finalize(bool const writeSQLite, boost::optional< uint256 > const &referenceHash)
Finalize shard by walking its ledgers and verifying each Merkle tree.
bool containsLedger(std::uint32_t ledgerSeq) const
bool storeNodeObject(std::shared_ptr< NodeObject > const &nodeObject)
bool initSQLite(std::lock_guard< std::mutex > const &)
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, FetchReport &fetchReport)
std::atomic< State > state_
A collection of historical shards.
const std::uint32_t firstSeq_
std::unique_ptr< DatabaseCon > SQLiteDB
const std::uint32_t maxLedgers_
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
Count(Count const &)=delete
std::unique_ptr< AcquireInfo > acquireInfo_
static constexpr State final
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::chrono::steady_clock::time_point lastAccess_
Shard::Count makeBackendCount()
boost::optional< std::uint32_t > prepare()
bool open(std::lock_guard< std::mutex > const &lock)
Count & operator=(Count &&)=delete
std::uint32_t fdRequired_
std::uint32_t index() const
bool init(Scheduler &scheduler, nudb::context &context)
Initialize shard.
bool verifyLedger(std::shared_ptr< Ledger const > const &ledger, std::shared_ptr< Ledger const > const &next) const
void setFileStats(std::lock_guard< std::mutex > const &)
boost::icl::interval_set< T, std::less, ClosedInterval< T > > RangeSet
A set of closed intervals over the domain T.
Maintains a cache of keys with no associated data.
bool setLedgerStored(std::shared_ptr< Ledger const > const &ledger)
std::unique_ptr< DatabaseCon > txSQLiteDB_
const std::uint32_t index_
std::atomic< bool > stop_
std::atomic< std::uint32_t > * counter_
std::atomic< std::uint32_t > backendCount_
std::chrono::steady_clock::time_point getLastUse() const
std::int32_t getWriteLoad()