Commit 53c3944c authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add completion event to pcapper SNAPSHOT so that the caller (say, loghole)

knows when the logfiles are actually rolled.

Event groups complicated things a bit. To make this work properly, we
no longer subscribe to the link-tracemon event, but instead use a
real event group, created by assign wrapper for all of the linktrace
agents. So, you can know do things like this:

	tevc -w -e testbed/TT now link0_tracemon snapshot
or
	tevc -w -e testbed/TT now __all_tracemon snapshot

where __all_tracemon is a group of all tracemon agents for all links and
lans. I plan to change loghole to use this.
parent 5c99ae51
......@@ -552,6 +552,7 @@ int sends_complete(struct agent *agent, const char *evtype)
{
static char *run_completes[] = {
TBDB_EVENTTYPE_RUN,
TBDB_EVENTTYPE_HALT,
NULL
};
......@@ -567,6 +568,11 @@ int sends_complete(struct agent *agent, const char *evtype)
NULL
};
static char *linktrace_completes[] = {
TBDB_EVENTTYPE_SNAPSHOT,
NULL
};
static char *node_completes[] = {
TBDB_EVENTTYPE_REBOOT,
TBDB_EVENTTYPE_RELOAD,
......@@ -597,7 +603,7 @@ int sends_complete(struct agent *agent, const char *evtype)
{ TBDB_OBJECTTYPE_SEQUENCE, run_completes },
{ TBDB_OBJECTTYPE_CONSOLE, NULL },
{ TBDB_OBJECTTYPE_TOPOGRAPHY, NULL },
{ TBDB_OBJECTTYPE_LINKTRACE, NULL },
{ TBDB_OBJECTTYPE_LINKTRACE, linktrace_completes },
{ TBDB_OBJECTTYPE_EVPROXY, NULL },
{ TBDB_OBJECTTYPE_BGMON, NULL },
{ NULL, NULL }
......
......@@ -2062,7 +2062,7 @@ foreach my $lan (keys(%virt_lans)) {
DBQueryFatal("insert into event_groups ".
" (pid, eid, idx, group_name, agent_name) ".
" values ('$pid', '$eid', NULL, 'all_lans', '$lan')");
" values ('$pid', '$eid', NULL, '__all_lans', '$lan')");
# An event group to hit all the links and lans in an experiment
......@@ -2081,6 +2081,16 @@ 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_tracemon', '${lan}-${vnode}-tracemon')");
DBQueryFatal("insert into event_groups ".
" (pid, eid, idx, group_name, agent_name) ".
" values ('$pid', '$eid', NULL, ".
" '${lan}_tracemon','${lan}-${vnode}-tracemon')");
}
}
......
......@@ -210,7 +210,8 @@ sub doboot()
# For the event system, listen for events to the entire link/lan,
# and for this node on the link/lan.
#
$eventargs .= " -L ${linkname}-${vnode}-tracemon,${linkname}-tracemon";
$eventargs .= " -L ${linkname}-${vnode}-tracemon";
$eventargs .= " -k " . TMEVENTKEY();
#
# User can specify a snaplen. Otherwise, If the trace type is
......
......@@ -246,6 +246,7 @@ volatile int killme = 0;
volatile int stop = 0;
volatile int reload = 0;
char *reload_tag = NULL;
unsigned int reload_token = ~0;
#ifdef EVENTSYS
/*
......@@ -258,6 +259,9 @@ struct timeval start_time;
* 1 if we're adjusting timestamps by start_time, 0 otherwise
*/
int adjust_time = 0;
/* For the subscription. */
char *pideid;
#endif
/*
......@@ -386,9 +390,10 @@ int main (int argc, char **argv) {
int tcpdump_mode;
int interface_it;
#ifdef EVENTSYS
char *exp;
char *objname;
address_tuple_t tuple;
char *keyfile = NULL;
char *objname = NULL;
event_handle_t ehandle;
#endif
#ifdef EMULAB
FILE *control_interface;
......@@ -408,18 +413,13 @@ int main (int argc, char **argv) {
event_server = NULL;
#endif
#ifdef EVENTSYS
exp = 0;
objname = 0;
#endif
tcpdump_mode = 0;
global_bpf_filter = NULL;
/*
* Process command-line arguments
*/
while ((ch = getopt(argc, argv, "f:i:e:hpnNzs:otb:Icl:L:dP:a")) != -1)
while ((ch = getopt(argc,argv, "f:i:e:hpnNzs:otb:Icl:L:dP:ak:")) != -1)
switch(ch) {
case 'd':
debug++;
......@@ -459,7 +459,7 @@ int main (int argc, char **argv) {
break;
#ifdef EVENTSYS
case 'e':
exp = optarg;
pideid = optarg;
break;
case 'a':
adjust_time = 1;
......@@ -470,6 +470,9 @@ int main (int argc, char **argv) {
case 's':
event_server = optarg;
break;
case 'k':
keyfile = optarg;
break;
#endif
case 'h':
usage(argv[0]);
......@@ -804,12 +807,11 @@ int main (int argc, char **argv) {
* Wait for time to start
*/
#ifdef EVENTSYS
if (exp) {
event_handle_t ehandle;
if (pideid) {
char server_string[1024];
pthread_mutex_lock(&lib_lock);
printf("Waiting for time start in experiment %s\n",exp);
printf("Waiting for time start in experiment %s\n", pideid);
tuple = address_tuple_alloc();
if (tuple == NULL) {
fatal("could not allocate an address tuple");
......@@ -817,7 +819,7 @@ int main (int argc, char **argv) {
tuple->host = ADDRESSTUPLE_ANY;
tuple->site = ADDRESSTUPLE_ANY;
tuple->group = ADDRESSTUPLE_ANY;
tuple->expt = exp ? exp : ADDRESSTUPLE_ANY;
tuple->expt = pideid ? pideid : ADDRESSTUPLE_ANY;
tuple->objtype = TBDB_OBJECTTYPE_TIME;
tuple->objname = ADDRESSTUPLE_ANY;
tuple->eventtype = TBDB_EVENTTYPE_START;
......@@ -829,7 +831,7 @@ int main (int argc, char **argv) {
server_string[0] = '\0';
}
ehandle = event_register(server_string,0);
ehandle = event_register_withkeyfile(server_string, 0, keyfile);
if (ehandle == NULL) {
fatal("could not register with event system");
}
......@@ -1692,14 +1694,25 @@ static void
callback(event_handle_t handle,
event_notification_t notification, void *data) {
char objtype[256], eventtype[256];
int len = 256;
char objname[TBDB_FLEN_EVOBJNAME];
char eventtype[TBDB_FLEN_EVEVENTTYPE];
char objtype[TBDB_FLEN_EVOBJTYPE];
printf("Received an event (%d)\n", getpid());
fflush(stdout);
event_notification_get_objtype(handle, notification, objtype, len);
event_notification_get_eventtype(handle, notification, eventtype, len);
event_notification_get_objtype(handle, notification,
objtype, sizeof(objtype));
event_notification_get_eventtype(handle, notification,
eventtype, sizeof(eventtype));
event_notification_get_objname(handle, notification,
objname, sizeof(objname));
event_notification_get_int32(handle, notification,
"TOKEN", (int32_t *)&reload_token);
if (!strcmp(objtype,TBDB_OBJECTTYPE_TIME) &&
!strcmp(eventtype,TBDB_EVENTTYPE_START)) {
/* OK, time has started */
......@@ -1739,8 +1752,32 @@ callback(event_handle_t handle,
reload_tag = NULL;
}
if (capture_mode) {
int rc;
pthread_mutex_lock(&lock);
stop = 1;
reload = interfaces;
while (reload)
pthread_cond_wait(&cond, &lock);
pthread_mutex_unlock(&lock);
fprintf(stderr, "sending complete %d (%d)\n",
reload_token, getpid());
fflush(stderr);
rc = event_do(handle,
EA_Experiment, pideid,
EA_Type, TBDB_OBJECTTYPE_LINKTRACE,
EA_Name, objname,
EA_Event, TBDB_EVENTTYPE_COMPLETE,
EA_ArgInteger, "ERROR", 0,
EA_ArgInteger, "CTOKEN", reload_token,
EA_TAG_DONE);
fprintf(stderr, "returned %d\n", rc);
fflush(stderr);
}
}
return;
......
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