11 #ifndef WRENCH_SERVICE_H
12 #define WRENCH_SERVICE_H
19 #include "wrench/simgrid_S4U_util/S4U_Daemon.h"
20 #include "wrench/services/ServiceProperty.h"
21 #include "wrench/services/ServiceMessagePayload.h"
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;
31 class Service :
public S4U_Daemon,
public std::enable_shared_from_this<Service> {
39 void start(std::shared_ptr<Service> this_service,
bool daemonize,
bool auto_restart);
44 std::string getHostname();
45 std::string getPhysicalHostname();
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);
54 void assertServiceIsUp();
56 double getNetworkTimeoutValue();
57 void setNetworkTimeoutValue(
double value);
67 double getMessagePayloadValue(WRENCH_MESSAGEPAYLOAD_TYPE);
68 const WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE& getMessagePayloadList()
const;
70 void setStateToDown();
86 static void assertServiceIsUp(std::shared_ptr<Service> s) { s->assertServiceIsUp(); };
92 Service(std::string hostname, std::string process_name_prefix);
95 void setProperty(WRENCH_PROPERTY_TYPE,
const std::string&);
97 void setProperties(WRENCH_PROPERTY_COLLECTION_TYPE default_property_values,
98 WRENCH_PROPERTY_COLLECTION_TYPE overriden_property_values);
101 void setMessagePayload(WRENCH_MESSAGEPAYLOAD_TYPE,
double);
103 void setMessagePayloads(WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE default_messagepayload_values,
104 WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE overriden_messagepayload_values);
107 void serviceSanityCheck();
110 WRENCH_PROPERTY_COLLECTION_TYPE property_list;
113 WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list;
121 double network_timeout = 30.0;
129 std::shared_ptr<T> getSharedPtr() {
130 return std::dynamic_pointer_cast<T>(this->shared_from_this());
135 bool shutting_down =
false;
147 #endif //WRENCH_SERVICE_H