WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
Service.h
1 
11 #ifndef WRENCH_SERVICE_H
12 #define WRENCH_SERVICE_H
13 
14 
15 #include <string>
16 #include <map>
17 #include <memory>
18 
19 #include "wrench/simgrid_S4U_util/S4U_Daemon.h"
20 #include "wrench/services/ServiceProperty.h"
21 #include "wrench/services/ServiceMessagePayload.h"
22 namespace wrench {
23  typedef std::map<WRENCH_PROPERTY_TYPE,std::string> WRENCH_PROPERTY_COLLECTION_TYPE;
24  typedef std::unordered_map<WRENCH_MESSAGEPAYLOAD_TYPE ,double> WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE;
25  class FailureCause;
26 
31 class Service : public S4U_Daemon, public std::enable_shared_from_this<Service> {
32 
33  public:
34 
35  /***********************/
37  /***********************/
38 
39  void start(std::shared_ptr<Service> this_service, bool daemonize, bool auto_restart);
40  virtual void stop();
41  void suspend();
42  void resume();
43 
44  std::string getHostname();
45  std::string getPhysicalHostname();
46 
47  bool isUp();
48 
49  std::string getPropertyValueAsString(WRENCH_PROPERTY_TYPE);
50  double getPropertyValueAsDouble(WRENCH_PROPERTY_TYPE);
51  unsigned long getPropertyValueAsUnsignedLong(WRENCH_PROPERTY_TYPE);
52  bool getPropertyValueAsBoolean(WRENCH_PROPERTY_TYPE);
53 
54  void assertServiceIsUp();
55 
56  double getNetworkTimeoutValue();
57  void setNetworkTimeoutValue(double value);
58 
59  /***********************/
61  /***********************/
62 
63  /***********************/
65  /***********************/
66 
67  double getMessagePayloadValue(WRENCH_MESSAGEPAYLOAD_TYPE);
68  const WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE& getMessagePayloadList() const;
69 
70  void setStateToDown();
71 
72  /***********************/
74  /***********************/
75 
76  protected:
77 
78  /***********************/
80  /***********************/
81 
86  static void assertServiceIsUp(std::shared_ptr<Service> s) { s->assertServiceIsUp(); };
87 
88  friend class Simulation;
89 
90  ~Service() override;
91 
92  Service(std::string hostname, std::string process_name_prefix);
93 
94  // Property stuff
95  void setProperty(WRENCH_PROPERTY_TYPE, const std::string&);
96 
97  void setProperties(WRENCH_PROPERTY_COLLECTION_TYPE default_property_values,
98  WRENCH_PROPERTY_COLLECTION_TYPE overriden_property_values);
99 
100  // MessagePayload stuff
101  void setMessagePayload(WRENCH_MESSAGEPAYLOAD_TYPE, double);
102 
103  void setMessagePayloads(WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE default_messagepayload_values,
104  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE overriden_messagepayload_values);
105 
106 
107  void serviceSanityCheck();
108 
110  WRENCH_PROPERTY_COLLECTION_TYPE property_list;
111 
113  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list;
114 
116  std::string name;
117 
121  double network_timeout = 30.0;
122 
128  template <class T>
129  std::shared_ptr<T> getSharedPtr() {
130  return std::dynamic_pointer_cast<T>(this->shared_from_this());
131  }
132 
133 
135  bool shutting_down = false;
136 
137  private:
138 
139  /***********************/
141  /***********************/
142 
143  };
144 };
145 
146 
147 #endif //WRENCH_SERVICE_H
wrench
Definition: Action.cpp:28
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
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