1#include <xrpld/app/main/Application.h>
2#include <xrpld/app/main/LoadManager.h>
3#include <xrpld/app/misc/LoadFeeTrack.h>
4#include <xrpld/app/misc/NetworkOPs.h>
6#include <xrpl/beast/core/CurrentThreadName.h>
7#include <xrpl/json/to_string.h>
16 : app_(app), journal_(journal), lastHeartbeat_(), armed_(false)
57 XRPL_ASSERT(!
thread_.
joinable(),
"xrpl::LoadManager::start : thread not joinable");
85 using namespace std::chrono_literals;
88 auto t = clock_type::now();
100 auto const armed =
armed_;
105 auto const timeSpentStalled = duration_cast<seconds>(steady_clock::now() - lastHeartbeat);
107 constexpr auto reportingIntervalSeconds = 10s;
108 constexpr auto stallFatalLogMessageTimeLimit = 90s;
109 constexpr auto stallLogicErrorTimeLimit = 600s;
111 if (armed && (timeSpentStalled >= reportingIntervalSeconds))
114 if ((timeSpentStalled % reportingIntervalSeconds) == 0s)
116 if (timeSpentStalled < stallFatalLogMessageTimeLimit)
118 JLOG(
journal_.
warn()) <<
"Server stalled for " << timeSpentStalled.count() <<
" seconds.";
127 JLOG(
journal_.
fatal()) <<
"Server stalled for " << timeSpentStalled.count() <<
" seconds.";
135 if (timeSpentStalled >= stallLogicErrorTimeLimit)
137 JLOG(
journal_.
fatal()) <<
"LogicError: Fatal server stall detected. Stalled time: "
138 << timeSpentStalled.count() <<
"s";
A generic endpoint for log messages.
virtual LoadFeeTrack & getFeeTrack()=0
virtual JobQueue & getJobQueue()=0
virtual NetworkOPs & getOPs()=0
Json::Value getJson(int c=0)
std::chrono::steady_clock::time_point lastHeartbeat_
std::condition_variable cv_
beast::Journal const journal_
~LoadManager()
Destroy the manager.
void heartbeat()
Reset the stall detection timer.
void activateStallDetector()
Turn on stall detection.
virtual void reportFeeChange()=0
void setCurrentThreadName(std::string_view newThreadName)
Changes the name of the caller thread.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
std::unique_ptr< LoadManager > make_LoadManager(Application &app, beast::Journal journal)