Skip to content
Snippets Groups Projects
Commit c01110c4 authored by Millian Poquet's avatar Millian Poquet
Browse files

[code] stop CALL_ME_LATER once all jobs finished

parent b74b81f5
No related branches found
No related tags found
No related merge requests found
......@@ -1343,3 +1343,31 @@ bool EnergyBackfilling::is_fake_job(const std::string & job_id)
{
return boost::starts_with(job_id, "fakejob_");
}
bool EnergyBackfilling::contains_any_fake_job(const Schedule &schedule)
{
for (auto slice_it = schedule.begin(); slice_it != schedule.end(); ++slice_it)
{
for (auto mit : slice_it->allocated_jobs)
{
const Job * job = mit.first;
if (is_fake_job(job->id))
return true;
}
}
return false;
}
bool EnergyBackfilling::contains_any_nonfake_job(const Schedule &schedule)
{
for (auto slice_it = schedule.begin(); slice_it != schedule.end(); ++slice_it)
{
for (auto mit : slice_it->allocated_jobs)
{
const Job * job = mit.first;
if (!is_fake_job(job->id))
return true;
}
}
return false;
}
......@@ -156,6 +156,9 @@ protected:
static bool is_potential_sleep_job(const std::string & job_id);
static bool is_fake_job(const std::string & job_id);
static bool contains_any_fake_job(const Schedule & schedule);
static bool contains_any_nonfake_job(const Schedule & schedule);
protected:
Schedule _schedule;
bool _debug = false;
......
......@@ -120,26 +120,34 @@ void EnergyBackfillingMonitoringInertialShutdown::make_decisions(double date,
"Invalid nb_machines_sedated_for_being_idle value: %d\n",
_nb_machines_sedated_for_being_idle);
// Let's remove finished jobs from the schedule
for (const string & ended_job_id : _jobs_ended_recently)
if (!_jobs_ended_recently.empty())
{
const Job * ended_job = (*_workload)[ended_job_id];
++_nb_jobs_completed;
PPK_ASSERT_ERROR(_schedule.contains_job(ended_job),
"Invalid schedule: job '%s' just finished, "
"but it not in the schedule...\n%s",
ended_job_id.c_str(), _schedule.to_string().c_str());
PPK_ASSERT_ERROR(!_queue->contains_job(ended_job),
"Job '%s' just ended, but it is still in the "
"queue...\nQueue : %s",
ended_job_id.c_str(),
_queue->to_string().c_str());
// Let's remove the finished job from the schedule
_schedule.remove_job(ended_job);
}
// Let's remove finished jobs from the schedule
for (const string & ended_job_id : _jobs_ended_recently)
{
const Job * ended_job = (*_workload)[ended_job_id];
++_nb_jobs_completed;
PPK_ASSERT_ERROR(_schedule.contains_job(ended_job),
"Invalid schedule: job '%s' just finished, "
"but it not in the schedule...\n%s",
ended_job_id.c_str(), _schedule.to_string().c_str());
PPK_ASSERT_ERROR(!_queue->contains_job(ended_job),
"Job '%s' just ended, but it is still in the "
"queue...\nQueue : %s",
ended_job_id.c_str(),
_queue->to_string().c_str());
// Let's remove the finished job from the schedule
_schedule.remove_job(ended_job);
}
// Stop sending CALL_ME_LATER if all jobs have been executed.
if (_no_more_static_job_to_submit_received &&
_queue->is_empty() &&
!EnergyBackfilling::contains_any_nonfake_job(_schedule))
_stop_sending_call_me_later = true;
}
// Let's update the first slice of the schedule
update_first_slice_taking_sleep_jobs_into_account(date);
......
......@@ -65,13 +65,16 @@ void EnergyBackfillingMonitoringPeriod::on_requested_call(double date)
// Let's execute on_monitoring_stage
on_monitoring_stage(date);
// Let's request a call for the next monitoring stage
_next_monitoring_period_expected_date = date + _period_between_monitoring_stages;
_decision->add_call_me_later((double)(_next_monitoring_period_expected_date), date);
_nb_call_me_later_running++;
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: 'Chose to launch a call_me_later at %g",
(double)_next_monitoring_period_expected_date);
if (!_stop_sending_call_me_later)
{
// Let's request a call for the next monitoring stage
_next_monitoring_period_expected_date = date + _period_between_monitoring_stages;
_decision->add_call_me_later((double)(_next_monitoring_period_expected_date), date);
_nb_call_me_later_running++;
LOG_F(INFO, "EnergyBackfillingMonitoringPeriod: 'Chose to launch a call_me_later at %g",
(double)_next_monitoring_period_expected_date);
}
}
}
......
......@@ -29,6 +29,7 @@ public:
protected:
std::string _output_dir;
bool _stop_sending_call_me_later = false;
private:
bool _monitoring_period_launched = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment