WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
StandardJob.h
1 
11 #ifndef WRENCH_STANDARDJOB_H
12 #define WRENCH_STANDARDJOB_H
13 
14 
15 #include <map>
16 #include <set>
17 #include <vector>
18 #include <wrench/workflow/Workflow.h>
19 #include <wrench/workflow/WorkflowTask.h>
20 #include <wrench/data_file/DataFile.h>
21 
22 #include "Job.h"
23 
24 #include "wrench/services/storage/storage_helpers/FileLocation.h"
25 
26 namespace wrench {
27 
28  /***********************/
30  /***********************/
31 
32  class DataFile;
33  class WorkflowTask;
34  class Action;
35 
40  class StandardJob : public Job, public std::enable_shared_from_this<StandardJob> {
41 
42  public:
43 
45  enum State {
47  NOT_SUBMITTED,
49  PENDING,
51  RUNNING,
53  COMPLETED,
55  FAILED,
57  TERMINATED
58  };
59 
60  std::vector<std::shared_ptr<WorkflowTask>> getTasks();
61 
62  unsigned long getMinimumRequiredNumCores() const;
63 
64  unsigned long getMinimumRequiredMemory() const;
65 
66  unsigned long getNumCompletedTasks() const;
67 
68  unsigned long getNumTasks() const;
69 
70  StandardJob::State getState();
71 
72  bool usesScratch();
73 
74  std::map<std::shared_ptr<DataFile>, std::vector<std::shared_ptr<FileLocation>>> getFileLocations();
75 
76 
78  std::vector<std::shared_ptr<WorkflowTask>> tasks;
79 
81  double total_flops;
82 
84  std::map<std::shared_ptr<DataFile>, std::vector<std::shared_ptr<FileLocation>>> file_locations;
85 
87  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> , std::shared_ptr<FileLocation> >> pre_file_copies;
89  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> , std::shared_ptr<FileLocation> >> post_file_copies;
91  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> >> cleanup_file_deletions;
92 
97  std::shared_ptr<StandardJob> getSharedPtr() { return this->shared_from_this(); }
98 
99  /***********************/
101  /***********************/
102 
103  /***********************/
105  /***********************/
106 
107  double getPreJobOverheadInSeconds();
108  void setPreJobOverheadInSeconds(double overhead);
109  double getPostJobOverheadInSeconds();
110  void setPostJobOverheadInSeconds(double overhead);
111 
112 
113  private:
114 
115  friend class BareMetalComputeService;
116  friend class JobManager;
117  friend class ExecutionEvent;
118 
119  StandardJob(std::shared_ptr<JobManager> job_manager,
120  std::vector<std::shared_ptr<WorkflowTask>> tasks, std::map<std::shared_ptr<DataFile>, std::vector<std::shared_ptr<FileLocation>>> &file_locations,
121  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> , std::shared_ptr<FileLocation>>> &pre_file_copies,
122  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> , std::shared_ptr<FileLocation>>> &post_file_copies,
123  std::vector<std::tuple<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation> >> &cleanup_file_deletions);
124 
125  void createUnderlyingCompoundJob(const std::shared_ptr<ComputeService>& compute_service);
126  void processCompoundJobOutcome(std::map<std::shared_ptr<WorkflowTask>, WorkflowTask::State> &state_changes,
127  std::set<std::shared_ptr<WorkflowTask>> &failure_count_increments,
128  std::shared_ptr<FailureCause> &job_failure_cause,
129  Simulation *simulation);
130  void applyTaskUpdates(std::map<std::shared_ptr<WorkflowTask>, WorkflowTask::State> &state_changes,
131  std::set<std::shared_ptr<WorkflowTask>> &failure_count_increments);
132 
133  void analyzeActions(std::vector<std::shared_ptr<Action>> actions,
134  bool *at_least_one_failed,
135  bool *at_least_one_killed,
136  std::shared_ptr<FailureCause> *failure_cause,
137  double *earliest_start_date,
138  double *latest_end_date,
139  double *earliest_failure_date);
140 
141 
142  State state;
143  double pre_overhead = 0.0;
144  double post_overhead = 0.0;
145 
146  std::shared_ptr<CompoundJob> compound_job;
147  std::shared_ptr<Action> pre_overhead_action = nullptr;
148  std::shared_ptr<Action> post_overhead_action = nullptr;
149  std::vector<std::shared_ptr<Action>> pre_file_copy_actions;
150  std::map<std::shared_ptr<WorkflowTask>, std::vector<std::shared_ptr<Action>>> task_file_read_actions;
151  std::map<std::shared_ptr<WorkflowTask>, std::shared_ptr<Action>> task_compute_actions;
152  std::map<std::shared_ptr<WorkflowTask>, std::vector<std::shared_ptr<Action>>> task_file_write_actions;
153  std::vector<std::shared_ptr<Action>> post_file_copy_actions;
154  std::vector<std::shared_ptr<Action>> cleanup_actions;
155  std::shared_ptr<Action> scratch_cleanup = nullptr;
156  };
157 
158  /***********************/
160  /***********************/
161 
162 };
163 
164 #endif //WRENCH_MULTITASKJOB_H
wrench::WorkflowTask::State
State
Task states.
Definition: WorkflowTask.h:72
wrench
Definition: Action.cpp:28