mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Insight support for ResourceManager
This commit is contained in:
@@ -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 <Manager> make_Manager (
|
||||
insight::Collector::ptr const& collector,
|
||||
Journal journal);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
public:
|
||||
explicit TestLogic (Journal journal)
|
||||
: Logic (member, journal)
|
||||
: Logic (insight::NullCollector::New(), member, journal)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <boost/utility/base_from_member.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
#include "beast/beast/Insight.h"
|
||||
|
||||
#include "impl/Fees.cpp"
|
||||
# include "impl/Kind.h"
|
||||
# include "impl/Key.h"
|
||||
|
||||
@@ -194,8 +194,9 @@ public:
|
||||
getConfig().insightSettings,
|
||||
LogPartition::getJournal <CollectorManager> ()))
|
||||
|
||||
, m_resourceManager (add (Resource::Manager::New (
|
||||
LogPartition::getJournal <ResourceManagerLog> ())))
|
||||
, m_resourceManager (Resource::make_Manager (
|
||||
m_collectorManager->collector(),
|
||||
LogPartition::getJournal <ResourceManagerLog> ()))
|
||||
|
||||
, m_rpcServiceManager (RPC::Manager::New (
|
||||
LogPartition::getJournal <RPCServiceManagerLog> ()))
|
||||
@@ -277,6 +278,8 @@ public:
|
||||
|
||||
, m_probe (std::chrono::milliseconds (100), m_mainIoPool.getService())
|
||||
{
|
||||
add (m_resourceManager.get ());
|
||||
|
||||
//
|
||||
// VFALCO - READ THIS!
|
||||
//
|
||||
|
||||
@@ -24,7 +24,7 @@ class CollectorManagerImp
|
||||
{
|
||||
public:
|
||||
Journal m_journal;
|
||||
std::shared_ptr <insight::Collector> m_collector;
|
||||
insight::Collector::ptr m_collector;
|
||||
|
||||
CollectorManagerImp (StringPairArray const& params,
|
||||
Journal journal)
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr <insight::Collector> const& collector ()
|
||||
insight::Collector::ptr const& collector ()
|
||||
{
|
||||
return m_collector;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
static CollectorManager* New (StringPairArray const& params,
|
||||
Journal journal);
|
||||
virtual ~CollectorManager () = 0;
|
||||
virtual std::shared_ptr <insight::Collector> const& collector () = 0;
|
||||
virtual insight::Collector::ptr const& collector () = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
JobQueueImp (std::shared_ptr <insight::Collector> 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 <insight::Collector> const& collector,
|
||||
JobQueue* JobQueue::New (insight::Collector::ptr const& collector,
|
||||
Stoppable& parent, Journal journal)
|
||||
{
|
||||
return new JobQueueImp (collector, parent, journal);
|
||||
|
||||
@@ -26,7 +26,7 @@ protected:
|
||||
JobQueue (char const* name, Stoppable& parent);
|
||||
|
||||
public:
|
||||
static JobQueue* New (std::shared_ptr <insight::Collector> const& collector,
|
||||
static JobQueue* New (insight::Collector::ptr const& collector,
|
||||
Stoppable& parent, Journal journal);
|
||||
|
||||
virtual ~JobQueue () { }
|
||||
|
||||
Reference in New Issue
Block a user