Commit 268a3e13 authored by Huff, Israel's avatar Huff, Israel
Browse files

- adding initial implementations of qdel, qsub and qstat results parsing for PBS

- SessionWorker::requestExec() now also reads and returns from stderr stream
parent 9952b04d
Pipeline #97360 passed with stages
in 5 minutes and 34 seconds
......@@ -33,4 +33,81 @@ QString QueuePBS::showQueueInfo(QString queueName)
return "showq " + queueName;
}
QString QueuePBS::showFreeProcs(QString params) { return "showbf " + params; }
// returns job ID on success or -1 on failure
int QueuePBS::parseSubmitJobReturn(QString str)
{
// examples:
// 170405.thundersnow.ornl.gov
//
// qsub: submit error (Illegal attribute or resource value for
// Resource_List.walltime)
//
// qsub: submit error (Command syntax invalid MSG=Invalid Syntax)
int jobID = -1;
QRegularExpression re = QRegularExpression("^([0-9]+)");
QRegularExpressionMatch rem = re.match(str);
if (rem.hasMatch())
{
jobID = rem.captured(1).toInt();
}
return jobID;
}
// returns QSet of job IDs on success or emtpy QSet on failure or if no jobs
// running
QSet<int> QueuePBS::parseCheckJobsReturn(QString str)
{
// examples:
// Job ID Name User Time Use S Queue
//------------------------- ---------------- --------------- -------- - -----
// 170414.thundersnow.ornl.gov test i0h 00:00:36 C
// batch 170415.thundersnow.ornl.gov test i0h 0
// R batch
QSet<int> jobIDs;
QRegularExpression re = QRegularExpression("^([0-9]+)[.]");
QStringList subStrList =
str.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
for (auto subStr : subStrList)
{
QRegularExpressionMatch rem = re.match(subStr);
if (rem.hasMatch())
{
int jobID = rem.captured(1).toInt();
jobIDs.insert(jobID);
}
}
return jobIDs;
}
// returns QSet of job IDs on success or emtpy QSet on failure or if no jobs
// running
QSet<int> QueuePBS::parseDeleteJobsReturn(QString str)
{
// examples:
// ***no printout on success***
//
// qdel: Request invalid for state of job MSG=invalid state for job - COMPLETE
// 170405.thundersnow.ornl.gov
//
// qdel: nonexistent job id: 1111
QSet<int> jobIDs;
QRegularExpression re = QRegularExpression("^qdel[^0-9]*([0-9]+)");
QStringList subStrList =
str.split(QRegExp("[\r\n]"), QString::SkipEmptyParts);
for (auto subStr : subStrList)
{
QRegularExpressionMatch rem = re.match(subStr);
if (rem.hasMatch())
{
int jobID = rem.captured(1).toInt();
jobIDs.insert(jobID);
}
}
return jobIDs;
}
} // namespace rsm
#ifndef RSMPBS_QUEUEPBS_HH_
#define RSMPBS_QUEUEPBS_HH_
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSet>
#include "rsmcore/queuebase.hh"
namespace rsm
......@@ -16,6 +20,9 @@ class QueuePBS : public QueueBase
QString submitJob(QString params) override;
QString showQueueInfo(QString queueName) override;
QString showFreeProcs(QString params) override;
int parseSubmitJobReturn(QString str);
QSet<int> parseCheckJobsReturn(QString str);
QSet<int> parseDeleteJobsReturn(QString str);
}; // class QueuePBS
} // namespace rsm
......
......@@ -45,9 +45,11 @@ int QueueSGE::parseSubmitJobReturn(QString str)
{
// examples:
// Your job 99 ("spin_test") has been submitted
//
// Your job - array 90.1 - 16 : 1(" test ")has been submitted;
int jobID = -1;
QRegularExpression re = QRegularExpression("job[^0-9]*([0-9]+)");
QRegularExpression re = QRegularExpression("^Your job[^0-9]*([0-9]+)");
QRegularExpressionMatch rem = re.match(str);
if (rem.hasMatch())
{
......@@ -67,6 +69,7 @@ QSet<int> QueueSGE::parseCheckJobsReturn(QString str)
// 105 0.50000 spintest mpi_user r 04/14/2020 13:48:03
// all.q@rpi3-compute-node-1.clus 1 1 105 0.50000 spintest mpi_user
// r 04/14/2020 13:48:03 all.q@rpi3-compute-node-2.clus 1 2
QSet<int> jobIDs;
QRegularExpression re = QRegularExpression("[^0-9]*([0-9]+)");
QStringList subStrList =
......
......@@ -395,12 +395,20 @@ void SessionWorker::requestExec(QString command)
return;
}
// TODO: should we use timeout or non-blocking version of this call?
// read stdout
int nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0)
{
p->output_buffer.append(buffer, nbytes);
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
}
// read stderr
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 1);
while (nbytes > 0)
{
p->output_buffer.append(buffer, nbytes);
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 1);
}
emit execOutputReady();
radix_tagged_line("nbytes=" << nbytes);
radix_tagged_line("Finished reading response\n" << p->output_buffer.data());
......
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