mirror of
https://github.com/XRPLF/clio.git
synced 2025-12-06 17:27:58 +00:00
Add time/uptime/amendment_blocked to server_info (#775)
This commit is contained in:
@@ -79,8 +79,7 @@ ETLService::monitor()
|
||||
auto rng = backend_->hardFetchLedgerRangeNoThrow();
|
||||
if (!rng)
|
||||
{
|
||||
log_.info() << "Database is empty. Will download a ledger "
|
||||
"from the network.";
|
||||
log_.info() << "Database is empty. Will download a ledger from the network.";
|
||||
std::optional<ripple::LedgerInfo> ledger;
|
||||
|
||||
try
|
||||
@@ -98,23 +97,22 @@ ETLService::monitor()
|
||||
|
||||
if (mostRecentValidated)
|
||||
{
|
||||
log_.info() << "Ledger " << *mostRecentValidated << " has been validated. "
|
||||
<< "Downloading...";
|
||||
log_.info() << "Ledger " << *mostRecentValidated << " has been validated. Downloading...";
|
||||
ledger = ledgerLoader_.loadInitialLedger(*mostRecentValidated);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_.info() << "The wait for the next validated "
|
||||
<< "ledger has been aborted. "
|
||||
<< "Exiting monitor loop";
|
||||
log_.info() << "The wait for the next validated ledger has been aborted. Exiting monitor loop";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error const& e)
|
||||
{
|
||||
setAmendmentBlocked();
|
||||
|
||||
log_.fatal()
|
||||
<< "Failed to load initial ledger, Exiting monitor loop : " << e.what()
|
||||
<< "Failed to load initial ledger, Exiting monitor loop: " << e.what()
|
||||
<< " Possible cause: The ETL node is not compatible with the version of the rippled lib Clio is using.";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,6 +152,17 @@ public:
|
||||
return ledgerPublisher_.lastCloseAgeSeconds();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check for the amendment blocked state.
|
||||
*
|
||||
* @return true if currently amendment blocked; false otherwise
|
||||
*/
|
||||
bool
|
||||
isAmendmentBlocked() const
|
||||
{
|
||||
return state_.isAmendmentBlocked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get state of ETL as a JSON object
|
||||
*/
|
||||
@@ -236,4 +247,13 @@ private:
|
||||
*/
|
||||
void
|
||||
doWork();
|
||||
|
||||
/**
|
||||
* @brief Sets amendment blocked flag
|
||||
*/
|
||||
void
|
||||
setAmendmentBlocked()
|
||||
{
|
||||
state_.isAmendmentBlocked = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,4 +47,9 @@ struct SystemState
|
||||
* @brief Whether a write conflict was detected
|
||||
*/
|
||||
std::atomic_bool writeConflict = false;
|
||||
|
||||
/**
|
||||
* @brief Whether we detected an amendment block
|
||||
*/
|
||||
std::atomic_bool isAmendmentBlocked = false;
|
||||
};
|
||||
|
||||
@@ -186,8 +186,10 @@ private:
|
||||
}
|
||||
catch (std::runtime_error const& e)
|
||||
{
|
||||
setAmendmentBlocked();
|
||||
|
||||
log_.fatal()
|
||||
<< "Failed to build next ledger : " << e.what()
|
||||
<< "Failed to build next ledger: " << e.what()
|
||||
<< " Possible cause: The ETL node is not compatible with the version of the rippled lib Clio is using.";
|
||||
return {ripple::LedgerInfo{}, false};
|
||||
}
|
||||
@@ -414,6 +416,12 @@ private:
|
||||
{
|
||||
state_.get().writeConflict = conflict;
|
||||
}
|
||||
|
||||
void
|
||||
setAmendmentBlocked()
|
||||
{
|
||||
state_.get().isAmendmentBlocked = true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace clio::detail
|
||||
|
||||
@@ -97,6 +97,12 @@ Counters::onInternalError()
|
||||
++internalErrorCounter_;
|
||||
}
|
||||
|
||||
std::chrono::seconds
|
||||
Counters::uptime() const
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - startupTime_);
|
||||
}
|
||||
|
||||
boost::json::object
|
||||
Counters::report() const
|
||||
{
|
||||
|
||||
@@ -54,9 +54,10 @@ class Counters
|
||||
std::atomic_uint64_t internalErrorCounter_;
|
||||
|
||||
std::reference_wrapper<const WorkQueue> workQueue_;
|
||||
std::chrono::time_point<std::chrono::system_clock> startupTime_;
|
||||
|
||||
public:
|
||||
Counters(WorkQueue const& wq) : workQueue_(std::cref(wq)){};
|
||||
Counters(WorkQueue const& wq) : workQueue_(std::cref(wq)), startupTime_{std::chrono::system_clock::now()} {};
|
||||
|
||||
static Counters
|
||||
make_Counters(WorkQueue const& wq)
|
||||
@@ -94,6 +95,9 @@ public:
|
||||
void
|
||||
onInternalError();
|
||||
|
||||
std::chrono::seconds
|
||||
uptime() const;
|
||||
|
||||
boost::json::object
|
||||
report() const;
|
||||
};
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <rpc/common/Types.h>
|
||||
#include <rpc/common/Validators.h>
|
||||
|
||||
#include <ripple/basics/chrono.h>
|
||||
|
||||
#include <chrono>
|
||||
#include <fmt/core.h>
|
||||
|
||||
class SubscriptionManager;
|
||||
@@ -78,10 +81,13 @@ public:
|
||||
std::optional<AdminSection> adminSection = std::nullopt;
|
||||
std::string completeLedgers = {};
|
||||
uint32_t loadFactor = 1u;
|
||||
std::chrono::time_point<std::chrono::system_clock> time = std::chrono::system_clock::now();
|
||||
std::chrono::seconds uptime = {};
|
||||
std::string clioVersion = Build::getClioVersionString();
|
||||
std::optional<boost::json::object> rippledInfo = std::nullopt;
|
||||
ValidatedLedgerSection validatedLedger = {};
|
||||
CacheSection cache = {};
|
||||
bool isAmendmentBlocked = false;
|
||||
};
|
||||
|
||||
struct Output
|
||||
@@ -155,6 +161,8 @@ public:
|
||||
output.info.cache.latestLedgerSeq = backend_->cache().latestLedgerSequence();
|
||||
output.info.cache.objectHitRate = backend_->cache().getObjectHitRate();
|
||||
output.info.cache.successorHitRate = backend_->cache().getSuccessorHitRate();
|
||||
output.info.uptime = counters_.get().uptime();
|
||||
output.info.isAmendmentBlocked = etl_->isAmendmentBlocked();
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -172,14 +180,21 @@ private:
|
||||
friend void
|
||||
tag_invoke(boost::json::value_from_tag, boost::json::value& jv, InfoSection const& info)
|
||||
{
|
||||
using ripple::to_string;
|
||||
|
||||
jv = {
|
||||
{JS(complete_ledgers), info.completeLedgers},
|
||||
{JS(load_factor), info.loadFactor},
|
||||
{JS(time), to_string(std::chrono::floor<std::chrono::microseconds>(info.time))},
|
||||
{JS(uptime), info.uptime.count()},
|
||||
{"clio_version", info.clioVersion},
|
||||
{JS(validated_ledger), info.validatedLedger},
|
||||
{"cache", info.cache},
|
||||
};
|
||||
|
||||
if (info.isAmendmentBlocked)
|
||||
jv.as_object()[JS(amendment_blocked)] = true;
|
||||
|
||||
if (info.rippledInfo)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user