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();
73 CompoundJob::State getState();
74 std::string getStateAsString();
75 void setPriority(
double priority)
override;
77 std::shared_ptr<SleepAction> addSleepAction(std::string name,
double sleep_time);
79 std::shared_ptr<FileReadAction> addFileReadAction(std::string name,
80 std::shared_ptr<DataFile>file,
81 std::shared_ptr<FileLocation> file_location);
83 std::shared_ptr<FileReadAction> addFileReadAction(std::string name,
84 std::shared_ptr<DataFile>file,
85 std::vector<std::shared_ptr<FileLocation>> file_locations);
87 std::shared_ptr<FileWriteAction> addFileWriteAction(std::string name,
88 std::shared_ptr<DataFile>file,
89 std::shared_ptr<FileLocation> file_location);
91 std::shared_ptr<FileCopyAction> addFileCopyAction(std::string name,
92 std::shared_ptr<DataFile>file,
93 std::shared_ptr<FileLocation> src_file_location,
94 std::shared_ptr<FileLocation> dst_file_location);
96 std::shared_ptr<FileDeleteAction> addFileDeleteAction(std::string name,
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);
106 std::shared_ptr<ComputeAction> addComputeAction(std::string name,
109 unsigned long min_num_cores,
110 unsigned long max_num_cores,
111 std::shared_ptr<ParallelModel> parallel_model);
113 std::shared_ptr<CustomAction> addCustomAction(std::string name,
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);
119 void removeAction(std::shared_ptr<Action> &action);
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);
126 std::set<std::shared_ptr<CompoundJob>> getParentJobs();
127 std::set<std::shared_ptr<CompoundJob>> getChildrenJobs();
132 bool hasSuccessfullyCompleted();
135 void printActionDependencies();
139 unsigned long getMinimumRequiredNumCores();
141 double getMinimumRequiredMemory();
155 friend class BareMetalComputeService;
156 friend class JobManager;
159 CompoundJob(std::string name, std::shared_ptr<JobManager> job_manager);
164 std::set<std::shared_ptr<Action>> actions;
165 std::map<std::string, std::shared_ptr<Action>> name_map;
172 void setAllActionsFailed(
const std::shared_ptr<FailureCause>& cause);
174 bool hasAction(
const std::string &name);
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