mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Make ShardArchiveHandler downloads more resilient:
* Make ShardArchiveHandler a singleton. * Add state database for ShardArchiveHandler. * Use temporary database for SSLHTTPDownloader downloads. * Make ShardArchiveHandler a Stoppable class. * Automatically resume interrupted downloads at server start.
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#include <ripple/rpc/impl/RPCHelpers.h>
|
||||
#include <ripple/beast/asio/io_latency_probe.h>
|
||||
#include <ripple/beast/core/LexicalCast.h>
|
||||
#include <ripple/rpc/ShardArchiveHandler.h>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <ripple/app/main/GRPCServer.h>
|
||||
@@ -1610,6 +1611,53 @@ bool ApplicationImp::setup()
|
||||
}
|
||||
}
|
||||
|
||||
if (shardStore_)
|
||||
{
|
||||
using namespace boost::filesystem;
|
||||
|
||||
auto stateDb(
|
||||
RPC::ShardArchiveHandler::getDownloadDirectory(*config_)
|
||||
/ stateDBName);
|
||||
|
||||
try
|
||||
{
|
||||
if (exists(stateDb) &&
|
||||
is_regular_file(stateDb) &&
|
||||
!RPC::ShardArchiveHandler::hasInstance())
|
||||
{
|
||||
auto handler = RPC::ShardArchiveHandler::recoverInstance(
|
||||
*this,
|
||||
*m_jobQueue);
|
||||
|
||||
assert(handler);
|
||||
|
||||
if (!handler->initFromDB())
|
||||
{
|
||||
JLOG(m_journal.fatal())
|
||||
<< "Failed to initialize ShardArchiveHandler.";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!handler->start())
|
||||
{
|
||||
JLOG(m_journal.fatal())
|
||||
<< "Failed to start ShardArchiveHandler.";
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(std::exception const& e)
|
||||
{
|
||||
JLOG(m_journal.fatal())
|
||||
<< "Exception when starting ShardArchiveHandler from "
|
||||
"state database: " << e.what();
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user