StorageService.h
1 
11 #ifndef WRENCH_STORAGESERVICE_H
12 #define WRENCH_STORAGESERVICE_H
13 
14 
15 #include <string>
16 #include <set>
17 #include <wrench/workflow/job/StandardJob.h>
18 
19 #include "wrench/services/Service.h"
20 #include "wrench/workflow/execution_events/FailureCause.h"
21 
22 namespace wrench {
23 
24  class Simulation;
25 
26  class WorkflowFile;
27 
28  class FailureCause;
29 
30  class FileRegistryService;
31 
35  class StorageService : public Service {
36 
37  public:
38 
39  /***********************/
41  /***********************/
42 
43  void stop();
44 
45  virtual double getFreeSpace();
46 
47  double getTotalSpace();
48 
49  virtual bool lookupFile(WorkflowFile *file);
50 
51  virtual bool lookupFile(WorkflowFile *file, std::string dst_dir);
52 
53  virtual void deleteFile(WorkflowFile *file, FileRegistryService *file_registry_service=nullptr);
54 
55  virtual void deleteFile(WorkflowFile *file, std::string dst_dir, FileRegistryService *file_registry_service=nullptr);
56 
57  /***********************/
59  /***********************/
60 
61 
62  virtual void readFile(WorkflowFile *file, std::string src_dir);
63 
64  virtual void writeFile(WorkflowFile *file, std::string dst_dir);
65 
66  virtual void deleteFile(WorkflowFile *file, WorkflowJob* job, FileRegistryService *file_registry_service=nullptr);
67 
68  virtual bool lookupFile(WorkflowFile *file, WorkflowJob*);
69 
70  virtual void copyFile(WorkflowFile *file, StorageService *src, std::string src_dir, std::string dst_dir);
71 
72  virtual void copyFile(WorkflowFile *file, StorageService *src);
73 
74  virtual void copyFile(WorkflowFile *file, StorageService *src, WorkflowJob* src_job, WorkflowJob* dst_job);
75 
76  virtual void initiateFileCopy(std::string answer_mailbox,
77  WorkflowFile *file,
78  StorageService *src,
79  std::string src_dir,
80  std::string dst_dir);
81 
82  virtual void readFile(WorkflowFile *file);
83 
84  virtual void readFile(WorkflowFile *file, WorkflowJob* job);
85 
86  virtual void initiateFileRead(std::string mailbox_that_should_receive_file_content, WorkflowFile *file, std::string src_dir);
87 
88  virtual void writeFile(WorkflowFile *file);
89 
90  virtual void writeFile(WorkflowFile *file, WorkflowJob* job);
91 
92  static void readFiles(std::set<WorkflowFile *> files,
93  std::map<WorkflowFile *, StorageService *> file_locations,
94  StorageService *default_storage_service,
95  std::set<WorkflowFile*>& files_in_scratch,
96  WorkflowJob* job = nullptr);
97 
98  static void writeFiles(std::set<WorkflowFile *> files,
99  std::map<WorkflowFile *, StorageService *> file_locations,
100  StorageService *default_storage_service,
101  std::set<WorkflowFile*>& files_in_scratch,
102  WorkflowJob* job = nullptr);
103 
104  static void deleteFiles(std::set<WorkflowFile *> files,
105  std::map<WorkflowFile *, StorageService *> file_locations,
106  StorageService *default_storage_service);
107 
108  StorageService(const std::string &hostname,
109  const std::string &service_name,
110  const std::string &data_mailbox_name_prefix,
111  double capacity);
112 
113 
114  protected:
115 
116  friend class Simulation;
117  friend class FileRegistryService;
118 
119 
120  void stageFile(WorkflowFile *);
121 
122  void removeFileFromStorage(WorkflowFile *, std::string);
123 
125  std::map<std::string, std::set<WorkflowFile *>> stored_files;
127  double capacity;
129  double occupied_space = 0;
130 
131  /***********************/
133  /***********************/
134 
135  private:
136 
137  enum FileOperation {
138  READ,
139  WRITE,
140  };
141 
142  static void writeOrReadFiles(FileOperation action, std::set<WorkflowFile *> files,
143  std::map<WorkflowFile *, StorageService *> file_locations,
144  StorageService *default_storage_service, std::set<WorkflowFile*>& files_in_scratch,
145  WorkflowJob* job);
146 
147 
148  };
149 
150  /***********************/
152  /***********************/
153 
154 };
155 
156 
157 #endif //WRENCH_STORAGESERVICE_H
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
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
A class that provides basic simulation methods.
Definition: Simulation.h:34
A file registry service (a.k.a. replica catalog) that holds a database of which files are available a...
Definition: FileRegistryService.h:33
The storage service base class.
Definition: StorageService.h:35
Definition: TerminalOutput.cpp:15