wrench::CompoundJob

class wrench::CompoundJob : public wrench::Job, public std::enable_shared_from_this<CompoundJob>

A compound job class.

Public Types

enum State

Compound job states.

Values:

enumerator NOT_SUBMITTED

Job hasn’t been submitted yet.

enumerator SUBMITTED

Job has been submitted to a JobManager.

enumerator COMPLETED

Job has finished executing and all actions were successfully completed.

enumerator 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.

Public 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)

Parameters
  • parent – the parent action

  • child – the child action

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)

Parameters

child – the child job

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

Add a compute action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • flops – the number of flops to perform

  • ram – the amount of RAM required

  • min_num_cores – the minimum number of cores needed

  • max_num_cores – the maximum number of cores allowed

  • parallel_model – the parallel speedup model

Returns

a compute action

std::shared_ptr<CustomAction> addCustomAction(const 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
  • name – the action’s name (if empty, a unique name will be picked for you)

  • ram – the action’s RAM footprint

  • num_cores – the action’s allocated number of cores

  • lambda_execute – the action execution function

  • lambda_terminate – the action termination function

Returns

a custom action

std::shared_ptr<FileCopyAction> addFileCopyAction(const 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
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • src_file_location – the file’s location where it should be read

  • dst_file_location – the file’s location where it should be written

Returns

a file copy action

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

Add a file delete action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_location – the location from which to delete the file

Returns

a file delete action

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

Add a file read action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_location – the file’s location

Returns

a file read action

std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name, const std::shared_ptr<DataFile> &file, const std::shared_ptr<FileLocation> &file_location, const double num_bytes_to_read)

Add a file read action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_location – the file’s location

  • num_bytes_to_read – the number of bytes to read

Returns

a file read action

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

Add a file read action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_locations – the locations to read the file from (will be tried in order until one succeeds)

Returns

a file read action

std::shared_ptr<FileReadAction> addFileReadAction(const std::string &name, const std::shared_ptr<DataFile> &file, const std::vector<std::shared_ptr<FileLocation>> &file_locations, const double num_bytes_to_read)

Add a file read action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_locations – the locations to read the file from (will be tried in order until one succeeds)

  • num_bytes_to_read – number of bytes to read

Returns

a file read action

std::shared_ptr<FileRegistryAddEntryAction> addFileRegistryAddEntryAction(const std::string &name, 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
  • name – the action’s name

  • file_registry – the file registry

  • file – the file

  • file_location – the file location

Returns

std::shared_ptr<FileRegistryDeleteEntryAction> addFileRegistryDeleteEntryAction(const std::string &name, 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
  • name – the action’s name

  • file_registry – the file registry

  • file – the file

  • file_location – the file location

Returns

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

Add a file write action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • file – the file

  • file_location – the file’s location where it should be written

Returns

a file write action

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)

Parameters

parent – the parent job

std::shared_ptr<SleepAction> addSleepAction(const std::string &name, double sleep_time)

Add a sleep action to the job.

Parameters
  • name – the action’s name (if empty, a unique name will be picked for you)

  • sleep_time – the time to sleep, in seconds

Returns

a sleep action

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

Get the job’s actions.

Returns

the set of actions in the job

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

Get the job’s children.

Returns

the (possibly empty) set of children jobs

double getMinimumRequiredMemory()

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

Returns

a number of bytes

unsigned long getMinimumRequiredNumCores()

Get the minimum required num cores to run the job.

Returns

a number of cores

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

Get the job’s parents.

Returns

the (possibly empty) set of parent jobs

inline std::shared_ptr<CompoundJob> getSharedPtr()

Get the shared pointer for this object.

Returns

a shared pointer to the object

CompoundJob::State getState()

Get the state of the standard job.

Returns

the state

std::string getStateAsString()

Get the state of the standard job.

Returns

the state

bool hasFailed()

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

Returns

true or false

bool hasSuccessfullyCompleted()

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

Returns

true or false

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

Remove an action from the job.

Parameters

action – the action to remove

void setPriority(double p) override

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

Parameters

p – a priority