11 #ifndef WRENCH_SERVICE_H 12 #define WRENCH_SERVICE_H 18 #include <wrench/simgrid_S4U_util/S4U_Daemon.h> 36 void start(std::shared_ptr<Service> this_service,
bool daemonize,
bool auto_restart);
41 std::string getHostname();
45 std::string getPropertyValueAsString(std::string);
46 double getPropertyValueAsDouble(std::string);
47 unsigned long getPropertyValueAsUnsignedLong(std::string);
48 bool getPropertyValueAsBoolean(std::string);
50 void assertServiceIsUp();
53 double getNetworkTimeoutValue();
54 void setNetworkTimeoutValue(
double value);
64 double getMessagePayloadValue(std::string);
66 void setStateToDown();
68 static void increaseNumCompletedServicesCount();
69 static void clearTrackedServices();
70 static void cleanupTrackedServices();
86 static void assertServiceIsUp(std::shared_ptr<Service> s) { s->assertServiceIsUp(); };
92 Service(std::string hostname, std::string process_name_prefix, std::string mailbox_name_prefix);
95 void setProperty(std::string, std::string);
97 void setProperties(std::map<std::string, std::string> default_property_values,
98 std::map<std::string, std::string> overriden_property_values);
101 void setMessagePayload(std::string,
double);
103 void setMessagePayloads(std::map<std::string, double> default_messagepayload_values,
104 std::map<std::string, double> overriden_messagepayload_values);
107 void serviceSanityCheck();
110 std::map<std::string, std::string> property_list;
113 std::map<std::string, double> messagepayload_list;
121 double network_timeout = 30.0;
129 std::shared_ptr<T> getSharedPtr() {
130 if (Service::service_shared_ptr_map.find(
this) == Service::service_shared_ptr_map.end()) {
131 throw std::runtime_error(
"Service::getSharedPtr(): master shared_ptr to service not found! This should happen only " 132 "if the service has not been started, in which case this method shouldn't have been called");
134 auto shared_ptr = std::dynamic_pointer_cast<T>(Service::service_shared_ptr_map[
this]);
135 if (not shared_ptr) {
136 throw std::runtime_error(
"Service::getSharedPtr(): Invalid provided template");
148 static std::shared_ptr<T> getServiceByName(std::string name) {
149 for (
auto const &s : Service::service_shared_ptr_map) {
150 if (s.first->getName() == name) {
151 return std::dynamic_pointer_cast<T>(s.second);
160 static std::unordered_map<Service *, std::shared_ptr<Service>> service_shared_ptr_map;
162 bool shutting_down =
false;
164 static unsigned long num_terminated_services;
175 #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. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:45