10 #ifndef WRENCH_ACTION_H
11 #define WRENCH_ACTION_H
28 class Action :
public std::enable_shared_from_this<Action> {
48 const std::string &
getName()
const;
49 std::shared_ptr<CompoundJob>
getJob()
const;
60 std::set<std::shared_ptr<Action>>
getParents();
104 std::shared_ptr<Action>
getSharedPtr() {
return this->shared_from_this(); }
124 virtual ~
Action() =
default;
126 Action(
const std::string& name,
const std::string& prefix, std::shared_ptr<CompoundJob> job);
132 virtual void execute(std::shared_ptr<ActionExecutor> action_executor) = 0;
137 virtual void terminate(std::shared_ptr<ActionExecutor> action_executor) = 0;
148 std::set<Action*> parents;
149 std::set<Action*> children;
154 std::weak_ptr<CompoundJob> job;
156 std::map<std::string, std::string> service_specific_arguments;
158 static unsigned long getNewUniqueNumber();
160 std::stack<ActionExecution> execution_history;
165 #endif //WRENCH_ACTION_H
std::set< std::shared_ptr< Action > > getChildren()
Get the action's children.
Definition: Action.cpp:300
void setStartDate(double date)
Sets the action's start date.
Definition: Action.cpp:139
bool simulate_computation_as_sleep
Whether to simulate the computation as sleep.
Definition: Action.h:144
void setRAMAllocated(double ram)
Sets the action's allocated RAM.
Definition: Action.cpp:204
virtual void terminate(std::shared_ptr< ActionExecutor > action_executor)=0
Method called when the task terminates.
@ FAILED
Failed (has failed)
Definition: Action.h:45
double getEndDate() const
Returns this action's end date (-1.0 if not ended)
Definition: Action.cpp:163
std::shared_ptr< FailureCause > getFailureCause() const
Returns the action's failure cause.
Definition: Action.cpp:131
std::stack< Action::ActionExecution > & getExecutionHistory()
Retrieve the execution history.
Definition: Action.cpp:291
An action execution service that:
Definition: ActionExecutionService.h:38
virtual double getMinRAMFootprint() const
Get the minimum required amount of RAM to execute the action.
Definition: Action.cpp:283
void setThreadCreationOverhead(double overhead_in_seconds)
Set the thread creation overhead (default = zero)
Definition: Action.cpp:236
virtual void execute(std::shared_ptr< ActionExecutor > action_executor)=0
Method to execute the task.
std::shared_ptr< Action > getSharedPtr()
Get the shared pointer for this object.
Definition: Action.h:104
A data structure that keeps track of an action's execution(s)
Definition: Action.h:79
@ STARTED
Started (is being executed)
Definition: Action.h:39
@ COMPLETED
Completed (successfully completed)
Definition: Action.h:41
Action::State getState() const
Returns the action's state.
Definition: Action.cpp:71
@ NOT_READY
Not ready (not ready, because depends on other actions)
Definition: Action.h:35
Action::State state
final state
Definition: Action.h:85
A batch_standard_and_pilot_jobs-scheduled compute service that manages a set of compute hosts and con...
Definition: BatchComputeService.h:49
Definition: Action.cpp:28
virtual bool usesScratch() const
Determine whether the action uses scratch.
Definition: Action.cpp:369
virtual unsigned long getMinNumCores() const
Get the minimum number of cores required to execute the action.
Definition: Action.cpp:267
void setEndDate(double date)
Sets the action's end date.
Definition: Action.cpp:147
std::string execution_host
execution host (could be a virtual host)
Definition: Action.h:87
unsigned long num_cores_allocated
Number of allocated cores.
Definition: Action.h:91
static std::string getActionTypeAsString(const std::shared_ptr< Action > &action)
Returns an action's type as a human-readable string.
Definition: Action.cpp:341
std::set< std::shared_ptr< Action > > getParents()
Get the action's parents.
Definition: Action.cpp:312
double getPriority() const
Get the action's priority.
Definition: Action.cpp:332
std::shared_ptr< FailureCause > failure_cause
Failure cause (if applicable)
Definition: Action.h:95
double end_date
end date
Definition: Action.h:83
void updateState()
Update the action's state.
Definition: Action.cpp:243
std::shared_ptr< CompoundJob > getJob() const
Returns the job this action belongs to.
Definition: Action.cpp:112
void setFailureCause(std::shared_ptr< FailureCause > failure_cause)
Sets the action's failure cause.
Definition: Action.cpp:171
double start_date
start date
Definition: Action.h:81
void setNumCoresAllocated(unsigned long num_cores)
Sets the action's allocated number of cores.
Definition: Action.cpp:196
std::string physical_execution_host
physical execution host
Definition: Action.h:89
void setPriority(double priority)
Set the action's priority.
Definition: Action.cpp:324
void setState(Action::State new_state)
Sets the action's state to a new value.
Definition: Action.cpp:120
void setSimulateComputationAsSleep(bool simulate_computation_as_sleep)
Set whether simulation should be simulated as sleep (default = false)
Definition: Action.cpp:212
void newExecution(Action::State state)
Create a new execution data structure (e.g., after a restart)
Definition: Action.cpp:220
virtual unsigned long getMaxNumCores() const
Get the maximum number of cores that can be used to execute the action.
Definition: Action.cpp:275
Action(const std::string &name, const std::string &prefix, std::shared_ptr< CompoundJob > job)
Constructor.
Definition: Action.cpp:36
double getStartDate() const
Returns ths action's started date (-1.0 if not started)
Definition: Action.cpp:155
double ram_allocated
RAM allocated cores.
Definition: Action.h:93
std::string getStateAsString() const
Returns the action's state as a human-readable string.
Definition: Action.cpp:104
An abstract class that implements the concept of an action.
Definition: Action.h:28
void setExecutionHost(std::string host)
Sets the action's execution hosts (and the action's physical execution host)
Definition: Action.cpp:179
@ KILLED
Killed (due to user actions, service being terminated, etc.)
Definition: Action.h:43
double thread_creation_overhead
The thread creation overhead in seconds.
Definition: Action.h:142
@ READY
Ready (ready to execute)
Definition: Action.h:37
An service that performs an Action.
Definition: ActionExecutor.h:32
const std::string & getName() const
Returns the action's name.
Definition: Action.cpp:63
static std::string stateToString(Action::State state)
Convert an action state to a human-readable string.
Definition: Action.cpp:80
A compound job.
Definition: CompoundJob.h:47
State
Action states.
Definition: Action.h:33