WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
StorageService.h
1 
11 #ifndef WRENCH_STORAGESERVICE_H
12 #define WRENCH_STORAGESERVICE_H
13 
14 
15 #include <string>
16 #include <set>
17 
18 #include "wrench/services/Service.h"
19 #include "wrench/failure_causes/FailureCause.h"
20 #include "wrench/services/file_registry/FileRegistryService.h"
21 #include "wrench/job/StandardJob.h"
22 #include "wrench/services/storage/storage_helpers/LogicalFileSystem.h"
23 #include "wrench/services/storage/storage_helpers/FileLocation.h"
24 
25 
26 namespace wrench {
27 
28  class Simulation;
29  class DataFile;
30  class FailureCause;
31  class FileRegistryService;
32 
36  class StorageService : public Service {
37 
38  public:
39 
40 
41  /***********************/
43  /***********************/
44 
45  void stop() override;
46 
47  virtual std::map<std::string, double> getFreeSpace();
48 
49  virtual std::map<std::string, double> getTotalSpace();
50 
51  std::string getMountPoint();
52  std::set<std::string> getMountPoints();
53  bool hasMultipleMountPoints();
54  bool hasMountPoint(std::string mp);
55 
56  static bool lookupFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location);
57  static void deleteFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location,
58  std::shared_ptr<FileRegistryService> file_registry_service = nullptr);
59  static void readFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location);
60  static void readFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location, double num_bytes);
61  static void writeFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location);
62  static void createFile(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> location);
63 
64 
65  /***********************/
67  /***********************/
68  bool isScratch();
69  void setScratch();
70 
71  static void copyFile(std::shared_ptr<DataFile>file,
72  std::shared_ptr<FileLocation> src_location,
73  std::shared_ptr<FileLocation> dst_location);
74 
75 
76  static void initiateFileCopy(simgrid::s4u::Mailbox *answer_mailbox,
77  std::shared_ptr<DataFile>file,
78  std::shared_ptr<FileLocation> src_location,
79  std::shared_ptr<FileLocation> dst_location);
80 
81  static void readFiles(std::map<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation>> locations);
82 
83  static void writeFiles(std::map<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation>> locations);
84 
85 
86  StorageService(const std::string &hostname,
87  const std::set<std::string> mount_points,
88  const std::string &service_name);
89 
90  protected:
91 
92  friend class Simulation;
93  friend class FileRegistryService;
94  friend class FileTransferThread;
95 
96  static void stageFile(std::shared_ptr<DataFile>file , std::shared_ptr<FileLocation> location);
97 
99  unsigned long buffer_size;
100 
102  std::map<std::string, std::unique_ptr<LogicalFileSystem>> file_systems;
103 
104  /***********************/
106  /***********************/
107 
108  private:
109 
110  enum FileOperation {
111  READ,
112  WRITE,
113  };
114 
115  static void writeOrReadFiles(FileOperation action,
116  std::map<std::shared_ptr<DataFile>, std::shared_ptr<FileLocation>> locations);
117 
118  void stageFile(std::shared_ptr<DataFile>file , std::string mountpoint, std::string directory);
119 
120  bool is_stratch;
121 
122 
123  };
124 
125  /***********************/
127  /***********************/
128 
129 };
130 
131 
132 #endif //WRENCH_STORAGESERVICE_H
wrench::FileRegistryService
A file registry service (a.k.a. replica catalog) that holds a database of which files are available a...
Definition: FileRegistryService.h:35
wrench::StorageService
The storage service base class.
Definition: StorageService.h:36
wrench
Definition: Action.cpp:28
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
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:31