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) ...@@ -33,4 +33,81 @@ QString QueuePBS::showQueueInfo(QString queueName)
return "showq " + queueName; return "showq " + queueName;
} }
QString QueuePBS::showFreeProcs(QString params) { return "showbf " + params; } 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 } // namespace rsm
#ifndef RSMPBS_QUEUEPBS_HH_ #ifndef RSMPBS_QUEUEPBS_HH_
#define RSMPBS_QUEUEPBS_HH_ #define RSMPBS_QUEUEPBS_HH_
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QSet>
#include "rsmcore/queuebase.hh" #include "rsmcore/queuebase.hh"
namespace rsm namespace rsm
...@@ -16,6 +20,9 @@ class QueuePBS : public QueueBase ...@@ -16,6 +20,9 @@ class QueuePBS : public QueueBase
QString submitJob(QString params) override; QString submitJob(QString params) override;
QString showQueueInfo(QString queueName) override; QString showQueueInfo(QString queueName) override;
QString showFreeProcs(QString params) override; QString showFreeProcs(QString params) override;
int parseSubmitJobReturn(QString str);
QSet<int> parseCheckJobsReturn(QString str);
QSet<int> parseDeleteJobsReturn(QString str);
}; // class QueuePBS }; // class QueuePBS
} // namespace rsm } // namespace rsm
......
...@@ -45,9 +45,11 @@ int QueueSGE::parseSubmitJobReturn(QString str) ...@@ -45,9 +45,11 @@ int QueueSGE::parseSubmitJobReturn(QString str)
{ {
// examples: // examples:
// Your job 99 ("spin_test") has been submitted // Your job 99 ("spin_test") has been submitted
//
// Your job - array 90.1 - 16 : 1(" test ")has been submitted; // Your job - array 90.1 - 16 : 1(" test ")has been submitted;
int jobID = -1; 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); QRegularExpressionMatch rem = re.match(str);
if (rem.hasMatch()) if (rem.hasMatch())
{ {
...@@ -67,6 +69,7 @@ QSet<int> QueueSGE::parseCheckJobsReturn(QString str) ...@@ -67,6 +69,7 @@ QSet<int> QueueSGE::parseCheckJobsReturn(QString str)
// 105 0.50000 spintest mpi_user r 04/14/2020 13:48:03 // 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 // 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 // r 04/14/2020 13:48:03 all.q@rpi3-compute-node-2.clus 1 2
QSet<int> jobIDs; QSet<int> jobIDs;
QRegularExpression re = QRegularExpression("[^0-9]*([0-9]+)"); QRegularExpression re = QRegularExpression("[^0-9]*([0-9]+)");
QStringList subStrList = QStringList subStrList =
......
...@@ -395,12 +395,20 @@ void SessionWorker::requestExec(QString command) ...@@ -395,12 +395,20 @@ void SessionWorker::requestExec(QString command)
return; return;
} }
// TODO: should we use timeout or non-blocking version of this call? // TODO: should we use timeout or non-blocking version of this call?
// read stdout
int nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); int nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0) while (nbytes > 0)
{ {
p->output_buffer.append(buffer, nbytes); p->output_buffer.append(buffer, nbytes);
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0); 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(); emit execOutputReady();
radix_tagged_line("nbytes=" << nbytes); radix_tagged_line("nbytes=" << nbytes);
radix_tagged_line("Finished reading response\n" << p->output_buffer.data()); 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