From 666d1f011ca7ad17ca20d649c983d93e6a63cdc3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 30 Mar 2013 01:36:48 -0500 Subject: query: filter query_stats to only blocks requested --- lib/top_block_query.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp index f00efd2..96e2847 100644 --- a/lib/top_block_query.cpp +++ b/lib/top_block_query.cpp @@ -52,13 +52,28 @@ static std::string query_blocks(ElementImpl *self, const boost::property_tree::p return my_write_json(root); } -static std::string query_stats(ElementImpl *self, const boost::property_tree::ptree &) +static std::string query_stats(ElementImpl *self, const boost::property_tree::ptree &query) { + + //parse list of block ids needed in this query + std::vector block_ids; + BOOST_FOREACH(const boost::property_tree::ptree::value_type &v, query.get_child("args")) + { + if (v.first.data() == std::string("block")) + { + block_ids.push_back(v.second.get("")); + } + } + //get stats with custom receiver and set high prio GetStatsReceiver receiver; size_t outstandingCount(0); BOOST_FOREACH(Apology::Worker *worker, self->executor->get_workers()) { + //filter workers not needed in query + const std::string id = dynamic_cast(worker)->block_ptr->to_string(); + if (std::find(block_ids.begin(), block_ids.end(), id) == block_ids.end()) continue; + //send a message to the block's actor to query stats dynamic_cast(worker)->highPrioPreNotify(); worker->Push(GetStatsMessage(), receiver.GetAddress()); -- cgit