mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add historical ledger fetches per minute to get_counts
This commit is contained in:
@@ -353,9 +353,9 @@ void InboundLedger::done ()
|
||||
{
|
||||
mLedger->setClosed ();
|
||||
mLedger->setImmutable ();
|
||||
|
||||
if (mReason != fcHISTORY)
|
||||
getApp().getLedgerMaster ().storeLedger (mLedger);
|
||||
getApp().getInboundLedgers().onLedgerFetched(mReason);
|
||||
}
|
||||
else
|
||||
getApp().getInboundLedgers ().logFailure (mHash);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <ripple/app/ledger/InboundLedgers.h>
|
||||
#include <ripple/app/main/Application.h>
|
||||
#include <ripple/app/misc/NetworkOPs.h>
|
||||
#include <ripple/basics/DecayingSample.h>
|
||||
#include <ripple/basics/Log.h>
|
||||
#include <ripple/core/JobQueue.h>
|
||||
#include <beast/cxx14/memory.h> // <memory>
|
||||
@@ -32,6 +33,11 @@ class InboundLedgersImp
|
||||
: public InboundLedgers
|
||||
, public beast::Stoppable
|
||||
{
|
||||
private:
|
||||
std::mutex fetchRateMutex_;
|
||||
// measures ledgers per second, constants are important
|
||||
DecayWindow<30, clock_type> fetchRate_;
|
||||
|
||||
public:
|
||||
typedef std::pair<uint256, InboundLedger::pointer> u256_acq_pair;
|
||||
// How long before we try again to acquire the same ledger
|
||||
@@ -40,6 +46,7 @@ public:
|
||||
InboundLedgersImp (clock_type& clock, Stoppable& parent,
|
||||
beast::insight::Collector::ptr const& collector)
|
||||
: Stoppable ("InboundLedgers", parent)
|
||||
, fetchRate_(clock.now())
|
||||
, m_clock (clock)
|
||||
, mRecentFailures ("LedgerAcquireRecentFailures",
|
||||
clock, 0, kReacquireIntervalSeconds)
|
||||
@@ -250,6 +257,24 @@ public:
|
||||
mLedgers.clear();
|
||||
}
|
||||
|
||||
std::size_t fetchRate()
|
||||
{
|
||||
std::lock_guard<
|
||||
std::mutex> lock(fetchRateMutex_);
|
||||
return 60 * fetchRate_.value(
|
||||
m_clock.now());
|
||||
}
|
||||
|
||||
void onLedgerFetched (
|
||||
InboundLedger::fcReason why)
|
||||
{
|
||||
if (why != InboundLedger::fcHISTORY)
|
||||
return;
|
||||
std::lock_guard<
|
||||
std::mutex> lock(fetchRateMutex_);
|
||||
fetchRate_.add(1, m_clock.now());
|
||||
}
|
||||
|
||||
Json::Value getInfo()
|
||||
{
|
||||
Json::Value ret(Json::objectValue);
|
||||
|
||||
@@ -71,6 +71,12 @@ public:
|
||||
|
||||
virtual Json::Value getInfo() = 0;
|
||||
|
||||
/** Returns the rate of historical ledger fetches per minute. */
|
||||
virtual std::size_t fetchRate() = 0;
|
||||
|
||||
/** Called when a complete ledger is obtained. */
|
||||
virtual void onLedgerFetched (InboundLedger::fcReason why) = 0;
|
||||
|
||||
virtual void gotFetchPack (Job&) = 0;
|
||||
virtual void sweep () = 0;
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ JSS ( Invalid ); // out: app/misc/AccountState
|
||||
JSS ( LimitAmount ); // field.
|
||||
JSS ( OfferSequence ); // field.
|
||||
JSS ( Paths ); // in/out: TransactionSign
|
||||
JSS ( historical_perminute ); // historical_perminute
|
||||
JSS ( SLE_hit_rate ); // out: GetCounts
|
||||
JSS ( SendMax ); // in: TransactionSign
|
||||
JSS ( Sequence ); // in/out: TransactionSign; field.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <BeastConfig.h>
|
||||
#include <ripple/app/data/DatabaseCon.h>
|
||||
#include <ripple/app/ledger/AcceptedLedger.h>
|
||||
#include <ripple/app/ledger/InboundLedgers.h>
|
||||
#include <ripple/basics/UptimeTimer.h>
|
||||
#include <ripple/nodestore/Database.h>
|
||||
|
||||
@@ -69,6 +70,8 @@ Json::Value doGetCounts (RPC::Context& context)
|
||||
|
||||
ret[jss::write_load] = app.getNodeStore ().getWriteLoad ();
|
||||
|
||||
ret[jss::historical_perminute] = static_cast<int>(
|
||||
app.getInboundLedgers().fetchRate());
|
||||
ret[jss::SLE_hit_rate] = app.getSLECache ().getHitRate ();
|
||||
ret[jss::node_hit_rate] = app.getNodeStore ().getCacheHitRate ();
|
||||
ret[jss::ledger_hit_rate] = app.getLedgerMaster ().getCacheHitRate ();
|
||||
|
||||
Reference in New Issue
Block a user