wrench::S4U_Daemon
-
class S4U_Daemon : public std::enable_shared_from_this<S4U_Daemon>
A generic “running daemon” abstraction that serves as a basis for all simulated processes.
Subclassed by wrench::Service
Public Types
-
enum State
Daemon states.
Values:
-
enumerator CREATED
CREATED state: the daemon has been created but not started.
-
enumerator UP
UP state: the daemon has been started and is still running.
-
enumerator DOWN
DOWN state: the daemon has been shutdown and/or has terminated.
-
enumerator SUSPENDED
SUSPENDED state: the daemon has been suspended (and hopefully will be resumed0.
-
enumerator CREATED
Public Functions
-
S4U_Daemon(const std::string &hostname, const std::string &process_name_prefix)
Constructor (daemon with a commport)
- Parameters:
hostname – the name of the host on which the daemon will run
process_name_prefix – the prefix of the name of the simulated process/actor
-
virtual ~S4U_Daemon()
Destructor.
-
void acquireDaemonLock()
Method to acquire the daemon’s lock.
Lock the daemon’s lock.
-
virtual void cleanup(bool has_returned_from_main, int return_value)
Cleanup function called when the daemon terminates (for whatever reason). The default behavior is to throw an exception if the host is off. This method should be overriden in a daemons implements some fault-tolerant behavior, or is naturally tolerant.
- Parameters:
has_returned_from_main – whether the daemon returned from main() by itself
return_value – the return value from main (if has_terminated_cleanly is true)
- Throws:
std::runtime_error –
Create a life saver for the daemon.
- Parameters:
reference –
-
void deleteLifeSaver()
Delete the daemon’s life-saver (use at your own risks, if your not the Simulation class)
-
std::string getName() const
Retrieve the process name.
- Returns:
the name
-
int getReturnValue() const
Returns the value returned by main() (if the daemon has returned from main)
- Returns:
The return value
-
Simulation *getSimulation()
Get the service’s simulation.
- Returns:
a simulation
-
S4U_Daemon::State getState()
Get the daemon’s state.
- Returns:
a state
-
bool hasReturnedFromMain() const
Returns true if the daemon has returned from main() (i.e., not brutally killed)
- Returns:
The true or false
-
bool isDaemonized() const
Return the daemonized status of the daemon.
- Returns:
true or false
-
bool isSetToAutoRestart() const
Return the auto-restart status of the daemon.
- Returns:
true or false
-
std::pair<bool, int> join()
Join (i.e., wait for) the daemon.
-
bool killActor()
Kill the daemon/actor (does nothing if already dead)
- Throws:
std::shared_ptr<FatalFailure> –
- Returns:
true if actor was killed, false if not (e.g., daemon was already dead)
-
virtual int main() = 0
The daemon’s main method, to be overridden.
- Returns:
0 on success, non-0 on failure!
-
void releaseDaemonLock()
Method to release the daemon’s lock.
Unlock the daemon’s lock.
-
void resumeActor()
Resume the daemon/actor.
-
void setSimulation(Simulation *simulation)
Set the service’s simulation.
- Parameters:
simulation – a simulation
-
void setupOnExitFunction()
Sets up the on_exit function for the actor.
-
void startDaemon(bool _daemonized, bool _auto_restart)
Start the daemon.
- Parameters:
daemonized – whether the S4U actor should be daemonized
auto_restart – whether the S4U actor should automatically restart after a host reboot
- Throws:
std::runtime_error –
std::shared_ptr<HostError> –
-
void suspendActor()
Suspend the daemon/actor.
Public Members
-
S4U_CommPort *commport
The daemon’s commport_name.
-
std::string hostname
The name of the host on which the daemon is running.
-
std::string process_name
The name of the daemon.
-
S4U_CommPort *recv_commport
The daemon’s receive commport_name (to send to another daemon so that that daemon can reply)
Public Static Functions
-
static S4U_CommPort *getRunningActorRecvCommPort()
Return the running actor’s recv commport.
- Returns:
the commport
Public Static Attributes
-
static std::unordered_map<aid_t, std::set<simgrid::s4u::MutexPtr>> map_actor_to_held_mutexes
A map of actors to sets of held mutexes.
-
static std::unordered_map<aid_t, S4U_CommPort*> map_actor_to_recv_commport
A convenient map between actors and their default receive commports.
-
enum State