FileTransferThread.h
1 
10 #ifndef WRENCH_FILETRANSFERTHREAD_H
11 #define WRENCH_FILETRANSFERTHREAD_H
12 
13 #include <string>
14 #include <wrench/simgrid_S4U_util/S4U_Daemon.h>
15 #include <wrench/services/Service.h>
16 #include <wrench/services/storage/StorageService.h>
17 
18 namespace wrench {
19 
20  class WorkflowFile;
21  class SimulationTimestampFileCopyStart;
22 
26  class FileTransferThread : public Service {
27 
28  public:
29 
30 
31 
32  FileTransferThread(std::string hostname,
33  std::shared_ptr<StorageService> parent,
34  WorkflowFile *file,
35  std::string src_mailbox,
36  std::shared_ptr<FileLocation> dst_location,
37  std::string answer_mailbox_if_read,
38  std::string answer_mailbox_if_write,
39  std::string answer_mailbox_if_copy,
40  unsigned long buffer_size,
41  SimulationTimestampFileCopyStart *start_timestamp = nullptr);
42 
43  FileTransferThread(std::string hostname,
44  std::shared_ptr<StorageService> parent,
45  WorkflowFile *file,
46  std::shared_ptr<FileLocation> src_location,
47  std::string dst_mailbox,
48  std::string answer_mailbox_if_read,
49  std::string answer_mailbox_if_write,
50  std::string answer_mailbox_if_copy,
51  unsigned long buffer_size,
52  SimulationTimestampFileCopyStart *start_timestamp = nullptr);
53 
54  FileTransferThread(std::string hostname,
55  std::shared_ptr<StorageService> parent,
56  WorkflowFile *file,
57  std::shared_ptr<FileLocation> src_location,
58  std::shared_ptr<FileLocation> dsg_location,
59  std::string answer_mailbox_if_read,
60  std::string answer_mailbox_if_write,
61  std::string answer_mailbox_if_copy,
62  unsigned long buffer_size,
63  SimulationTimestampFileCopyStart *start_timestamp = nullptr);
64 
65  int main() override;
66  void cleanup(bool has_returned_from_main, int return_value) override;
67 
68 
69  private:
70 
71  std::shared_ptr<StorageService> parent;
72  WorkflowFile *file;
73 
74  // Only one of these two is valid
75  std::string src_mailbox;
76  std::shared_ptr<FileLocation> src_location;
77 
78  // Only one of these two is valid
79  std::string dst_mailbox;
80  std::shared_ptr<FileLocation> dst_location;
81 
82  std::string answer_mailbox_if_read;
83  std::string answer_mailbox_if_write;
84  std::string answer_mailbox_if_copy;
85  unsigned long buffer_size;
86  SimulationTimestampFileCopyStart *start_timestamp;
87 
88  void receiveFileFromNetwork(WorkflowFile *file, std::string mailbox, std::shared_ptr<FileLocation> location);
89  void sendLocalFileToNetwork(WorkflowFile *file, std::shared_ptr<FileLocation> location, std::string mailbox);
90  void downloadFileFromStorageService(WorkflowFile *file, std::shared_ptr<FileLocation> src_location, std::shared_ptr<FileLocation> dst_location);
91  void copyFileLocally(WorkflowFile *file, std::shared_ptr<FileLocation> src_location, std::shared_ptr<FileLocation> dst_location);
92 
93  };
94 
95 }
96 
97 #endif //WRENCH_FILETRANSFERTHREAD_H
98 
int main() override
Main method.
Definition: FileTransferThread.cpp:163
FileTransferThread(std::string hostname, std::shared_ptr< StorageService > parent, WorkflowFile *file, std::string src_mailbox, std::shared_ptr< FileLocation > dst_location, std::string answer_mailbox_if_read, std::string answer_mailbox_if_write, std::string answer_mailbox_if_copy, unsigned long buffer_size, SimulationTimestampFileCopyStart *start_timestamp=nullptr)
Constructor.
Definition: FileTransferThread.cpp:42
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 helper class that implements the concept of a communication thread that performs a file transfer...
Definition: FileTransferThread.h:26
A data file used/produced by a WorkflowTask in a Workflow.
Definition: WorkflowFile.h:26
void cleanup(bool has_returned_from_main, int return_value) override
Cleanup method.
Definition: FileTransferThread.cpp:155
A simulation timestamp class for file copy start times.
Definition: SimulationTimestampTypes.h:186
Definition: Alarm.cpp:19