WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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/services/memory/MemoryManager.h"
18 #include "wrench/simgrid_S4U_util/S4U_PendingCommunication.h"
19 
20 namespace wrench {
21 
22  class SimulationMessage;
23 
24  class SimulationTimestampFileCopyStart;
25 
26  class S4U_PendingCommunication;
27 
45 
46  private:
47  WRENCH_PROPERTY_COLLECTION_TYPE default_property_values = {
49  {SimpleStorageServiceProperty::BUFFER_SIZE, "10485760"}, // 10 MEGA BYTE
50  };
51 
52 WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE default_messagepayload_values = {
67  };
68 
69  public:
70  // Public Constructor
71  SimpleStorageService(std::string hostname,
72  std::set <std::string> mount_points,
73  WRENCH_PROPERTY_COLLECTION_TYPE property_list = {},
74  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list = {});
75 
76  /***********************/
78  /***********************/
79 
80  ~SimpleStorageService() override;
81 
82  void cleanup(bool has_returned_from_main, int return_value) override;
83 
84  /***********************/
86  /***********************/
87 
88  private:
89  friend class Simulation;
90 
91  // Low-level Constructor
92  SimpleStorageService(std::string hostname,
93  std::set <std::string> mount_points,
94  WRENCH_PROPERTY_COLLECTION_TYPE property_list,
95  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list,
96  std::string suffix);
97 
98  int main() override;
99 
100  bool processNextMessage();
101 
102  unsigned long getNewUniqueNumber();
103 
104  bool processFileDeleteRequest(std::shared_ptr<DataFile>file, std::shared_ptr <FileLocation> location,
105  simgrid::s4u::Mailbox *answer_mailbox);
106 
107  bool processFileWriteRequest(std::shared_ptr<DataFile>file, std::shared_ptr <FileLocation>, simgrid::s4u::Mailbox *answer_mailbox,
108  unsigned long buffer_size);
109 
110  bool
111  processFileReadRequest(std::shared_ptr<DataFile>file, std::shared_ptr <FileLocation> location,
112  double num_bytes_to_read, simgrid::s4u::Mailbox *answer_mailbox,
113  simgrid::s4u::Mailbox *mailbox_to_receive_the_file_content, unsigned long buffer_size);
114 
115  bool processFileCopyRequest(std::shared_ptr<DataFile>file,
116  std::shared_ptr <FileLocation> src,
117  std::shared_ptr <FileLocation> dst,
118  simgrid::s4u::Mailbox *answer_mailbox);
119 
120  bool processFileTransferThreadNotification(
121  std::shared_ptr <FileTransferThread> ftt,
122  std::shared_ptr<DataFile>file,
123  simgrid::s4u::Mailbox *src_mailbox,
124  std::shared_ptr <FileLocation> src_location,
125  simgrid::s4u::Mailbox *dst_mailbox,
126  std::shared_ptr <FileLocation> dst_location,
127  bool success,
128  std::shared_ptr <FailureCause> failure_cause,
129  simgrid::s4u::Mailbox *answer_mailbox_if_read,
130  simgrid::s4u::Mailbox *answer_mailbox_if_write,
131  simgrid::s4u::Mailbox *answer_mailbox_if_copy);
132 
133  unsigned long num_concurrent_connections;
134 
135  void startPendingFileTransferThread();
136 
137  std::deque <std::shared_ptr<FileTransferThread>> pending_file_transfer_threads;
138  std::set <std::shared_ptr<FileTransferThread>> running_file_transfer_threads;
139 
140  void validateProperties();
141 
142  std::shared_ptr<MemoryManager> memory_manager;
143 
144  };
145 
146 };
147 
148 #endif //WRENCH_SIMPLESTORAGESERVICE_H
wrench::Service::property_list
WRENCH_PROPERTY_COLLECTION_TYPE property_list
The service's property list.
Definition: Service.h:110
wrench::StorageServiceProperty::BUFFER_SIZE
static const std::string BUFFER_SIZE
Buffer size used when copying/communicating data:
Definition: StorageServiceProperty.h:32
wrench::ServiceMessagePayload::DAEMON_STOPPED_MESSAGE_PAYLOAD
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:37
wrench::StorageServiceMessagePayload::FILE_READ_ANSWER_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_COPY_ANSWER_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FREE_SPACE_ANSWER_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_WRITE_ANSWER_MESSAGE_PAYLOAD
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
wrench::Service::messagepayload_list
WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list
The service's messagepayload list.
Definition: Service.h:113
wrench::StorageService
The storage service base class.
Definition: StorageService.h:36
wrench::StorageServiceMessagePayload::FILE_LOOKUP_REQUEST_MESSAGE_PAYLOAD
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
wrench::SimpleStorageService::SimpleStorageService
SimpleStorageService(std::string hostname, std::set< std::string > mount_points, WRENCH_PROPERTY_COLLECTION_TYPE property_list={}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list={})
Public constructor.
Definition: SimpleStorageService.cpp:71
wrench
Definition: Action.cpp:28
wrench::StorageServiceMessagePayload::FILE_WRITE_REQUEST_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_READ_REQUEST_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_DELETE_ANSWER_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_DELETE_REQUEST_MESSAGE_PAYLOAD
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
wrench::SimpleStorageService::cleanup
void cleanup(bool has_returned_from_main, int return_value) override
Cleanup method.
Definition: SimpleStorageService.cpp:57
wrench::StorageServiceMessagePayload::FREE_SPACE_REQUEST_MESSAGE_PAYLOAD
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
wrench::StorageServiceMessagePayload::FILE_LOOKUP_ANSWER_MESSAGE_PAYLOAD
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
wrench::ServiceMessagePayload::STOP_DAEMON_MESSAGE_PAYLOAD
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:35
wrench::StorageService::buffer_size
unsigned long buffer_size
The service's buffer size.
Definition: StorageService.h:99
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:60
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
wrench::StorageServiceMessagePayload::FILE_COPY_REQUEST_MESSAGE_PAYLOAD
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
wrench::SimpleStorageServiceProperty::MAX_NUM_CONCURRENT_DATA_CONNECTIONS
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
wrench::SimpleStorageService
A storage service that provides direct access to some storage resources (e.g., one or more disks)....
Definition: SimpleStorageService.h:44
wrench::SimpleStorageService::~SimpleStorageService
~SimpleStorageService() override
Destructor.
Definition: SimpleStorageService.cpp:47