From 11b780bcad17e1dfe7ab4aa1f7cf43030bd9acd1 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 21 Feb 2014 20:11:13 -0500 Subject: [PATCH] Add find_create stat to InboundLedgers --- src/ripple_app/ledger/InboundLedgers.cpp | 12 +++++++++--- src/ripple_app/ledger/InboundLedgers.h | 3 ++- src/ripple_app/main/Application.cpp | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ripple_app/ledger/InboundLedgers.cpp b/src/ripple_app/ledger/InboundLedgers.cpp index 55b1f48abb3..e52f4928686 100644 --- a/src/ripple_app/ledger/InboundLedgers.cpp +++ b/src/ripple_app/ledger/InboundLedgers.cpp @@ -28,12 +28,14 @@ class InboundLedgersImp // How long before we try again to acquire the same ledger static const int kReacquireIntervalSeconds = 300; - InboundLedgersImp (clock_type& clock, Stoppable& parent) + InboundLedgersImp (clock_type& clock, Stoppable& parent, + insight::Collector::ptr const& collector) : Stoppable ("InboundLedgers", parent) , m_clock (clock) , mLock (this, "InboundLedger", __FILE__, __LINE__) , mRecentFailures ("LedgerAcquireRecentFailures", clock, 0, kReacquireIntervalSeconds) + , mCounter(collector->make_counter("ledger_fetches")) { } @@ -61,6 +63,7 @@ class InboundLedgersImp assert (ret); mLedgers.insert (std::make_pair (hash, ret)); ret->init (sl, couldBeNew); + ++mCounter; } } } @@ -396,6 +399,8 @@ class InboundLedgersImp uint256 mConsensusLedger; uint256 mValidationLedger; + + beast::insight::Counter mCounter; }; //------------------------------------------------------------------------------ @@ -404,9 +409,10 @@ InboundLedgers::~InboundLedgers() { } -InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent) +InboundLedgers* InboundLedgers::New (clock_type& clock, Stoppable& parent, + insight::Collector::ptr const& collector) { - return new InboundLedgersImp (clock, parent); + return new InboundLedgersImp (clock, parent, collector); } diff --git a/src/ripple_app/ledger/InboundLedgers.h b/src/ripple_app/ledger/InboundLedgers.h index a66b3b3b301..cd841d21acf 100644 --- a/src/ripple_app/ledger/InboundLedgers.h +++ b/src/ripple_app/ledger/InboundLedgers.h @@ -34,7 +34,8 @@ class InboundLedgers // VFALCO TODO Make this a free function outside the class: // std::unique_ptr make_InboundLedgers (...) // - static InboundLedgers* New (clock_type& clock, Stoppable& parent); + static InboundLedgers* New (clock_type& clock, Stoppable& parent, + insight::Collector::ptr const& collector); // VFALCO TODO Should this be called findOrAdd ? // diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index 204e9b55ee5..ff89603a0a5 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -264,7 +264,8 @@ class ApplicationImp // VFALCO NOTE must come before NetworkOPs to prevent a crash due // to dependencies in the destructor. // - , m_inboundLedgers (InboundLedgers::New (get_seconds_clock (), *m_jobQueue)) + , m_inboundLedgers (InboundLedgers::New (get_seconds_clock (), *m_jobQueue, + m_collectorManager->collector ())) // VFALCO NOTE Does NetworkOPs depend on LedgerMaster? , m_networkOPs (NetworkOPs::New (get_seconds_clock (), *m_ledgerMaster,