Commit d4881005 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Okay, this is a nasty little hack ... Add support for a global delays

reset. I've done this with an event group cause otherwise I was going
to get sucked into the event system and spit out the other end. You can
reset the delays in your experiment either from the ns file:

	$ns at 100 "$ns reset-lans"

or from the command line:

	tevc -e foo/bar now all_lans reset

and yes, "all_lans" is a magic token.

It would be nice to support per-link or lan reset, but that is going
to require reorganizing the delay start up scripts on the delay nodes,
since right now a single delay agent operates for muliple links and lans.
parent 59ba782a
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2004 University of Utah and the Flux Group.
* Copyright (c) 2000-2004, 2006 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -53,19 +53,15 @@ char *myexp = NULL;
/* The list of linknames in tuple format, for the event subscription */
char myobjects[1024];
char lanobjects[1024];
int debug = 0;
char buf_link [MAX_LINKS][MAX_LINE_LENGTH];
/************************GLOBALS*****************************************/
/************************** FUNCTION DEFS *******************************/
/************************* main **************************************
************************* main **************************************/
void reset_callback(event_handle_t handle,
event_notification_t notification, void *data);
char *myvnode;
int main(int argc, char **argv)
{
......@@ -87,7 +83,7 @@ int main(int argc, char **argv)
opterr = 0;
/* get params from the optstring */
while ((c = getopt(argc, argv, "s:p:f:dE:l:i:k:")) != -1) {
while ((c = getopt(argc, argv, "s:p:f:dE:l:i:k:j")) != -1) {
switch (c) {
case 'd':
debug++;
......@@ -113,6 +109,9 @@ int main(int argc, char **argv)
case 'k':
keyfile = optarg;
break;
case 'j':
myvnode = optarg;
break;
case '?':
default:
usage(argv[0]);
......@@ -192,11 +191,16 @@ int main(int argc, char **argv)
/* Do not have name yet, so add it to the string */
if (strlen(myobjects)) {
strcat(myobjects, ",");
strcat(lanobjects, ",");
}
sprintf(&myobjects[strlen(myobjects)], "%s,%s",
link_map[link_index].linkname,
link_map[link_index].linkvnodes[0]);
/* For the reset event below */
sprintf(&lanobjects[strlen(lanobjects)], "%s",
link_map[link_index].linkname);
if(!strcmp(link_map[link_index].linktype,"duplex") &&
!link_map[link_index].islan) {
sprintf(&myobjects[strlen(myobjects)], ",%s",
......@@ -297,6 +301,19 @@ int main(int argc, char **argv)
return 1;
}
strcat(lanobjects, ",");
strcat(lanobjects, ADDRESSTUPLE_ALL);
event_t->objname = lanobjects;
event_t->objtype = TBDB_OBJECTTYPE_LINK;
event_t->eventtype = TBDB_EVENTTYPE_RESET;
event_t->host = ADDRESSTUPLE_ANY;
event_t->expt = myexp;
if (event_subscribe(handle, reset_callback, event_t, NULL) == NULL) {
error("could not subscribe to %d event\n",event_t->eventtype);
return 1;
}
info("subscribed...\n");
/* free the memory for the address tuple*/
address_tuple_free(event_t);
......@@ -342,7 +359,8 @@ void fill_tuple(address_tuple_t at)
/* fill the objectname, objecttype and the eventtype from the file*/
at->objname = myobjects;
at->objtype = TBDB_OBJECTTYPE_LINK;
at->eventtype = ADDRESSTUPLE_ANY;
at->eventtype = TBDB_EVENTTYPE_UP ","
TBDB_EVENTTYPE_DOWN "," TBDB_EVENTTYPE_MODIFY;
at->expt = myexp;
at->host = ADDRESSTUPLE_ANY;
......@@ -403,3 +421,24 @@ void dump_link_map(){
}
}
/************************** FUNCTION DEFS *******************************/
void
reset_callback(event_handle_t handle,
event_notification_t notification, void *data)
{
char buf1[BUFSIZ], buf2[BUFSIZ];
char *prog = "delaysetup";
info("Got a RESET event!\n");
if (myvnode) {
sprintf(buf1, "%s -u -j %s", prog, myvnode);
sprintf(buf2, "%s -i -j %s", prog, myvnode);
}
else {
sprintf(buf1, "%s -u", prog);
sprintf(buf2, "%s -i", prog);
}
system(buf1);
system(buf2);
}
......@@ -2058,6 +2058,12 @@ foreach my $lan (keys(%virt_lans)) {
" idx from event_objecttypes where ".
" event_objecttypes.type='LINKTRACE'");
DBQueryFatal("insert into event_groups ".
" (pid, eid, idx, group_name, agent_name) ".
" values ('$pid', '$eid', NULL, 'all_lans', '$lan')");
# An event group to hit all the links and lans in an experiment
foreach my $member (virtlanmembers($lan)) {
my ($vnode) = split(":", $member);
......
......@@ -1681,6 +1681,12 @@ Simulator instproc make_event {outer event} {
}
set args "STARTAT=1 STOPAT=$(-stopat)"
}
"reset-lans" {
set otype LINK
set vname "all_lans"
set vnode "*"
set etype RESET
}
unknown {
punsup "$obj $cmd $evargs"
return
......
#!/usr/bin/perl -w
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# Copyright (c) 2000-2006 University of Utah and the Flux Group.
# All rights reserved.
#
use English;
......@@ -52,10 +52,12 @@ my $MAPFILE = TMDELMAP();
my $KEYFILE = TMEVENTKEY();
my $logfile;
my $pidfile;
my $vnodearg = "";
if (defined($vnodeid)) {
$logfile = CONFDIR() . "/delayagent.debug";
$pidfile = CONFDIR() . "/delayagent.pid";
$vnodearg = "-j $vnodeid";
}
else {
$logfile = "$LOGDIR/delayagent.debug";
......@@ -92,6 +94,6 @@ my ($pid, $eid, $vname) = check_nickname();
#
my $elvind = "localhost";
system("delay-agent -s $elvind -E $pid/$eid ".
system("delay-agent -s $elvind -E $pid/$eid $vnodearg ".
"-f $MAPFILE -l $logfile -i $pidfile -k $KEYFILE &");
exit($? >> 0);
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