Commit 62341a85 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Ready Bit support. New field in the nodes table. Initialized by

handle_os. Two new TMCC commands. "ready" says the node is ready (sets
ready to 1 in nodes table). "readycount" returns an N of M ready count
to the caller. This is not a barrier sync operation! Nodes must poll,
and there is no way to reset the count since that would require some
sort of synchronization, which of course we do not have.
parent df9a7400
......@@ -176,7 +176,8 @@ if (! &ir_exists("/cmdline")) {
foreach (split("\n",&ir_get("/cmdline"))) {
($node,$cmdline) = /^([^ ]+)(.*)$/;
$cmdline =~ s/^ //;
$sth = $dbh->prepare("UPDATE nodes set def_boot_cmd_line = \"$cmdline\" where node_id = \"$nodemap{$node}\"");
$sth = $dbh->prepare("UPDATE nodes set def_boot_cmd_line = \"$cmdline\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
......@@ -187,7 +188,8 @@ if (! &ir_exists("/startup")) {
foreach (split("\n",&ir_get("/startup"))) {
($node,$cmdline) = /^([^ ]+)(.*)$/;
$cmdline =~ s/^ //;
$sth = $dbh->prepare("UPDATE nodes set startupcmd = \"$cmdline\", startstatus = \"none\" where node_id = \"$nodemap{$node}\"");
$sth = $dbh->prepare("UPDATE nodes set startupcmd = \"$cmdline\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
......@@ -199,7 +201,16 @@ foreach (split("\n",&ir_get("/rpms"))) {
($node,$rpms) = /^([^ ]+)(.*)$/;
$rpms =~ s/^ //;
$rpms =~ s/ /:/g;
$sth = $dbh->prepare("UPDATE nodes set rpms = \"$rpms\" where node_id = \"$nodemap{$node}\"");
$sth = $dbh->prepare("UPDATE nodes set rpms = \"$rpms\" ".
"where node_id = \"$nodemap{$node}\"");
$sth->execute;
$sth->finish;
}
foreach (keys(%nodemap)) {
$node = $_;
$sth = $dbh->prepare("UPDATE nodes set ready=0,startstatus = \"none\" ".
"where node_id = \"$node\"");
$sth->execute;
$sth->finish;
}
......
......@@ -43,6 +43,8 @@ static int dohosts(int sock, struct in_addr ipaddr, char *request, int tcp);
static int dorpms(int sock, struct in_addr ipaddr, char *request, int tcp);
static int dostartcmd(int sock, struct in_addr ipaddr, char *request, int tcp);
static int dostartstat(int sock, struct in_addr ipaddr, char *request,int tcp);
static int doready(int sock, struct in_addr ipaddr, char *request,int tcp);
static int doreadycount(int sock, struct in_addr ipaddr,char *request,int tcp);
struct command {
char *cmdname;
......@@ -56,7 +58,10 @@ struct command {
{ "hostnames", dohosts },
{ "rpms", dorpms },
{ "startupcmd", dostartcmd },
{ "startstatus",dostartstat }, /* Leave this before next one */
{ "startstat", dostartstat },
{ "readycount", doreadycount },
{ "ready", doready },
};
static int numcommands = sizeof(command_array)/sizeof(struct command);
......@@ -234,7 +239,7 @@ main(int argc, char **argv)
for (i = 0; i < numcommands; i++) {
if (strncmp(cp, command_array[i].cmdname,
strlen(command_array[i].cmdname)) == 0) {
err = command_array[i].func(clientsock,
err = command_array[i].func(clientsock,
client.sin_addr,
cp, istcp);
break;
......@@ -1047,6 +1052,112 @@ dostartstat(int sock, struct in_addr ipaddr, char *request, int tcp)
return 0;
}
/*
* Accept notification of ready for action
*/
static int
doready(int sock, struct in_addr ipaddr, char *request, int tcp)
{
char nodeid[32];
char pid[64];
char eid[64];
if (iptonodeid(ipaddr, nodeid)) {
syslog(LOG_ERR, "READY: %s: No such node",
inet_ntoa(ipaddr));
return 1;
}
/*
* Make sure currently allocated to an experiment!
*/
if (nodeidtoexp(nodeid, pid, eid)) {
syslog(LOG_INFO, "READY: %s: Node is free", nodeid);
return 0;
}
/*
* Update the ready_bits table.
*/
if (mydb_update("update nodes set ready=1 "
"where node_id='%s'", nodeid)) {
syslog(LOG_ERR, "READY: %s: DB Error setting ready bit!",
nodeid);
return 1;
}
syslog(LOG_INFO, "READY: %s: Node is reporting ready", nodeid);
/*
* Nothing is written back
*/
return 0;
}
/*
* Return ready bits count (NofM)
*/
static int
doreadycount(int sock, struct in_addr ipaddr, char *request, int tcp)
{
MYSQL_RES *res;
MYSQL_ROW row;
char nodeid[32];
char pid[64];
char eid[64];
char buf[BUFSIZ];
int total, ready, i;
if (iptonodeid(ipaddr, nodeid)) {
syslog(LOG_ERR, "READYCOUNT: %s: No such node",
inet_ntoa(ipaddr));
return 1;
}
/*
* Make sure currently allocated to an experiment!
*/
if (nodeidtoexp(nodeid, pid, eid)) {
syslog(LOG_INFO, "READYCOUNT: %s: Node is free", nodeid);
return 0;
}
/*
* See how many are ready. This is a non sync protocol. Clients
* keep asking until N and M are equal. Can only be used once
* of course, after experiment creation.
*/
res = mydb_query("SELECT ready FROM nodes "
"LEFT JOIN reserved "
"ON nodes.node_id=reserved.node_id "
"WHERE reserved.eid='%s' and reserved.pid='%s'",
1, eid, pid);
if (!res) {
syslog(LOG_ERR, "READYCOUNT: %s: DB Error getting ready bits",
nodeid);
return 1;
}
ready = 0;
total = (int) mysql_num_rows(res);
if (total) {
for (i = 0; i < total; i++) {
row = mysql_fetch_row(res);
if (atoi(row[0]))
ready++;
}
}
sprintf(buf, "READY=%d TOTAL=%d\n", ready, total);
client_writeback(sock, buf, strlen(buf), tcp);
syslog(LOG_INFO, "READYCOUNT: %s: %s", nodeid, buf);
return 0;
}
/*
* DB stuff
*/
......
......@@ -58,7 +58,8 @@ if (!$isadmin) {
echo "<center>
<h1>Batch Mode Experiment Information</h1>
<table align=center border=1>\n";
</center>
<table align=center border=1>\n";
$created = $exprow[created];
$expires = $exprow[expires];
......
......@@ -275,7 +275,8 @@ function SHOWNODES($pid, $eid) {
<td align=center>Default<br>Path</td>
<td align=center>Default<br>Cmdline</td>
<td align=center>Startup<br>Command</td>
<td align=center>Startup<br>Status</td>
<td align=center>Startup<br>Status[1]</td>
<td align=center>Ready<br>Status[2]</td>
</tr>\n";
$query_result = mysql_db_query($TBDBNAME,
......@@ -296,6 +297,7 @@ function SHOWNODES($pid, $eid) {
$next_boot_cmd_line = $row[next_boot_cmd_line];
$startupcmd = $row[startupcmd];
$startstatus = $row[startstatus];
$readystatus = $row[ready];
if (!$def_boot_cmd_line)
$def_boot_cmd_line = "NULL";
......@@ -309,6 +311,10 @@ function SHOWNODES($pid, $eid) {
$startupcmd = "NULL";
if (!$vname)
$vname = "--";
if ($readystatus)
$readylabel = "Yes";
else
$readylabel = "No";
echo "<tr>
<td align=center>
......@@ -322,9 +328,18 @@ function SHOWNODES($pid, $eid) {
<td>$def_boot_cmd_line</td>
<td>$startupcmd</td>
<td align=center>$startstatus</td>
<td align=center>$readylabel</td>
</tr>\n";
}
echo "</table>\n";
echo "<h4><blockquote><blockquote><blockquote><blockquote>
<dl COMPACT>
<dt>[1]
<dd>Exit value of the node startup command.
<dt>[2]
<dd>User application has reported ready via TMCC.
</dl>
</blockquote></blockquote></blockquote></blockquote></h4>\n";
}
}
......
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