From 8dfe53ff7a96668fd3818a16eb04c7a9d6c6883d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 6 Oct 2013 16:11:22 -0700 Subject: [PATCH] More PropertyStream output for PeerFinder --- src/beast/beast/utility/PropertyStream.h | 2 +- src/ripple/peerfinder/impl/Cache.h | 5 +++++ src/ripple/peerfinder/impl/LegacyEndpointCache.h | 5 +++++ src/ripple/peerfinder/impl/Manager.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/beast/beast/utility/PropertyStream.h b/src/beast/beast/utility/PropertyStream.h index a8fb8956c..d5181ff2b 100644 --- a/src/beast/beast/utility/PropertyStream.h +++ b/src/beast/beast/utility/PropertyStream.h @@ -142,7 +142,7 @@ public: template PropertyStream const& operator<< (Value value) const - { append (value); return &this; } + { append (value); return *this; } /** @} */ private: diff --git a/src/ripple/peerfinder/impl/Cache.h b/src/ripple/peerfinder/impl/Cache.h index aee3ca624..7357469cd 100644 --- a/src/ripple/peerfinder/impl/Cache.h +++ b/src/ripple/peerfinder/impl/Cache.h @@ -61,6 +61,11 @@ public: { } + std::size_t size() const + { + return m_now.size() + m_prev.size(); + } + // Cycle the tables void cycle() { diff --git a/src/ripple/peerfinder/impl/LegacyEndpointCache.h b/src/ripple/peerfinder/impl/LegacyEndpointCache.h index 8c7bc8779..5b9139b76 100644 --- a/src/ripple/peerfinder/impl/LegacyEndpointCache.h +++ b/src/ripple/peerfinder/impl/LegacyEndpointCache.h @@ -158,6 +158,11 @@ public: { } + std::size_t size() const + { + return m_map.size(); + } + /** Load the legacy endpoints cache from the database. */ void load () { diff --git a/src/ripple/peerfinder/impl/Manager.cpp b/src/ripple/peerfinder/impl/Manager.cpp index dd76d85cd..7cf909ce7 100644 --- a/src/ripple/peerfinder/impl/Manager.cpp +++ b/src/ripple/peerfinder/impl/Manager.cpp @@ -297,6 +297,8 @@ public: void onWrite (PropertyStream stream) { + // VFALCO NOTE this is not thread safe (yet) + stream ["peers"] = m_logic.m_slots.peerCount; stream ["in"] = m_logic.m_slots.inboundCount; stream ["out"] = m_logic.m_slots.outboundCount; @@ -305,6 +307,8 @@ public: stream ["in_max"] = m_logic.m_slots.inboundSlotsMaximum; stream ["minutes"] = m_logic.m_slots.uptimeMinutes(); stream ["round"] = m_logic.m_slots.roundUpwards(); + stream ["cache"] = uint32(m_logic.m_cache.size()); + stream ["legacy"] = uint32(m_logic.m_legacyCache.size()); } //-------------------------------------------------------------------------- @@ -375,8 +379,8 @@ public: //------------------------------------------------------------------------------ Manager::Manager (Stoppable& parent) - : PropertyStream::Source ("peerfinder") - , Stoppable ("PeerFinder", parent) + : Stoppable ("PeerFinder", parent) + , PropertyStream::Source ("peerfinder") { }