Commit 2917542a authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Add code to the parser to populate a new virt_agents table, which

provides a mapping from an object ($cbr0) to the node on which the
agent is running ($nodeA). It also includes the type of agent
(TRAFGEN, LINK, etc). There were a number of reasons for adding this
table:

* To avoid a series of specialized table lookups in the event
  scheduler to map from a name (link0) to the node on which the agent
  is running. Previously, it was looking the delays table and the
  virt_trafgens table. Well, now it just needs to look at this one
  table and store the mapping internally. When a dynamic event comes
  in, we can figure out where to send it easily.

* For NSE traffic generation. Unlike the simple TG based CBRs, Shashi
  wants to be able to send events to any of the objects in the config
  (udp0, telnet0, ftp0, etc). Well, the virt_trafgens table certainly
  does not store that info, and it would have been painful to work
  this into it. For every agent/application, just add an entry in the
  virt_agents table and the scheduler knows where to send the events.

* It nicely supports the new program object; just plug an entry in the
  virt_agents table.

Okay, there is one messy aspect; delays nodes! Delay nodes are not
computed until after assign wrapper runs, so in addition to munging
the static event list in assign_wrapper, we now munge the virt_agents
table as well. Not much to do about this; delay nodes are handled
outside the normal path everywhere.
parent f7024783
......@@ -168,7 +168,7 @@ main(int argc, char **argv)
}
count++;
if ((count % 10) == 0)
info("Waiting for nodes in %s/%s to come up ...");
info("Waiting for nodes in %s/%s to come up ...\n");
sleep(1);
}
......@@ -355,33 +355,37 @@ get_static_events(event_handle_t handle)
/*
* Build up a table of agents that can receive dynamic events.
* Currently, these are trafgens and delay nodes. We want to
* be able to quickly map from "cbr0" to the node on which it
* lives (for dynamic events).
* These are stored in the virt_trafgens table, which we join
* with the reserved table to get the physical node name where
* the agent is running.
*
* That is, we want to be able to quickly map from "cbr0" to
* the node on which it lives (for dynamic events).
*/
res = mydb_query("select vi.vname,vi.vnode,r.node_id "
" from virt_trafgens as vi "
res = mydb_query("select vi.vname,vi.vnode,r.node_id,o.type "
" from virt_agents as vi "
"left join reserved as r on "
" r.vname=vi.vnode and r.pid=vi.pid and r.eid=vi.eid "
"where vi.role='source' and "
" vi.pid='%s' and vi.eid='%s'",
3, pid, eid);
"left join event_objecttypes as o on "
" o.idx=vi.objecttype "
"where vi.pid='%s' and vi.eid='%s'",
4, pid, eid);
if (!res) {
error("getting virt_trafgens list for %s/%s", pid, eid);
error("getting virt_agents list for %s/%s", pid, eid);
return 0;
}
nrows = mysql_num_rows(res);
while (nrows--) {
row = mysql_fetch_row(res);
if (!row[0] || !row[1] || !row[2])
if (!row[0] || !row[1] || !row[2] || !row[3])
continue;
strcpy(agents[numagents].objname, row[0]);
strcpy(agents[numagents].vnode, row[1]);
strcpy(agents[numagents].nodeid, row[2]);
strcpy(agents[numagents].objtype, TBDB_OBJECTTYPE_TRAFGEN);
strcpy(agents[numagents].objtype, row[3]);
if (! mydb_nodeidtoip(row[2], agents[numagents].ipaddr))
continue;
......@@ -389,33 +393,6 @@ get_static_events(event_handle_t handle)
}
mysql_free_result(res);
res = mydb_query("select d.vname,r.vname,d.node_id from delays as d "
"left join reserved as r on r.node_id=d.node_id "
"where d.pid='%s' and d.eid='%s'",
3, pid, eid);
if (!res) {
error("getting delays list for %s/%s", pid, eid);
return 0;
}
nrows = mysql_num_rows(res);
while (nrows--) {
row = mysql_fetch_row(res);
if (!row[0] || !row[1] || !row[2])
continue;
strcpy(agents[numagents].objname, row[0]);
strcpy(agents[numagents].vnode, row[1]);
strcpy(agents[numagents].nodeid, row[2]);
strcpy(agents[numagents].objtype, TBDB_OBJECTTYPE_LINK);
if (! mydb_nodeidtoip(row[2], agents[numagents].ipaddr))
continue;
numagents++;
}
mysql_free_result(res);
if (debug) {
for (adx = 0; adx < numagents; adx++) {
info("Agent %d: %10s %10s %10s %8s %16s\n", adx,
......
......@@ -1024,7 +1024,8 @@ foreach $vnodeport (keys(%portbw)) {
#
# Post pass the event list. At present, all LINK operations apply to
# the delay node that is in the middle of it. Rewrite the vnode in
# the event list.
# the event list. This info becomes stale when the experiment is swapped
# out, but thats okay since it gets redone at swapin.
#
$eventlist_result =
DBQueryFatal("select ex.idx,ex.vname,r.vname ".
......@@ -1040,6 +1041,25 @@ while (my ($idx,$vname,$vnode) = $eventlist_result->fetchrow_array) {
"where idx=$idx and pid='$pid' and eid='$eid'");
}
#
# Delay nodes also require that we augment the virt_agents list, since
# that holds the mapping between a link and the node where it is controlled.
# This is for the benefit of the event scheduler and dynamic events, which
# need to map a link name on the fly, instead of from the static list we
# munged above.
#
foreach $delay (keys(%delays)) {
($pnode,undef,undef,$vname) = @{$delays{$delay}};
$vnode = $p2vmap{$pnode};
DBQueryFatal("replace into virt_agents ".
" (pid, eid, vname, vnode, objecttype) ".
" select '$pid', '$eid', '$vname', '$vnode', ".
" idx from event_objecttypes where ".
" event_objecttypes.type='LINK'");
}
######################################################################
# Subroutines
######################################################################
......
......@@ -83,6 +83,8 @@ DBQueryWarn("DELETE from virt_lans where pid='$pid' and eid='$eid'") or
$errors++;
DBQueryWarn("DELETE from virt_trafgens where pid='$pid' and eid='$eid'") or
$errors++;
DBQueryWarn("DELETE from virt_agents where pid='$pid' and eid='$eid'") or
$errors++;
DBQueryWarn("DELETE from nseconfigs where pid='$pid' and eid='$eid'") or
$errors++;
DBQueryWarn("DELETE from eventlist where pid='$pid' and eid='$eid'") or
......
......@@ -66,7 +66,8 @@ sub cleanup {
DBQueryWarn("DELETE from virt_nodes where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from virt_lans where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from virt_trafgens where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from nseconfigs where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from virt_agents where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from nseconfigs where pid='$pid' and eid='$eid'");
DBQueryWarn("DELETE from eventlist where pid='$pid' and eid='$eid'");
SetExpState($pid, $eid, EXPTSTATE_NEW);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment