WRENCH  1.10
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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 
23  /***********************/
25  /***********************/
26 
30  class FileTransferThread : public Service {
31 
32  public:
33 
34 
35 
36  FileTransferThread(std::string hostname,
37  std::shared_ptr<StorageService> parent,
38  WorkflowFile *file,
39  std::string src_mailbox,
40  std::shared_ptr<FileLocation> dst_location,
41  std::string answer_mailbox_if_read,
42  std::string answer_mailbox_if_write,
43  std::string answer_mailbox_if_copy,
44  unsigned long buffer_size);
45 
46  FileTransferThread(std::string hostname,
47  std::shared_ptr<StorageService> parent,
48  WorkflowFile *file,
49  std::shared_ptr<FileLocation> src_location,
50  std::string dst_mailbox,
51  std::string answer_mailbox_if_read,
52  std::string answer_mailbox_if_write,
53  std::string answer_mailbox_if_copy,
54  unsigned long buffer_size);
55 
56  FileTransferThread(std::string hostname,
57  std::shared_ptr<StorageService> parent,
58  WorkflowFile *file,
59  std::shared_ptr<FileLocation> src_location,
60  std::shared_ptr<FileLocation> dsg_location,
61  std::string answer_mailbox_if_read,
62  std::string answer_mailbox_if_write,
63  std::string answer_mailbox_if_copy,
64  unsigned long buffer_size);
65 
66  int main() override;
67  void cleanup(bool has_returned_from_main, int return_value) override;
68 
69 
70  private:
71 
72  std::shared_ptr<StorageService> parent;
73  WorkflowFile *file;
74 
75  // Only one of these two is valid
76  std::string src_mailbox;
77  std::shared_ptr<FileLocation> src_location;
78 
79  // Only one of these two is valid
80  std::string dst_mailbox;
81  std::shared_ptr<FileLocation> dst_location;
82 
83  std::string answer_mailbox_if_read;
84  std::string answer_mailbox_if_write;
85  std::string answer_mailbox_if_copy;
86  unsigned long buffer_size;
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  /***********************/
97  /***********************/
98 }
99 
100 #endif //WRENCH_FILETRANSFERTHREAD_H
101 
wrench::FileTransferThread
A helper class that implements the concept of a communication thread that performs a file transfer.
Definition: FileTransferThread.h:30
wrench::FileTransferThread::cleanup
void cleanup(bool has_returned_from_main, int return_value) override
Cleanup method.
Definition: FileTransferThread.cpp:142
wrench::FileTransferThread::main
int main() override
Main method.
Definition: FileTransferThread.cpp:150
wrench
Definition: Alarm.cpp:20
wrench::FileTransferThread::FileTransferThread
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)
Constructor.
Definition: FileTransferThread.cpp:40
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
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