WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
JobManager.h
1 
11 #ifndef WRENCH_PILOTJOBMANAGER_H
12 #define WRENCH_PILOTJOBMANAGER_H
13 
14 #include <vector>
15 #include <set>
16 
17 #include "wrench/services/Service.h"
18 
19 namespace wrench {
20 
21  class WMS;
22 
23  class Workflow;
24 
25  class WorkflowTask;
26 
27  class WorkflowFile;
28 
29  class WorkflowJob;
30 
31  class PilotJob;
32 
33  class StandardJob;
34 
35  class ComputeService;
36 
37  class StorageService;
38 
39  /***********************/
41  /***********************/
42 
43 
48  class JobManager : public Service {
49 
50  public:
51 
52 
53  void stop() override;
54 
55  void kill();
56 
57 
58  std::shared_ptr<StandardJob> createStandardJob(std::vector<WorkflowTask *> tasks,
59  std::map<WorkflowFile *, std::shared_ptr<FileLocation> > file_locations,
60  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation>, std::shared_ptr<FileLocation> >> pre_file_copies,
61  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation>, std::shared_ptr<FileLocation> >> post_file_copies,
62  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation> >> cleanup_file_deletions);
63 
64  std::shared_ptr<StandardJob> createStandardJob(std::vector<WorkflowTask *> tasks,
65  std::map<WorkflowFile *, std::vector<std::shared_ptr<FileLocation>>> file_locations,
66  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation>, std::shared_ptr<FileLocation> >> pre_file_copies,
67  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation>, std::shared_ptr<FileLocation> >> post_file_copies,
68  std::vector<std::tuple<WorkflowFile *, std::shared_ptr<FileLocation> >> cleanup_file_deletions);
69 
70 
71  std::shared_ptr<StandardJob> createStandardJob(std::vector<WorkflowTask *> tasks,
72  std::map<WorkflowFile *, std::shared_ptr<FileLocation>> file_locations);
73 
74  std::shared_ptr<StandardJob> createStandardJob(std::vector<WorkflowTask *> tasks,
75  std::map<WorkflowFile *, std::vector<std::shared_ptr<FileLocation>>> file_locations);
76 
77  std::shared_ptr<StandardJob> createStandardJob(WorkflowTask *task,
78  std::map<WorkflowFile *, std::shared_ptr<FileLocation>> file_locations);
79 
80  std::shared_ptr<StandardJob> createStandardJob(WorkflowTask *task,
81  std::map<WorkflowFile *, std::vector<std::shared_ptr<FileLocation>>> file_locations);
82 
83  std::shared_ptr<StandardJob> createStandardJob(std::vector<WorkflowTask *> tasks);
84 
85  std::shared_ptr<StandardJob> createStandardJob(WorkflowTask *task);
86 
87  std::shared_ptr<PilotJob> createPilotJob();
88 
89  void submitJob(std::shared_ptr<WorkflowJob> job, std::shared_ptr<ComputeService> compute_service,
90  std::map<std::string, std::string> service_specific_args = {});
91 
92  void terminateJob(std::shared_ptr<WorkflowJob> job);
93 
94 // void forgetJob(WorkflowJob *job);
95 
96  std::set<std::shared_ptr<PilotJob>> getPendingPilotJobs();
97 
98  std::set<std::shared_ptr<PilotJob>> getRunningPilotJobs();
99 
100  /***********************/
102  /***********************/
103 
104  ~JobManager() override;
105 
106  protected:
107 
108  friend class WMS;
109 
110  explicit JobManager(std::shared_ptr<WMS> wms);
111 
112  /***********************/
114  /***********************/
115 
116  private:
117 
118  int main() override;
119 
120  bool processNextMessage();
121 
122  void
123  processStandardJobCompletion(std::shared_ptr<StandardJob> job, std::shared_ptr<ComputeService> compute_service);
124 
125  void
126  processStandardJobFailure(std::shared_ptr<StandardJob> job, std::shared_ptr<ComputeService> compute_service,
127  std::shared_ptr<FailureCause> cause);
128 
129  void processPilotJobStart(std::shared_ptr<PilotJob> job, std::shared_ptr<ComputeService> compute_service);
130 
131  void processPilotJobExpiration(std::shared_ptr<PilotJob> job, std::shared_ptr<ComputeService> compute_service);
132 
133 
134  // Relevant WMS
135  std::shared_ptr<WMS> wms;
136 
137  // Job lists
138  std::set<std::shared_ptr<StandardJob>> new_standard_jobs;
139  std::set<std::shared_ptr<StandardJob>> pending_standard_jobs;
140  std::set<std::shared_ptr<StandardJob>> running_standard_jobs;
141  std::set<std::shared_ptr<StandardJob>> completed_standard_jobs;
142  std::set<std::shared_ptr<StandardJob>> failed_standard_jobs;
143 
144  std::set<std::shared_ptr<PilotJob>> new_pilot_jobs;
145  std::set<std::shared_ptr<PilotJob>> pending_pilot_jobs;
146  std::set<std::shared_ptr<PilotJob>> running_pilot_jobs;
147  std::set<std::shared_ptr<PilotJob>> completed_pilot_jobs;
148 
149  };
150 
151  /***********************/
153  /***********************/
154 
155 };
156 
157 #endif //WRENCH_PILOTJOBMANAGER_H
wrench::JobManager::createPilotJob
std::shared_ptr< PilotJob > createPilotJob()
Create a pilot job.
Definition: JobManager.cpp:371
wrench::JobManager::terminateJob
void terminateJob(std::shared_ptr< WorkflowJob > job)
Terminate a job (standard or pilot) that hasn't completed/expired/failed yet.
Definition: JobManager.cpp:507
wrench::JobManager::~JobManager
~JobManager() override
Destructor, which kills the daemon (and clears all the jobs)
Definition: JobManager.cpp:45
wrench::JobManager::getPendingPilotJobs
std::set< std::shared_ptr< PilotJob > > getPendingPilotJobs()
Get the list of currently pending pilot jobs.
Definition: JobManager.cpp:573
wrench::JobManager::submitJob
void submitJob(std::shared_ptr< WorkflowJob > job, std::shared_ptr< ComputeService > compute_service, std::map< std::string, std::string > service_specific_args={})
Submit a job to compute service.
Definition: JobManager.cpp:403
wrench::JobManager::kill
void kill()
Kill the job manager (brutally terminate the daemon, clears all jobs)
Definition: JobManager.cpp:59
wrench::JobManager::stop
void stop() override
Stop the job manager.
Definition: JobManager.cpp:77
wrench::JobManager
A helper daemon (co-located with and explicitly started by a WMS), which is used to handle all job ex...
Definition: JobManager.h:48
wrench
Definition: Alarm.cpp:20
wrench::JobManager::JobManager
JobManager(std::shared_ptr< WMS > wms)
Constructor.
Definition: JobManager.cpp:37
wrench::WorkflowTask
A computational task in a Workflow.
Definition: WorkflowTask.h:31
wrench::Service
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:26
wrench::JobManager::getRunningPilotJobs
std::set< std::shared_ptr< PilotJob > > getRunningPilotJobs()
Get the list of currently running pilot jobs.
Definition: JobManager.cpp:565
wrench::WorkflowFile
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
wrench::WMS
A workflow management system (WMS)
Definition: WMS.h:43