From 1e47d8f946056d832f28525e9e1a446f3966429d Mon Sep 17 00:00:00 2001 From: henricasanova Date: Thu, 15 Mar 2018 17:55:03 -1000 Subject: [PATCH] tentative work-around for daemonization madness --- .../services/compute/batch/BatchService.h | 2 + .../services/compute/batch/BatchService.cpp | 37 +++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/wrench/services/compute/batch/BatchService.h b/include/wrench/services/compute/batch/BatchService.h index 2d0de2b67d..ae93986aa9 100644 --- a/include/wrench/services/compute/batch/BatchService.h +++ b/include/wrench/services/compute/batch/BatchService.h @@ -91,6 +91,8 @@ namespace wrench { unsigned int batsched_port; #endif + bool clean_exit = false; + //Configuration to create randomness in measurement period initially unsigned long random_interval = 10; diff --git a/src/wrench/services/compute/batch/BatchService.cpp b/src/wrench/services/compute/batch/BatchService.cpp index 336b168ae7..90a325c76a 100644 --- a/src/wrench/services/compute/batch/BatchService.cpp +++ b/src/wrench/services/compute/batch/BatchService.cpp @@ -509,6 +509,7 @@ namespace wrench { } WRENCH_INFO("Batch Service on host %s terminated!", S4U_Simulation::getHostName().c_str()); + this->clean_exit = true; return 0; } @@ -954,9 +955,11 @@ namespace wrench { */ void BatchService::cleanup() { - this->setStateToDown(); - WRENCH_INFO("Failing current standard jobs"); - this->failCurrentStandardJobs(std::shared_ptr(new ServiceIsDown(this))); + if (this->clean_exit) { + this->setStateToDown(); + WRENCH_INFO("Failing current standard jobs"); + this->failCurrentStandardJobs(std::shared_ptr(new ServiceIsDown(this))); + } // //remove standard job alarms // std::vector>::iterator it; @@ -1018,19 +1021,21 @@ namespace wrench { #endif - if (this->supports_pilot_jobs) { - for (auto & job : this->running_jobs) { - if ((job)->getWorkflowJob()->getType() == WorkflowJob::PILOT) { - PilotJob *p_job = (PilotJob *) ((job)->getWorkflowJob()); - BatchService *cs = (BatchService *) p_job->getComputeService(); - if (cs == nullptr) { - throw std::runtime_error( - "BatchService::terminate(): can't find compute service associated to pilot job"); - } - try { - cs->stop(); - } catch (wrench::WorkflowExecutionException &e) { - // ignore + if (this->clean_exit) { + if (this->supports_pilot_jobs) { + for (auto &job : this->running_jobs) { + if ((job)->getWorkflowJob()->getType() == WorkflowJob::PILOT) { + PilotJob *p_job = (PilotJob *) ((job)->getWorkflowJob()); + BatchService *cs = (BatchService *) p_job->getComputeService(); + if (cs == nullptr) { + throw std::runtime_error( + "BatchService::terminate(): can't find compute service associated to pilot job"); + } + try { + cs->stop(); + } catch (wrench::WorkflowExecutionException &e) { + // ignore + } } } }