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>
24#include <xrpl/basics/UptimeClock.h>
25#include <xrpl/beast/core/CurrentThreadName.h>
26#include <xrpl/json/to_string.h>
34 : app_(app), journal_(journal), deadLock_(), armed_(false)
48 <<
"std::exception in ~LoadManager. " << ex.
what();
78 "ripple::LoadManager::start : thread not joinable");
106 using namespace std::chrono_literals;
109 auto t = clock_type::now();
121 auto const armed =
armed_;
126 auto const timeSpentDeadlocked =
127 duration_cast<seconds>(steady_clock::now() - deadLock);
129 constexpr auto reportingIntervalSeconds = 10s;
130 constexpr auto deadlockFatalLogMessageTimeLimit = 90s;
131 constexpr auto deadlockLogicErrorTimeLimit = 600s;
133 if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))
137 if ((timeSpentDeadlocked % reportingIntervalSeconds) == 0s)
139 if (timeSpentDeadlocked < deadlockFatalLogMessageTimeLimit)
142 <<
"Server stalled for " << timeSpentDeadlocked.count()
152 <<
"Deadlock detected. Deadlocked time: "
153 << timeSpentDeadlocked.count() <<
"s";
163 if (timeSpentDeadlocked >= deadlockLogicErrorTimeLimit)
166 <<
"LogicError: Deadlock detected. Deadlocked time: "
167 << timeSpentDeadlocked.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)
void resetDeadlockDetector()
Reset the deadlock detection timer.
std::condition_variable cv_
beast::Journal const journal_
void activateDeadlockDetector()
Turn on deadlock detection.
std::chrono::steady_clock::time_point deadLock_
~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.