10 #ifndef WRENCH_COMPOUNDJOB_H
11 #define WRENCH_COMPOUNDJOB_H
18 #include <wrench/action/Action.h>
32 class FileWriteAction;
34 class FileDeleteAction;
35 class FileRegistryService;
36 class FileRegistryAddEntryAction;
37 class FileRegistryDeleteEntryAction;
47 class CompoundJob :
public Job,
public std::enable_shared_from_this<CompoundJob> {
70 std::shared_ptr<CompoundJob>
getSharedPtr() {
return this->shared_from_this(); }
72 std::set<std::shared_ptr<Action>>
getActions();
80 std::shared_ptr<DataFile>file,
81 std::shared_ptr<FileLocation> file_location);
84 std::shared_ptr<DataFile>file,
85 std::vector<std::shared_ptr<FileLocation>> file_locations);
88 std::shared_ptr<DataFile>file,
89 std::shared_ptr<FileLocation> file_location);
92 std::shared_ptr<DataFile>file,
93 std::shared_ptr<FileLocation> src_file_location,
94 std::shared_ptr<FileLocation> dst_file_location);
97 std::shared_ptr<DataFile>file,
98 std::shared_ptr<FileLocation> file_location);
100 std::shared_ptr<FileRegistryAddEntryAction>
addFileRegistryAddEntryAction(std::shared_ptr<FileRegistryService> file_registry, std::shared_ptr<DataFile>file,
101 std::shared_ptr<FileLocation> file_location);
103 std::shared_ptr<FileRegistryDeleteEntryAction>
addFileRegistryDeleteEntryAction(std::shared_ptr<FileRegistryService> file_registry, std::shared_ptr<DataFile>file,
104 std::shared_ptr<FileLocation> file_location);
109 unsigned long min_num_cores,
110 unsigned long max_num_cores,
111 std::shared_ptr<ParallelModel> parallel_model);
115 unsigned long num_cores,
116 const std::function<
void (std::shared_ptr<ActionExecutor> action_executor)> &lambda_execute,
117 const std::function<
void (std::shared_ptr<ActionExecutor> action_executor)> &lambda_terminate);
121 void addActionDependency(
const std::shared_ptr<Action>& parent,
const std::shared_ptr<Action>& child);
123 void addParentJob(
const std::shared_ptr<CompoundJob>& parent);
124 void addChildJob(
const std::shared_ptr<CompoundJob>& child);
164 std::set<std::shared_ptr<Action>> actions;
165 std::map<std::string, std::shared_ptr<Action>> name_map;
176 std::set<std::shared_ptr<CompoundJob>> &
getChildren();
177 std::set<std::shared_ptr<CompoundJob>> &
getParents();
181 double pre_job_overhead;
182 double post_job_overhead;
184 void assertJobNotSubmitted();
185 void assertActionNameDoesNotAlreadyExist(
const std::string &
name);
187 void addAction(
const std::shared_ptr<Action>& action);
189 bool pathExists(
const std::shared_ptr<Action>& a,
const std::shared_ptr<Action> &b);
190 bool pathExists(
const std::shared_ptr<CompoundJob>& a,
const std::shared_ptr<CompoundJob> &b);
192 std::set<std::shared_ptr<CompoundJob>> parents;
193 std::set<std::shared_ptr<CompoundJob>> children;
195 std::map<std::string, std::string> service_specific_args;
197 std::unordered_map<Action::State, std::set<std::shared_ptr<Action>>> state_task_map;
208 #endif //WRENCH_COMPOUNDJOB_H
std::shared_ptr< CustomAction > 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.
Definition: CompoundJob.cpp:248
std::set< std::shared_ptr< CompoundJob > > getChildrenJobs()
Get the job's children.
Definition: CompoundJob.cpp:341
@ SUBMITTED
Job has been submitted to a JobManager.
Definition: CompoundJob.h:56
State
Compound job states.
Definition: CompoundJob.h:52
void printTaskMap()
Print the task map.
Definition: CompoundJob.cpp:401
std::set< std::shared_ptr< CompoundJob > > & getParents()
Returns the job's parent jobs, if any.
Definition: CompoundJob.cpp:490
CompoundJob::State getState()
Get the state of the standard job.
Definition: CompoundJob.cpp:56
std::shared_ptr< SleepAction > addSleepAction(std::string name, double sleep_time)
Add a sleep action to the job.
Definition: CompoundJob.cpp:95
std::shared_ptr< FileReadAction > addFileReadAction(std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
Add a file read action to the job.
Definition: CompoundJob.cpp:132
std::string getStateAsString()
Get the state of the standard job.
Definition: CompoundJob.cpp:64
Abstraction of a job used for executing tasks in a Workflow.
Definition: Job.h:34
@ NOT_SUBMITTED
Job hasn't been submitted yet.
Definition: CompoundJob.h:54
double getMinimumRequiredMemory()
Get the minimum required amount of memory to run the job.
Definition: CompoundJob.cpp:559
void setPriority(double priority) override
Set the job's priority (the higher the priority value, the higher the priority)
Definition: CompoundJob.cpp:84
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)
Definition: CompoundJob.cpp:277
A helper daemon (co-located with and explicitly started by an execution controller),...
Definition: JobManager.h:56
unsigned long getMinimumRequiredNumCores()
Get the minimum required num cores to run the job.
Definition: CompoundJob.cpp:547
std::shared_ptr< FileCopyAction > 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.
Definition: CompoundJob.cpp:181
void setAllActionsFailed(const std::shared_ptr< FailureCause > &cause)
Set all actions to FAILED for the same failure cause (e.g., a job-level failure)
Definition: CompoundJob.cpp:434
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 deadlock...
Definition: CompoundJob.cpp:301
Definition: Action.cpp:28
std::shared_ptr< CompoundJob > getSharedPtr()
Get the shared pointer for this object.
Definition: CompoundJob.h:70
std::string name
The job's name.
Definition: Job.h:93
std::shared_ptr< JobManager > job_manager
The Job Manager in charge of this job.
Definition: Job.h:86
bool hasAction(const std::string &name)
Determine whether an action with a given name exists in job.
Definition: CompoundJob.cpp:539
std::shared_ptr< FileRegistryDeleteEntryAction > 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.
Definition: CompoundJob.cpp:231
std::shared_ptr< ComputeAction > 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.
Definition: CompoundJob.cpp:111
std::set< std::shared_ptr< CompoundJob > > getParentJobs()
Get the job's parents.
Definition: CompoundJob.cpp:333
std::set< std::shared_ptr< Action > > getActions()
Get the job's actions.
Definition: CompoundJob.cpp:48
std::shared_ptr< FileDeleteAction > addFileDeleteAction(std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
Add a file delete action to the job.
Definition: CompoundJob.cpp:199
std::shared_ptr< FileRegistryAddEntryAction > 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.
Definition: CompoundJob.cpp:214
bool hasSuccessfullyCompleted()
Return whether the job has terminated and has done so successfully.
Definition: CompoundJob.cpp:394
void removeAction(std::shared_ptr< Action > &action)
Remove an action from the job.
Definition: CompoundJob.cpp:498
std::set< std::shared_ptr< CompoundJob > > & getChildren()
Returns the job's child jobs, if any.
Definition: CompoundJob.cpp:482
@ DISCONTINUED
Job has finished executing but not all actions were successfully completed. Actions may have failed,...
Definition: CompoundJob.h:63
void updateStateActionMap(const std::shared_ptr< Action > &action, Action::State old_state, Action::State new_state)
Update the internal State-Action map.
Definition: CompoundJob.cpp:365
An abstract class that implements the concept of an action.
Definition: Action.h:28
CompoundJob(std::string name, std::shared_ptr< JobManager > job_manager)
Constructor.
Definition: CompoundJob.cpp:37
bool hasFailed()
Return whether the job has terminated and has done so with some tasks having failed.
Definition: CompoundJob.cpp:422
std::shared_ptr< FileWriteAction > addFileWriteAction(std::string name, std::shared_ptr< DataFile >file, std::shared_ptr< FileLocation > file_location)
Add a file write action to the job.
Definition: CompoundJob.cpp:164
void printActionDependencies()
Print the list of actions with their children and parents.
Definition: CompoundJob.cpp:515
@ COMPLETED
Job has finished executing and all actions were successfully completed.
Definition: CompoundJob.h:58
bool isReady()
Get the readiness of the job.
Definition: CompoundJob.cpp:350
A compound job.
Definition: CompoundJob.h:47
State
Action states.
Definition: Action.h:33
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...
Definition: CompoundJob.cpp:317
bool usesScratch()
Determine whether the job uses scratch.
Definition: CompoundJob.cpp:571