summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2013-09-15 23:18:24 -0700
committerJosh Blum2013-09-15 23:18:24 -0700
commitdda8032dfb75b61256144e3f90701925f52c0fc2 (patch)
tree03967637a96ef788fa3614916e8cb4c8afbd0ec8 /lib
parent4f50f9d0c52b1efd09d1f7ed7aadbfef94949eb2 (diff)
downloadsandhi-dda8032dfb75b61256144e3f90701925f52c0fc2.tar.gz
sandhi-dda8032dfb75b61256144e3f90701925f52c0fc2.tar.bz2
sandhi-dda8032dfb75b61256144e3f90701925f52c0fc2.zip
gras: added topology display to the webgui
Diffstat (limited to 'lib')
-rw-r--r--lib/top_block_query.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/top_block_query.cpp b/lib/top_block_query.cpp
index 68a56ef..56b39ae 100644
--- a/lib/top_block_query.cpp
+++ b/lib/top_block_query.cpp
@@ -184,14 +184,31 @@ static ptree query_calls(ElementImpl *self, const ptree &query)
static std::string query_topology(ElementImpl *self, const ptree &query)
{
+ //parse list of block ids needed in this query
+ std::vector<std::string> block_ids;
+ if (query.count("blocks") != 0)
+ {
+ BOOST_FOREACH(const ptree::value_type &v, query.get_child("blocks"))
+ {
+ block_ids.push_back(v.second.get_value<std::string>());
+ }
+ }
+
std::string buff;
buff += "digraph flat_flows {\n";
buff += "rankdir=LR;\n";
buff += "node [shape=record, fontsize=10];\n";
+ std::vector<long long> worker_ids_mentioned;
BOOST_FOREACH(Apology::Worker *w, self->topology->get_workers())
{
BlockActor *actor = dynamic_cast<BlockActor *>(w->get_actor());
+
+ //filter workers not needed in query, empty block list means all blocks
+ const std::string id = actor->data->block->get_uid();
+ if (not block_ids.empty() and std::find(block_ids.begin(), block_ids.end(), id) == block_ids.end()) continue;
+ worker_ids_mentioned.push_back(actor->GetAddress().AsInteger());
+
std::string in_ports_str, out_ports_str;
const bool done = actor->data->block_state == BLOCK_STATE_DONE;
for (size_t i = 0; i < w->get_num_inputs(); i++)
@@ -224,10 +241,17 @@ static std::string query_topology(ElementImpl *self, const ptree &query)
BOOST_FOREACH(const Apology::Flow &flow, self->topology->get_flat_flows())
{
+ //filter out flows that do not have mentioned workers
+ const long long src_id = dynamic_cast<const Apology::Worker *>(flow.src.elem)->get_actor()->GetAddress().AsInteger();
+ const long long dst_id = dynamic_cast<const Apology::Worker *>(flow.dst.elem)->get_actor()->GetAddress().AsInteger();
+ if (std::find(worker_ids_mentioned.begin(), worker_ids_mentioned.end(), src_id) == worker_ids_mentioned.end()) continue;
+ if (std::find(worker_ids_mentioned.begin(), worker_ids_mentioned.end(), dst_id) == worker_ids_mentioned.end()) continue;
+
+ //create a dot connection for the flow
buff += str(boost::format("%u:out%u -> %u:in%u;\n")
- % dynamic_cast<const Apology::Worker *>(flow.src.elem)->get_actor()->GetAddress().AsInteger()
+ % src_id
% flow.src.index
- % dynamic_cast<const Apology::Worker *>(flow.dst.elem)->get_actor()->GetAddress().AsInteger()
+ % dst_id
% flow.dst.index
);
}