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

[code] handle user-provided (un)available events

parent db0450a6
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,8 @@ void ISchedulingAlgorithm::clear_recent_data_structures()
_jobs_killed_recently.clear();
_jobs_whose_waiting_time_estimation_has_been_requested_recently.clear();
_machines_whose_pstate_changed_recently.clear();
_machines_that_became_available_recently.clear();
_machines_that_became_unavailable_recently.clear();
_nopped_recently = false;
_consumed_joules_updated_recently = false;
_consumed_joules = -1;
......@@ -91,6 +93,12 @@ void ISchedulingAlgorithm::on_no_more_static_job_to_submit_received(double date)
_no_more_static_job_to_submit_received = true;
}
void ISchedulingAlgorithm::on_no_more_external_event_to_occur(double date)
{
(void) date;
_no_more_external_event_to_occur_received = true;
}
void ISchedulingAlgorithm::on_answer_energy_consumption(double date, double consumed_joules)
{
(void) date;
......@@ -98,6 +106,18 @@ void ISchedulingAlgorithm::on_answer_energy_consumption(double date, double cons
_consumed_joules_updated_recently = true;
}
void ISchedulingAlgorithm::on_machine_available_notify_event(double date, IntervalSet machines)
{
(void) date;
_machines_that_became_available_recently += machines;
}
void ISchedulingAlgorithm::on_machine_unavailable_notify_event(double date, IntervalSet machines)
{
(void) date;
_machines_that_became_unavailable_recently += machines;
}
void ISchedulingAlgorithm::on_query_estimate_waiting_time(double date, const string &job_id)
{
(void) date;
......
......@@ -84,6 +84,12 @@ public:
*/
virtual void on_no_more_static_job_to_submit_received(double date);
/**
* @brief This function is called when the on_no_more_external_event_to_occur
* notification is received
*/
virtual void on_no_more_external_event_to_occur(double date);
/**
* @brief This function is called when an ANSWER message about energy consumption is received
* @param[in] date The date at which the ANSWER message has been received
......@@ -91,6 +97,20 @@ public:
*/
virtual void on_answer_energy_consumption(double date, double consumed_joules);
/**
* @brief This function is called when a machine_available NOTIFY event is received.
* @param[in] date The date at which the NOTIFY event has been received.
* @param[in] machines The machines whose availability has changed.
*/
virtual void on_machine_available_notify_event(double date, IntervalSet machines);
/**
* @brief This function is called when a machine_unavailable NOTIFY event is received.
* @param[in] date The date at which the NOTIFY event has been received.
* @param[in] machines The machines whose availability has changed.
*/
virtual void on_machine_unavailable_notify_event(double date, IntervalSet machines);
/**
* @brief This function is called when a QUERY message about estimating waiting time of potential jobs is received.
* @param[in] date The date at which the QUERY message has been received
......@@ -137,6 +157,7 @@ protected:
int _nb_machines = -1;
RedisStorage * _redis = nullptr;
bool _no_more_static_job_to_submit_received = false;
bool _no_more_external_event_to_occur_received = false;
protected:
std::vector<std::string> _jobs_released_recently;
......@@ -144,6 +165,8 @@ protected:
std::vector<std::string> _jobs_killed_recently;
std::vector<std::string> _jobs_whose_waiting_time_estimation_has_been_requested_recently;
std::map<int, IntervalSet> _machines_whose_pstate_changed_recently;
IntervalSet _machines_that_became_available_recently;
IntervalSet _machines_that_became_unavailable_recently;
bool _nopped_recently;
bool _consumed_joules_updated_recently;
double _consumed_joules;
......
......@@ -502,6 +502,20 @@ void run(Network & n, ISchedulingAlgorithm * algo, SchedulingDecision & d,
{
algo->on_no_more_static_job_to_submit_received(current_date);
}
else if (notify_type == "no_more_external_event_to_occur")
{
algo->on_no_more_external_event_to_occur(current_date);
}
else if (notify_type == "event_machine_available")
{
IntervalSet resources = IntervalSet::from_string_hyphen(event_data["resources"].GetString(), " ");
algo->on_machine_available_notify_event(current_date, resources);
}
else if (notify_type == "event_machine_unavailable")
{
IntervalSet resources = IntervalSet::from_string_hyphen(event_data["resources"].GetString(), " ");
algo->on_machine_unavailable_notify_event(current_date, resources);
}
else
{
throw runtime_error("Unknown NOTIFY type received. Type = " + notify_type);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment