Insight support for ResourceManager

This commit is contained in:
Vinnie Falco
2014-01-21 09:35:20 -05:00
parent c95dccfec6
commit 65ffdff40c
10 changed files with 63 additions and 21 deletions

View File

@@ -53,19 +53,34 @@ public:
typedef SharedData <State> 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 <std::chrono::seconds>& 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;
}

View File

@@ -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 <std::chrono::steady_clock, std::chrono::seconds> (),
journal)
{
startThread ();
}
@@ -106,11 +110,17 @@ Manager::Manager ()
{
}
Manager::~Manager ()
{
}
//------------------------------------------------------------------------------
Manager* Manager::New (Journal journal)
std::unique_ptr <Manager> make_Manager (
insight::Collector::ptr const& collector,
Journal journal)
{
return new ManagerImp (journal);
return std::make_unique <ManagerImp> (collector, journal);
}
}

View File

@@ -34,7 +34,7 @@ public:
public:
explicit TestLogic (Journal journal)
: Logic (member, journal)
: Logic (insight::NullCollector::New(), member, journal)
{
}