FailureCause.h
1 
10 #ifndef WRENCH_STANDARDJOBFAILURECAUSE_H
11 #define WRENCH_STANDARDJOBFAILURECAUSE_H
12 
13 
14 #include <set>
15 #include <string>
16 
17 #include "wrench/services/Service.h"
18 #include "wrench/services/storage/StorageService.h"
19 #include "wrench/services/compute/ComputeService.h"
20 
21 namespace wrench {
22 
23  class Service;
24  class WorkflowFile;
25  class WorkflowJob;
26  class FileLocation;
27 
28  /***********************/
30  /***********************/
31 
32 
38  class FailureCause {
39 
40  public:
41 
42  FailureCause() = default;
43 
44  /***********************/
46  /***********************/
47  virtual ~FailureCause() = default;
48  /***********************/
50  /***********************/
51 
52 
58  virtual std::string toString() = 0;
59 
60  };
61 
62 
66  class NoScratchSpace : public FailureCause {
67 
68  public:
69  /***********************/
71  /***********************/
72  NoScratchSpace(std::string error);
73  /***********************/
75  /***********************/
76 
77  std::string toString();
78  private:
79  std::string error;
80  };
81 
85  class FileNotFound : public FailureCause {
86 
87  public:
88  /***********************/
90  /***********************/
91  FileNotFound(WorkflowFile *file, std::shared_ptr<FileLocation> location);
92  /***********************/
94  /***********************/
95 
96  WorkflowFile *getFile();
97  std::shared_ptr<FileLocation> getLocation();
98  std::string toString();
99 
100 
101  private:
102  WorkflowFile *file;
103  std::shared_ptr<FileLocation> location;
104  };
105 
109  class StorageServiceNotEnoughSpace : public FailureCause {
110 
111  public:
112  /***********************/
114  /***********************/
115  StorageServiceNotEnoughSpace(WorkflowFile *file, std::shared_ptr<StorageService> storage_service);
116  /***********************/
118  /***********************/
119 
120  WorkflowFile *getFile();
121  std::shared_ptr<StorageService> getStorageService();
122  std::string toString();
123 
124 
125  private:
126  WorkflowFile *file;
127  std::shared_ptr<StorageService> storage_service;
128  };
129 
130 // /**
131 // * @brief A "file is already there" failure cause
132 // */
133 // class StorageServiceFileAlreadyThere : public FailureCause {
134 //
135 // public:
136 // /***********************/
137 // /** \cond INTERNAL */
138 // /***********************/
139 // StorageServiceFileAlreadyThere(WorkflowFile *file, std::shared_ptr<StorageService> storage_service);
140 // /***********************/
141 // /** \endcond */
142 // /***********************/
143 //
144 // WorkflowFile *getFile();
145 // std::shared_ptr<StorageService> getStorageService();
146 // std::string toString();
147 //
148 //
149 // private:
150 // WorkflowFile *file;
151 // std::shared_ptr<StorageService> storage_service;
152 // };
153 
157  class InvalidDirectoryPath : public FailureCause {
158 
159  public:
160  /***********************/
162  /***********************/
164  std::shared_ptr<StorageService> storage_service,
165  std::string invalid_path);
166  /***********************/
168  /***********************/
169 
170  std::shared_ptr<StorageService> getStorageService();
171  std::string getInvalidPath();
172  std::string toString();
173 
174 
175  private:
176  std::shared_ptr<StorageService> storage_service;
177  std::string invalid_path;
178  };
179 
180 
181  class FileLocation;
182 
186  class FileAlreadyBeingCopied : public FailureCause {
187 
188 
189  public:
190  /***********************/
192  /***********************/
193  FileAlreadyBeingCopied(WorkflowFile *file,
194  std::shared_ptr<FileLocation> src,
195  std::shared_ptr<FileLocation> dst);
196  /***********************/
198  /***********************/
199 
200  WorkflowFile *getFile();
201  std::shared_ptr<FileLocation> getSourceLocation();
202  std::shared_ptr<FileLocation> getDestinationLocation();
203  std::string toString();
204 
205  private:
206  WorkflowFile *file;
207  std::shared_ptr<FileLocation> src_location;
208  std::shared_ptr<FileLocation> dst_location;
209  };
210 
214  class ServiceIsDown : public FailureCause {
215  public:
216  /***********************/
218  /***********************/
219  explicit ServiceIsDown(std::shared_ptr<Service> service);
220  /***********************/
222  /***********************/
223 
224  std::shared_ptr<Service> getService();
225  std::string toString() override;
226 
227  private:
228  std::shared_ptr<Service> service;
229  };
230 
234  class ServiceIsSuspended : public FailureCause {
235  public:
236  /***********************/
238  /***********************/
239  explicit ServiceIsSuspended(std::shared_ptr<Service> service);
240  /***********************/
242  /***********************/
243 
244  std::shared_ptr<Service> getService();
245  std::string toString() override;
246 
247  private:
248  std::shared_ptr<Service> service;
249  };
250 
254  class JobTypeNotSupported : public FailureCause {
255  public:
256  /***********************/
258  /***********************/
259  JobTypeNotSupported(WorkflowJob *job, std::shared_ptr<ComputeService> compute_service);
260  /***********************/
262  /***********************/
263 
264  WorkflowJob *getJob();
265  std::shared_ptr<ComputeService> getComputeService();
266  std::string toString();
267 
268  private:
269  WorkflowJob *job;
270  std::shared_ptr<ComputeService> compute_service;
271  };
272 
276  class FunctionalityNotAvailable : public FailureCause {
277  public:
278  /***********************/
280  /***********************/
281  FunctionalityNotAvailable(std::shared_ptr<Service> service, std::string functionality_name);
282  /***********************/
284  /***********************/
285 
286  std::shared_ptr<Service> getService();
287  std::string getFunctionalityName();
288  std::string toString();
289 
290  private:
291  std::shared_ptr<Service> service;
292  std::string functionality_name;
293  };
294 
295 
299  class NotEnoughResources : public FailureCause {
300  public:
301  /***********************/
303  /***********************/
304  NotEnoughResources(WorkflowJob *job, std::shared_ptr<ComputeService> compute_service);
305  /***********************/
307  /***********************/
308 
309  WorkflowJob *getJob();
310  std::shared_ptr<ComputeService> getComputeService();
311  std::string toString();
312 
313  private:
314  WorkflowJob *job;
315  std::shared_ptr<ComputeService> compute_service;
316  };
317 
321  class JobKilled : public FailureCause {
322  public:
323  /***********************/
325  /***********************/
326  JobKilled(WorkflowJob *job, std::shared_ptr<ComputeService> compute_service);
327  /***********************/
329  /***********************/
330 
331  WorkflowJob *getJob();
332  std::shared_ptr<ComputeService> getComputeService();
333  std::string toString();
334 
335  private:
336  WorkflowJob *job;
337  std::shared_ptr<ComputeService> compute_service;
338  };
339 
340 
344  class NetworkError : public FailureCause {
345  public:
350  SENDING,
351  RECEIVING
352  };
353 
356  enum ErrorType {
357  TIMEOUT,
358  FAILURE
359  };
360 
361  /***********************/
363  /***********************/
365  /***********************/
367  /***********************/
368 
369  std::string toString();
370  bool whileReceiving();
371  bool whileSending();
372  bool isTimeout();
373  std::string getMailbox();
374 
375  private:
376  NetworkError::OperationType operation_type;
377  NetworkError::ErrorType error_type;
378  bool while_sending = false;
379  std::string mailbox = "";
380  };
381 
385  class HostError : public FailureCause {
386  public:
387 
388  /***********************/
390  /***********************/
391  HostError(std::string hostname);
392 
393  /***********************/
395  /***********************/
396 
397  std::string toString();
398 
399  private:
400  std::string hostname;
401  };
402 
403 
407  class ComputeThreadHasDied : public FailureCause {
408  public:
409  /***********************/
411  /***********************/
413  /***********************/
415  /***********************/
416 
417  std::string toString();
418 
419  private:
420  };
421 
425  class FatalFailure : public FailureCause {
426  public:
427  /***********************/
429  /***********************/
430  FatalFailure();
431  /***********************/
433  /***********************/
434 
435  std::string toString();
436 
437  private:
438  };
439 
440 
444  class JobTimeout : public FailureCause {
445  public:
446  /***********************/
448  /***********************/
449  JobTimeout(WorkflowJob *job);
450  /***********************/
452  /***********************/
453 
454  WorkflowJob *getJob();
455  std::string toString();
456 
457  private:
458  WorkflowJob *job;
459  };
460 
464  class NotAllowed : public FailureCause {
465  public:
466  /***********************/
468  /***********************/
469  NotAllowed(std::shared_ptr<Service> service, std::string &error_message);
470  /***********************/
472  /***********************/
473 
474  std::shared_ptr<Service> getService();
475  std::string toString();
476 
477  private:
478  std::shared_ptr<Service> service;
479  std::string error_message;
480  };
481 
482 
483 
484  /***********************/
486  /***********************/
487 };
488 
489 
490 #endif //WRENCH_STANDARDJOBFAILURECAUSE_H
A "network error (or endpoint is down)" failure cause.
Definition: FailureCause.h:344
ErrorType
Enumerated type to describe the type of the network error.
Definition: FailureCause.h:356
A "not enough space on storage service" failure cause.
Definition: FailureCause.h:109
A "file is already being copied" failure cause.
Definition: FailureCause.h:186
A "service is down" failure cause.
Definition: FailureCause.h:214
A "service is suspended" failure cause.
Definition: FailureCause.h:234
A "compute service doesn&#39;t have enough cores" failure cause.
Definition: FailureCause.h:299
A "no scratch space" failure cause.
Definition: FailureCause.h:66
A "operation not allowed" failure cause.
Definition: FailureCause.h:464
A "compute service does not support requested job type" failure cause.
Definition: FailureCause.h:254
A "host error" failure cause (e.g., attempted to start a daemon on a host that is off) ...
Definition: FailureCause.h:385
An "Unknown" failure cause (should not happen)
Definition: FailureCause.h:425
A "requested functionality is not available on that service" failure cause.
Definition: FailureCause.h:276
OperationType
Enumerated type to describe whether the network error occured while sending or receiving.
Definition: FailureCause.h:349
A "file is already there" failure cause.
Definition: FailureCause.h:157
virtual std::string toString()=0
Return an error message that describes the failure cause (to be overridden)
A "file was not found" failure cause.
Definition: FailureCause.h:85
A "job has been killed" failure cause.
Definition: FailureCause.h:321
A "compute thread has died" failure cause.
Definition: FailureCause.h:407
A "job has times out" failure cause.
Definition: FailureCause.h:444
Definition: Alarm.cpp:19