Commit 22ea472e authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Minor stats collection change; move the code for gathering assign

generated stats into libdb along with other stats code. Cleaner.
I am committing this now so I can install my own assign_wrapper and
have it work against the DB on boss (my tree is heavily stats hacked).
parent e55e2479
......@@ -140,7 +140,7 @@ use Exporter;
TBSiteVarExists TBGetSiteVar
TBActivityReport GatherSwapStats
TBActivityReport GatherSwapStats GatherAssignStats
);
# Must come after package declaration!
......@@ -3184,6 +3184,42 @@ sub GatherSwapStats($$$$$;$)
"values (0, now(), $idx, '$mode', $ecode)");
}
#
# Gather Assign stats. Its expected that the hash that comes in
# will reflect the slot names in the DB.
#
# usage: GatherAssignStats(char *pid, char *eid,
# char *mode, int code, int flags)
# Mode is one of preload, start, in, out, modify, end.
#
sub GatherAssignStats($$%)
{
my ($pid, $eid, %stats) = @_;
my @updates = ();
local $DBQUERY_MAXTRIES = 5;
#
# Need the exptidx for the insert.
#
my $result =
DBQueryFatal("select idx from experiments ".
"where pid='$pid' and eid='$eid'");
my ($idx) = $result->fetchrow_array;
if (defined($idx) && $idx) {
foreach my $key (keys(%stats)) {
$val = $stats{$key};
push (@updates, "$key=$val");
}
DBQueryFatal("update experiment_stats ".
"set " . join(",", @updates) . " ".
"where pid='$pid' and eid='$eid' and idx=$idx");
}
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......
......@@ -2636,25 +2636,5 @@ sub UploadVlans()
#
sub UploadStats()
{
my @updates = ();
#
# Need the exptidx for the insert.
#
my $result =
DBQueryFatal("select idx from experiments ".
"where pid='$pid' and eid='$eid'");
my ($idx) = $result->fetchrow_array;
if (defined($idx) && $idx) {
foreach my $key (keys(%expt_stats)) {
$val = $expt_stats{$key};
push (@updates, "$key=$val");
}
DBQueryFatal("update experiment_stats ".
"set " . join(",", @updates) . " ".
"where pid='$pid' and eid='$eid' and idx=$idx");
}
GatherAssignStats($pid, $eid, %expt_stats);
}
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