rippled
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ripple::RPC::ShardArchiveHandler Class Reference

Handles the download and import of one or more shard archives. More...

Inheritance diagram for ripple::RPC::ShardArchiveHandler:
Inheritance graph
[legend]
Collaboration diagram for ripple::RPC::ShardArchiveHandler:
Collaboration graph
[legend]

Public Types

using TimerOpCounter = ClosureCounter< void, boost::system::error_code const & >
 

Public Member Functions

 ShardArchiveHandler (Application &app)
 
virtual ~ShardArchiveHandler ()=default
 
bool init ()
 
bool add (std::uint32_t shardIndex, std::pair< parsedURL, std::string > &&url)
 
bool start ()
 Starts downloading and importing archives. More...
 
void stop ()
 
void release ()
 

Static Public Member Functions

static boost::filesystem::path getDownloadDirectory (Config const &config)
 
static std::unique_ptr< ShardArchiveHandlermakeShardArchiveHandler (Application &app)
 
static std::unique_ptr< ShardArchiveHandlertryMakeRecoveryHandler (Application &app)
 

Private Member Functions

 ShardArchiveHandler ()=delete
 
 ShardArchiveHandler (ShardArchiveHandler const &)=delete
 
ShardArchiveHandleroperator= (ShardArchiveHandler &&)=delete
 
ShardArchiveHandleroperator= (ShardArchiveHandler const &)=delete
 
bool initFromDB (std::lock_guard< std::mutex > const &)
 
bool add (std::uint32_t shardIndex, parsedURL &&url, std::lock_guard< std::mutex > const &)
 Add an archive to be downloaded and imported. More...
 
bool next (std::lock_guard< std::mutex > const &l)
 
void complete (boost::filesystem::path dstPath)
 
void process (boost::filesystem::path const &dstPath)
 
void remove (std::lock_guard< std::mutex > const &)
 
void doRelease (std::lock_guard< std::mutex > const &)
 
bool onClosureFailed (std::string const &errorMsg, std::lock_guard< std::mutex > const &lock)
 
bool removeAndProceed (std::lock_guard< std::mutex > const &lock)
 

Private Attributes

std::mutex m_
 
std::atomic_bool stopping_ {false}
 
std::shared_ptr< DatabaseDownloaderdownloader_
 
std::map< std::uint32_t, parsedURLarchives_
 
bool process_
 
std::unique_ptr< DatabaseConsqlDB_
 
Applicationapp_
 
const beast::Journal j_
 
const boost::filesystem::path downloadDir_
 
boost::asio::basic_waitable_timer< std::chrono::steady_clocktimer_
 
JobCounter jobCounter_
 
TimerOpCounter timerCounter_
 
ShardVerificationScheduler verificationScheduler_
 

Detailed Description

Handles the download and import of one or more shard archives.

Definition at line 42 of file ShardArchiveHandler.h.

Member Typedef Documentation

◆ TimerOpCounter

using ripple::RPC::ShardArchiveHandler::TimerOpCounter = ClosureCounter<void, boost::system::error_code const&>

Definition at line 46 of file ShardArchiveHandler.h.

Constructor & Destructor Documentation

◆ ShardArchiveHandler() [1/3]

ripple::RPC::ShardArchiveHandler::ShardArchiveHandler ( Application app)
explicit

Definition at line 71 of file ShardArchiveHandler.cpp.

◆ ~ShardArchiveHandler()

virtual ripple::RPC::ShardArchiveHandler::~ShardArchiveHandler ( )
virtualdefault

◆ ShardArchiveHandler() [2/3]

ripple::RPC::ShardArchiveHandler::ShardArchiveHandler ( )
privatedelete

◆ ShardArchiveHandler() [3/3]

ripple::RPC::ShardArchiveHandler::ShardArchiveHandler ( ShardArchiveHandler const &  )
privatedelete

Member Function Documentation

◆ getDownloadDirectory()

boost::filesystem::path ripple::RPC::ShardArchiveHandler::getDownloadDirectory ( Config const &  config)
static

Definition at line 38 of file ShardArchiveHandler.cpp.

◆ makeShardArchiveHandler()

std::unique_ptr< ShardArchiveHandler > ripple::RPC::ShardArchiveHandler::makeShardArchiveHandler ( Application app)
static

Definition at line 50 of file ShardArchiveHandler.cpp.

◆ tryMakeRecoveryHandler()

std::unique_ptr< ShardArchiveHandler > ripple::RPC::ShardArchiveHandler::tryMakeRecoveryHandler ( Application app)
static

Definition at line 56 of file ShardArchiveHandler.cpp.

◆ init()

bool ripple::RPC::ShardArchiveHandler::init ( )

Definition at line 90 of file ShardArchiveHandler.cpp.

◆ add() [1/2]

bool ripple::RPC::ShardArchiveHandler::add ( std::uint32_t  shardIndex,
std::pair< parsedURL, std::string > &&  url 
)

Definition at line 200 of file ShardArchiveHandler.cpp.

◆ start()

bool ripple::RPC::ShardArchiveHandler::start ( )

Starts downloading and importing archives.

Definition at line 236 of file ShardArchiveHandler.cpp.

◆ stop()

void ripple::RPC::ShardArchiveHandler::stop ( )

Definition at line 177 of file ShardArchiveHandler.cpp.

◆ release()

void ripple::RPC::ShardArchiveHandler::release ( )

Definition at line 288 of file ShardArchiveHandler.cpp.

◆ operator=() [1/2]

ShardArchiveHandler& ripple::RPC::ShardArchiveHandler::operator= ( ShardArchiveHandler &&  )
privatedelete

◆ operator=() [2/2]

ShardArchiveHandler& ripple::RPC::ShardArchiveHandler::operator= ( ShardArchiveHandler const &  )
privatedelete

◆ initFromDB()

bool ripple::RPC::ShardArchiveHandler::initFromDB ( std::lock_guard< std::mutex > const &  lock)
private

Definition at line 132 of file ShardArchiveHandler.cpp.

◆ add() [2/2]

bool ripple::RPC::ShardArchiveHandler::add ( std::uint32_t  shardIndex,
parsedURL &&  url,
std::lock_guard< std::mutex > const &   
)
private

Add an archive to be downloaded and imported.

Parameters
shardIndexthe index of the shard to be imported.
urlthe location of the archive.
Returns
true if successfully added.
Note
Returns false if called while downloading.

Definition at line 215 of file ShardArchiveHandler.cpp.

◆ next()

bool ripple::RPC::ShardArchiveHandler::next ( std::lock_guard< std::mutex > const &  l)
private

Definition at line 295 of file ShardArchiveHandler.cpp.

◆ complete()

void ripple::RPC::ShardArchiveHandler::complete ( boost::filesystem::path  dstPath)
private

Definition at line 392 of file ShardArchiveHandler.cpp.

◆ process()

void ripple::RPC::ShardArchiveHandler::process ( boost::filesystem::path const &  dstPath)
private

Definition at line 473 of file ShardArchiveHandler.cpp.

◆ remove()

void ripple::RPC::ShardArchiveHandler::remove ( std::lock_guard< std::mutex > const &  )
private

Definition at line 512 of file ShardArchiveHandler.cpp.

◆ doRelease()

void ripple::RPC::ShardArchiveHandler::doRelease ( std::lock_guard< std::mutex > const &  )
private

Definition at line 534 of file ShardArchiveHandler.cpp.

◆ onClosureFailed()

bool ripple::RPC::ShardArchiveHandler::onClosureFailed ( std::string const &  errorMsg,
std::lock_guard< std::mutex > const &  lock 
)
private

Definition at line 561 of file ShardArchiveHandler.cpp.

◆ removeAndProceed()

bool ripple::RPC::ShardArchiveHandler::removeAndProceed ( std::lock_guard< std::mutex > const &  lock)
private

Definition at line 574 of file ShardArchiveHandler.cpp.

Member Data Documentation

◆ m_

std::mutex ripple::RPC::ShardArchiveHandler::m_
mutableprivate

Definition at line 137 of file ShardArchiveHandler.h.

◆ stopping_

std::atomic_bool ripple::RPC::ShardArchiveHandler::stopping_ {false}
private

Definition at line 138 of file ShardArchiveHandler.h.

◆ downloader_

std::shared_ptr<DatabaseDownloader> ripple::RPC::ShardArchiveHandler::downloader_
private

Definition at line 139 of file ShardArchiveHandler.h.

◆ archives_

std::map<std::uint32_t, parsedURL> ripple::RPC::ShardArchiveHandler::archives_
private

Definition at line 140 of file ShardArchiveHandler.h.

◆ process_

bool ripple::RPC::ShardArchiveHandler::process_
private

Definition at line 141 of file ShardArchiveHandler.h.

◆ sqlDB_

std::unique_ptr<DatabaseCon> ripple::RPC::ShardArchiveHandler::sqlDB_
private

Definition at line 142 of file ShardArchiveHandler.h.

◆ app_

Application& ripple::RPC::ShardArchiveHandler::app_
private

Definition at line 145 of file ShardArchiveHandler.h.

◆ j_

const beast::Journal ripple::RPC::ShardArchiveHandler::j_
private

Definition at line 146 of file ShardArchiveHandler.h.

◆ downloadDir_

const boost::filesystem::path ripple::RPC::ShardArchiveHandler::downloadDir_
private

Definition at line 147 of file ShardArchiveHandler.h.

◆ timer_

boost::asio::basic_waitable_timer<std::chrono::steady_clock> ripple::RPC::ShardArchiveHandler::timer_
private

Definition at line 148 of file ShardArchiveHandler.h.

◆ jobCounter_

JobCounter ripple::RPC::ShardArchiveHandler::jobCounter_
private

Definition at line 149 of file ShardArchiveHandler.h.

◆ timerCounter_

TimerOpCounter ripple::RPC::ShardArchiveHandler::timerCounter_
private

Definition at line 150 of file ShardArchiveHandler.h.

◆ verificationScheduler_

ShardVerificationScheduler ripple::RPC::ShardArchiveHandler::verificationScheduler_
private

Definition at line 151 of file ShardArchiveHandler.h.