rippled
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ripple::SHAMapStoreImp Class Reference
Inheritance diagram for ripple::SHAMapStoreImp:
Inheritance graph
[legend]
Collaboration diagram for ripple::SHAMapStoreImp:
Collaboration graph
[legend]

Classes

class  SavedStateDB
 

Public Member Functions

 SHAMapStoreImp (Application &app, NodeStore::Scheduler &scheduler, beast::Journal journal)
 
std::uint32_t clampFetchDepth (std::uint32_t fetch_depth) const override
 
std::unique_ptr< NodeStore::DatabasemakeNodeStore (int readThreads) override
 
LedgerIndex setCanDelete (LedgerIndex seq) override
 Highest ledger that may be deleted. More...
 
bool advisoryDelete () const override
 Whether advisory delete is enabled. More...
 
LedgerIndex getLastRotated () override
 Maximum ledger that has been deleted, or will be deleted if currently in the act of online deletion. More...
 
LedgerIndex getCanDelete () override
 Highest ledger that may be deleted. More...
 
void onLedgerClosed (std::shared_ptr< Ledger const > const &ledger) override
 Called by LedgerMaster every time a ledger validates. More...
 
void rendezvous () const override
 
int fdRequired () const override
 Returns the number of file descriptors that are needed. More...
 
std::optional< LedgerIndexminimumOnline () const override
 The minimum ledger to try and maintain in our database. More...
 
void start () override
 
void stop () override
 

Private Types

enum  HealthResult { stopping, keepGoing }
 This is a health check for online deletion that waits until rippled is stable before returning. More...
 

Private Member Functions

bool copyNode (std::uint64_t &nodeCount, SHAMapTreeNode const &node)
 
void run ()
 
void dbPaths ()
 
std::unique_ptr< NodeStore::BackendmakeBackendRotating (std::string path=std::string())
 
template<class CacheInstance >
bool freshenCache (CacheInstance &cache)
 
void clearSql (LedgerIndex lastRotated, std::string const &TableName, std::function< std::optional< LedgerIndex >()> const &getMinSeq, std::function< void(LedgerIndex)> const &deleteBeforeSeq)
 delete from sqlite table in batches to not lock the db excessively. More...
 
void clearCaches (LedgerIndex validatedSeq)
 
void freshenCaches ()
 
void clearPrior (LedgerIndex lastRotated)
 
HealthResult healthWait ()
 

Private Attributes

Applicationapp_
 
const std::string dbName_ = "state"
 
const std::string dbPrefix_ = "rippledb"
 
const std::uint64_t checkHealthInterval_ = 1000
 
std::atomic< LedgerIndexminimumOnline_ {}
 
NodeStore::Schedulerscheduler_
 
const beast::Journal journal_
 
NodeStore::DatabaseRotatingdbRotating_ = nullptr
 
SavedStateDB state_db_
 
std::thread thread_
 
bool stop_ = false
 
bool healthy_ = true
 
std::condition_variable cond_
 
std::condition_variable rendezvous_
 
std::mutex mutex_
 
std::shared_ptr< Ledger const > newLedger_
 
std::atomic< bool > working_
 
std::atomic< LedgerIndexcanDelete_
 
int fdRequired_ = 0
 
std::uint32_t deleteInterval_ = 0
 
bool advisoryDelete_ = false
 
std::uint32_t deleteBatch_ = 100
 
std::chrono::milliseconds backOff_ {100}
 
std::chrono::seconds ageThreshold_ {60}
 
std::chrono::seconds recoveryWaitTime_ {5}
 If the node is out of sync during an online_delete healthWait() call, sleep the thread for this time, and continue checking until recovery. More...
 
NetworkOPsnetOPs_ = nullptr
 
LedgerMasterledgerMaster_ = nullptr
 
FullBelowCachefullBelowCache_ = nullptr
 
TreeNodeCachetreeNodeCache_ = nullptr
 

Static Private Attributes

static const std::uint32_t minimumDeletionInterval_ = 256
 
static const std::uint32_t minimumDeletionIntervalSA_ = 8
 
static constexpr auto nodeStoreName_ = "NodeStore"
 

Detailed Description

Definition at line 40 of file SHAMapStoreImp.h.

Member Enumeration Documentation

◆ HealthResult

This is a health check for online deletion that waits until rippled is stable before returning.

It returns an indication of whether the server is stopping.

Returns
Whether the server is stopping.
Enumerator
stopping 
keepGoing 

Definition at line 232 of file SHAMapStoreImp.h.

Constructor & Destructor Documentation

◆ SHAMapStoreImp()

ripple::SHAMapStoreImp::SHAMapStoreImp ( Application app,
NodeStore::Scheduler scheduler,
beast::Journal  journal 
)

Definition at line 85 of file SHAMapStoreImp.cpp.

Member Function Documentation

◆ clampFetchDepth()

std::uint32_t ripple::SHAMapStoreImp::clampFetchDepth ( std::uint32_t  fetch_depth) const
overridevirtual

Implements ripple::SHAMapStore.

Definition at line 129 of file SHAMapStoreImp.h.

◆ makeNodeStore()

std::unique_ptr< NodeStore::Database > ripple::SHAMapStoreImp::makeNodeStore ( int  readThreads)
overridevirtual

Implements ripple::SHAMapStore.

Definition at line 170 of file SHAMapStoreImp.cpp.

◆ setCanDelete()

LedgerIndex ripple::SHAMapStoreImp::setCanDelete ( LedgerIndex  canDelete)
overridevirtual

Highest ledger that may be deleted.

Implements ripple::SHAMapStore.

Definition at line 139 of file SHAMapStoreImp.h.

◆ advisoryDelete()

bool ripple::SHAMapStoreImp::advisoryDelete ( ) const
overridevirtual

Whether advisory delete is enabled.

Implements ripple::SHAMapStore.

Definition at line 147 of file SHAMapStoreImp.h.

◆ getLastRotated()

LedgerIndex ripple::SHAMapStoreImp::getLastRotated ( )
overridevirtual

Maximum ledger that has been deleted, or will be deleted if currently in the act of online deletion.

Implements ripple::SHAMapStore.

Definition at line 155 of file SHAMapStoreImp.h.

◆ getCanDelete()

LedgerIndex ripple::SHAMapStoreImp::getCanDelete ( )
overridevirtual

Highest ledger that may be deleted.

Implements ripple::SHAMapStore.

Definition at line 163 of file SHAMapStoreImp.h.

◆ onLedgerClosed()

void ripple::SHAMapStoreImp::onLedgerClosed ( std::shared_ptr< Ledger const > const &  ledger)
overridevirtual

Called by LedgerMaster every time a ledger validates.

Implements ripple::SHAMapStore.

Definition at line 235 of file SHAMapStoreImp.cpp.

◆ rendezvous()

void ripple::SHAMapStoreImp::rendezvous ( ) const
overridevirtual

Implements ripple::SHAMapStore.

Definition at line 246 of file SHAMapStoreImp.cpp.

◆ fdRequired()

int ripple::SHAMapStoreImp::fdRequired ( ) const
overridevirtual

Returns the number of file descriptors that are needed.

Implements ripple::SHAMapStore.

Definition at line 256 of file SHAMapStoreImp.cpp.

◆ minimumOnline()

std::optional< LedgerIndex > ripple::SHAMapStoreImp::minimumOnline ( ) const
overridevirtual

The minimum ledger to try and maintain in our database.

This defines the lower bound for attempting to acquire historical ledgers over the peer to peer network.

If online_delete is enabled, then each time online_delete executes and just prior to clearing SQL databases of historical ledgers, move the value forward to one past the greatest ledger being deleted. This minimizes fetching of ledgers that are in the process of being deleted. Without online_delete or before online_delete is executed, this value is always the minimum value persisted in the ledger database, if any.

Returns
The minimum ledger sequence to keep online based on the description above. If not set, then an unseated optional.

Implements ripple::SHAMapStore.

Definition at line 716 of file SHAMapStoreImp.cpp.

◆ copyNode()

bool ripple::SHAMapStoreImp::copyNode ( std::uint64_t nodeCount,
SHAMapTreeNode const &  node 
)
private

Definition at line 262 of file SHAMapStoreImp.cpp.

◆ run()

void ripple::SHAMapStoreImp::run ( )
private

Definition at line 280 of file SHAMapStoreImp.cpp.

◆ dbPaths()

void ripple::SHAMapStoreImp::dbPaths ( )
private

Definition at line 428 of file SHAMapStoreImp.cpp.

◆ makeBackendRotating()

std::unique_ptr< NodeStore::Backend > ripple::SHAMapStoreImp::makeBackendRotating ( std::string  path = std::string())
private

Definition at line 521 of file SHAMapStoreImp.cpp.

◆ freshenCache()

template<class CacheInstance >
bool ripple::SHAMapStoreImp::freshenCache ( CacheInstance &  cache)
private

Definition at line 193 of file SHAMapStoreImp.h.

◆ clearSql()

void ripple::SHAMapStoreImp::clearSql ( LedgerIndex  lastRotated,
std::string const &  TableName,
std::function< std::optional< LedgerIndex >()> const &  getMinSeq,
std::function< void(LedgerIndex)> const &  deleteBeforeSeq 
)
private

delete from sqlite table in batches to not lock the db excessively.

Pause briefly to extend access time to other users. Call with mutex object unlocked.

Definition at line 550 of file SHAMapStoreImp.cpp.

◆ clearCaches()

void ripple::SHAMapStoreImp::clearCaches ( LedgerIndex  validatedSeq)
private

Definition at line 601 of file SHAMapStoreImp.cpp.

◆ freshenCaches()

void ripple::SHAMapStoreImp::freshenCaches ( )
private

Definition at line 608 of file SHAMapStoreImp.cpp.

◆ clearPrior()

void ripple::SHAMapStoreImp::clearPrior ( LedgerIndex  lastRotated)
private

Definition at line 617 of file SHAMapStoreImp.cpp.

◆ healthWait()

SHAMapStoreImp::HealthResult ripple::SHAMapStoreImp::healthWait ( )
private

Definition at line 680 of file SHAMapStoreImp.cpp.

◆ start()

void ripple::SHAMapStoreImp::start ( )
overridevirtual

Implements ripple::SHAMapStore.

Definition at line 238 of file SHAMapStoreImp.h.

◆ stop()

void ripple::SHAMapStoreImp::stop ( )
overridevirtual

Implements ripple::SHAMapStore.

Definition at line 702 of file SHAMapStoreImp.cpp.

Member Data Documentation

◆ app_

Application& ripple::SHAMapStoreImp::app_
private

Definition at line 72 of file SHAMapStoreImp.h.

◆ dbName_

const std::string ripple::SHAMapStoreImp::dbName_ = "state"
private

Definition at line 75 of file SHAMapStoreImp.h.

◆ dbPrefix_

const std::string ripple::SHAMapStoreImp::dbPrefix_ = "rippledb"
private

Definition at line 77 of file SHAMapStoreImp.h.

◆ checkHealthInterval_

const std::uint64_t ripple::SHAMapStoreImp::checkHealthInterval_ = 1000
private

Definition at line 79 of file SHAMapStoreImp.h.

◆ minimumDeletionInterval_

const std::uint32_t ripple::SHAMapStoreImp::minimumDeletionInterval_ = 256
staticprivate

Definition at line 81 of file SHAMapStoreImp.h.

◆ minimumDeletionIntervalSA_

const std::uint32_t ripple::SHAMapStoreImp::minimumDeletionIntervalSA_ = 8
staticprivate

Definition at line 83 of file SHAMapStoreImp.h.

◆ minimumOnline_

std::atomic<LedgerIndex> ripple::SHAMapStoreImp::minimumOnline_ {}
private

Definition at line 85 of file SHAMapStoreImp.h.

◆ scheduler_

NodeStore::Scheduler& ripple::SHAMapStoreImp::scheduler_
private

Definition at line 87 of file SHAMapStoreImp.h.

◆ journal_

const beast::Journal ripple::SHAMapStoreImp::journal_
private

Definition at line 88 of file SHAMapStoreImp.h.

◆ dbRotating_

NodeStore::DatabaseRotating* ripple::SHAMapStoreImp::dbRotating_ = nullptr
private

Definition at line 89 of file SHAMapStoreImp.h.

◆ state_db_

SavedStateDB ripple::SHAMapStoreImp::state_db_
private

Definition at line 90 of file SHAMapStoreImp.h.

◆ thread_

std::thread ripple::SHAMapStoreImp::thread_
private

Definition at line 91 of file SHAMapStoreImp.h.

◆ stop_

bool ripple::SHAMapStoreImp::stop_ = false
private

Definition at line 92 of file SHAMapStoreImp.h.

◆ healthy_

bool ripple::SHAMapStoreImp::healthy_ = true
private

Definition at line 93 of file SHAMapStoreImp.h.

◆ cond_

std::condition_variable ripple::SHAMapStoreImp::cond_
mutableprivate

Definition at line 94 of file SHAMapStoreImp.h.

◆ rendezvous_

std::condition_variable ripple::SHAMapStoreImp::rendezvous_
mutableprivate

Definition at line 95 of file SHAMapStoreImp.h.

◆ mutex_

std::mutex ripple::SHAMapStoreImp::mutex_
mutableprivate

Definition at line 96 of file SHAMapStoreImp.h.

◆ newLedger_

std::shared_ptr<Ledger const> ripple::SHAMapStoreImp::newLedger_
private

Definition at line 97 of file SHAMapStoreImp.h.

◆ working_

std::atomic<bool> ripple::SHAMapStoreImp::working_
private

Definition at line 98 of file SHAMapStoreImp.h.

◆ canDelete_

std::atomic<LedgerIndex> ripple::SHAMapStoreImp::canDelete_
private

Definition at line 99 of file SHAMapStoreImp.h.

◆ fdRequired_

int ripple::SHAMapStoreImp::fdRequired_ = 0
private

Definition at line 100 of file SHAMapStoreImp.h.

◆ deleteInterval_

std::uint32_t ripple::SHAMapStoreImp::deleteInterval_ = 0
private

Definition at line 102 of file SHAMapStoreImp.h.

◆ advisoryDelete_

bool ripple::SHAMapStoreImp::advisoryDelete_ = false
private

Definition at line 103 of file SHAMapStoreImp.h.

◆ deleteBatch_

std::uint32_t ripple::SHAMapStoreImp::deleteBatch_ = 100
private

Definition at line 104 of file SHAMapStoreImp.h.

◆ backOff_

std::chrono::milliseconds ripple::SHAMapStoreImp::backOff_ {100}
private

Definition at line 105 of file SHAMapStoreImp.h.

◆ ageThreshold_

std::chrono::seconds ripple::SHAMapStoreImp::ageThreshold_ {60}
private

Definition at line 106 of file SHAMapStoreImp.h.

◆ recoveryWaitTime_

std::chrono::seconds ripple::SHAMapStoreImp::recoveryWaitTime_ {5}
private

If the node is out of sync during an online_delete healthWait() call, sleep the thread for this time, and continue checking until recovery.

See also: "recovery_wait_seconds" in rippled-example.cfg

Definition at line 111 of file SHAMapStoreImp.h.

◆ netOPs_

NetworkOPs* ripple::SHAMapStoreImp::netOPs_ = nullptr
private

Definition at line 115 of file SHAMapStoreImp.h.

◆ ledgerMaster_

LedgerMaster* ripple::SHAMapStoreImp::ledgerMaster_ = nullptr
private

Definition at line 116 of file SHAMapStoreImp.h.

◆ fullBelowCache_

FullBelowCache* ripple::SHAMapStoreImp::fullBelowCache_ = nullptr
private

Definition at line 117 of file SHAMapStoreImp.h.

◆ treeNodeCache_

TreeNodeCache* ripple::SHAMapStoreImp::treeNodeCache_ = nullptr
private

Definition at line 118 of file SHAMapStoreImp.h.

◆ nodeStoreName_

constexpr auto ripple::SHAMapStoreImp::nodeStoreName_ = "NodeStore"
staticconstexprprivate

Definition at line 120 of file SHAMapStoreImp.h.