WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
WorkflowTask.h
1 
10 #ifndef WRENCH_WORKFLOWTASK_H
11 #define WRENCH_WORKFLOWTASK_H
12 
13 #include <map>
14 #include <stack>
15 #include <set>
16 
17 #include "wrench/workflow/job/WorkflowJob.h"
18 #include "wrench/workflow/WorkflowFile.h"
19 #include "wrench/workflow/parallel_model/ParallelModel.h"
20 #include "wrench/workflow/parallel_model/AmdahlParallelModel.h"
21 #include "wrench/workflow/parallel_model/ConstantEfficiencyParallelModel.h"
22 #include "wrench/workflow/parallel_model/CustomParallelModel.h"
23 
24 #include <boost/graph/adjacency_list.hpp>
25 
26 namespace wrench {
27 
31  class WorkflowTask {
32 
33  public:
34  const std::string& getID() const;
35 
36  double getFlops() const;
37 
38  unsigned long getMinNumCores() const;
39 
40  unsigned long getMaxNumCores() const;
41 
42  std::shared_ptr<ParallelModel> getParallelModel() const;
43 
44  void setParallelModel(std::shared_ptr<ParallelModel> model);
45 
46  double getMemoryRequirement() const;
47 
48  unsigned long getNumberOfChildren() const;
49 
50  std::vector<WorkflowTask *> getChildren() const;
51 
52  unsigned long getNumberOfParents() const;
53 
54  std::vector<WorkflowTask *> getParents() const;
55 
56  void addInputFile(WorkflowFile *file);
57 
58  void addOutputFile(WorkflowFile *file);
59 
60  unsigned int getFailureCount();
61 
62 
63  /***********************/
65  /***********************/
66 
68  enum State {
79  };
80 
81  static std::string stateToString(WorkflowTask::State state);
82 
83  WorkflowJob *getJob() const;
84 
85  Workflow *getWorkflow() const;
86 
87  std::string getClusterID() const;
88 
89  void setClusterID(std::string);
90 
91  void setPriority(long);
92 
93  unsigned long getPriority() const;
94 
95  void setAverageCPU(double);
96 
97  double getAverageCPU() const;
98 
99  void setBytesRead(unsigned long);
100 
101  unsigned long getBytesRead() const;
102 
103  void setBytesWritten(unsigned long);
104 
105  unsigned long getBytesWritten() const;
106 
107  std::vector<WorkflowFile *> getInputFiles() const;
108 
109  std::vector<WorkflowFile *> getOutputFiles() const;
110 
111  unsigned long getTopLevel() const;
112 
113  double getStartDate() const;
114 
115  double getEndDate() const;
116 
117  double getFailureDate() const;
118 
119  double getTerminationDate() const;
120 
121  double getReadInputStartDate() const;
122 
123  double getReadInputEndDate() const;
124 
125  double getComputationStartDate() const;
126 
127  double getComputationEndDate() const;
128 
129  double getWriteOutputStartDate() const;
130 
131  double getWriteOutputEndDate() const;
132 
133  unsigned long getNumCoresAllocated() const;
134 
135  struct WorkflowTaskExecution;
136 
137  std::stack<WorkflowTaskExecution> getExecutionHistory() const;
138 
139  std::string getExecutionHost() const;
140 
141  std::string getPhysicalExecutionHost()const ;
142 
144 
145  std::string getColor() const;
146 
147  void setColor(std::string);
148 
149  /***********************/
151  /***********************/
152 
153 
154  /***********************/
156  /***********************/
157 
159  enum InternalState {
160  TASK_NOT_READY,
161  TASK_READY,
162  TASK_RUNNING,
163  TASK_COMPLETED,
164  TASK_FAILED
165  };
166 
167  static std::string stateToString(WorkflowTask::InternalState state);
168 
169  unsigned long updateTopLevel();
170 
171  void setInternalState(WorkflowTask::InternalState);
172 
173  void setState(WorkflowTask::State);
174 
175  void setUpcomingState(WorkflowTask::State);
176 
177  WorkflowTask::State getUpcomingState() const;
178 
179  WorkflowTask::InternalState getInternalState() const;
180 
181  void setJob(WorkflowJob *job);
182 
183  void setStartDate(double date);
184 
185  void setEndDate(double date);
186 
187  void setReadInputStartDate(double date);
188 
189  void setReadInputEndDate(double date);
190 
191  void setComputationStartDate(double date);
192 
193  void setComputationEndDate(double date);
194 
195  void setWriteOutputStartDate(double date);
196 
197  void setWriteOutputEndDate(double date);
198 
199  void setFailureDate(double date);
200 
201  void setTerminationDate(double date);
202 
203  void incrementFailureCount();
204 
205  void setExecutionHost(std::string hostname);
206 
207  void setNumCoresAllocated(unsigned long num_cores);
208 
212  struct WorkflowTaskExecution {
214  double task_start = -1.0;
216  double read_input_start = -1.0;
218  double read_input_end = -1.0;
220  double computation_start = -1.0;
222  double computation_end = -1.0;
224  double write_output_start = -1.0;
226  double write_output_end = -1.0;
228  double task_end = -1.0;
230  double task_failed = -1.0;
232  double task_terminated = -1.0;
233 
235  std::string execution_host = "";
237  std::string physical_execution_host = "";
239  unsigned long num_cores_allocated = 0;
240 
246  WorkflowTaskExecution(double task_start) : task_start(task_start) {}
247 
248 
249  };
250 
251 
252  /***********************/
254  /***********************/
255 
256  private:
257  friend class Workflow;
258 
259  std::string id; // Task ID
260  std::string cluster_id; // ID for clustered task
261  std::string color; // A RGB color formatted as "#rrggbb"
262  double flops; // Number of flops
263  double average_cpu = -1; // Average CPU utilization
264  unsigned long bytes_read = -1; // Total bytes read in KB
265  unsigned long bytes_written = -1; // Total bytes written in KB
266  unsigned long min_num_cores;
267  unsigned long max_num_cores;
268  std::shared_ptr<ParallelModel> parallel_model;
269  double memory_requirement;
270  unsigned long priority = 0; // Task priority
271  unsigned long toplevel; // 0 if entry task
272  unsigned int failure_count = 0; // Number of times the tasks has failed
273  std::string execution_host; // Host on which the task executed ("" if not executed successfully - yet)
274  State visible_state; // To be exposed to developer level
275  State upcoming_visible_state; // A visible state that will become active once a WMS has process a previously sent workflow execution event
276  InternalState internal_state; // Not to be exposed to developer level
277 
278  Workflow *workflow; // Containing workflow
279 
280  std::map<std::string, WorkflowFile *> output_files; // List of output files
281  std::map<std::string, WorkflowFile *> input_files; // List of input files
282 
283  // Private constructor (called by Workflow)
284  WorkflowTask(std::string id,
285  double t,
286  unsigned long min_num_cores,
287  unsigned long max_num_cores,
288  double memory_requirement);
289 
290  // Containing job
291  WorkflowJob *job;
292 
293  std::stack<WorkflowTaskExecution> execution_history;
294 
295  friend class DagOfTasks;
296  };
297 };
298 
299 #endif //WRENCH_WORKFLOWTASK_H
wrench::WorkflowTask::PENDING
@ PENDING
Pending (has been submitted to a compute service)
Definition: WorkflowTask.h:74
wrench::WorkflowTask::READY
@ READY
Ready (parents have completed)
Definition: WorkflowTask.h:72
wrench::WorkflowTask::getExecutionHistory
std::stack< WorkflowTaskExecution > getExecutionHistory() const
Get the execution history of this task.
Definition: WorkflowTask.cpp:587
wrench::WorkflowTask::UNKNOWN
@ UNKNOWN
Some Unknown state (should not happen)
Definition: WorkflowTask.h:78
wrench::WorkflowTask::getState
WorkflowTask::State getState() const
Get the state of the task.
Definition: WorkflowTask.cpp:198
wrench::WorkflowTask::State
State
Task states.
Definition: WorkflowTask.h:68
wrench::WorkflowTask::getAverageCPU
double getAverageCPU() const
Get the task average CPU usage.
Definition: WorkflowTask.cpp:397
wrench::WorkflowTask::setClusterID
void setClusterID(std::string)
Set the cluster id for the task.
Definition: WorkflowTask.cpp:373
wrench::WorkflowTask::getTerminationDate
double getTerminationDate() const
Get the tasks's most recent termination date (when it was explicitly requested to be terminated by th...
Definition: WorkflowTask.cpp:709
wrench::WorkflowTask::getChildren
std::vector< WorkflowTask * > getChildren() const
Get the children of a task.
Definition: WorkflowTask.cpp:171
wrench::WorkflowTask::getID
const std::string & getID() const
Get the id of the task.
Definition: WorkflowTask.cpp:117
wrench::WorkflowTask::getComputationStartDate
double getComputationStartDate() const
Get the tasks's most recent computation start date.
Definition: WorkflowTask.cpp:653
wrench::WorkflowTask::addInputFile
void addInputFile(WorkflowFile *file)
Add an input file to the task.
Definition: WorkflowTask.cpp:57
wrench::WorkflowTask::getMaxNumCores
unsigned long getMaxNumCores() const
Get the maximum number of cores that the task can use.
Definition: WorkflowTask.cpp:144
wrench::WorkflowTask::getNumberOfChildren
unsigned long getNumberOfChildren() const
Get the number of children of a task.
Definition: WorkflowTask.cpp:162
wrench::WorkflowTask::setBytesWritten
void setBytesWritten(unsigned long)
Set the number of bytes written by the task.
Definition: WorkflowTask.cpp:437
wrench::WorkflowTask::getTopLevel
unsigned long getTopLevel() const
Returns the task's top level (max number of hops on a reverse path up to an entry task....
Definition: WorkflowTask.cpp:740
wrench
Definition: Alarm.cpp:20
wrench::Workflow
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
wrench::WorkflowTask::COMPLETED
@ COMPLETED
Completed (successfully completed)
Definition: WorkflowTask.h:76
wrench::WorkflowTask::stateToString
static std::string stateToString(WorkflowTask::State state)
Convert task state to a string (useful for output, debugging, logging, etc.)
Definition: WorkflowTask.cpp:225
wrench::WorkflowTask::getInputFiles
std::vector< WorkflowFile * > getInputFiles() const
Get the list of input WorkflowFile objects for the task.
Definition: WorkflowTask.cpp:611
wrench::WorkflowTask::setPriority
void setPriority(long)
Set the task priority.
Definition: WorkflowTask.cpp:389
wrench::WorkflowTask::getMinNumCores
unsigned long getMinNumCores() const
Get the minimum number of cores required for running the task.
Definition: WorkflowTask.cpp:135
wrench::WorkflowTask::getBytesWritten
unsigned long getBytesWritten() const
Get the number of bytes written by the task.
Definition: WorkflowTask.cpp:429
wrench::WorkflowTask::getFailureDate
double getFailureDate() const
Get the task's most recent failure date.
Definition: WorkflowTask.cpp:701
wrench::WorkflowTask::getParallelModel
std::shared_ptr< ParallelModel > getParallelModel() const
Get the task's parallel model.
Definition: WorkflowTask.cpp:834
wrench::WorkflowTask::getWorkflow
Workflow * getWorkflow() const
Get the workflow that contains the task.
Definition: WorkflowTask.cpp:270
wrench::WorkflowTask::setParallelModel
void setParallelModel(std::shared_ptr< ParallelModel > model)
Set the task's parallel model.
Definition: WorkflowTask.cpp:826
wrench::WorkflowTask
A computational task in a Workflow.
Definition: WorkflowTask.h:31
wrench::WorkflowTask::getPhysicalExecutionHost
std::string getPhysicalExecutionHost() const
Returns the name of the PHYSICAL host on which the task has most recently been executed,...
Definition: WorkflowTask.cpp:758
wrench::WorkflowTask::getFailureCount
unsigned int getFailureCount()
Get the number of times a task has failed.
Definition: WorkflowTask.cpp:596
wrench::WorkflowTask::getMemoryRequirement
double getMemoryRequirement() const
Get the memory_manager_service requirement of the task.
Definition: WorkflowTask.cpp:153
wrench::WorkflowJob
Abstraction of a job used for executing tasks in a Workflow.
Definition: WorkflowJob.h:34
wrench::WorkflowTask::setBytesRead
void setBytesRead(unsigned long)
Set the number of bytes read by the task.
Definition: WorkflowTask.cpp:421
wrench::WorkflowTask::getStartDate
double getStartDate() const
Get the task's most recent start date.
Definition: WorkflowTask.cpp:637
wrench::WorkflowTask::getWriteOutputStartDate
double getWriteOutputStartDate() const
Get the task's most recent write output start date.
Definition: WorkflowTask.cpp:685
wrench::WorkflowTask::getExecutionHost
std::string getExecutionHost() const
Returns the name of the host on which the task has most recently been executed, or "" if the task has...
Definition: WorkflowTask.cpp:749
wrench::WorkflowTask::getReadInputStartDate
double getReadInputStartDate() const
Get the task's most recent read input start date.
Definition: WorkflowTask.cpp:669
wrench::WorkflowTask::getPriority
unsigned long getPriority() const
Get the task priority. By default, priority is 0.
Definition: WorkflowTask.cpp:381
wrench::WorkflowTask::getClusterID
std::string getClusterID() const
Get the cluster Id for the task.
Definition: WorkflowTask.cpp:364
wrench::WorkflowTask::getBytesRead
unsigned long getBytesRead() const
Get the number of bytes read by the task.
Definition: WorkflowTask.cpp:413
wrench::WorkflowTask::NOT_READY
@ NOT_READY
Not ready (parents have not completed)
Definition: WorkflowTask.h:70
wrench::WorkflowTask::getReadInputEndDate
double getReadInputEndDate() const
Get the task's most recent read input end date.
Definition: WorkflowTask.cpp:677
wrench::WorkflowTask::getParents
std::vector< WorkflowTask * > getParents() const
Get the parents of a task.
Definition: WorkflowTask.cpp:189
wrench::WorkflowTask::getWriteOutputEndDate
double getWriteOutputEndDate() const
Get the task's most recent write output end date.
Definition: WorkflowTask.cpp:693
wrench::WorkflowTask::setAverageCPU
void setAverageCPU(double)
Set the task average CPU usage.
Definition: WorkflowTask.cpp:405
wrench::WorkflowTask::addOutputFile
void addOutputFile(WorkflowFile *file)
Add an output file to the task.
Definition: WorkflowTask.cpp:87
wrench::WorkflowTask::getJob
WorkflowJob * getJob() const
Get the task's containing job.
Definition: WorkflowTask.cpp:356
wrench::WorkflowTask::getNumberOfParents
unsigned long getNumberOfParents() const
Get the number of parents of a task.
Definition: WorkflowTask.cpp:180
wrench::WorkflowTask::getOutputFiles
std::vector< WorkflowFile * > getOutputFiles() const
Get the list of output WorkflowFile objects for the task.
Definition: WorkflowTask.cpp:624
wrench::WorkflowTask::getEndDate
double getEndDate() const
Get the task's most recent end date.
Definition: WorkflowTask.cpp:645
wrench::WorkflowTask::getNumCoresAllocated
unsigned long getNumCoresAllocated() const
Returns the number of cores allocated for this task's most recent execution or 0 if an execution atte...
Definition: WorkflowTask.cpp:766
wrench::WorkflowFile
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
wrench::WorkflowTask::getFlops
double getFlops() const
Get the number of flops of the task.
Definition: WorkflowTask.cpp:126
wrench::WorkflowTask::getColor
std::string getColor() const
Get the task's color ("" if none)
Definition: WorkflowTask.cpp:810
wrench::WorkflowTask::setColor
void setColor(std::string)
Set the task's color.
Definition: WorkflowTask.cpp:818
wrench::WorkflowTask::getComputationEndDate
double getComputationEndDate() const
Get the task's most recent computation end date.
Definition: WorkflowTask.cpp:661