20#include <xrpld/app/main/Application.h>
21#include <xrpld/app/main/LoadManager.h>
22#include <xrpld/app/misc/LoadFeeTrack.h>
23#include <xrpld/app/misc/NetworkOPs.h>
25#include <xrpl/beast/core/CurrentThreadName.h>
26#include <xrpl/json/to_string.h>
35 : app_(app), journal_(journal), lastHeartbeat_(), armed_(false)
49 <<
"std::exception in ~LoadManager. " << ex.
what();
79 "ripple::LoadManager::start : thread not joinable");
107 using namespace std::chrono_literals;
110 auto t = clock_type::now();
122 auto const armed =
armed_;
127 auto const timeSpentStalled =
128 duration_cast<seconds>(steady_clock::now() - lastHeartbeat);
130 constexpr auto reportingIntervalSeconds = 10s;
131 constexpr auto stallFatalLogMessageTimeLimit = 90s;
132 constexpr auto stallLogicErrorTimeLimit = 600s;
134 if (armed && (timeSpentStalled >= reportingIntervalSeconds))
137 if ((timeSpentStalled % reportingIntervalSeconds) == 0s)
139 if (timeSpentStalled < stallFatalLogMessageTimeLimit)
142 <<
"Server stalled for " << timeSpentStalled.count()
154 <<
"Server stalled for " << timeSpentStalled.count()
164 if (timeSpentStalled >= stallLogicErrorTimeLimit)
167 <<
"LogicError: Fatal server stall detected. Stalled time: "
168 << timeSpentStalled.count() <<
"s";
179 JLOG(
journal_.
info()) <<
"Raising local fee (JQ overload): "
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_
void activateStallDetector()
Turn on stall detection.
beast::Journal const journal_
void heartbeat()
Reset the stall detection timer.
~LoadManager()
Destroy the manager.
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.
std::unique_ptr< LoadManager > make_LoadManager(Application &app, beast::Journal journal)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.