WRENCH  1.10
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/workflow/failure_causes/FailureCause.h>
20 #include <wrench/services/file_registry/FileRegistryService.h>
21 #include <wrench/workflow/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 WorkflowFile;
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();
54  bool hasMountPoint(std::string mp);
55 
56  static bool lookupFile(WorkflowFile *file, std::shared_ptr<FileLocation> location);
57  static void deleteFile(WorkflowFile *file, std::shared_ptr<FileLocation> location,
58  std::shared_ptr<FileRegistryService> file_registry_service = nullptr);
59  static void readFile(WorkflowFile *file, std::shared_ptr<FileLocation> location);
60  static void writeFile(WorkflowFile *file, std::shared_ptr<FileLocation> location);
61 
62 
63  /***********************/
65  /***********************/
66  bool isScratch();
67  void setScratch();
68 
69  static void copyFile(WorkflowFile *file,
70  std::shared_ptr<FileLocation> src_location,
71  std::shared_ptr<FileLocation> dst_location);
72 
73 
74  static void initiateFileCopy(std::string answer_mailbox,
75  WorkflowFile *file,
76  std::shared_ptr<FileLocation> src_location,
77  std::shared_ptr<FileLocation> dst_location);
78 
79  static void readFiles(std::map<WorkflowFile *, std::shared_ptr<FileLocation>> locations);
80 
81  static void writeFiles(std::map<WorkflowFile *, std::shared_ptr<FileLocation>> locations);
82 
83 
84  StorageService(const std::string &hostname,
85  const std::set<std::string> mount_points,
86  const std::string &service_name,
87  const std::string &data_mailbox_name_prefix);
88 
89  protected:
90 
91  friend class Simulation;
92  friend class FileRegistryService;
93  friend class FileTransferThread;
94 
95  static void stageFile(WorkflowFile *file , std::shared_ptr<FileLocation> location);
96 
98  unsigned long buffer_size;
99 
101  std::map<std::string, std::unique_ptr<LogicalFileSystem>> file_systems;
102 
103  /***********************/
104 
105 
107  /***********************/
108 
109  private:
110 
111  enum FileOperation {
112  READ,
113  WRITE,
114  };
115 
116  static void writeOrReadFiles(FileOperation action,
117  std::map<WorkflowFile *, std::shared_ptr<FileLocation>> locations);
118 
119  void stageFile(WorkflowFile *file , std::string mountpoint, std::string directory);
120 
121  bool is_stratch;
122 
123 
124  };
125 
126  /***********************/
128  /***********************/
129 
130 };
131 
132 
133 #endif //WRENCH_STORAGESERVICE_H
wrench::StorageService::getMountPoint
std::string getMountPoint()
Get the mount point (will throw is more than one)
Definition: StorageService.cpp:640
wrench::StorageService::copyFile
static void copyFile(WorkflowFile *file, std::shared_ptr< FileLocation > src_location, std::shared_ptr< FileLocation > dst_location)
Synchronously ask the storage service to read a file from another storage service.
Definition: StorageService.cpp:532
wrench::StorageService::stageFile
static void stageFile(WorkflowFile *file, std::shared_ptr< FileLocation > location)
Store a file at a particular mount point BEFORE the simulation is launched.
Definition: StorageService.cpp:84
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::hasMultipleMountPoints
bool hasMultipleMountPoints()
Checked whether the storage service has multiple mount points.
Definition: StorageService.cpp:664
wrench::StorageService::initiateFileCopy
static void initiateFileCopy(std::string answer_mailbox, WorkflowFile *file, std::shared_ptr< FileLocation > src_location, std::shared_ptr< FileLocation > dst_location)
Asynchronously ask for a file copy between two storage services.
Definition: StorageService.cpp:593
wrench::FileTransferThread
A helper class that implements the concept of a communication thread that performs a file transfer.
Definition: FileTransferThread.h:30
wrench::StorageService::StorageService
StorageService(const std::string &hostname, const std::set< std::string > mount_points, const std::string &service_name, const std::string &data_mailbox_name_prefix)
Constructor.
Definition: StorageService.cpp:39
wrench::StorageService::deleteFile
static void deleteFile(WorkflowFile *file, std::shared_ptr< FileLocation > location, std::shared_ptr< FileRegistryService > file_registry_service=nullptr)
Synchronously delete a file at a location.
Definition: StorageService.cpp:471
wrench::StorageService::setScratch
void setScratch()
Indicate that this storace service is a scratch service of a ComputeService.
Definition: StorageService.cpp:72
wrench::StorageService::writeFiles
static void writeFiles(std::map< WorkflowFile *, std::shared_ptr< FileLocation >> locations)
Synchronously and sequentially upload a set of files from storage services.
Definition: StorageService.cpp:407
wrench::StorageService::getMountPoints
std::set< std::string > getMountPoints()
Get the set of mount points.
Definition: StorageService.cpp:652
wrench::StorageService
The storage service base class.
Definition: StorageService.h:36
wrench
Definition: Alarm.cpp:20
wrench::StorageService::getTotalSpace
virtual std::map< std::string, double > getTotalSpace()
Get the total static capacity of the storage service (in zero simulation time)
Definition: StorageService.cpp:628
wrench::StorageService::hasMountPoint
bool hasMountPoint(std::string mp)
Checked whether the storage service has a particular mount point.
Definition: StorageService.cpp:674
wrench::StorageService::stop
void stop() override
Stop the service.
Definition: StorageService.cpp:108
wrench::StorageService::readFiles
static void readFiles(std::map< WorkflowFile *, std::shared_ptr< FileLocation >> locations)
Synchronously and sequentially read a set of files from storage services.
Definition: StorageService.cpp:395
wrench::StorageService::writeFile
static void writeFile(WorkflowFile *file, std::shared_ptr< FileLocation > location)
Synchronously write a file to the storage service.
Definition: StorageService.cpp:309
wrench::StorageService::lookupFile
static bool lookupFile(WorkflowFile *file, std::shared_ptr< FileLocation > location)
Synchronously asks the storage service whether it holds a file.
Definition: StorageService.cpp:168
wrench::StorageService::isScratch
bool isScratch()
Determines whether the storage service is a scratch service of a ComputeService.
Definition: StorageService.cpp:65
wrench::StorageService::readFile
static void readFile(WorkflowFile *file, std::shared_ptr< FileLocation > location)
Synchronously read a file from the storage service.
Definition: StorageService.cpp:216
wrench::StorageService::getFreeSpace
virtual std::map< std::string, double > getFreeSpace()
Synchronously asks the storage service for its capacity at all its mount points.
Definition: StorageService.cpp:127
wrench::StorageService::buffer_size
unsigned long buffer_size
The service's buffer size.
Definition: StorageService.h:98
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
wrench::StorageService::file_systems
std::map< std::string, std::unique_ptr< LogicalFileSystem > > file_systems
File systems.
Definition: StorageService.h:101
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::WorkflowFile
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26