SimpleStorageService.h
1 
10 #ifndef WRENCH_SIMPLESTORAGESERVICE_H
11 #define WRENCH_SIMPLESTORAGESERVICE_H
12 
13 #include <wrench/services/storage/storage_helpers/FileTransferThread.h>
14 #include "wrench/services/storage/StorageService.h"
15 #include "SimpleStorageServiceProperty.h"
16 #include "SimpleStorageServiceMessagePayload.h"
17 #include "wrench/simgrid_S4U_util/S4U_PendingCommunication.h"
18 
19 namespace wrench {
20 
21  class SimulationMessage;
22 
23  class SimulationTimestampFileCopyStart;
24 
25  class S4U_PendingCommunication;
26 
44 
45  private:
46  std::map <std::string, std::string> default_property_values = {
48  {SimpleStorageServiceProperty::BUFFER_SIZE, "10485760"}, // 10 MEGA BYTE
49  };
50 
51  std::map<std::string, double> default_messagepayload_values = {
66  };
67 
68  public:
69  // Public Constructor
70  SimpleStorageService(std::string hostname,
71  std::set <std::string> mount_points,
72  std::map <std::string, std::string> property_list = {},
73  std::map<std::string, double> messagepayload_list = {});
74 
75  /***********************/
77  /***********************/
78 
79  ~SimpleStorageService() override;
80 
81  void cleanup(bool has_returned_from_main, int return_value) override;
82 
83  /***********************/
85  /***********************/
86 
87  private:
88  friend class Simulation;
89 
90  // Low-level Constructor
91  SimpleStorageService(std::string hostname,
92  std::set <std::string> mount_points,
93  std::map <std::string, std::string> property_list,
94  std::map<std::string, double> messagepayload_list,
95  std::string suffix);
96 
97  int main() override;
98 
99  bool processNextMessage();
100 
101  unsigned long getNewUniqueNumber();
102 
103  bool processFileDeleteRequest(WorkflowFile *file, std::shared_ptr <FileLocation> location,
104  std::string answer_mailbox);
105 
106  bool processFileWriteRequest(WorkflowFile *file, std::shared_ptr <FileLocation>, std::string answer_mailbox,
107  unsigned long buffer_size);
108 
109  bool
110  processFileReadRequest(WorkflowFile *file, std::shared_ptr <FileLocation> location, std::string answer_mailbox,
111  std::string mailbox_to_receive_the_file_content, unsigned long buffer_size);
112 
113  bool processFileCopyRequest(WorkflowFile *file,
114  std::shared_ptr <FileLocation> src,
115  std::shared_ptr <FileLocation> dst,
116  std::string answer_mailbox);
117 
118  bool processFileTransferThreadNotification(
119  std::shared_ptr <FileTransferThread> ftt,
120  WorkflowFile *file,
121  std::string src_mailbox,
122  std::shared_ptr <FileLocation> src_location,
123  std::string dst_mailbox,
124  std::shared_ptr <FileLocation> dst_location,
125  bool success,
126  std::shared_ptr <FailureCause> failure_cause,
127  std::string answer_mailbox_if_read,
128  std::string answer_mailbox_if_write,
129  std::string answer_mailbox_if_copy);
130 
131  unsigned long num_concurrent_connections;
132 
133  void startPendingFileTransferThread();
134 
135  std::deque <std::shared_ptr<FileTransferThread>> pending_file_transfer_threads;
136  std::set <std::shared_ptr<FileTransferThread>> running_file_transfer_threads;
137 
138  void validateProperties();
139 
140  };
141 
142 };
143 
144 #endif //WRENCH_SIMPLESTORAGESERVICE_H
SimpleStorageService(std::string hostname, std::set< std::string > mount_points, std::map< std::string, std::string > property_list={}, std::map< std::string, double > messagepayload_list={})
Public constructor.
Definition: SimpleStorageService.cpp:70
static const std::string BUFFER_SIZE
Buffer size used when copying/communicating data:
Definition: StorageServiceProperty.h:32
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 FILE_READ_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer a file copy request.
Definition: StorageServiceMessagePayload.h:54
static const std::string FILE_COPY_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer a file copy request.
Definition: StorageServiceMessagePayload.h:44
static const std::string FREE_SPACE_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer free space information reques...
Definition: StorageServiceMessagePayload.h:29
static const std::string FILE_WRITE_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer a file copy request.
Definition: StorageServiceMessagePayload.h:49
The storage service base class.
Definition: StorageService.h:36
static const std::string FILE_LOOKUP_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request a file lookup.
Definition: StorageServiceMessagePayload.h:32
Definition: Alarm.cpp:20
static const std::string FILE_WRITE_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request a file copy.
Definition: StorageServiceMessagePayload.h:47
static const std::string FILE_READ_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request a file copy.
Definition: StorageServiceMessagePayload.h:52
static const std::string FILE_DELETE_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer a file deletion request.
Definition: StorageServiceMessagePayload.h:39
static const std::string FILE_DELETE_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request a file deletion.
Definition: StorageServiceMessagePayload.h:37
void cleanup(bool has_returned_from_main, int return_value) override
Cleanup method.
Definition: SimpleStorageService.cpp:56
static const std::string FREE_SPACE_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request its free space information.
Definition: StorageServiceMessagePayload.h:27
static const std::string FILE_LOOKUP_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to answer a file lookup request.
Definition: StorageServiceMessagePayload.h:34
std::map< std::string, double > messagepayload_list
The service's messagepayload list.
Definition: Service.h:112
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
unsigned long buffer_size
The service's buffer size.
Definition: StorageService.h:98
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
static const std::string FILE_COPY_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request a file copy.
Definition: StorageServiceMessagePayload.h:42
static const std::string MAX_NUM_CONCURRENT_DATA_CONNECTIONS
The maximum number of concurrent data connections supported by the service (default = "infinity")
Definition: SimpleStorageServiceProperty.h:26
A storage service that provides direct access to some storage resources (e.g., one or more disks)....
Definition: SimpleStorageService.h:43
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
~SimpleStorageService() override
Destructor.
Definition: SimpleStorageService.cpp:46
std::map< std::string, std::string > property_list
The service's property list.
Definition: Service.h:109