WRENCH
1.11
Cyberinfrastructure Simulation Workbench
|
Overview | Installation | Getting Started | WRENCH 101 | WRENCH 102 |
A generic "running daemon" abstraction that serves as a basis for all simulated processes. More...
#include <S4U_Daemon.h>
Public Types | |
enum | State { UP, DOWN, SUSPENDED } |
Daemon states. More... | |
Public Member Functions | |
S4U_Daemon (std::string hostname, std::string process_name_prefix) | |
Constructor (daemon with a mailbox) More... | |
void | acquireDaemonLock () |
Method to acquire the daemon's lock. More... | |
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. More... | |
void | createLifeSaver (std::shared_ptr< S4U_Daemon > reference) |
Create a life saver for the daemon. More... | |
std::string | getName () |
Retrieve the process name. More... | |
int | getReturnValue () |
Returns the value returned by main() (if the daemon has returned from main) More... | |
Simulation * | getSimulation () |
Get the service's simulation. More... | |
S4U_Daemon::State | getState () |
Get the daemon's state. More... | |
bool | hasReturnedFromMain () |
Returns true if the daemon has returned from main() (i.e., not brutally killed) More... | |
bool | isDaemonized () |
Return the daemonized status of the daemon. More... | |
bool | isSetToAutoRestart () |
Return the auto-restart status of the daemon. More... | |
std::pair< bool, int > | join () |
Join (i.e., wait for) the daemon. More... | |
virtual int | main ()=0 |
The daemon's main method, to be overridden. More... | |
void | releaseDaemonLock () |
Method to release the daemon's lock. More... | |
void | resumeActor () |
Resume the daemon/actor. | |
void | setSimulation (Simulation *simulation) |
Set the service's simulation. More... | |
void | setupOnExitFunction () |
Sets up the on_exit function for the actor. | |
void | startDaemon (bool _daemonized, bool _auto_restart) |
Start the daemon. More... | |
void | suspendActor () |
Suspend the daemon/actor. | |
Static Public Member Functions | |
static simgrid::s4u::Mailbox * | getRunningActorRecvMailbox () |
Return the running actor's recv mailbox. More... | |
Public Attributes | |
std::string | hostname |
The name of the host on which the daemon is running. | |
LifeSaver * | life_saver = nullptr |
The daemon's life saver. | |
simgrid::s4u::Mailbox * | mailbox |
The daemon's mailbox. | |
std::string | process_name |
The name of the daemon. | |
simgrid::s4u::Mailbox * | recv_mailbox |
The daemon's receive mailbox (to send to another daemon so that that daemon can reply) | |
Static Public Attributes | |
static std::unordered_map< aid_t, simgrid::s4u::Mailbox * > | map_actor_to_recv_mailbox |
Protected Member Functions | |
bool | killActor () |
Kill the daemon/actor (does nothing if already dead) More... | |
void | runMainMethod () |
Method that run's the user-defined main method (that's called by the S4U actor class) | |
Protected Attributes | |
unsigned int | num_starts = 0 |
The number of time that this daemon has started (i.e., 1 + number of restarts) | |
Simulation * | simulation |
a pointer to the simulation object | |
State | state |
The service's state. | |
A generic "running daemon" abstraction that serves as a basis for all simulated processes.
wrench::S4U_Daemon::S4U_Daemon | ( | std::string | hostname, |
std::string | process_name_prefix | ||
) |
Constructor (daemon with a mailbox)
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 |
void wrench::S4U_Daemon::acquireDaemonLock | ( | ) |
Method to acquire the daemon's lock.
Lock the daemon's lock.
|
virtual |
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.
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) |
std::runtime_error |
Reimplemented in wrench::BareMetalComputeService, wrench::SimpleStorageService, wrench::FileTransferThread, wrench::ActionExecutor, and wrench::ComputeThread.
void wrench::S4U_Daemon::createLifeSaver | ( | std::shared_ptr< S4U_Daemon > | reference | ) |
Create a life saver for the daemon.
reference |
std::string wrench::S4U_Daemon::getName | ( | ) |
Retrieve the process name.
int wrench::S4U_Daemon::getReturnValue | ( | ) |
Returns the value returned by main() (if the daemon has returned from main)
|
static |
Return the running actor's recv mailbox.
Simulation * wrench::S4U_Daemon::getSimulation | ( | ) |
Get the service's simulation.
S4U_Daemon::State wrench::S4U_Daemon::getState | ( | ) |
Get the daemon's state.
bool wrench::S4U_Daemon::hasReturnedFromMain | ( | ) |
Returns true if the daemon has returned from main() (i.e., not brutally killed)
bool wrench::S4U_Daemon::isDaemonized | ( | ) |
Return the daemonized status of the daemon.
bool wrench::S4U_Daemon::isSetToAutoRestart | ( | ) |
Return the auto-restart status of the daemon.
std::pair< bool, int > wrench::S4U_Daemon::join | ( | ) |
|
protected |
Kill the daemon/actor (does nothing if already dead)
std::shared_ptr<FatalFailure> |
|
pure virtual |
The daemon's main method, to be overridden.
Implemented in wrench::BareMetalComputeService, wrench::CloudComputeService, wrench::VirtualizedClusterComputeService, wrench::FileTransferThread, wrench::ActionExecutor, wrench::WorkloadTraceFileReplayerEventReceiver, and wrench::ComputeThread.
void wrench::S4U_Daemon::releaseDaemonLock | ( | ) |
Method to release the daemon's lock.
Unlock the daemon's lock.
void wrench::S4U_Daemon::setSimulation | ( | Simulation * | simulation | ) |
Set the service's simulation.
simulation | a simulation |
void wrench::S4U_Daemon::startDaemon | ( | bool | daemonized, |
bool | auto_restart | ||
) |
Start the daemon.
daemonized | whether the S4U actor should be daemonized |
auto_restart | whether the S4U actor should automatically restart after a host reboot |
std::runtime_error | |
std::shared_ptr<HostError> |