Commit 6587659d authored by Leigh B. Stoller's avatar Leigh B. Stoller

Check in more of the replay support. There is a new button in the

template record to replay an instance, but all it really does is
replay the first run. There is also support to replay a specific run
in an instance, but that is not hooked up to the web page yet.

Note that the bulk of the replay code went in by mistake a couple of
days ago.
parent d56273d8
......@@ -1013,9 +1013,9 @@ sub CleanLogFiles($)
#
# Copy log files to user visible space. Maybe not such a good idea anymore?
#
sub CopyLogFiles($)
sub CopyLogFiles($;@)
{
my ($self) = @_;
my ($self, @files) = @_;
# Must be a real reference.
return -1
......@@ -1026,9 +1026,15 @@ sub CopyLogFiles($)
my $workdir = $self->WorkDir();
my $userdir = $self->UserDir();
# Specific files, then return.
if (@files) {
mysystem("/bin/cp -fp @files $userdir/tbdata");
return 0;
}
opendir(DIR, $workdir) or
return -1;
my @files = readdir(DIR);
@files = readdir(DIR);
closedir(DIR);
my @copy = ();
......
......@@ -211,7 +211,7 @@ if (defined($replay_exptidx)) {
#
# XXX Need to convert these other routines to return Run objects
my $row = $replay_instance->FirstRun();
if (defined($row)) {
if (!defined($row)) {
tbdie("Could not find first run for $replay_instance!");
}
$replay_runidx = $row->{'idx'};
......@@ -299,7 +299,9 @@ if ($paramfile) {
}
elsif (defined($replay_instance)) {
#
# Bindings come from the replay instance (well, run).
# Bindings come from the replay instance (well, run), although the
# use can still have provided a parameter file (above) to override
# the values from the record.
#
my %replay_bindings = ();
......@@ -534,11 +536,12 @@ if (defined($replay_instance)) {
$datastore_tag = $replay_run->start_tag();
}
print "Checking out a copy of the template datastore ($datastore_tag)\n";
$instance->CopyDataStore($datastore_tag,
"$instance_path/template_datastore") == 0
or fatal(-1, "Could not copy datastore ($template_tag) to instance");
or fatal(-1, "Could not copy datastore to instance");
# Ditto for dynamic events.
# Ditto for dynamic events.
$instance->CopyTemplateEvents() == 0
or fatal(-1, "Could not copy template events to instance");
......@@ -599,7 +602,7 @@ if ($batchmode) {
}
elsif ($state eq EXPTSTATE_SWAPPED()) {
# Dumped out of the batch system for some reason.
print "Experiment ha been removed from the batch queue.\n";
print "Experiment has been removed from the batch queue.\n";
#
# We are done; remove record of this attempt and exit.
......
......@@ -211,7 +211,7 @@ if (defined($replay_exptidx)) {
#
# XXX Need to convert these other routines to return Run objects
my $row = $replay_instance->FirstRun();
if (defined($row)) {
if (!defined($row)) {
tbdie("Could not find first run for $replay_instance!");
}
$replay_runidx = $row->{'idx'};
......@@ -299,7 +299,9 @@ if ($paramfile) {
}
elsif (defined($replay_instance)) {
#
# Bindings come from the replay instance (well, run).
# Bindings come from the replay instance (well, run), although the
# use can still have provided a parameter file (above) to override
# the values from the record.
#
my %replay_bindings = ();
......@@ -534,11 +536,12 @@ if (defined($replay_instance)) {
$datastore_tag = $replay_run->start_tag();
}
print "Checking out a copy of the template datastore ($datastore_tag)\n";
$instance->CopyDataStore($datastore_tag,
"$instance_path/template_datastore") == 0
or fatal(-1, "Could not copy datastore ($template_tag) to instance");
or fatal(-1, "Could not copy datastore to instance");
# Ditto for dynamic events.
# Ditto for dynamic events.
$instance->CopyTemplateEvents() == 0
or fatal(-1, "Could not copy template events to instance");
......@@ -599,7 +602,7 @@ if ($batchmode) {
}
elsif ($state eq EXPTSTATE_SWAPPED()) {
# Dumped out of the batch system for some reason.
print "Experiment ha been removed from the batch queue.\n";
print "Experiment has been removed from the batch queue.\n";
#
# We are done; remove record of this attempt and exit.
......
......@@ -541,7 +541,7 @@ class Template
<th align=center>Show</th>
<th align=center>Archive</th>
<th align=center>Export</th>
<th align=center>Analyze</th>
<th align=center>Replay</th>
</tr>\n";
$idlemark = "<b>*</b>";
......@@ -599,8 +599,9 @@ class Template
"<img border=0 alt='Show' src='greenball.gif'>");
echo " <td align=center>".
MakeLink("analyze",
"guid=$guid&version=$vers&exptidx=$exptidx",
MakeLink("swapin",
"guid=$guid&version=$vers".
"&replay_instance_idx=$exptidx",
"<img border=0 alt='Show' src='greenball.gif'>");
echo " </td>
</tr>\n";
......@@ -1294,6 +1295,29 @@ class TemplateInstance
}
return 0;
}
#
# Return an array of the bindings for a run of template instance.
#
function RunBindings($runidx, &$bindings) {
$bindings = array();
$instance_idx = $this->idx();
$exptidx = $this->exptidx();
$query_result =
DBQueryFatal("select * from experiment_run_bindings ".
"where exptidx='$exptidx' and runidx='$runidx'");
while ($row = mysql_fetch_array($query_result)) {
$name = $row['name'];
$value = $row['value'];
$bindings[$name] = $value;
}
return 0;
}
#
# Show graph stuff, either for entire instance or for a run. Very hacky.
#
......@@ -1645,6 +1669,9 @@ function MakeLink($which, $args, $text)
elseif ($which == "analyze") {
$page = "template_analyze.php";
}
elseif ($which == "swapin") {
$page = "template_swapin.php";
}
return "<a href=${page}?${args}>$text</a>";
}
......
......@@ -77,6 +77,19 @@ function SPITFORM($template, $formfields, $parameters, $errors)
" method=post>\n";
echo "<table align=center border=1>\n";
#
# Pass along replay info, but no need to display it.
#
if (isset($formfields["replay_instance_idx"])) {
echo "<input type=hidden name=\"formfields[replay_instance_idx]\"
value='" . $formfields["replay_instance_idx"] . "'>\n";
if (isset($formfields["replay_run_idx"])) {
echo "<input type=hidden name=\"formfields[replay_run_idx]\"
value='" . $formfields["replay_run_idx"] . "'>\n";
}
}
#
# EID:
#
......@@ -336,10 +349,41 @@ if (!isset($swapin)) {
$defaults[exp_idleswap_timeout] = TBGetSiteVar("idle/threshold");
$defaults[exp_autoswap] = TBGetSiteVar("general/autoswap_mode");
$defaults[exp_autoswap_timeout] = TBGetSiteVar("general/autoswap_threshold");
#
# Look for formal parameters that the user can specify.
# Optional replay instance/run.
#
$template->FormalParameters($parameters);
unset($replay_instance);
if (isset($replay_instance_idx)) {
if (!TBvalid_integer($replay_instance_idx)) {
PAGEARGERROR("Invalid characters in replay instance IDX!");
}
$replay_instance =
TemplateInstance::LookupByExptidx($replay_instance_idx);
if (!$replay_instance) {
USERERROR("No such instance $replay_instance_idx in template!", 1);
}
$defaults["replay_instance_idx"] = $replay_instance_idx;
if (isset($replay_run_idx)) {
if (!TBvalid_integer($replay_run_idx)) {
PAGEARGERROR("Invalid characters in replay run IDX!");
}
$replay_instance->RunBindings($parameters);
$defaults["replay_run_idx"] = $replay_run_idx;
}
else {
$replay_instance->Bindings($parameters);
}
}
else {
#
# Look for formal parameters that the user can specify.
#
$template->FormalParameters($parameters);
}
#
# Allow formfields that are already set to override defaults
......@@ -578,6 +622,28 @@ if (isset($formfields[exp_linktest]) && $formfields[exp_linktest] != "") {
}
}
#
# Replay info.
#
if (isset($formfields["replay_instance_idx"]) &&
$formfields["replay_instance_idx"] != "") {
if (!preg_match("/^[\d]+$/", $formfields["replay_instance_idx"])) {
$errors["Replay Instance"] = "Invalid replay instance";
}
else {
$command_options .= " -r " . $formfields["replay_instance_idx"];
}
if (isset($formfields["replay_run_idx"]) &&
$formfields["replay_run_idx"] != "") {
if (!preg_match("/^[\d]+$/", $formfields["replay_run_idx"])) {
$errors["Replay Run"] = "Invalid replay run";
}
else {
$command_options .= ":" . $formfields["replay_run_idx"];
}
}
}
if (count($errors)) {
SPITFORM($template, $formfields, $parameters, $errors);
PAGEFOOTER();
......
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