WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
Workflow.h
1 
10 #ifndef WRENCH_WORKFLOW_H
11 #define WRENCH_WORKFLOW_H
12 
13 #include <map>
14 #include <set>
15 
16 #include "wrench/workflow/execution_events/WorkflowExecutionEvent.h"
17 #include "WorkflowFile.h"
18 #include "WorkflowTask.h"
19 #include "DagOfTasks.h"
20 
21 #include <boost/graph/adjacency_list.hpp>
22 #include <wrench/workflow/parallel_model/ParallelModel.h>
23 
24 class WorkflowTask;
25 
26 namespace wrench {
27 
28  class Simulation;
29 
30 
34  class Workflow {
35 
36  public:
37  Workflow();
38 
39  WorkflowTask *addTask(std::string, double flops,
40  unsigned long min_num_cores,
41  unsigned long max_num_cores,
42  double memory_requirement);
43 
44  void removeTask(WorkflowTask *task);
45 
46  void removeFile(WorkflowFile *file);
47 
48  WorkflowTask *getTaskByID(const std::string &id);
49 
50  WorkflowFile *addFile(std::string, double);
51 
52  WorkflowFile *getFileByID(const std::string &id);
53 
54  static double getSumFlops(const std::vector<WorkflowTask *> tasks);
55 
56  void addControlDependency(WorkflowTask *src, WorkflowTask *dest, bool redundant_dependencies = false);
58 
59  unsigned long getNumberOfTasks();
60 
61  unsigned long getNumLevels();
62 
63  double getCompletionDate();
64 
65  void exportToEPS(std::string);
66 
67  std::vector<WorkflowFile *> getFiles() const;
68  std::map<std::string, WorkflowFile *> getFileMap() const;
69  std::vector<WorkflowFile *> getInputFiles() const;
70  std::map<std::string, WorkflowFile *> getInputFileMap() const;
71  std::vector<WorkflowFile *> getOutputFiles() const;
72  std::map<std::string, WorkflowFile *> getOutputFileMap() const;
73 
74  std::vector<WorkflowTask *> getTasks();
75  std::map<std::string, WorkflowTask *> getTaskMap();
76  std::map<std::string, WorkflowTask *> getEntryTaskMap() const;
77  std::vector<WorkflowTask *> getEntryTasks() const;
78  std::map<std::string, WorkflowTask *> getExitTaskMap() const;
79  std::vector<WorkflowTask *> getExitTasks() const;
80 
81  std::vector<WorkflowTask *> getTaskParents(const WorkflowTask *task);
82  long getTaskNumberOfParents(const WorkflowTask *task);
83  std::vector<WorkflowTask *> getTaskChildren(const WorkflowTask *task);
84  long getTaskNumberOfChildren(const WorkflowTask *task);
85 
86  bool pathExists(const WorkflowTask *src, const WorkflowTask *dst);
87 
88 
89  bool isDone();
90 
91  /***********************/
93  /***********************/
94 
95  std::vector<WorkflowTask *> getTasksInTopLevelRange(unsigned long min, unsigned long max);
96 
97  std::vector<WorkflowTask *> getReadyTasks();
98 
99  std::map<std::string, std::vector<WorkflowTask *>> getReadyClusters();
100 
101  /***********************/
103  /***********************/
104 
105 
106  /***********************/
108  /***********************/
109  std::shared_ptr<WorkflowExecutionEvent> waitForNextExecutionEvent();
110  std::shared_ptr<WorkflowExecutionEvent> waitForNextExecutionEvent(double timeout);
111 
112  std::string getCallbackMailbox();
113 
114 // void updateTaskState(WorkflowTask *task, WorkflowTask::State state);
115 
116  /***********************/
118  /***********************/
119 
120  private:
121  friend class WMS;
122 
123  friend class WorkflowTask;
124 
125  struct Vertex{ WorkflowTask *task;};
126  typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, Vertex> DAG;
127  typedef boost::graph_traits<DAG>::vertex_descriptor vertex_t;
128 
129  DagOfTasks dag;
130 
131  std::map<std::string, std::unique_ptr<WorkflowTask>> tasks;
132  std::map<std::string, std::unique_ptr<WorkflowFile>> files;
133 
134 
135  std::string callback_mailbox;
136  ComputeService *parent_compute_service; // The compute service to which the job was submitted, if any
137  Simulation *simulation; // a ptr to the simulation so that the simulation can obtain simulation timestamps for workflow tasks
138  };
139 };
140 
141 #endif //WRENCH_WORKFLOW_H
wrench::Workflow::getTaskMap
std::map< std::string, WorkflowTask * > getTaskMap()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:385
wrench::Workflow::removeControlDependency
void removeControlDependency(WorkflowTask *src, WorkflowTask *dest)
Remove a control dependency between tasks (does nothing if none)
Definition: Workflow.cpp:190
wrench::Workflow::addFile
WorkflowFile * addFile(std::string, double)
Add a new file to the workflow.
Definition: Workflow.cpp:235
wrench::Workflow::getFiles
std::vector< WorkflowFile * > getFiles() const
Get the list of all files in the workflow.
Definition: Workflow.cpp:424
wrench::Workflow::getOutputFileMap
std::map< std::string, WorkflowFile * > getOutputFileMap() const
Retrieve a list of the output files of the workflow (i.e., those files that are output from some task...
Definition: Workflow.cpp:554
wrench::Workflow::addControlDependency
void addControlDependency(WorkflowTask *src, WorkflowTask *dest, bool redundant_dependencies=false)
Create a control dependency between two workflow tasks. Will not do anything if there is already a pa...
Definition: Workflow.cpp:165
wrench::Workflow::getTaskChildren
std::vector< WorkflowTask * > getTaskChildren(const WorkflowTask *task)
Get the list of children for a task.
Definition: Workflow.cpp:439
wrench::Workflow::getEntryTaskMap
std::map< std::string, WorkflowTask * > getEntryTaskMap() const
Get the list of exit tasks of the workflow, i.e., those tasks that don't have parents.
Definition: Workflow.cpp:616
wrench::Workflow::pathExists
bool pathExists(const WorkflowTask *src, const WorkflowTask *dst)
Determine whether one source is an ancestor of a destination task.
Definition: Workflow.cpp:299
wrench::ComputeService
The compute service base class.
Definition: ComputeService.h:33
wrench::Workflow::getTaskNumberOfParents
long getTaskNumberOfParents(const WorkflowTask *task)
Get the number of parents for a task.
Definition: Workflow.cpp:481
wrench::Workflow::getInputFiles
std::vector< WorkflowFile * > getInputFiles() const
Retrieve the list of the input files of the workflow (i.e., those files that are input to some tasks ...
Definition: Workflow.cpp:538
wrench::Workflow::addTask
WorkflowTask * addTask(std::string, double flops, unsigned long min_num_cores, unsigned long max_num_cores, double memory_requirement)
Create and add a new computational task to the workflow.
Definition: Workflow.cpp:40
wrench::Workflow::getExitTaskMap
std::map< std::string, WorkflowTask * > getExitTaskMap() const
Get the exit tasks of the workflow, i.e., those tasks that don't have children.
Definition: Workflow.cpp:650
wrench::Workflow::exportToEPS
void exportToEPS(std::string)
Output the workflow's dependency graph to EPS.
Definition: Workflow.cpp:278
wrench::Workflow::getFileByID
WorkflowFile * getFileByID(const std::string &id)
Find a WorkflowFile based on its ID.
Definition: Workflow.cpp:264
wrench::Workflow::removeTask
void removeTask(WorkflowTask *task)
Remove a task from the workflow. WARNING: this method de-allocated memory_manager_service for the tas...
Definition: Workflow.cpp:104
wrench
Definition: Alarm.cpp:20
wrench::Workflow
A workflow (to be executed by a WMS)
Definition: Workflow.h:34
wrench::Workflow::getTaskParents
std::vector< WorkflowTask * > getTaskParents(const WorkflowTask *task)
Get the list of parents for a task.
Definition: Workflow.cpp:467
wrench::WorkflowTask
A computational task in a Workflow.
Definition: WorkflowTask.h:31
wrench::Workflow::isDone
bool isDone()
Returns whether all tasks are complete.
Definition: Workflow.cpp:370
wrench::Workflow::getSumFlops
static double getSumFlops(const std::vector< WorkflowTask * > tasks)
Get the total number of flops for a list of tasks.
Definition: Workflow.cpp:587
wrench::Workflow::getCompletionDate
double getCompletionDate()
Returns the workflow's completion date.
Definition: Workflow.cpp:702
wrench::Workflow::getTaskNumberOfChildren
long getTaskNumberOfChildren(const WorkflowTask *task)
Get the number of children for a task.
Definition: Workflow.cpp:453
wrench::Workflow::getNumberOfTasks
unsigned long getNumberOfTasks()
Get the number of tasks in the workflow.
Definition: Workflow.cpp:287
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
wrench::Workflow::removeFile
void removeFile(WorkflowFile *file)
Remove a file from the workflow. WARNING: this method de-allocated memory_manager_service for the fil...
Definition: Workflow.cpp:79
wrench::Workflow::getOutputFiles
std::vector< WorkflowFile * > getOutputFiles() const
Retrieve a list of the output files of the workflow (i.e., those files that are output from some task...
Definition: Workflow.cpp:570
wrench::Workflow::Workflow
Workflow()
Constructor.
Definition: Workflow.cpp:306
wrench::Workflow::getExitTasks
std::vector< WorkflowTask * > getExitTasks() const
Get the exit tasks of the workflow, i.e., those tasks that don't have children.
Definition: Workflow.cpp:667
wrench::Workflow::getNumLevels
unsigned long getNumLevels()
Returns the number of levels in the workflow.
Definition: Workflow.cpp:684
wrench::Workflow::getFileMap
std::map< std::string, WorkflowFile * > getFileMap() const
Get the list of all files in the workflow.
Definition: Workflow.cpp:411
wrench::Workflow::getTaskByID
WorkflowTask * getTaskByID(const std::string &id)
Find a WorkflowTask based on its ID.
Definition: Workflow.cpp:148
wrench::WorkflowFile
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
wrench::Workflow::getEntryTasks
std::vector< WorkflowTask * > getEntryTasks() const
Get the list of exit tasks of the workflow, i.e., those tasks that don't have parents.
Definition: Workflow.cpp:633
wrench::Workflow::getTasks
std::vector< WorkflowTask * > getTasks()
Get the list of all tasks in the workflow.
Definition: Workflow.cpp:398
wrench::WMS
A workflow management system (WMS)
Definition: WMS.h:43
wrench::Workflow::getInputFileMap
std::map< std::string, WorkflowFile * > getInputFileMap() const
Retrieve the list of the input files of the workflow (i.e., those files that are input to some tasks ...
Definition: Workflow.cpp:522