HostStateChangeDetector.h
1 
10 #ifndef WRENCH_HOSTSTATECHANGEDETECTOR_H
11 #define WRENCH_HOSTSTATECHANGEDETECTOR_H
12 
13 #include <wrench/services/Service.h>
14 #include "wrench/simgrid_S4U_util/S4U_Daemon.h"
15 #include "HostStateChangeDetectorProperty.h"
16 
17 namespace wrench {
18 
19  /***********************/
21  /***********************/
22 
27 
28  private:
29  std::map<std::string, std::string> default_property_values = {
31  };
32 
33  public:
34 
35  explicit HostStateChangeDetector(std::string host_on_which_to_run,
36  std::vector<std::string> hosts_to_monitor,
37  bool notify_when_turned_on,
38  bool notify_when_turned_off,
39  bool notify_when_speed_change,
40  std::shared_ptr<S4U_Daemon> creator,
41  std::string mailbox_to_notify,
42  std::map<std::string, std::string> property_list = {}
43  );
44 
45  void kill();
46 
47 
48  private:
49 
50  void cleanup(bool has_terminated_cleanly, int return_value) override;
51  void hostStateChangeCallback(std::string const &hostname);
52  void hostSpeedChangeCallback(std::string const &hostname);
53 
54  std::vector<std::string> hosts_to_monitor;
55  bool notify_when_turned_on;
56  bool notify_when_turned_off;
57  bool notify_when_speed_change;
58  std::string mailbox_to_notify;
59  int main() override;
60 
61  std::vector<std::pair<std::string, bool>> hosts_that_have_recently_changed_state;
62  std::vector<std::pair<std::string, double>> hosts_that_have_recently_changed_speed;
63 
64  std::shared_ptr<S4U_Daemon> creator;
65 
66  std::vector<std::string> hosts_that_have_recently_turned_on;
67  std::vector<std::string> hosts_that_have_recently_turned_off;
68 
69  unsigned int on_state_change_call_back_id;
70  unsigned int on_speed_change_call_back_id;
71 
72  };
73 
74  /***********************/
76  /***********************/
77 
78 };
79 
80 
81 
82 #endif //WRENCH_HOSTSTATECHANGEDETECTOR_H
static const std::string MONITORING_PERIOD
The monitoring period in seconds (default: 1.0)
Definition: HostStateChangeDetectorProperty.h:29
HostStateChangeDetector(std::string host_on_which_to_run, std::vector< std::string > hosts_to_monitor, bool notify_when_turned_on, bool notify_when_turned_off, bool notify_when_speed_change, std::shared_ptr< S4U_Daemon > creator, std::string mailbox_to_notify, std::map< std::string, std::string > property_list={})
Constructor.
Definition: HostStateChangeDetector.cpp:48
Definition: Alarm.cpp:20
void kill()
Kill the service.
Definition: HostStateChangeDetector.cpp:169
A service that detects and reports on host state changes (turned on, turned off)
Definition: HostStateChangeDetector.h:26
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:26
std::map< std::string, std::string > property_list
The service's property list.
Definition: Service.h:109