diff --git a/src/isalgorithm.cpp b/src/isalgorithm.cpp index e1effd6c96d65b5f7b479f0d1df20f1fe963706d..f282844d63aa3bd59e4623ac97bf850f9596d84f 100644 --- a/src/isalgorithm.cpp +++ b/src/isalgorithm.cpp @@ -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; diff --git a/src/isalgorithm.hpp b/src/isalgorithm.hpp index 125707e68127b2e73dbcb06022cb5a66608774b8..ff6a8c308580b4fd1b1e28a88fa70b9baaa80fbb 100644 --- a/src/isalgorithm.hpp +++ b/src/isalgorithm.hpp @@ -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; diff --git a/src/main.cpp b/src/main.cpp index 9a2ac65f79c3d423711c77a2cf9b8267e49448ca..8da64b1f8c07009c5f2237bb38c87fb9e292a717 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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);