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);
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
void setNetworkTimeoutValue(double value)
Sets the service's network timeout value.
Definition: Service.cpp:414
std::string getPropertyValueAsString(WRENCH_PROPERTY_TYPE)
Get a property of the Service as a string.
Definition: Service.cpp:86
void start(std::shared_ptr< Service > this_service, bool daemonize, bool auto_restart)
Start the service.
Definition: Service.cpp:207
bool getPropertyValueAsBoolean(WRENCH_PROPERTY_TYPE)
Get a property of the Service as a boolean.
Definition: Service.cpp:179
double getPropertyValueAsDouble(WRENCH_PROPERTY_TYPE)
Get a property of the Service as a double.
Definition: Service.cpp:102
void assertServiceIsUp()
Throws an exception if the service is not up.
Definition: Service.cpp:422
bool isUp()
Returns true if the service is UP, false otherwise.
Definition: Service.cpp:344
Definition: Action.cpp:28
void suspend()
Suspend the service.
Definition: Service.cpp:294
virtual void stop()
Synchronously stop the service (does nothing if the service is already stopped)
Definition: Service.cpp:244
double getNetworkTimeoutValue()
Returns the service's network timeout value.
Definition: Service.cpp:405
std::string getPhysicalHostname()
Get the physical name of the host on which the service is / will be running.
Definition: Service.cpp:332
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
unsigned long getPropertyValueAsUnsignedLong(WRENCH_PROPERTY_TYPE)
Get a property of the Service as an unsigned long.
Definition: Service.cpp:128
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
std::string getHostname()
Get the name of the host on which the service is / will be running.
Definition: Service.cpp:324
void resume()
Resume the service.
Definition: Service.cpp:310