Skip to content
Snippets Groups Projects
Commit f977f07c authored by Langella Olivier's avatar Langella Olivier
Browse files

new try catch blocks to ensure condor process

parent a9a57d51
No related branches found
No related tags found
No related merge requests found
......@@ -249,81 +249,96 @@ TandemCondorProcess::run()
QStringList arguments;
arguments << QFileInfo(submit_file.fileName()).absoluteFilePath();
QProcess *condor_process = new QProcess();
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::run command " << _condor_submit_command
<< " " << arguments.join(" ");
condor_process->start(_condor_submit_command, arguments);
try
{
QProcess condor_process;
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::run command " << _condor_submit_command
<< " " << arguments.join(" ");
condor_process.start(_condor_submit_command, arguments);
if(!condor_process->waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed to start"));
}
if(!condor_process.waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed to start"));
}
if(!condor_process->waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed to finish"));
}
if(!condor_process.waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed to finish"));
}
QString perr = condor_process->readAllStandardError();
if(perr.length())
{
QString perr = condor_process.readAllStandardError();
if(perr.length())
{
qDebug() << "TandemCondorProcess::run readAllStandardError " << perr;
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed :\n%1").arg(perr));
}
else
{
qDebug() << "TandemCondorProcess::run readAllStandardError OK " << perr;
}
qDebug() << "TandemCondorProcess::run readAllStandardError " << perr;
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed :\n%1").arg(perr));
}
else
{
qDebug() << "TandemCondorProcess::run readAllStandardError OK "
<< perr;
}
QString pjob = condor_process->readAllStandardOutput();
if(pjob.length())
{
qDebug() << "TandemCondorProcess::run readAllStandardOutput OK " << pjob;
}
else
{
qDebug() << "TandemCondorProcess::run readAllStandardOutput " << pjob;
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed :\n%1").arg(pjob));
}
QString pjob = condor_process.readAllStandardOutput();
if(pjob.length())
{
qDebug() << "TandemCondorProcess::run readAllStandardOutput OK "
<< pjob;
}
else
{
qDebug() << "TandemCondorProcess::run readAllStandardOutput " << pjob;
throw pappso::PappsoException(
QObject::tr("HTCondor X!Tandem process failed :\n%1").arg(pjob));
}
// Submitting job(s).\n1 job(s) submitted to cluster 29.\n
parseCondorJobNumber(pjob);
// Submitting job(s).\n1 job(s) submitted to cluster 29.\n
parseCondorJobNumber(pjob);
_p_monitor->setProgressMaximumValue(_condor_job_size);
qDebug() << "TandemCondorProcess::run job=" << _condor_cluster_number
<< " size=" << _condor_job_size;
_p_monitor->setProgressMaximumValue(_condor_job_size);
qDebug() << "TandemCondorProcess::run job=" << _condor_cluster_number
<< " size=" << _condor_job_size;
/*
if (!xt_process->waitForFinished(_max_xt_time_ms)) {
throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem process
to finish : timeout at %1").arg(_max_xt_time_ms));
}
*/
QByteArray result = condor_process->readAll();
/*
if (!xt_process->waitForFinished(_max_xt_time_ms)) {
throw pappso::PappsoException(QObject::tr("can't wait for X!Tandem
process to finish : timeout at %1").arg(_max_xt_time_ms));
}
*/
QByteArray result = condor_process.readAll();
QProcess::ExitStatus Status = condor_process->exitStatus();
QProcess::ExitStatus Status = condor_process.exitStatus();
qDebug() << "TandemCondorProcess::run ExitStatus " << Status << result.data();
if(Status != 0)
qDebug() << "TandemCondorProcess::run ExitStatus " << Status
<< result.data();
if(Status != 0)
{
// != QProcess::NormalExit
throw pappso::PappsoException(
QObject::tr("error executing HTCondor Status != 0 : %1 %2\n%3")
.arg(_tandem_run_batch._tandem_bin_path)
.arg(arguments.join(" ").arg(result.data())));
}
}
catch(pappso::PappsoException exception_pappso)
{
// != QProcess::NormalExit
throw pappso::PappsoException(
QObject::tr("error executing HTCondor Status != 0 : %1 %2\n%3")
.arg(_tandem_run_batch._tandem_bin_path)
.arg(arguments.join(" ").arg(result.data())));
QObject::tr("error launching X!Tandem condor jobs :\n%1")
.arg(exception_pappso.qwhat()));
}
catch(std::exception exception_std)
{
throw pappso::PappsoException(
QObject::tr(
"error launching X!Tandem condor jobs (std::exception):\n%1")
.arg(exception_std.what()));
}
delete condor_process;
surveyCondorJob();
......@@ -365,6 +380,7 @@ TandemCondorProcess::surveyCondorJob()
}
}
}
void
TandemCondorProcess::condorRemoveJob()
{
......@@ -372,43 +388,59 @@ TandemCondorProcess::condorRemoveJob()
QStringList arguments;
arguments << QString("%1").arg(_condor_cluster_number);
QString pjob;
try
{
QProcess condor_q_process;
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::condorRemoveJob command "
<< _condor_rm_command << " " << arguments.join(" ");
condor_q_process.start(_condor_rm_command, arguments);
QProcess condor_q_process;
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::condorRemoveJob command "
<< _condor_rm_command << " " << arguments.join(" ");
condor_q_process.start(_condor_rm_command, arguments);
if(!condor_q_process.waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_rm process failed to start"));
}
if(!condor_q_process.waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_rm process failed to start"));
}
if(!condor_q_process.waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_rm process failed to finish"));
}
if(!condor_q_process.waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_rm process failed to finish"));
}
QString perr = condor_q_process.readAllStandardError();
if(perr.length())
{
QString perr = condor_q_process.readAllStandardError();
if(perr.length())
{
qDebug()
<< "TandemCondorProcess::condorRemoveJob readAllStandardError "
<< perr;
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(perr));
}
else
{
qDebug()
<< "TandemCondorProcess::condorRemoveJob readAllStandardError OK "
<< perr;
}
qDebug() << "TandemCondorProcess::condorRemoveJob readAllStandardError "
<< perr;
pjob = condor_q_process.readAllStandardOutput();
}
catch(pappso::PappsoException exception_pappso)
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(perr));
QObject::tr("error removing condor jobs :\n%1")
.arg(exception_pappso.qwhat()));
}
else
catch(std::exception exception_std)
{
qDebug()
<< "TandemCondorProcess::condorRemoveJob readAllStandardError OK "
<< perr;
throw pappso::PappsoException(
QObject::tr("error removing condor jobs (std::exception):\n%1")
.arg(exception_std.what()));
}
QString pjob = condor_q_process.readAllStandardOutput();
if(pjob.length())
{
qDebug()
......@@ -431,65 +463,80 @@ TandemCondorProcess::getCondorJobState()
QStringList arguments;
arguments << "-xml" << QString("%1").arg(_condor_cluster_number);
QString pjob;
try
{
QProcess condor_q_process;
// QProcess::error(QProcess::ProcessError)
// finished(int,QProcess::ExitStatus)
// connect(&condor_q_process, &QProcess::finished, this,
// &TandemCondorProcess::receivedCondorQueueProcessCompleted);
// connect(&condor_q_process, &QProcess::error, this,
// &TandemCondorProcess::receivedCondorQueueProcessError);
QProcess condor_q_process;
// QProcess::error(QProcess::ProcessError)
// finished(int,QProcess::ExitStatus)
// connect(&condor_q_process, &QProcess::finished, this,
// &TandemCondorProcess::receivedCondorQueueProcessCompleted);
// connect(&condor_q_process, &QProcess::error, this,
// &TandemCondorProcess::receivedCondorQueueProcessError);
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::getCondorJobState command "
<< _condor_q_command << " " << arguments.join(" ");
condor_q_process.start(_condor_q_command, arguments);
// hk_process->setWorkingDirectory(QFileInfo(_hardklor_exe).absolutePath());
qDebug() << "TandemCondorProcess::getCondorJobState command "
<< _condor_q_command << " " << arguments.join(" ");
condor_q_process.start(_condor_q_command, arguments);
if(!condor_q_process.waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed to start"));
}
if(!condor_q_process.waitForStarted())
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed to start"));
}
if(!condor_q_process.waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed to finish"));
}
if(!condor_q_process.waitForFinished(_max_xt_time_ms))
{
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed to finish"));
}
QString perr = condor_q_process.readAllStandardError();
if(perr.length())
{
QString perr = condor_q_process.readAllStandardError();
if(perr.length())
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardError "
<< perr;
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(perr));
}
else
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardError OK "
<< perr;
}
qDebug() << "TandemCondorProcess::getCondorJobState readAllStandardError "
<< perr;
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(perr));
pjob = condor_q_process.readAllStandardOutput();
if(pjob.length())
{
qDebug() << "TandemCondorProcess::getCondorJobState "
"readAllStandardOutput OK "
<< pjob;
}
else
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardOutput "
<< pjob;
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(pjob));
}
}
else
catch(pappso::PappsoException exception_pappso)
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardError OK "
<< perr;
throw pappso::PappsoException(
QObject::tr("error watching condor status :\n%1")
.arg(exception_pappso.qwhat()));
}
QString pjob = condor_q_process.readAllStandardOutput();
if(pjob.length())
catch(std::exception exception_std)
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardOutput OK "
<< pjob;
}
else
{
qDebug()
<< "TandemCondorProcess::getCondorJobState readAllStandardOutput "
<< pjob;
throw pappso::PappsoException(
QObject::tr("HTCondor condor_q process failed :\n%1").arg(pjob));
QObject::tr("error watching condor status (std::exception):\n%1")
.arg(exception_std.what()));
}
// Submitting job(s).\n1 job(s) submitted to cluster 29.\n
parseCondorQueue(pjob);
}
......@@ -498,31 +545,45 @@ void
TandemCondorProcess::parseCondorQueue(QString &condor_q_xml)
{
try
{
CondorQxmlSaxHandler *parser = new CondorQxmlSaxHandler(this);
CondorQxmlSaxHandler *parser = new CondorQxmlSaxHandler(this);
QXmlSimpleReader simplereader;
simplereader.setContentHandler(parser);
simplereader.setErrorHandler(parser);
QXmlSimpleReader simplereader;
simplereader.setContentHandler(parser);
simplereader.setErrorHandler(parser);
qDebug() << "TandemCondorProcess::parseCondorQueue Read condor_q_xml";
qDebug() << "TandemCondorProcess::parseCondorQueue Read condor_q_xml";
QXmlInputSource xml_input_source;
xml_input_source.setData(condor_q_xml);
QXmlInputSource xml_input_source;
xml_input_source.setData(condor_q_xml);
if(simplereader.parse(xml_input_source))
{
}
else
{
qDebug() << parser->errorString();
if(simplereader.parse(xml_input_source))
throw pappso::PappsoException(
QObject::tr("Error reading condor_q xml string :\n %1\n%2")
.arg(parser->errorString())
.arg(condor_q_xml));
}
delete parser;
}
catch(pappso::PappsoException exception_pappso)
{
throw pappso::PappsoException(
QObject::tr("error parsing condor queue :\n%1")
.arg(exception_pappso.qwhat()));
}
else
catch(std::exception exception_std)
{
qDebug() << parser->errorString();
throw pappso::PappsoException(
QObject::tr("Error reading condor_q xml string :\n %1\n%2")
.arg(parser->errorString())
.arg(condor_q_xml));
QObject::tr("error parsing condor queue (std::exception):\n%1")
.arg(exception_std.what()));
}
delete parser;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment