diff options
author | Josh Blum | 2013-03-31 22:31:13 -0700 |
---|---|---|
committer | Josh Blum | 2013-03-31 22:31:13 -0700 |
commit | a6cfe0fc89473d6f39d3376147f1de1658b47c46 (patch) | |
tree | bdf6bbf333607c27456a0e6bb989283e0cad6234 /lib | |
parent | 9b96f5791d3cf743ff69be1665f6096bee683e32 (diff) | |
parent | bd00a7db0d10287b2b5d65bb9401b47108b35c10 (diff) | |
download | sandhi-a6cfe0fc89473d6f39d3376147f1de1658b47c46.tar.gz sandhi-a6cfe0fc89473d6f39d3376147f1de1658b47c46.tar.bz2 sandhi-a6cfe0fc89473d6f39d3376147f1de1658b47c46.zip |
Merge branch 'query_work'
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()); |