summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/top_block_query.cpp10
-rw-r--r--python/gras/query/chart_factory.js14
-rw-r--r--python/gras/query/main.js2
3 files changed, 22 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 "";
}
diff --git a/python/gras/query/chart_factory.js b/python/gras/query/chart_factory.js
index 3cce4d6..bd51c53 100644
--- a/python/gras/query/chart_factory.js
+++ b/python/gras/query/chart_factory.js
@@ -12,6 +12,20 @@ var gras_chart_get_registry = function()
}
/***********************************************************************
+ * get blocks that need active querying
+ **********************************************************************/
+function gras_chart_factory_active_blocks(registry)
+{
+ if (!('active_charts' in registry)) return "";
+ var block_ids = new Array();
+ $.each(registry.active_charts, function(index, chart_info)
+ {
+ $.merge(block_ids, chart_info.args.block_ids);
+ });
+ return $.unique(block_ids);
+}
+
+/***********************************************************************
* update after new query event
**********************************************************************/
function gras_chart_factory_update(registry, point)
diff --git a/python/gras/query/main.js b/python/gras/query/main.js
index 8255f97..ff05b15 100644
--- a/python/gras/query/main.js
+++ b/python/gras/query/main.js
@@ -26,6 +26,8 @@ var gras_query_stats = function(registry)
async: true,
url: "/stats.json",
dataType: "json",
+ traditional: true, //needed to parse data
+ data: {block:gras_chart_factory_active_blocks(registry)},
success: function(response)
{
registry.online = true;