20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/main/LoadManager.h>
22 #include <ripple/app/misc/LoadFeeTrack.h>
23 #include <ripple/app/misc/NetworkOPs.h>
24 #include <ripple/basics/UptimeClock.h>
25 #include <ripple/beast/core/CurrentThreadName.h>
26 #include <ripple/json/to_string.h>
56 <<
"std::exception in ~LoadManager. " << ex.
what();
116 using namespace std::chrono_literals;
119 auto t = clock_type::now();
128 auto const armed =
armed_;
134 auto const timeSpentDeadlocked =
135 duration_cast<seconds>(steady_clock::now() - deadLock);
137 constexpr
auto reportingIntervalSeconds = 10s;
138 constexpr
auto deadlockFatalLogMessageTimeLimit = 90s;
139 constexpr
auto deadlockLogicErrorTimeLimit = 600s;
140 if (armed && (timeSpentDeadlocked >= reportingIntervalSeconds))
144 if ((timeSpentDeadlocked % reportingIntervalSeconds) == 0s)
146 if (timeSpentDeadlocked < deadlockFatalLogMessageTimeLimit)
149 <<
"Server stalled for "
150 << timeSpentDeadlocked.count() <<
" seconds.";
155 <<
"Deadlock detected. Deadlocked time: "
156 << timeSpentDeadlocked.count() <<
"s";
169 if (timeSpentDeadlocked >= deadlockLogicErrorTimeLimit)
172 <<
"LogicError: Deadlock detected. Deadlocked time: "
173 << timeSpentDeadlocked.count() <<
"s";
202 auto const duration = t - clock_type::now();
207 t = clock_type::now();
void activateDeadlockDetector()
Turn on deadlock detection.
void stopped()
Called by derived classes to indicate that the stoppable has stopped.
bool alertable_sleep_until(std::chrono::system_clock::time_point const &t)
Sleep or wake up on stop.
Json::Value getJson(int c=0)
void onStop() override
Override called when the stop notification is issued.
const beast::Journal journal_
virtual NetworkOPs & getOPs()=0
virtual LoadFeeTrack & getFeeTrack()=0
Provides an interface for starting and stopping.
~LoadManager()
Destroy the manager.
virtual void reportFeeChange()=0
virtual JobQueue & getJobQueue()=0
A generic endpoint for log messages.
void resetDeadlockDetector()
Reset the deadlock detection timer.
void onStart() override
Override called during start.
void setCurrentThreadName(std::string_view name)
Changes the name of the caller thread.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
friend std::unique_ptr< LoadManager > make_LoadManager(Application &app, Stoppable &parent, beast::Journal journal)
void LogicError(std::string const &how) noexcept
Called when faulty logic causes a broken invariant.
void onPrepare() override
Override called during preparation.
std::chrono::steady_clock::time_point deadLock_
bool isStopping() const
Returns true if the stoppable should stop.