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

A compound job. More...

#include <CompoundJob.h>

Inheritance diagram for wrench::CompoundJob:
wrench::Job

Public Types

enum  State { NOT_SUBMITTED, SUBMITTED, COMPLETED, DISCONTINUED }
 Compound job states. More...
 

Public Member Functions

void addActionDependency (const std::shared_ptr< Action > &parent, const std::shared_ptr< Action > &child)
 Add a dependency between two actions (does nothing if dependency already exists) More...
 
void addChildJob (const std::shared_ptr< CompoundJob > &child)
 Add a child job to this job (be careful not to add circular dependencies, which may lead to deadlocks) More...
 
std::shared_ptr< ComputeActionaddComputeAction (std::string name, double flops, double ram, unsigned long min_num_cores, unsigned long max_num_cores, std::shared_ptr< ParallelModel > parallel_model)
 Add a compute action to the job. More...
 
std::shared_ptr< CustomActionaddCustomAction (std::string name, double ram, unsigned long num_cores, const std::function< void(std::shared_ptr< ActionExecutor > action_executor)> &lambda_execute, const std::function< void(std::shared_ptr< ActionExecutor > action_executor)> &lambda_terminate)
 Add a custom action to the job. More...
 
std::shared_ptr< FileCopyActionaddFileCopyAction (std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > src_file_location, std::shared_ptr< FileLocation > dst_file_location)
 Add a file copy action to the job. More...
 
std::shared_ptr< FileDeleteActionaddFileDeleteAction (std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
 Add a file delete action to the job. More...
 
std::shared_ptr< FileReadActionaddFileReadAction (std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
 Add a file read action to the job. More...
 
std::shared_ptr< FileReadActionaddFileReadAction (std::string name, std::shared_ptr< DataFile >file, std::vector< std::shared_ptr< FileLocation >> file_locations)
 Add a file read action to the job. More...
 
std::shared_ptr< FileRegistryAddEntryActionaddFileRegistryAddEntryAction (std::shared_ptr< FileRegistryService > file_registry, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
 Add a file registry add entry action. More...
 
std::shared_ptr< FileRegistryDeleteEntryActionaddFileRegistryDeleteEntryAction (std::shared_ptr< FileRegistryService > file_registry, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
 Add a file registry add entry action. More...
 
std::shared_ptr< FileWriteActionaddFileWriteAction (std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
 Add a file write action to the job. More...
 
void addParentJob (const std::shared_ptr< CompoundJob > &parent)
 Add a parent job to this job (be careful not to add circular dependencies, which may lead to deadlocks) More...
 
std::shared_ptr< SleepActionaddSleepAction (std::string name, double sleep_time)
 Add a sleep action to the job. More...
 
std::set< std::shared_ptr< Action > > getActions ()
 Get the job's actions. More...
 
std::set< std::shared_ptr< CompoundJob > > getChildrenJobs ()
 Get the job's children. More...
 
double getMinimumRequiredMemory ()
 Get the minimum required amount of memory to run the job. More...
 
unsigned long getMinimumRequiredNumCores ()
 Get the minimum required num cores to run the job. More...
 
std::set< std::shared_ptr< CompoundJob > > getParentJobs ()
 Get the job's parents. More...
 
std::shared_ptr< CompoundJobgetSharedPtr ()
 Get the shared pointer for this object. More...
 
CompoundJob::State getState ()
 Get the state of the standard job. More...
 
std::string getStateAsString ()
 Get the state of the standard job. More...
 
bool hasFailed ()
 Return whether the job has terminated and has done so with some tasks having failed. More...
 
bool hasSuccessfullyCompleted ()
 Return whether the job has terminated and has done so successfully. More...
 
void printActionDependencies ()
 Print the list of actions with their children and parents.
 
void printTaskMap ()
 Print the task map.
 
void removeAction (std::shared_ptr< Action > &action)
 Remove an action from the job. More...
 
void setPriority (double priority) override
 Set the job's priority (the higher the priority value, the higher the priority) More...
 
bool usesScratch ()
 Determine whether the job uses scratch. More...
 
- Public Member Functions inherited from wrench::Job
virtual ~Job ()
 Destructor.
 
simgrid::s4u::Mailbox * getCallbackMailbox ()
 Get the job's "next" callback mailbox, without popping it. More...
 
double getEndDate ()
 Get the date at which the job ended (<0 means "never submitted") More...
 
std::string getName ()
 Get the job's name. More...
 
simgrid::s4u::Mailbox * getOriginCallbackMailbox ()
 Get the "origin" callback mailbox. More...
 
std::shared_ptr< ComputeServicegetParentComputeService ()
 Get the compute service that is running /ran the job. More...
 
double getPriority () const
 Get the job's priority (the higher the priority value, the higher the priority) More...
 
std::map< std::string, std::string > & getServiceSpecificArguments ()
 Return the service-specific arguments that are used during job submission. More...
 
double getSubmitDate ()
 Get the date at which the job was last submitted (<0 means "never submitted") More...
 
simgrid::s4u::Mailbox * popCallbackMailbox ()
 Get the "next" callback mailbox (returns the workflow mailbox if the mailbox stack is empty), and pops it. More...
 
void printCallbackMailboxStack ()
 Method to print the call back stack.
 
void pushCallbackMailbox (simgrid::s4u::Mailbox *mailbox)
 Pushes a callback mailbox. More...
 
void setParentComputeService (std::shared_ptr< ComputeService > compute_service)
 Set the parent compute service of the job. More...
 

Protected Member Functions

 CompoundJob (std::string name, std::shared_ptr< JobManager > job_manager)
 Constructor. More...
 
std::set< std::shared_ptr< CompoundJob > > & getChildren ()
 Returns the job's child jobs, if any. More...
 
std::set< std::shared_ptr< CompoundJob > > & getParents ()
 Returns the job's parent jobs, if any. More...
 
bool hasAction (const std::string &name)
 Determine whether an action with a given name exists in job. More...
 
bool isReady ()
 Get the readiness of the job. More...
 
void setAllActionsFailed (const std::shared_ptr< FailureCause > &cause)
 Set all actions to FAILED for the same failure cause (e.g., a job-level failure) More...
 
void updateStateActionMap (const std::shared_ptr< Action > &action, Action::State old_state, Action::State new_state)
 Update the internal State-Action map. More...
 
- Protected Member Functions inherited from wrench::Job
 Job (std::string name, std::shared_ptr< JobManager > job_manager)
 Constructor. More...
 
unsigned long getNewUniqueNumber ()
 Generate a unique number (for each newly generated job) More...
 
void setServiceSpecificArguments (std::map< std::string, std::string > args)
 Sets the service-specific arguments that are used during job submission. More...
 

Protected Attributes

std::set< std::shared_ptr< Action > > actions
 
std::map< std::string, std::shared_ptr< Action > > name_map
 
double priority
 
State state
 
- Protected Attributes inherited from wrench::Job
bool already_submitted_to_job_manager = false
 Whether the job has already been submitted to the job manager.
 
std::stack< simgrid::s4u::Mailbox * > callback_mailbox_stack
 Stack of callback mailboxes (to pop notifications)
 
double end_date
 The date at which the job ended (with success or failure)
 
std::shared_ptr< JobManagerjob_manager
 The Job Manager in charge of this job.
 
std::string name
 The job's name.
 
simgrid::s4u::Mailbox * originator_mailbox
 The originator's mailbox.
 
std::shared_ptr< ComputeServiceparent_compute_service
 The compute service to which the job was submitted.
 
double priority = 0.0
 The job's priority (the higher the number, the higher the priority)
 
std::map< std::string, std::string > service_specific_args
 Service-specific arguments used during job submission.
 
double submit_date
 The date at which the job was last submitted.
 

Detailed Description

A compound job.

Member Enumeration Documentation

◆ State

Compound job states.

Enumerator
NOT_SUBMITTED 

Job hasn't been submitted yet.

SUBMITTED 

Job has been submitted to a JobManager.

COMPLETED 

Job has finished executing and all actions were successfully completed.

DISCONTINUED 

Job has finished executing but not all actions were successfully completed. Actions may have failed, the job may have been terminated/killed, or parent jobs may have been discontinued.

Constructor & Destructor Documentation

◆ CompoundJob()

wrench::CompoundJob::CompoundJob ( std::string  name,
std::shared_ptr< JobManager job_manager 
)
protected

Constructor.

Parameters
namethe job's name (if empty, a unique name will be chosen for you)
job_managerthe Job Manager in charge of this job
Exceptions
std::invalid_argument

Member Function Documentation

◆ addActionDependency()

void wrench::CompoundJob::addActionDependency ( const std::shared_ptr< Action > &  parent,
const std::shared_ptr< Action > &  child 
)

Add a dependency between two actions (does nothing if dependency already exists)

Parameters
parentthe parent action
childthe child action

◆ addChildJob()

void wrench::CompoundJob::addChildJob ( const std::shared_ptr< CompoundJob > &  child)

Add a child job to this job (be careful not to add circular dependencies, which may lead to deadlocks)

Parameters
childthe child job

◆ addComputeAction()

std::shared_ptr< ComputeAction > wrench::CompoundJob::addComputeAction ( std::string  name,
double  flops,
double  ram,
unsigned long  min_num_cores,
unsigned long  max_num_cores,
std::shared_ptr< ParallelModel parallel_model 
)

Add a compute action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
flopsthe number of flops to perform
ramthe amount of RAM required
min_num_coresthe minimum number of cores needed
max_num_coresthe maximum number of cores allowed
parallel_modelthe parallel speedup model
Returns
a compute action

◆ addCustomAction()

std::shared_ptr< CustomAction > wrench::CompoundJob::addCustomAction ( std::string  name,
double  ram,
unsigned long  num_cores,
const std::function< void(std::shared_ptr< ActionExecutor > action_executor)> &  lambda_execute,
const std::function< void(std::shared_ptr< ActionExecutor > action_executor)> &  lambda_terminate 
)

Add a custom action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
lambda_executethe action execution function
lambda_terminatethe action termination function
Returns
a custom action

◆ addFileCopyAction()

std::shared_ptr< FileCopyAction > wrench::CompoundJob::addFileCopyAction ( std::string  name,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation src_file_location,
std::shared_ptr< FileLocation dst_file_location 
)

Add a file copy action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
filethe file
src_file_locationthe file's location where it should be read
dst_file_locationthe file's location where it should be written
Returns
a file copy action

◆ addFileDeleteAction()

std::shared_ptr< FileDeleteAction > wrench::CompoundJob::addFileDeleteAction ( std::string  name,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation file_location 
)

Add a file delete action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
filethe file
file_locationthe location from which to delete the file
Returns
a file delete action

◆ addFileReadAction() [1/2]

std::shared_ptr< FileReadAction > wrench::CompoundJob::addFileReadAction ( std::string  name,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation file_location 
)

Add a file read action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
filethe file
file_locationthe file's location
Returns
a file read action

◆ addFileReadAction() [2/2]

std::shared_ptr< FileReadAction > wrench::CompoundJob::addFileReadAction ( std::string  name,
std::shared_ptr< DataFile file,
std::vector< std::shared_ptr< FileLocation >>  file_locations 
)

Add a file read action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
filethe file
file_locationsthe locations to read the file from (will be tried in order until one succeeds)
Returns
a file read action

◆ addFileRegistryAddEntryAction()

std::shared_ptr< FileRegistryAddEntryAction > wrench::CompoundJob::addFileRegistryAddEntryAction ( std::shared_ptr< FileRegistryService file_registry,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation file_location 
)

Add a file registry add entry action.

Parameters
file_registrythe file registry
filethe file
file_locationthe file location
Returns

◆ addFileRegistryDeleteEntryAction()

std::shared_ptr< FileRegistryDeleteEntryAction > wrench::CompoundJob::addFileRegistryDeleteEntryAction ( std::shared_ptr< FileRegistryService file_registry,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation file_location 
)

Add a file registry add entry action.

Parameters
file_registrythe file registry
filethe file
file_locationthe file location
Returns

◆ addFileWriteAction()

std::shared_ptr< FileWriteAction > wrench::CompoundJob::addFileWriteAction ( std::string  name,
std::shared_ptr< DataFile file,
std::shared_ptr< FileLocation file_location 
)

Add a file write action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
filethe file
file_locationthe file's location where it should be written
Returns
a file write action

◆ addParentJob()

void wrench::CompoundJob::addParentJob ( const std::shared_ptr< CompoundJob > &  parent)

Add a parent job to this job (be careful not to add circular dependencies, which may lead to deadlocks)

Parameters
parentthe parent job

◆ addSleepAction()

std::shared_ptr< SleepAction > wrench::CompoundJob::addSleepAction ( std::string  name,
double  sleep_time 
)

Add a sleep action to the job.

Parameters
namethe action's name (if empty, a unique name will be picked for you)
sleep_timethe time to sleep, in seconds
Returns
a sleep action

◆ getActions()

std::set< std::shared_ptr< Action > > wrench::CompoundJob::getActions ( )

Get the job's actions.

Returns
the set of actions in the job

◆ getChildren()

std::set< std::shared_ptr< CompoundJob > > & wrench::CompoundJob::getChildren ( )
protected

Returns the job's child jobs, if any.

Returns
a set of jobs

◆ getChildrenJobs()

std::set< std::shared_ptr< CompoundJob > > wrench::CompoundJob::getChildrenJobs ( )

Get the job's children.

Returns
the (possibly empty) set of children jobs

◆ getMinimumRequiredMemory()

double wrench::CompoundJob::getMinimumRequiredMemory ( )

Get the minimum required amount of memory to run the job.

Returns
a number of bytes

◆ getMinimumRequiredNumCores()

unsigned long wrench::CompoundJob::getMinimumRequiredNumCores ( )

Get the minimum required num cores to run the job.

Returns
a number of cores

◆ getParentJobs()

std::set< std::shared_ptr< CompoundJob > > wrench::CompoundJob::getParentJobs ( )

Get the job's parents.

Returns
the (possibly empty) set of parent jobs

◆ getParents()

std::set< std::shared_ptr< CompoundJob > > & wrench::CompoundJob::getParents ( )
protected

Returns the job's parent jobs, if any.

Returns
a set of jobs

◆ getSharedPtr()

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

Get the shared pointer for this object.

Returns
a shared pointer to the object

◆ getState()

CompoundJob::State wrench::CompoundJob::getState ( )

Get the state of the standard job.

Returns
the state

◆ getStateAsString()

std::string wrench::CompoundJob::getStateAsString ( )

Get the state of the standard job.

Returns
the state

◆ hasAction()

bool wrench::CompoundJob::hasAction ( const std::string &  name)
protected

Determine whether an action with a given name exists in job.

Parameters
nameaction name
Returns
true or false

◆ hasFailed()

bool wrench::CompoundJob::hasFailed ( )

Return whether the job has terminated and has done so with some tasks having failed.

Returns
true or false

◆ hasSuccessfullyCompleted()

bool wrench::CompoundJob::hasSuccessfullyCompleted ( )

Return whether the job has terminated and has done so successfully.

Returns
true or false

◆ isReady()

bool wrench::CompoundJob::isReady ( )
protected

Get the readiness of the job.

Returns
true if ready, false otherwise

◆ removeAction()

void wrench::CompoundJob::removeAction ( std::shared_ptr< Action > &  action)

Remove an action from the job.

Parameters
actionthe action to remove

◆ setAllActionsFailed()

void wrench::CompoundJob::setAllActionsFailed ( const std::shared_ptr< FailureCause > &  cause)
protected

Set all actions to FAILED for the same failure cause (e.g., a job-level failure)

Parameters
causea failure cause

◆ setPriority()

void wrench::CompoundJob::setPriority ( double  priority)
overridevirtual

Set the job's priority (the higher the priority value, the higher the priority)

Parameters
prioritya priority

Reimplemented from wrench::Job.

◆ updateStateActionMap()

void wrench::CompoundJob::updateStateActionMap ( const std::shared_ptr< Action > &  action,
Action::State  old_state,
Action::State  new_state 
)
protected

Update the internal State-Action map.

Parameters
actionthe action
old_statethe action's old state
new_statethe action's new state

◆ usesScratch()

bool wrench::CompoundJob::usesScratch ( )

Determine whether the job uses scratch.

Returns
true if the job uses scratch, false otherwise

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