diff --git a/src/ripple/resource/api/Manager.h b/src/ripple/resource/api/Manager.h index beb140086..4522c5b57 100644 --- a/src/ripple/resource/api/Manager.h +++ b/src/ripple/resource/api/Manager.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_RESOURCE_MANAGER_H_INCLUDED #define RIPPLE_RESOURCE_MANAGER_H_INCLUDED +#include "beast/beast/insight/Collector.h" + namespace ripple { namespace Resource { @@ -30,9 +32,7 @@ protected: Manager (); public: - static Manager* New (Journal journal); - - virtual ~Manager() { } + virtual ~Manager() = 0; /** Create a new endpoint keyed by inbound IP address. */ virtual Consumer newInboundEndpoint (IPAddress const& address) = 0; @@ -56,6 +56,12 @@ public: virtual void importConsumers (std::string const& origin, Gossip const& gossip) = 0; }; +//------------------------------------------------------------------------------ + +std::unique_ptr make_Manager ( + insight::Collector::ptr const& collector, + Journal journal); + } } diff --git a/src/ripple/resource/impl/Logic.h b/src/ripple/resource/impl/Logic.h index 7e0ebe7a4..6783eebb3 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/src/ripple/resource/impl/Logic.h @@ -53,19 +53,34 @@ public: typedef SharedData SharedState; + struct Stats + { + Stats (insight::Collector::ptr const& collector) + { + warn = collector->make_meter ("warn"); + drop = collector->make_meter ("drop"); + } + + insight::Meter warn; + insight::Meter drop; + }; + SharedState m_state; + Stats m_stats; abstract_clock & m_clock; Journal m_journal; //-------------------------------------------------------------------------- - Logic (clock_type& clock, Journal journal) - : m_clock (clock) + Logic (insight::Collector::ptr const& collector, + clock_type& clock, Journal journal) + : m_stats (collector) + , m_clock (clock) , m_journal (journal) { } - virtual ~Logic () + ~Logic () { // These have to be cleared before the Logic is destroyed // since their destructors call back into the class. @@ -179,7 +194,8 @@ public: key.kind = kindAdmin; key.name = name; - m_journal.info << "Elevate " << prior << " to " << name; + m_journal.info << + "Elevate " << prior << " to " << name; Entry* entry (nullptr); @@ -478,6 +494,9 @@ public: m_journal.info << "Load warning: " << entry; + if (notify) + ++m_stats.warn; + return notify; } @@ -490,6 +509,8 @@ public: charge (entry, feeDrop, state); drop = true; } + if (drop) + ++m_stats.drop; return drop; } diff --git a/src/ripple/resource/impl/Manager.cpp b/src/ripple/resource/impl/Manager.cpp index 0d7fff470..3b68806da 100644 --- a/src/ripple/resource/impl/Manager.cpp +++ b/src/ripple/resource/impl/Manager.cpp @@ -17,6 +17,8 @@ */ //============================================================================== +#include "beast/beast/make_unique.h" + namespace ripple { namespace Resource { @@ -28,11 +30,13 @@ public: Journal m_journal; Logic m_logic; - ManagerImp (Journal journal) + ManagerImp (insight::Collector::ptr const& collector, + Journal journal) : Thread ("Resource::Manager") , m_journal (journal) - , m_logic (get_abstract_clock < - std::chrono::steady_clock, std::chrono::seconds> (), journal) + , m_logic (collector, + get_abstract_clock (), + journal) { startThread (); } @@ -106,11 +110,17 @@ Manager::Manager () { } +Manager::~Manager () +{ +} + //------------------------------------------------------------------------------ -Manager* Manager::New (Journal journal) +std::unique_ptr make_Manager ( + insight::Collector::ptr const& collector, + Journal journal) { - return new ManagerImp (journal); + return std::make_unique (collector, journal); } } diff --git a/src/ripple/resource/impl/Tests.cpp b/src/ripple/resource/impl/Tests.cpp index a7a1f40f8..0f7c18ae1 100644 --- a/src/ripple/resource/impl/Tests.cpp +++ b/src/ripple/resource/impl/Tests.cpp @@ -34,7 +34,7 @@ public: public: explicit TestLogic (Journal journal) - : Logic (member, journal) + : Logic (insight::NullCollector::New(), member, journal) { } diff --git a/src/ripple/resource/ripple_resource.cpp b/src/ripple/resource/ripple_resource.cpp index 62db919d2..d9a135f91 100644 --- a/src/ripple/resource/ripple_resource.cpp +++ b/src/ripple/resource/ripple_resource.cpp @@ -27,6 +27,8 @@ #include #include +#include "beast/beast/Insight.h" + #include "impl/Fees.cpp" # include "impl/Kind.h" # include "impl/Key.h" diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index 10af7d71e..085a16825 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -194,8 +194,9 @@ public: getConfig().insightSettings, LogPartition::getJournal ())) - , m_resourceManager (add (Resource::Manager::New ( - LogPartition::getJournal ()))) + , m_resourceManager (Resource::make_Manager ( + m_collectorManager->collector(), + LogPartition::getJournal ())) , m_rpcServiceManager (RPC::Manager::New ( LogPartition::getJournal ())) @@ -277,6 +278,8 @@ public: , m_probe (std::chrono::milliseconds (100), m_mainIoPool.getService()) { + add (m_resourceManager.get ()); + // // VFALCO - READ THIS! // diff --git a/src/ripple_app/main/CollectorManager.cpp b/src/ripple_app/main/CollectorManager.cpp index 57b0d0580..0d3919b3a 100644 --- a/src/ripple_app/main/CollectorManager.cpp +++ b/src/ripple_app/main/CollectorManager.cpp @@ -24,7 +24,7 @@ class CollectorManagerImp { public: Journal m_journal; - std::shared_ptr m_collector; + insight::Collector::ptr m_collector; CollectorManagerImp (StringPairArray const& params, Journal journal) @@ -50,7 +50,7 @@ public: { } - std::shared_ptr const& collector () + insight::Collector::ptr const& collector () { return m_collector; } diff --git a/src/ripple_app/main/CollectorManager.h b/src/ripple_app/main/CollectorManager.h index 9285db52f..5e215185d 100644 --- a/src/ripple_app/main/CollectorManager.h +++ b/src/ripple_app/main/CollectorManager.h @@ -31,7 +31,7 @@ public: static CollectorManager* New (StringPairArray const& params, Journal journal); virtual ~CollectorManager () = 0; - virtual std::shared_ptr const& collector () = 0; + virtual insight::Collector::ptr const& collector () = 0; }; } diff --git a/src/ripple_core/functional/JobQueue.cpp b/src/ripple_core/functional/JobQueue.cpp index 2de7c2000..bc4bf310a 100644 --- a/src/ripple_core/functional/JobQueue.cpp +++ b/src/ripple_core/functional/JobQueue.cpp @@ -74,7 +74,7 @@ public: //-------------------------------------------------------------------------- - JobQueueImp (std::shared_ptr const& collector, + JobQueueImp (insight::Collector::ptr const& collector, Stoppable& parent, Journal journal) : JobQueue ("JobQueue", parent) , m_journal (journal) @@ -743,7 +743,7 @@ JobQueue::JobQueue (char const* name, Stoppable& parent) //------------------------------------------------------------------------------ -JobQueue* JobQueue::New (std::shared_ptr const& collector, +JobQueue* JobQueue::New (insight::Collector::ptr const& collector, Stoppable& parent, Journal journal) { return new JobQueueImp (collector, parent, journal); diff --git a/src/ripple_core/functional/JobQueue.h b/src/ripple_core/functional/JobQueue.h index c320c9e60..c6a6a5b3b 100644 --- a/src/ripple_core/functional/JobQueue.h +++ b/src/ripple_core/functional/JobQueue.h @@ -26,7 +26,7 @@ protected: JobQueue (char const* name, Stoppable& parent); public: - static JobQueue* New (std::shared_ptr const& collector, + static JobQueue* New (insight::Collector::ptr const& collector, Stoppable& parent, Journal journal); virtual ~JobQueue () { }