10 #ifndef WRENCH_WORKFLOWTASK_H
11 #define WRENCH_WORKFLOWTASK_H
19 #include "wrench/job/Job.h"
20 #include "wrench/data_file/DataFile.h"
21 #include "wrench/workflow/parallel_model/ParallelModel.h"
22 #include "wrench/workflow/parallel_model/AmdahlParallelModel.h"
23 #include "wrench/workflow/parallel_model/ConstantEfficiencyParallelModel.h"
24 #include "wrench/workflow/parallel_model/CustomParallelModel.h"
26 #include <boost/graph/adjacency_list.hpp>
33 class WorkflowTask :
public std::enable_shared_from_this<WorkflowTask> {
36 const std::string&
getID()
const;
52 std::vector<std::shared_ptr<WorkflowTask>>
getChildren();
56 std::vector<std::shared_ptr<WorkflowTask>>
getParents();
64 std::shared_ptr<WorkflowTask> getSharedPtr() {
return this->shared_from_this(); }
85 static std::string stateToString(WorkflowTask::State state);
89 std::shared_ptr<Workflow> getWorkflow()
const;
91 std::string getClusterID()
const;
93 void setClusterID(std::string);
95 void setPriority(
long);
97 unsigned long getPriority()
const;
99 void setAverageCPU(
double);
101 double getAverageCPU()
const;
103 void setBytesRead(
unsigned long);
105 unsigned long getBytesRead()
const;
107 void setBytesWritten(
unsigned long);
109 unsigned long getBytesWritten()
const;
111 std::vector<std::shared_ptr<DataFile>> getInputFiles()
const;
113 std::vector<std::shared_ptr<DataFile>> getOutputFiles()
const;
115 unsigned long getTopLevel()
const;
117 double getStartDate()
const;
119 double getEndDate()
const;
121 double getFailureDate()
const;
123 double getTerminationDate()
const;
125 double getReadInputStartDate()
const;
127 double getReadInputEndDate()
const;
129 double getComputationStartDate()
const;
131 double getComputationEndDate()
const;
133 double getWriteOutputStartDate()
const;
135 double getWriteOutputEndDate()
const;
137 unsigned long getNumCoresAllocated()
const;
139 struct WorkflowTaskExecution;
141 std::stack<WorkflowTaskExecution> getExecutionHistory()
const;
143 std::string getExecutionHost()
const;
145 std::string getPhysicalExecutionHost()
const ;
147 WorkflowTask::State getState()
const;
149 std::string getStateAsString()
const;
151 std::string getColor()
const;
153 void setColor(std::string);
173 void updateReadiness();
175 static std::string stateToString(WorkflowTask::InternalState state);
177 unsigned long updateTopLevel();
179 void setInternalState(WorkflowTask::InternalState);
181 void setState(WorkflowTask::State);
187 WorkflowTask::InternalState getInternalState()
const;
189 void setJob(Job *job);
191 void setStartDate(
double date);
193 void updateStartDate(
double date);
195 void setEndDate(
double date);
197 void setReadInputStartDate(
double date);
199 void setReadInputEndDate(
double date);
201 void setComputationStartDate(
double date);
203 void setComputationEndDate(
double date);
205 void setWriteOutputStartDate(
double date);
207 void setWriteOutputEndDate(
double date);
209 void setFailureDate(
double date);
211 void setTerminationDate(
double date);
213 void incrementFailureCount();
215 void setExecutionHost(std::string hostname);
217 void setNumCoresAllocated(
unsigned long num_cores);
222 struct WorkflowTaskExecution {
224 double task_start = -1.0;
226 double read_input_start = -1.0;
228 double read_input_end = -1.0;
230 double computation_start = -1.0;
232 double computation_end = -1.0;
234 double write_output_start = -1.0;
236 double write_output_end = -1.0;
238 double task_end = -1.0;
240 double task_failed = -1.0;
242 double task_terminated = -1.0;
245 std::string execution_host =
"";
247 std::string physical_execution_host =
"";
249 unsigned long num_cores_allocated = 0;
256 WorkflowTaskExecution(
double task_start) : task_start(task_start) {}
270 std::string cluster_id;
273 double average_cpu = -1;
274 unsigned long bytes_read = -1;
275 unsigned long bytes_written = -1;
276 unsigned long min_num_cores;
277 unsigned long max_num_cores;
278 std::shared_ptr<ParallelModel> parallel_model;
279 double memory_requirement;
280 unsigned long priority = 0;
281 unsigned long toplevel;
282 unsigned int failure_count = 0;
283 std::string execution_host;
285 State upcoming_visible_state;
286 InternalState internal_state;
288 std::shared_ptr<Workflow> workflow;
290 std::map<std::string, std::shared_ptr<DataFile>> output_files;
291 std::map<std::string, std::shared_ptr<DataFile>> input_files;
296 unsigned long min_num_cores,
297 unsigned long max_num_cores,
298 double memory_requirement);
303 std::stack<WorkflowTaskExecution> execution_history;
305 friend class DagOfTasks;
309 #endif //WRENCH_WORKFLOWTASK_H