Service.h
1 
11 #ifndef WRENCH_SERVICE_H
12 #define WRENCH_SERVICE_H
13 
14 
15 #include <string>
16 #include <map>
17 
18 #include <wrench/simgrid_S4U_util/S4U_Daemon.h>
19 
20 namespace wrench {
21 
26  class Service : public S4U_Daemon {
27 
28  public:
29 
30  /***********************/
32  /***********************/
33 
35  enum State {
37  UP,
39  DOWN,
40  };
41 
42  void start(std::shared_ptr<Service> this_service, bool daemonize, bool auto_restart);
43 
44  virtual void stop();
45 
46  std::string getHostname();
47 
48  bool isUp();
49 
50  std::string getPropertyValueAsString(std::string);
51 
52  double getPropertyValueAsDouble(std::string);
53 
54  bool getPropertyValueAsBoolean(std::string);
55 
56  double getNetworkTimeoutValue();
57 
58  void setNetworkTimeoutValue(double value);
59 
60  /***********************/
62  /***********************/
63 
64  /***********************/
66  /***********************/
67 
68  std::string getMessagePayloadValueAsString(std::string);
69 
70  double getMessagePayloadValueAsDouble(std::string);
71 
72  void setStateToDown();
73 
74  /***********************/
76  /***********************/
77 
78  protected:
79 
80  /***********************/
82  /***********************/
83 
84  friend class Simulation;
85 
86  Service(std::string hostname, std::string process_name_prefix, std::string mailbox_name_prefix);
87 
88  // Property stuff
89  void setProperty(std::string, std::string);
90 
91  void setProperties(std::map<std::string, std::string> default_property_values,
92  std::map<std::string, std::string> overriden_property_values);
93 
94  // MessagePayload stuff
95  void setMessagePayload(std::string, std::string);
96 
97  void setMessagePayloads(std::map<std::string, std::string> default_messagepayload_values,
98  std::map<std::string, std::string> overriden_messagepayload_values);
99 
100 
101  void serviceSanityCheck();
102 
104  std::map<std::string, std::string> property_list;
105 
107  std::map<std::string, std::string> messagepayload_list;
108 
109 
111  State state;
112 
114  std::string name;
115 
119  double network_timeout = 30.0;
120 
121  private:
122  bool shutting_down = false;
123 
124  /***********************/
126  /***********************/
127 
128  };
129 };
130 
131 
132 #endif //WRENCH_SERVICE_H
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
A class that provides basic simulation methods.
Definition: Simulation.h:34
Definition: TerminalOutput.cpp:15