WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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  WRENCH_PROPERTY_COLLECTION_TYPE 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  simgrid::s4u::Mailbox *mailbox_to_notify,
42  WRENCH_PROPERTY_COLLECTION_TYPE 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  simgrid::s4u::Mailbox *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
wrench::Service::property_list
WRENCH_PROPERTY_COLLECTION_TYPE property_list
The service's property list.
Definition: Service.h:110
wrench::HostStateChangeDetectorProperty::MONITORING_PERIOD
static const std::string MONITORING_PERIOD
The monitoring period in seconds (default: 1.0)
Definition: HostStateChangeDetectorProperty.h:29
wrench
Definition: Action.cpp:28
wrench::HostStateChangeDetector::kill
void kill()
Kill the service.
Definition: HostStateChangeDetector.cpp:160
wrench::HostStateChangeDetector
A service that detects and reports on host state changes (turned on, turned off)
Definition: HostStateChangeDetector.h:26
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:60
wrench::Service
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:31
wrench::HostStateChangeDetector::HostStateChangeDetector
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, simgrid::s4u::Mailbox *mailbox_to_notify, WRENCH_PROPERTY_COLLECTION_TYPE property_list={})
Constructor.
Definition: HostStateChangeDetector.cpp:49