diff options
author | Josh Blum | 2013-03-30 01:36:48 -0500 |
---|---|---|
committer | Josh Blum | 2013-03-30 01:36:48 -0500 |
commit | 666d1f011ca7ad17ca20d649c983d93e6a63cdc3 (patch) | |
tree | c7c5dafe675a7b1dee9c80bfc82d26d242cd604d /lib | |
parent | 8fc23dc97c52747790b429dda214042746c9ff17 (diff) | |
download | sandhi-666d1f011ca7ad17ca20d649c983d93e6a63cdc3.tar.gz sandhi-666d1f011ca7ad17ca20d649c983d93e6a63cdc3.tar.bz2 sandhi-666d1f011ca7ad17ca20d649c983d93e6a63cdc3.zip |
query: filter query_stats to only blocks requested
Diffstat (limited to 'lib')
-rw-r--r-- | lib/top_block_query.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
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<std::string> 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<std::string>("")); + } + } + //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<BlockActor *>(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<BlockActor *>(worker)->highPrioPreNotify(); worker->Push(GetStatsMessage(), receiver.GetAddress()); |