rippled
DatabaseShardImp.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2017 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_NODESTORE_DATABASESHARDIMP_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASESHARDIMP_H_INCLUDED
22 
23 #include <ripple/nodestore/DatabaseShard.h>
24 #include <ripple/nodestore/impl/Shard.h>
25 #include <ripple/nodestore/impl/TaskQueue.h>
26 
27 #include <boost/asio/basic_waitable_timer.hpp>
28 
29 namespace ripple {
30 namespace NodeStore {
31 
33 {
34 public:
35  DatabaseShardImp() = delete;
36  DatabaseShardImp(DatabaseShardImp const&) = delete;
39  operator=(DatabaseShardImp const&) = delete;
41  operator=(DatabaseShardImp&&) = delete;
42 
44  Application& app,
45  Scheduler& scheduler,
46  int readThreads,
47  beast::Journal j);
48 
50  {
51  stop();
52  }
53 
54  [[nodiscard]] bool
55  init() override;
56 
58  prepareLedger(std::uint32_t validLedgerSeq) override;
59 
60  bool
61  prepareShards(std::vector<std::uint32_t> const& shardIndexes) override;
62 
63  void
64  removePreShard(std::uint32_t shardIndex) override;
65 
67  getPreShards() override;
68 
69  bool
70  importShard(std::uint32_t shardIndex, boost::filesystem::path const& srcDir)
71  override;
72 
74  fetchLedger(uint256 const& hash, std::uint32_t ledgerSeq) override;
75 
76  void
77  setStored(std::shared_ptr<Ledger const> const& ledger) override;
78 
80  getShardInfo() const override;
81 
82  size_t
83  getNumTasks() const override;
84 
85  boost::filesystem::path const&
86  getRootDir() const override
87  {
88  return dir_;
89  }
90 
92  getName() const override
93  {
94  return backendName_;
95  }
96 
97  void
98  stop() override;
99 
104  void
105  importDatabase(Database& source) override;
106 
107  void
109 
111  getWriteLoad() const override;
112 
113  bool
115  {
116  return seqToShardIndex(s1) == seqToShardIndex(s2);
117  }
118 
119  void
120  store(
121  NodeObjectType type,
122  Blob&& data,
123  uint256 const& hash,
124  std::uint32_t ledgerSeq) override;
125 
126  void
127  sync() override{};
128 
129  bool
130  storeLedger(std::shared_ptr<Ledger const> const& srcLedger) override;
131 
132  void
133  sweep() override;
134 
136  getDatabaseImportStatus() const override;
137 
139  startNodeToShard() override;
140 
142  stopNodeToShard() override;
143 
145  getDatabaseImportSequence() const override;
146 
147  bool
149  LedgerIndex ledgerSeq,
150  std::function<bool(soci::session& session)> const& callback) override;
151 
152  bool
154  std::uint32_t const shardIndex,
155  std::function<bool(soci::session& session)> const& callback) override;
156 
157  bool
159  LedgerIndex ledgerSeq,
160  std::function<bool(soci::session& session)> const& callback) override;
161 
162  bool
164  std::uint32_t const shardIndex,
165  std::function<bool(soci::session& session)> const& callback) override;
166 
167  bool
169  std::optional<std::uint32_t> minShardIndex,
171  bool(soci::session& session, std::uint32_t shardIndex)> const&
172  callback) override;
173 
174  bool
176  std::optional<std::uint32_t> minShardIndex,
178  bool(soci::session& session, std::uint32_t shardIndex)> const&
179  callback) override;
180 
181  bool
183  std::optional<std::uint32_t> maxShardIndex,
185  bool(soci::session& session, std::uint32_t shardIndex)> const&
186  callback) override;
187 
188  bool
190  std::optional<std::uint32_t> maxShardIndex,
192  bool(soci::session& session, std::uint32_t shardIndex)> const&
193  callback) override;
194 
195 private:
196  enum class PathDesignation : uint8_t {
197  none, // No path specified
198  historical // Needs a historical path
199  };
200 
202  {
210  {
211  }
212 
213  // Index of the first shard to be imported
215 
216  // Index of the last shard to be imported
218 
219  // Index of the shard currently being imported
221 
222  // First ledger sequence of the current shard
224 
225  // Last ledger sequence of the current shard
227 
228  // The shard currently being imported
230  };
231 
234  bool init_{false};
235 
236  // The context shared with all shard backend databases
238 
239  // Queue of background tasks to be performed
241 
242  // Shards held by this server
244 
245  // Shard indexes being imported from the shard archive handler
247 
248  // Shard index being acquired from the peer network
250 
251  // The shard store root directory
252  boost::filesystem::path dir_;
253 
254  // If new shards can be stored
255  bool canAdd_{true};
256 
257  // The name associated with the backend used with the shard store
259 
260  // Maximum number of historical shards to store.
262 
263  // Contains historical shard paths
265 
266  // Storage space utilized by the shard store (in bytes)
268 
269  // Average storage space required by a shard (in bytes)
271 
272  // The limit of final shards with open databases at any time
274 
275  // File name used to mark shards being imported from node store
276  static constexpr auto databaseImportMarker_ = "database_import";
277 
278  // latestShardIndex_ and secondLatestShardIndex hold the indexes
279  // of the shards most recently confirmed by the network. These
280  // values are not updated in real time and are modified only
281  // when adding shards to the database, in order to determine where
282  // pending shards will be stored on the filesystem. A value of
283  // std::nullopt indicates that the corresponding shard is not held
284  // by the database.
287 
288  // Struct used for node store import progress
290 
291  // Thread for running node store import
293 
294  // Indicates whether the import should stop
296 
297  // Initialize settings from the configuration file
298  // Lock must be held
299  bool
301 
304  uint256 const& hash,
305  std::uint32_t ledgerSeq,
306  FetchReport& fetchReport,
307  bool duplicate) override;
308 
309  void
311  {
312  Throw<std::runtime_error>("Import from shard store not supported");
313  }
314 
315  // Randomly select a shard index not stored
316  // Lock must be held
319  std::uint32_t validLedgerSeq,
321 
322  // Queue a task to finalize a shard by verifying its databases
323  // Lock must be held
324  void
326  std::shared_ptr<Shard>& shard,
327  bool writeSQLite,
328  std::optional<uint256> const& expectedHash);
329 
330  // Update storage and file descriptor usage stats
331  void
332  updateFileStats();
333 
334  // Returns true if the file system has enough storage
335  // available to hold the specified number of shards.
336  // The value of pathDesignation determines whether
337  // the shard(s) in question are historical and thus
338  // meant to be stored at a path designated for historical
339  // shards.
340  bool
342  std::uint32_t numShards,
343  PathDesignation pathDesignation,
344  std::lock_guard<std::mutex> const&) const;
345 
346  bool
348  std::shared_ptr<Shard>& shard,
349  std::shared_ptr<Ledger const> const& ledger);
350 
351  void
353 
354  // Returns the index that represents the logical
355  // partition between historical and recent shards
357  shardBoundaryIndex() const;
358 
361 
362  // Shifts the recent and second most recent (by index)
363  // shards as new shards become available on the network.
364  // Older shards are moved to a historical shard path.
365  void
367 
368  // Checks whether the shard can be stored. If
369  // the new shard can't be stored, returns
370  // std::nullopt. Otherwise returns an enum
371  // indicating whether the new shard should be
372  // placed in a separate directory for historical
373  // shards.
376  std::uint32_t shardIndex,
378  std::lock_guard<std::mutex> const& lock);
379 
380  boost::filesystem::path
382 
392  bool
394  std::optional<std::uint32_t> minShardIndex,
395  std::function<bool(Shard& shard)> const& visit);
396 
406  bool
408  std::optional<std::uint32_t> maxShardIndex,
409  std::function<bool(Shard& shard)> const& visit);
410 
411  bool
413 
416 
417  // Update peers with the status of every complete and incomplete shard
418  void
419  updatePeers(std::lock_guard<std::mutex> const& lock) const;
420 
421  // Start the node store import process
422  void
424 };
425 
426 } // namespace NodeStore
427 } // namespace ripple
428 
429 #endif
ripple::NodeStore::DatabaseShardImp::iterateLedgerSQLsForward
bool iterateLedgerSQLsForward(std::optional< std::uint32_t > minShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback) override
iterateLedgerSQLsForward Checks out ledger databases for all shards in ascending order starting from ...
Definition: DatabaseShardImp.cpp:2103
ripple::Application
Definition: Application.h:115
ripple::NodeStore::DatabaseShardImp::for_each
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
Definition: DatabaseShardImp.h:310
ripple::NodeStore::DatabaseShardImp::mutex_
std::mutex mutex_
Definition: DatabaseShardImp.h:233
ripple::NodeStore::DatabaseShardImp::app_
Application & app_
Definition: DatabaseShardImp.h:232
ripple::NodeStore::DatabaseShardImp::storeLedger
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Store a ledger from a different database.
Definition: DatabaseShardImp.cpp:1136
ripple::NodeStore::Database
Persistency layer for NodeObject.
Definition: Database.h:51
std::string
STL class.
std::shared_ptr< Ledger >
ripple::NodeStore::DatabaseShardImp::shards_
std::map< std::uint32_t, std::shared_ptr< Shard > > shards_
Definition: DatabaseShardImp.h:243
ripple::NodeStore::DatabaseShardImp::PathDesignation
PathDesignation
Definition: DatabaseShardImp.h:196
ripple::NodeStore::DatabaseShardImp::callForLedgerSQLByLedgerSeq
bool callForLedgerSQLByLedgerSeq(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback) override
Invoke a callback on the SQLite db holding the corresponding ledger.
Definition: DatabaseShardImp.cpp:2023
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::lastSeq
std::uint32_t lastSeq
Definition: DatabaseShardImp.h:226
ripple::NodeStore::DatabaseShardImp::getName
std::string getName() const override
Retrieve the name associated with this backend.
Definition: DatabaseShardImp.h:92
ripple::NodeStore::DatabaseShardImp::removePreShard
void removePreShard(std::uint32_t shardIndex) override
Remove a previously prepared shard index for import.
Definition: DatabaseShardImp.cpp:416
ripple::NodeStore::DatabaseShardImp::~DatabaseShardImp
~DatabaseShardImp()
Definition: DatabaseShardImp.h:49
ripple::NodeStore::DatabaseShardImp::fileSz_
std::uint64_t fileSz_
Definition: DatabaseShardImp.h:267
std::vector
STL class.
ripple::NodeStore::DatabaseShardImp::stop
void stop() override
Definition: DatabaseShardImp.cpp:699
ripple::NodeObjectType
NodeObjectType
The types of node objects.
Definition: NodeObject.h:32
ripple::NodeStore::DatabaseShardImp
Definition: DatabaseShardImp.h:32
ripple::NodeStore::DatabaseShardImp::taskQueue_
TaskQueue taskQueue_
Definition: DatabaseShardImp.h:240
ripple::NodeStore::DatabaseShardImp::setStored
void setStored(std::shared_ptr< Ledger const > const &ledger) override
Notifies the database that the given ledger has been fully acquired and stored.
Definition: DatabaseShardImp.cpp:630
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::DatabaseImportStatus
DatabaseImportStatus(std::uint32_t const earliestIndex, std::uint32_t const latestIndex, std::uint32_t const currentIndex)
Definition: DatabaseShardImp.h:203
std::lock_guard
STL class.
ripple::NodeStore::FetchReport
Contains information about a fetch operation.
Definition: ripple/nodestore/Scheduler.h:32
ripple::NodeStore::DatabaseShardImp::getDatabaseImportSequence
std::optional< std::uint32_t > getDatabaseImportSequence() const override
Returns the first ledger sequence of the shard currently being imported from the NodeStore.
Definition: DatabaseShardImp.cpp:1297
std::function
ripple::NodeStore::DatabaseShardImp::operator=
DatabaseShardImp & operator=(DatabaseShardImp const &)=delete
ripple::NodeStore::DatabaseShardImp::importDatabase
void importDatabase(Database &source) override
Import the application local node store.
Definition: DatabaseShardImp.cpp:765
ripple::NodeStore::DatabaseShardImp::databaseImporter_
std::thread databaseImporter_
Definition: DatabaseShardImp.h:292
ripple::NodeStore::DatabaseShardImp::openFinalLimit_
const std::uint32_t openFinalLimit_
Definition: DatabaseShardImp.h:273
ripple::NodeStore::DatabaseShardImp::iterateShardsForward
bool iterateShardsForward(std::optional< std::uint32_t > minShardIndex, std::function< bool(Shard &shard)> const &visit)
iterateShardsForward Visits all shards starting from given in ascending order and calls given callbac...
Definition: DatabaseShardImp.cpp:2075
ripple::NodeStore::DatabaseShardImp::sweep
void sweep() override
Remove expired entries from the positive and negative caches.
Definition: DatabaseShardImp.cpp:1171
ripple::NodeStore::DatabaseShardImp::stopNodeToShard
Json::Value stopNodeToShard() override
Terminates a NodeStore to ShardStore import and returns the result in a JSON object.
Definition: DatabaseShardImp.cpp:1275
ripple::NodeStore::DatabaseShardImp::PathDesignation::historical
@ historical
ripple::NodeStore::DatabaseShardImp::getDatabaseImportStatus
Json::Value getDatabaseImportStatus() const override
Returns a JSON object detailing the status of an ongoing database import if one is running,...
Definition: DatabaseShardImp.cpp:1223
ripple::NodeStore::DatabaseShardImp::secondLatestShardIndex_
std::optional< std::uint32_t > secondLatestShardIndex_
Definition: DatabaseShardImp.h:286
ripple::NodeStore::DatabaseShardImp::avgShardFileSz_
std::uint64_t avgShardFileSz_
Definition: DatabaseShardImp.h:270
ripple::NodeStore::DatabaseShardImp::callForTransactionSQLByLedgerSeq
bool callForTransactionSQLByLedgerSeq(LedgerIndex ledgerSeq, std::function< bool(soci::session &session)> const &callback) override
Invoke a callback on the transaction SQLite db for the corresponding ledger.
Definition: DatabaseShardImp.cpp:2052
ripple::base_uint< 256 >
ripple::NodeStore::DatabaseShardImp::updatePeers
void updatePeers(std::lock_guard< std::mutex > const &lock) const
Definition: DatabaseShardImp.cpp:2201
ripple::NodeStore::DatabaseShardImp::getPreShards
std::string getPreShards() override
Get shard indexes being imported.
Definition: DatabaseShardImp.cpp:426
ripple::NodeStore::DatabaseShardImp::databaseImportStatus_
std::unique_ptr< DatabaseImportStatus > databaseImportStatus_
Definition: DatabaseShardImp.h:289
ripple::NodeStore::DatabaseShardImp::getWriteLoad
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
Definition: DatabaseShardImp.cpp:1085
ripple::NodeStore::DatabaseShardImp::findAcquireIndex
std::optional< std::uint32_t > findAcquireIndex(std::uint32_t validLedgerSeq, std::lock_guard< std::mutex > const &)
Definition: DatabaseShardImp.cpp:1402
ripple::NodeStore::TaskQueue
Definition: TaskQueue.h:31
ripple::NodeStore::DatabaseShardImp::iterateTransactionSQLsBack
bool iterateTransactionSQLsBack(std::optional< std::uint32_t > maxShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback) override
iterateTransactionSQLsBack Checks out transaction databases for all shards in descending order starti...
Definition: DatabaseShardImp.cpp:2167
ripple::NodeStore::DatabaseShardImp::haltDatabaseImport_
std::atomic_bool haltDatabaseImport_
Definition: DatabaseShardImp.h:295
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::currentIndex
std::uint32_t currentIndex
Definition: DatabaseShardImp.h:220
ripple::NodeStore::DatabaseShardImp::chooseHistoricalPath
boost::filesystem::path chooseHistoricalPath(std::lock_guard< std::mutex > const &) const
Definition: DatabaseShardImp.cpp:1909
ripple::NodeStore::DatabaseShardImp::sufficientStorage
bool sufficientStorage(std::uint32_t numShards, PathDesignation pathDesignation, std::lock_guard< std::mutex > const &) const
Definition: DatabaseShardImp.cpp:1602
ripple::NodeStore::DatabaseShardImp::fetchNodeObject
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t ledgerSeq, FetchReport &fetchReport, bool duplicate) override
Definition: DatabaseShardImp.cpp:1382
ripple::NodeStore::DatabaseShardImp::init_
bool init_
Definition: DatabaseShardImp.h:234
std::thread
STL class.
ripple::NodeStore::DatabaseShardImp::isSameDB
bool isSameDB(std::uint32_t s1, std::uint32_t s2) override
Definition: DatabaseShardImp.h:114
ripple::NodeStore::DatabaseShardImp::callForLedgerSQLByShardIndex
bool callForLedgerSQLByShardIndex(std::uint32_t const shardIndex, std::function< bool(soci::session &session)> const &callback) override
Invoke a callback on the ledger SQLite db for the corresponding shard.
Definition: DatabaseShardImp.cpp:2038
ripple::NodeStore::DatabaseShardImp::doImportDatabase
void doImportDatabase()
Definition: DatabaseShardImp.cpp:784
ripple::NodeStore::DatabaseShardImp::dir_
boost::filesystem::path dir_
Definition: DatabaseShardImp.h:252
ripple::NodeStore::DatabaseShardImp::removeFailedShard
void removeFailedShard(std::shared_ptr< Shard > &shard)
Definition: DatabaseShardImp.cpp:1690
ripple::NodeStore::DatabaseShard
A collection of historical shards.
Definition: DatabaseShard.h:37
ripple::NodeStore::DatabaseShardImp::getNumTasks
size_t getNumTasks() const override
Returns the number of queued tasks.
Definition: DatabaseShardImp.cpp:2194
ripple::NodeStore::DatabaseShardImp::importShard
bool importShard(std::uint32_t shardIndex, boost::filesystem::path const &srcDir) override
Import a shard from the shard archive handler into the shard database.
Definition: DatabaseShardImp.cpp:444
ripple::NodeStore::DatabaseShardImp::store
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t ledgerSeq) override
Store the object.
Definition: DatabaseShardImp.cpp:1102
ripple::NodeStore::DatabaseShardImp::PathDesignation::none
@ none
ripple::NodeStore::DatabaseShardImp::initConfig
bool initConfig(std::lock_guard< std::mutex > const &)
Definition: DatabaseShardImp.cpp:1308
ripple::NodeStore::DatabaseShardImp::latestShardIndex_
std::optional< std::uint32_t > latestShardIndex_
Definition: DatabaseShardImp.h:285
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
std::uint32_t
std::atomic_bool
ripple::NodeStore::DatabaseShardImp::acquireIndex_
std::uint32_t acquireIndex_
Definition: DatabaseShardImp.h:249
std::map
STL class.
ripple::NodeStore::Scheduler
Scheduling for asynchronous backend activity.
Definition: ripple/nodestore/Scheduler.h:60
ripple::NodeStore::DatabaseShardImp::startNodeToShard
Json::Value startNodeToShard() override
Initiates a NodeStore to ShardStore import and returns the result in a JSON object.
Definition: DatabaseShardImp.cpp:1252
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::latestIndex
std::uint32_t latestIndex
Definition: DatabaseShardImp.h:217
ripple::NodeStore::DatabaseShardImp::preparedIndexes_
std::set< std::uint32_t > preparedIndexes_
Definition: DatabaseShardImp.h:246
ripple::NodeStore::DatabaseShardImp::init
bool init() override
Initialize the database.
Definition: DatabaseShardImp.cpp:70
std::weak_ptr
STL class.
ripple::NodeStore::DatabaseShardImp::historicalPaths_
std::vector< boost::filesystem::path > historicalPaths_
Definition: DatabaseShardImp.h:264
ripple::NodeStore::DatabaseShardImp::getRootDir
boost::filesystem::path const & getRootDir() const override
Returns the root database directory.
Definition: DatabaseShardImp.h:86
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::NodeStore::DatabaseShardImp::checkHistoricalPaths
bool checkHistoricalPaths(std::lock_guard< std::mutex > const &) const
Definition: DatabaseShardImp.cpp:1942
ripple::NodeStore::DatabaseShardImp::maxHistoricalShards_
std::uint32_t maxHistoricalShards_
Definition: DatabaseShardImp.h:261
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::currentShard
std::weak_ptr< Shard > currentShard
Definition: DatabaseShardImp.h:229
ripple::NodeStore::DatabaseShardImp::callForTransactionSQLByShardIndex
bool callForTransactionSQLByShardIndex(std::uint32_t const shardIndex, std::function< bool(soci::session &session)> const &callback) override
Invoke a callback on the transaction SQLite db for the corresponding shard.
Definition: DatabaseShardImp.cpp:2061
ripple::NodeStore::DatabaseShardImp::fetchLedger
std::shared_ptr< Ledger > fetchLedger(uint256 const &hash, std::uint32_t ledgerSeq) override
Fetch a ledger from the shard store.
Definition: DatabaseShardImp.cpp:552
ripple::NodeStore::Database::seqToShardIndex
std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept
Calculates the shard index for a given ledger sequence.
Definition: Database.h:283
ripple::NodeStore::DatabaseShardImp::iterateShardsBack
bool iterateShardsBack(std::optional< std::uint32_t > maxShardIndex, std::function< bool(Shard &shard)> const &visit)
iterateShardsBack Visits all shards starting from given in descending order and calls given callback ...
Definition: DatabaseShardImp.cpp:2127
ripple::NodeStore::DatabaseShardImp::numHistoricalShards
std::uint32_t numHistoricalShards(std::lock_guard< std::mutex > const &lock) const
Definition: DatabaseShardImp.cpp:1730
ripple::NodeStore::DatabaseShardImp::relocateOutdatedShards
void relocateOutdatedShards(std::lock_guard< std::mutex > const &lock)
Definition: DatabaseShardImp.cpp:1741
ripple::NodeStore::DatabaseShardImp::iterateLedgerSQLsBack
bool iterateLedgerSQLsBack(std::optional< std::uint32_t > maxShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback) override
iterateLedgerSQLsBack Checks out ledger databases for all shards in descending order starting from gi...
Definition: DatabaseShardImp.cpp:2156
ripple::NodeStore::DatabaseShardImp::updateFileStats
void updateFileStats()
Definition: DatabaseShardImp.cpp:1541
ripple::NodeStore::DatabaseShardImp::shardBoundaryIndex
std::uint32_t shardBoundaryIndex() const
Definition: DatabaseShardImp.cpp:1714
ripple::NodeStore::DatabaseShardImp::prepareShards
bool prepareShards(std::vector< std::uint32_t > const &shardIndexes) override
Prepare one or more shard indexes to be imported into the database.
Definition: DatabaseShardImp.cpp:299
std::optional< std::uint32_t >
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::firstSeq
std::uint32_t firstSeq
Definition: DatabaseShardImp.h:223
std::mutex
STL class.
ripple::NodeStore::DatabaseShardImp::startDatabaseImportThread
void startDatabaseImportThread(std::lock_guard< std::mutex > const &)
Definition: DatabaseShardImp.cpp:2213
ripple::NodeStore::DatabaseShardImp::setStoredInShard
bool setStoredInShard(std::shared_ptr< Shard > &shard, std::shared_ptr< Ledger const > const &ledger)
Definition: DatabaseShardImp.cpp:1657
ripple::NodeStore::DatabaseShardImp::canAdd_
bool canAdd_
Definition: DatabaseShardImp.h:255
ripple::NodeStore::DatabaseShardImp::finalizeShard
void finalizeShard(std::shared_ptr< Shard > &shard, bool writeSQLite, std::optional< uint256 > const &expectedHash)
Definition: DatabaseShardImp.cpp:1467
ripple::NodeStore::DatabaseShardImp::sync
void sync() override
Definition: DatabaseShardImp.h:127
ripple::NodeStore::Shard
Definition: nodestore/impl/Shard.h:55
ripple::NodeStore::DatabaseShardImp::DatabaseShardImp
DatabaseShardImp()=delete
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus
Definition: DatabaseShardImp.h:201
std::unique_ptr
STL class.
ripple::NodeStore::DatabaseShardImp::databaseImportMarker_
static constexpr auto databaseImportMarker_
Definition: DatabaseShardImp.h:276
ripple::NodeStore::DatabaseShardImp::DatabaseImportStatus::earliestIndex
std::uint32_t earliestIndex
Definition: DatabaseShardImp.h:214
std::set< std::uint32_t >
ripple::NodeStore::DatabaseShardImp::prepareForNewShard
std::optional< PathDesignation > prepareForNewShard(std::uint32_t shardIndex, std::uint32_t numHistoricalShards, std::lock_guard< std::mutex > const &lock)
Definition: DatabaseShardImp.cpp:1878
ripple::NodeStore::DatabaseShardImp::iterateTransactionSQLsForward
bool iterateTransactionSQLsForward(std::optional< std::uint32_t > minShardIndex, std::function< bool(soci::session &session, std::uint32_t shardIndex)> const &callback) override
iterateTransactionSQLsForward Checks out transaction databases for all shards in ascending order star...
Definition: DatabaseShardImp.cpp:2115
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::NodeStore::DatabaseShardImp::prepareLedger
std::optional< std::uint32_t > prepareLedger(std::uint32_t validLedgerSeq) override
Prepare to store a new ledger in the shard being acquired.
Definition: DatabaseShardImp.cpp:229
ripple::NodeStore::DatabaseShardImp::ctx_
std::unique_ptr< nudb::context > ctx_
Definition: DatabaseShardImp.h:237
ripple::NodeStore::DatabaseShardImp::backendName_
std::string backendName_
Definition: DatabaseShardImp.h:258
ripple::NodeStore::DatabaseShardImp::getShardInfo
std::unique_ptr< ShardInfo > getShardInfo() const override
Query information about shards held.
Definition: DatabaseShardImp.cpp:692