WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
wrench::Action Class Referenceabstract

An abstract class that implements the concept of an action. More...

#include <Action.h>

Inheritance diagram for wrench::Action:
wrench::ComputeAction wrench::CustomAction wrench::FileCopyAction wrench::FileDeleteAction wrench::FileReadAction wrench::FileRegistryAction wrench::FileWriteAction wrench::SleepAction

Classes

struct  ActionExecution
 A data structure that keeps track of an action's execution(s) More...
 

Public Types

enum  State {
  NOT_READY, READY, STARTED, COMPLETED,
  KILLED, FAILED
}
 Action states. More...
 

Public Member Functions

std::set< std::shared_ptr< Action > > getChildren ()
 Get the action's children. More...
 
double getEndDate () const
 Returns this action's end date (-1.0 if not ended) More...
 
std::stack< Action::ActionExecution > & getExecutionHistory ()
 Retrieve the execution history. More...
 
std::shared_ptr< FailureCausegetFailureCause () const
 Returns the action's failure cause. More...
 
std::shared_ptr< CompoundJobgetJob () const
 Returns the job this action belongs to. More...
 
virtual unsigned long getMaxNumCores () const
 Get the maximum number of cores that can be used to execute the action. More...
 
virtual unsigned long getMinNumCores () const
 Get the minimum number of cores required to execute the action. More...
 
virtual double getMinRAMFootprint () const
 Get the minimum required amount of RAM to execute the action. More...
 
const std::string & getName () const
 Returns the action's name. More...
 
std::set< std::shared_ptr< Action > > getParents ()
 Get the action's parents. More...
 
double getPriority () const
 Get the action's priority. More...
 
std::shared_ptr< ActiongetSharedPtr ()
 Get the shared pointer for this object. More...
 
double getStartDate () const
 Returns ths action's started date (-1.0 if not started) More...
 
Action::State getState () const
 Returns the action's state. More...
 
std::string getStateAsString () const
 Returns the action's state as a human-readable string. More...
 
void setPriority (double priority)
 Set the action's priority. More...
 
void setSimulateComputationAsSleep (bool simulate_computation_as_sleep)
 Set whether simulation should be simulated as sleep (default = false) More...
 
void setThreadCreationOverhead (double overhead_in_seconds)
 Set the thread creation overhead (default = zero) More...
 
virtual bool usesScratch () const
 Determine whether the action uses scratch. More...
 

Static Public Member Functions

static std::string getActionTypeAsString (const std::shared_ptr< Action > &action)
 Returns an action's type as a human-readable string. More...
 
static std::string stateToString (Action::State state)
 Convert an action state to a human-readable string. More...
 

Protected Member Functions

 Action (const std::string &name, const std::string &prefix, std::shared_ptr< CompoundJob > job)
 Constructor. More...
 
virtual void execute (std::shared_ptr< ActionExecutor > action_executor)=0
 Method to execute the task. More...
 
void newExecution (Action::State state)
 Create a new execution data structure (e.g., after a restart) More...
 
void setEndDate (double date)
 Sets the action's end date. More...
 
void setExecutionHost (std::string host)
 Sets the action's execution hosts (and the action's physical execution host) More...
 
void setFailureCause (std::shared_ptr< FailureCause > failure_cause)
 Sets the action's failure cause. More...
 
void setNumCoresAllocated (unsigned long num_cores)
 Sets the action's allocated number of cores. More...
 
void setRAMAllocated (double ram)
 Sets the action's allocated RAM. More...
 
void setStartDate (double date)
 Sets the action's start date. More...
 
void setState (Action::State new_state)
 Sets the action's state to a new value. More...
 
virtual void terminate (std::shared_ptr< ActionExecutor > action_executor)=0
 Method called when the task terminates. More...
 
void updateState ()
 Update the action's state.
 

Protected Attributes

bool simulate_computation_as_sleep
 Whether to simulate the computation as sleep.
 
double thread_creation_overhead
 The thread creation overhead in seconds.
 

Detailed Description

An abstract class that implements the concept of an action.

Member Enumeration Documentation

◆ State

Action states.

Enumerator
NOT_READY 

Not ready (not ready, because depends on other actions)

READY 

Ready (ready to execute)

STARTED 

Started (is being executed)

COMPLETED 

Completed (successfully completed)

KILLED 

Killed (due to user actions, service being terminated, etc.)

FAILED 

Failed (has failed)

Constructor & Destructor Documentation

◆ Action()

wrench::Action::Action ( const std::string &  name,
const std::string &  prefix,
std::shared_ptr< CompoundJob job 
)
protected

Constructor.

Parameters
namethe action's name (if empty, a unique name will be picked)
prefixthe action's name prefix (if name is empty)
jobthe job that contains this action

Member Function Documentation

◆ execute()

virtual void wrench::Action::execute ( std::shared_ptr< ActionExecutor action_executor)
protectedpure virtual

Method to execute the task.

Parameters
action_executorthe executor that executes this action

Implemented in wrench::FileRegistryAction, wrench::ComputeAction, wrench::FileCopyAction, wrench::FileReadAction, wrench::CustomAction, wrench::FileDeleteAction, wrench::FileWriteAction, and wrench::SleepAction.

◆ getActionTypeAsString()

std::string wrench::Action::getActionTypeAsString ( const std::shared_ptr< Action > &  action)
static

Returns an action's type as a human-readable string.

Parameters
actionthe action
Returns
the type as a string

◆ getChildren()

std::set< std::shared_ptr< Action > > wrench::Action::getChildren ( )

Get the action's children.

Returns
a set of children

◆ getEndDate()

double wrench::Action::getEndDate ( ) const

Returns this action's end date (-1.0 if not ended)

Returns
a data

◆ getExecutionHistory()

std::stack< Action::ActionExecution > & wrench::Action::getExecutionHistory ( )

Retrieve the execution history.

Returns
the execution history

◆ getFailureCause()

std::shared_ptr< FailureCause > wrench::Action::getFailureCause ( ) const

Returns the action's failure cause.

Returns
an internal state

◆ getJob()

std::shared_ptr< CompoundJob > wrench::Action::getJob ( ) const

Returns the job this action belongs to.

Returns
the job

◆ getMaxNumCores()

unsigned long wrench::Action::getMaxNumCores ( ) const
virtual

Get the maximum number of cores that can be used to execute the action.

Returns
a number of cores

Reimplemented in wrench::CustomAction, and wrench::ComputeAction.

◆ getMinNumCores()

unsigned long wrench::Action::getMinNumCores ( ) const
virtual

Get the minimum number of cores required to execute the action.

Returns
a number of cores

Reimplemented in wrench::CustomAction, and wrench::ComputeAction.

◆ getMinRAMFootprint()

double wrench::Action::getMinRAMFootprint ( ) const
virtual

Get the minimum required amount of RAM to execute the action.

Returns
a number of bytes

Reimplemented in wrench::CustomAction, and wrench::ComputeAction.

◆ getName()

const std::string & wrench::Action::getName ( ) const

Returns the action's name.

Returns
the name

◆ getParents()

std::set< std::shared_ptr< Action > > wrench::Action::getParents ( )

Get the action's parents.

Returns
a set of parents

◆ getPriority()

double wrench::Action::getPriority ( ) const

Get the action's priority.

Returns
a priority

◆ getSharedPtr()

std::shared_ptr<Action> wrench::Action::getSharedPtr ( )
inline

Get the shared pointer for this object.

Returns
a shared pointer to the object

◆ getStartDate()

double wrench::Action::getStartDate ( ) const

Returns ths action's started date (-1.0 if not started)

Returns
a data

◆ getState()

Action::State wrench::Action::getState ( ) const

Returns the action's state.

Returns
the state

◆ getStateAsString()

std::string wrench::Action::getStateAsString ( ) const

Returns the action's state as a human-readable string.

Returns
a string

◆ newExecution()

void wrench::Action::newExecution ( Action::State  state)
protected

Create a new execution data structure (e.g., after a restart)

Parameters
statethe action state

◆ setEndDate()

void wrench::Action::setEndDate ( double  date)
protected

Sets the action's end date.

Parameters
datethe date

◆ setExecutionHost()

void wrench::Action::setExecutionHost ( std::string  host)
protected

Sets the action's execution hosts (and the action's physical execution host)

Parameters
hosta hostname

◆ setFailureCause()

void wrench::Action::setFailureCause ( std::shared_ptr< FailureCause failure_cause)
protected

Sets the action's failure cause.

Parameters
failure_causethe failure cause

◆ setNumCoresAllocated()

void wrench::Action::setNumCoresAllocated ( unsigned long  num_cores)
protected

Sets the action's allocated number of cores.

Parameters
num_coresa number of cores

◆ setPriority()

void wrench::Action::setPriority ( double  priority)

Set the action's priority.

Parameters
prioritya priority

◆ setRAMAllocated()

void wrench::Action::setRAMAllocated ( double  ram)
protected

Sets the action's allocated RAM.

Parameters
rama number of bytes

◆ setSimulateComputationAsSleep()

void wrench::Action::setSimulateComputationAsSleep ( bool  simulate_computation_as_sleep)

Set whether simulation should be simulated as sleep (default = false)

Parameters
simulate_computation_as_sleeptrue or false

◆ setStartDate()

void wrench::Action::setStartDate ( double  date)
protected

Sets the action's start date.

Parameters
datethe date

◆ setState()

void wrench::Action::setState ( Action::State  new_state)
protected

Sets the action's state to a new value.

Parameters
new_statethe new state

◆ setThreadCreationOverhead()

void wrench::Action::setThreadCreationOverhead ( double  overhead_in_seconds)

Set the thread creation overhead (default = zero)

Parameters
overhead_in_secondsoverhead in seconds

◆ stateToString()

std::string wrench::Action::stateToString ( Action::State  state)
static

Convert an action state to a human-readable string.

Parameters
statean action state
Returns
a string

◆ terminate()

virtual void wrench::Action::terminate ( std::shared_ptr< ActionExecutor action_executor)
protectedpure virtual

Method called when the task terminates.

Parameters
action_executorthe executor that executes this action

Implemented in wrench::FileRegistryAction, wrench::ComputeAction, wrench::FileCopyAction, wrench::FileReadAction, wrench::CustomAction, wrench::FileDeleteAction, wrench::FileWriteAction, and wrench::SleepAction.

◆ usesScratch()

bool wrench::Action::usesScratch ( ) const
virtual

Determine whether the action uses scratch.

Returns
true if the action uses scratch, false otherwise

Reimplemented in wrench::FileCopyAction, wrench::FileReadAction, wrench::FileDeleteAction, and wrench::FileWriteAction.


The documentation for this class was generated from the following files: