summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2013-03-28 22:02:41 -0500
committerJosh Blum2013-03-28 22:02:41 -0500
commitfd5e1bdc2331f4dd8dc5a07d4b0b9a568fa8d8ff (patch)
tree1f96b262e95f9b4af2ac411111ff1e9a4fcf7252 /lib
parentd00575db6dbe8ec4a0df411a8bfe18922138db6e (diff)
downloadsandhi-fd5e1bdc2331f4dd8dc5a07d4b0b9a568fa8d8ff.tar.gz
sandhi-fd5e1bdc2331f4dd8dc5a07d4b0b9a568fa8d8ff.tar.bz2
sandhi-fd5e1bdc2331f4dd8dc5a07d4b0b9a568fa8d8ff.zip
gras: work on passing only active blocks into the request
Diffstat (limited to 'lib')
-rw-r--r--lib/top_block_query.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp
index 4333b63..beec598 100644
--- a/lib/top_block_query.cpp
+++ b/lib/top_block_query.cpp
@@ -7,6 +7,7 @@
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/regex.hpp>
+#include <algorithm>
#include <sstream>
using namespace gras;
@@ -37,7 +38,7 @@ static std::string my_write_json(const boost::property_tree::ptree &pt)
return rv;
}
-static std::string query_blocks(ElementImpl *self)
+static std::string query_blocks(ElementImpl *self, const boost::property_tree::ptree &)
{
boost::property_tree::ptree root;
boost::property_tree::ptree e;
@@ -51,13 +52,14 @@ static std::string query_blocks(ElementImpl *self)
return my_write_json(root);
}
-static std::string query_stats(ElementImpl *self)
+static std::string query_stats(ElementImpl *self, const boost::property_tree::ptree &)
{
//get stats with custom receiver and set high prio
GetStatsReceiver receiver;
size_t outstandingCount(0);
BOOST_FOREACH(Apology::Worker *worker, self->executor->get_workers())
{
+ //send a message to the block's actor to query stats
dynamic_cast<BlockActor *>(worker)->highPrioPreNotify();
worker->Push(GetStatsMessage(), receiver.GetAddress());
outstandingCount++;
@@ -119,7 +121,7 @@ std::string TopBlock::query(const std::string &args)
//dispatch based on path arg
std::string path = query_args_pt.get<std::string>("args.path");
- if (path == "/blocks.json") return query_blocks(this->get());
- if (path == "/stats.json") return query_stats(this->get());
+ if (path == "/blocks.json") return query_blocks(this->get(), query_args_pt);
+ if (path == "/stats.json") return query_stats(this->get(), query_args_pt);
return "";
}