BatchComputeService.h
1 
11 #ifndef WRENCH_BATCH_SERVICE_H
12 #define WRENCH_BATCH_SERVICE_H
13 
14 #include "wrench/services/compute/ComputeService.h"
15 #include "wrench/services/compute/standard_job_executor/StandardJobExecutor.h"
16 #include "wrench/services/compute/batch/BatchJob.h"
17 #include "wrench/services/compute/batch/BatschedNetworkListener.h"
18 #include "wrench/services/compute/batch/BatchComputeServiceProperty.h"
19 #include "wrench/services/compute/batch/BatchComputeServiceMessagePayload.h"
20 #include "wrench/services/helpers/Alarm.h"
21 #include "wrench/workflow/job/StandardJob.h"
22 #include "wrench/workflow/job/WorkflowJob.h"
23 #include "wrench/services/compute/batch/batch_schedulers/BatchScheduler.h"
24 
25 #include <deque>
26 #include <queue>
27 #include <set>
28 #include <tuple>
29 
30 namespace wrench {
31 
32  class WorkloadTraceFileReplayer; // forward
33 
50 
54  private:
55 
56  std::map<std::string, std::string> default_property_values = {
62 #ifdef ENABLE_BATSCHED
64 // {BatchComputeServiceProperty::BATCH_SCHEDULING_ALGORITHM, "easy_bf"},
65 // {BatchComputeServiceProperty::BATCH_SCHEDULING_ALGORITHM, "easy_bf_fast"},
66 
68 #else
70 #endif
80  };
81 
82  std::map<std::string, double> default_messagepayload_values = {
99  };
100 
101  public:
102  BatchComputeService(const std::string &hostname,
103  std::vector<std::string> compute_hosts,
104  std::string scratch_space_mount_point,
105  std::map<std::string, std::string> property_list = {},
106  std::map<std::string, double> messagepayload_list = {}
107  );
108 
109  /***********************/
111  /***********************/
112  std::map<std::string,double> getStartTimeEstimates(std::set<std::tuple<std::string,unsigned long,unsigned long, double>> resources);
113 
114  /***********************/
116  /***********************/
117 
118  /***********************/
120  /***********************/
121  ~BatchComputeService() override;
122  /***********************/
124  /***********************/
125 
126  private:
127 
128  friend class WorkloadTraceFileReplayer;
129  friend class FCFSBatchScheduler;
130  friend class CONSERVATIVEBFBatchScheduler;
131  friend class BatschedBatchScheduler;
132 
133  BatchComputeService(const std::string hostname,
134  std::vector<std::string> compute_hosts,
135  unsigned long cores_per_host,
136  double ram_per_host,
137  std::string scratch_space_mount_point,
138  std::map<std::string, std::string> property_list,
139  std::map<std::string, double> messagepayload_list,
140  std::string suffix
141  );
142 
143  // helper function
144  static unsigned long parseUnsignedLongServiceSpecificArgument(std::string key, std::map<std::string, std::string> &args);
145 
146  // helper function
147  void submitWorkflowJob(WorkflowJob *job, std::map<std::string, std::string> &batch_job_args);
148 
149  //submits a standard job
150  void submitStandardJob(StandardJob *job, std::map<std::string, std::string> &batch_job_args) override;
151 
152  //submits a standard job
153  void submitPilotJob(PilotJob *job, std::map<std::string, std::string> &batch_job_args) override;
154 
155  // helper function
156  void terminateWorkflowJob(WorkflowJob *job);
157 
158  // terminate a standard job
159  void terminateStandardJob(StandardJob *job) override;
160 
161  // terminate a pilot job
162  void terminatePilotJob(PilotJob *job) override;
163 
164  std::vector<std::tuple<std::string, double, double, double, double, unsigned int>> workload_trace;
165  std::shared_ptr<WorkloadTraceFileReplayer> workload_trace_replayer;
166 
167  bool clean_exit = false;
168 
169  //Configuration to create randomness in measurement period initially
170  unsigned long random_interval = 10;
171 
172  //create alarms for standard jobs
173  std::map<std::string,std::shared_ptr<Alarm>> standard_job_alarms;
174 
175  //alarms for pilot jobs (only one pilot job alarm)
176  std::map<std::string,std::shared_ptr<Alarm>> pilot_job_alarms;
177 
178  /* Resources information in BatchService */
179  unsigned long total_num_of_nodes;
180  unsigned long num_cores_per_node;
181  std::map<std::string, unsigned long> nodes_to_cores_map;
182  std::vector<double> timeslots;
183  std::map<std::string, unsigned long> available_nodes_to_cores;
184  std::map<unsigned long, std::string> host_id_to_names;
185  std::vector<std::string> compute_hosts;
186  /* End Resources information in BatchService */
187 
188  // Vector of standard job executors
189  std::set<std::shared_ptr<StandardJobExecutor>> running_standard_job_executors;
190 
191  // Vector of standard job executors (which is cleared periodically)
192  std::set<std::shared_ptr<StandardJobExecutor>> finished_standard_job_executors;
193 
194  // Master List of batch jobs
195  std::set<std::shared_ptr<BatchJob>> all_jobs;
196 
197  //A set of running batch jobs
198  std::set<std::shared_ptr<BatchJob>> running_jobs;
199 
200  // The batch queue
201  std::deque<std::shared_ptr<BatchJob>> batch_queue;
202 
203  // A set of "waiting" batch jobs, i.e., jobs that are waiting to be sent to
204  // the scheduler (useful for batsched only)
205  std::set<std::shared_ptr<BatchJob>> waiting_jobs;
206 
207  // Scheduler
208  std::unique_ptr<BatchScheduler> scheduler;
209 
210 
211 #ifdef ENABLE_BATSCHED
212 
213  std::set<std::string> scheduling_algorithms = {"conservative_bf", "crasher", "easy_bf", "easy_bf_fast",
214  "easy_bf_plot_liquid_load_horizon",
215  "energy_bf", "energy_bf_dicho", "energy_bf_idle_sleeper",
216  "energy_bf_monitoring",
217  "energy_bf_monitoring_inertial", "energy_bf_subpart_sleeper",
218  "energy_watcher", "fcfs_fast", "fast_conservative_bf",
219  "filler", "killer", "killer2", "random", "rejecter",
220  "sequencer", "sleeper", "submitter", "waiting_time_estimator"
221  };
222 
223  std::set<std::string> queue_ordering_options = {"fcfs", "lcfs", "desc_bounded_slowdown", "desc_slowdown",
224  "asc_size", "desc_size", "asc_walltime", "desc_walltime"
225 
226  };
227 #else
228  std::set<std::string> scheduling_algorithms = {"fcfs", "conservative_bf",
229  };
230 
231  //Batch queue ordering options
232  std::set<std::string> queue_ordering_options = {
233  };
234 
235 #endif
236 
237  unsigned long generateUniqueJobID();
238 
239  void removeJobFromRunningList(std::shared_ptr<BatchJob> job);
240 
241  void removeJobFromBatchQueue(std::shared_ptr<BatchJob> job);
242 
243  void removeBatchJobFromJobsList(std::shared_ptr<BatchJob> job);
244 
245  int main() override;
246 
247  bool processNextMessage();
248 
249  void startBackgroundWorkloadProcess();
250 
251  void processGetResourceInformation(const std::string &answer_mailbox);
252 
253  void processStandardJobCompletion(std::shared_ptr<StandardJobExecutor> executor, StandardJob *job);
254 
255  void processStandardJobFailure(std::shared_ptr<StandardJobExecutor> executor,
256  StandardJob *job,
257  std::shared_ptr<FailureCause> cause);
258 
259  void terminateRunningStandardJob(StandardJob *job);
260 
261 
262  //Terminate the batch service (this is usually for pilot jobs when they act as a batch service)
263  void cleanup(bool has_returned_from_main, int return_value) override;
264 
265  // Terminate currently running pilot jobs
266  void terminateRunningPilotJobs();
267 
268  //Fail the standard jobs
269  void failCurrentStandardJobs();
270 
271  //Process the pilot job completion
272  void processPilotJobCompletion(PilotJob *job);
273 
274  //Process standardjob timeout
275  void processStandardJobTimeout(StandardJob *job);
276 
277  //process standard job termination request
278  void processStandardJobTerminationRequest(StandardJob *job, std::string answer_mailbox);
279 
280  //process pilot job termination request
281  void processPilotJobTerminationRequest(PilotJob *job, std::string answer_mailbox);
282 
283  // process a batch job tiemout event
284  void processAlarmJobTimeout(std::shared_ptr<BatchJob>job);
285 
286  //Process pilot job timeout
287  void processPilotJobTimeout(PilotJob *job);
288 
289  //free up resources
290  void freeUpResources(std::map<std::string, std::tuple<unsigned long, double>> resources);
291 
292  //send call back to the pilot job submitters
293  void sendPilotJobExpirationNotification(PilotJob *job);
294 
295  //send call back to the standard job submitters
296  void sendStandardJobFailureNotification(StandardJob *job, std::string job_id, std::shared_ptr<FailureCause> cause);
297 
298  // process a job submission
299  void processJobSubmission(std::shared_ptr<BatchJob>job, std::string answer_mailbox);
300 
301  //start a job
302  void startJob(std::map<std::string, std::tuple<unsigned long, double>>, WorkflowJob *,
303  std::shared_ptr<BatchJob>, unsigned long, unsigned long, unsigned long);
304 
305 
306  void processExecuteJobFromBatSched(std::string bat_sched_reply);
307 
308  };
309 }
310 
311 
312 #endif //WRENCH_BATCH_SERVICE_H
static const std::string SIMULATE_COMPUTATION_AS_SLEEP
Simulate computation as just a sleep instead of an actual compute thread. This is for scalability rea...
Definition: BatchComputeServiceProperty.h:139
static const std::string PILOT_JOB_EXPIRED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a pilot job has expired.
Definition: ComputeServiceMessagePayload.h:44
static const std::string TERMINATE_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a pilot job termination.
Definition: ComputeServiceMessagePayload.h:54
A class that implements a FCFS batch scheduler.
Definition: FCFSBatchScheduler.h:25
static const std::string SUBMIT_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a standard job.
Definition: ComputeServiceMessagePayload.h:26
static const std::string DAEMON_STOPPED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to confirm it has terminated.
Definition: ServiceMessagePayload.h:33
static const std::string TERMINATE_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a standard job terminati...
Definition: ComputeServiceMessagePayload.h:36
static const std::string IGNORE_INVALID_JOBS_IN_WORKLOAD_TRACE_FILE
Whether, when simulating a workload trace file, to abort when there is an invalid job specification (...
Definition: BatchComputeServiceProperty.h:101
static const std::string USE_REAL_RUNTIMES_AS_REQUESTED_RUNTIMES_IN_WORKLOAD_TRACE_FILE
Whether, when simulating a workload trace file, to use the actual runtimes as requested runtimes (i....
Definition: BatchComputeServiceProperty.h:92
static const std::string RESOURCE_DESCRIPTION_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to ask it for information on its resour...
Definition: ComputeServiceMessagePayload.h:56
static const std::string BATSCHED_CONTIGUOUS_ALLOCATION
Controls Batsched node allocation policy.
Definition: BatchComputeServiceProperty.h:157
static const std::string HOST_SELECTION_ALGORITHM
The host selection algorithm. Can be:
Definition: BatchComputeServiceProperty.h:59
The compute service base class.
Definition: ComputeService.h:35
static const std::string SUBMIT_TIME_OF_FIRST_JOB_IN_WORKLOAD_TRACE_FILE
A specification of the submit time of the first job in a provided trace file.
Definition: BatchComputeServiceProperty.h:108
A standard (i.e., non-pilot) workflow job that can be submitted to a ComputeService by a WMS (via a J...
Definition: StandardJob.h:37
static const std::string SIMULATED_WORKLOAD_TRACE_FILE
Path to a workload trace file to be replayed. The trace file can be be in the SWF format (see http://...
Definition: BatchComputeServiceProperty.h:82
static const std::string TERMINATE_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate a pilot job.
Definition: ComputeServiceMessagePayload.h:52
A batch-scheduled compute service that manages a set of compute hosts and controls access to their re...
Definition: BatchComputeService.h:49
static const std::string STANDARD_JOB_DONE_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that it has completed a standa...
Definition: ComputeServiceMessagePayload.h:30
static const std::string STANDARD_JOB_FAILED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a running standard job ha...
Definition: ComputeServiceMessagePayload.h:32
Definition: Alarm.cpp:20
static const std::string TERMINATE_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate a standard job.
Definition: ComputeServiceMessagePayload.h:34
static const std::string SUBMIT_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent from the daemon to acknowledge a pilot job submission...
Definition: ComputeServiceMessagePayload.h:40
std::map< std::string, double > getStartTimeEstimates(std::set< std::tuple< std::string, unsigned long, unsigned long, double >> resources)
Retrieve start time estimates for a set of job configurations.
Definition: BatchComputeService.cpp:219
A class that defines a batsched batch scheduler.
Definition: BatschedBatchScheduler.h:24
static const std::string TASK_STARTUP_OVERHEAD
The overhead to start a task execution, in seconds.
Definition: BatchComputeServiceProperty.h:27
static const std::string BATSCHED_LOGGING_MUTED
Controls Batsched logging.
Definition: BatchComputeServiceProperty.h:147
static const std::string TASK_SELECTION_ALGORITHM
The algorithm to pick which ready computational task (within a standard job executed by the batch ser...
Definition: BatchComputeServiceProperty.h:69
Abstraction of a job used for executing tasks in a Workflow.
Definition: WorkflowJob.h:34
A service that goes through a job submission trace (as loaded by a TraceFileLoader),...
Definition: WorkloadTraceFileReplayer.h:28
std::map< std::string, double > messagepayload_list
The service's messagepayload list.
Definition: Service.h:112
static const std::string RESOURCE_DESCRIPTION_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state information on its resources.
Definition: ComputeServiceMessagePayload.h:58
static const std::string OUTPUT_CSV_JOB_LOG
Path to a to-be-generated Batsim-style CSV trace file (e.g. for b3atch schedule visualization purpose...
Definition: BatchComputeServiceProperty.h:119
static const std::string STOP_DAEMON_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate it.
Definition: ServiceMessagePayload.h:31
static const std::string PILOT_JOB_STARTED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state that a pilot job has started.
Definition: ComputeServiceMessagePayload.h:42
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
static const std::string SUBMIT_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a standard job submissio...
Definition: ComputeServiceMessagePayload.h:28
static const std::string BATCH_SCHEDULING_ALGORITHM
The batch scheduling algorithm. Can be:
Definition: BatchComputeServiceProperty.h:40
static const std::string SUBMIT_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a pilot job.
Definition: ComputeServiceMessagePayload.h:38
static const std::string SUPPORTS_PILOT_JOBS
Whether the compute service supports pilot jobs (true or false)
Definition: ComputeServiceProperty.h:26
A pilot (i.e., non-standard) workflow job that can be submitted to a ComputeService by a WMS (via a J...
Definition: PilotJob.h:29
static const std::string BATCH_RJMS_PADDING_DELAY
Integral number of seconds that the Batch Scheduler adds to the runtime of each incoming job....
Definition: BatchComputeServiceProperty.h:129
A class that defines a conservative backfilling batch scheduler.
Definition: CONSERVATIVEBFBatchScheduler.h:26
BatchComputeService(const std::string &hostname, std::vector< std::string > compute_hosts, std::string scratch_space_mount_point, std::map< std::string, std::string > property_list={}, std::map< std::string, double > messagepayload_list={})
Constructor.
Definition: BatchComputeService.cpp:60
static const std::string BATCH_QUEUE_ORDERING_ALGORITHM
The batch queue ordering algorithm. Can be:
Definition: BatchComputeServiceProperty.h:49
std::map< std::string, std::string > property_list
The service's property list.
Definition: Service.h:109
static const std::string SUPPORTS_STANDARD_JOBS
Whether the compute service supports standard jobs (true or false)
Definition: ComputeServiceProperty.h:24