WRENCH  1.11
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 #include <iostream>
18 
19 namespace wrench {
20 
21  class DataFile;
22  class SimulationTimestampFileCopyStart;
23 
24  /***********************/
26  /***********************/
27 
31  class FileTransferThread : public Service {
32 
33  public:
34 
36  }
37 
38 
39  FileTransferThread(std::string hostname,
40  std::shared_ptr<StorageService> parent,
41  std::shared_ptr<DataFile>file,
42  double num_bytes_to_transfer,
43  simgrid::s4u::Mailbox *src_mailbox,
44  std::shared_ptr<FileLocation> dst_location,
45  simgrid::s4u::Mailbox *answer_mailbox_if_read,
46  simgrid::s4u::Mailbox *answer_mailbox_if_write,
47  simgrid::s4u::Mailbox *answer_mailbox_if_copy,
48  unsigned long buffer_size);
49 
50  FileTransferThread(std::string hostname,
51  std::shared_ptr<StorageService> parent,
52  std::shared_ptr<DataFile>file,
53  double num_bytes_to_transfer,
54  std::shared_ptr<FileLocation> src_location,
55  simgrid::s4u::Mailbox *dst_mailbox,
56  simgrid::s4u::Mailbox *answer_mailbox_if_read,
57  simgrid::s4u::Mailbox *answer_mailbox_if_write,
58  simgrid::s4u::Mailbox *answer_mailbox_if_copy,
59  unsigned long buffer_size);
60 
61  FileTransferThread(std::string hostname,
62  std::shared_ptr<StorageService> parent,
63  std::shared_ptr<DataFile>file,
64  double num_bytes_to_transfer,
65  std::shared_ptr<FileLocation> src_location,
66  std::shared_ptr<FileLocation> dsg_location,
67  simgrid::s4u::Mailbox *answer_mailbox_if_read,
68  simgrid::s4u::Mailbox *answer_mailbox_if_write,
69  simgrid::s4u::Mailbox *answer_mailbox_if_copy,
70  unsigned long buffer_size);
71 
72  int main() override;
73  void cleanup(bool has_returned_from_main, int return_value) override;
74 
75 
76  private:
77 
78  std::shared_ptr<StorageService> parent;
79  std::shared_ptr<DataFile>file;
80 
81  // Only one of these two is valid
82  simgrid::s4u::Mailbox *src_mailbox;
83  std::shared_ptr<FileLocation> src_location;
84 
85  // Only one of these two is valid
86  simgrid::s4u::Mailbox *dst_mailbox;
87  std::shared_ptr<FileLocation> dst_location;
88 
89  double num_bytes_to_transfer;
90 
91  simgrid::s4u::Mailbox *answer_mailbox_if_read;
92  simgrid::s4u::Mailbox *answer_mailbox_if_write;
93  simgrid::s4u::Mailbox *answer_mailbox_if_copy;
94  unsigned long buffer_size;
95 
96  void receiveFileFromNetwork(std::shared_ptr<DataFile> file, simgrid::s4u::Mailbox *mailbox, std::shared_ptr<FileLocation> location);
97  void sendLocalFileToNetwork(std::shared_ptr<DataFile> file, std::shared_ptr<FileLocation> location, double num_bytes_to_transfer, simgrid::s4u::Mailbox *mailbox);
98  void downloadFileFromStorageService(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src_location, std::shared_ptr<FileLocation> dst_location);
99  void copyFileLocally(std::shared_ptr<DataFile>file, std::shared_ptr<FileLocation> src_location, std::shared_ptr<FileLocation> dst_location);
100 
101  };
102 
103  /***********************/
105  /***********************/
106 }
107 
108 #endif //WRENCH_FILETRANSFERTHREAD_H
109 
wrench::FileTransferThread
A helper class that implements the concept of a communication thread that performs a file transfer.
Definition: FileTransferThread.h:31
wrench::FileTransferThread::cleanup
void cleanup(bool has_returned_from_main, int return_value) override
Cleanup method.
Definition: FileTransferThread.cpp:149
wrench::FileTransferThread::main
int main() override
Main method.
Definition: FileTransferThread.cpp:157
wrench
Definition: Action.cpp:28
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:60
wrench::FileTransferThread::FileTransferThread
FileTransferThread(std::string hostname, std::shared_ptr< StorageService > parent, std::shared_ptr< DataFile >file, double num_bytes_to_transfer, simgrid::s4u::Mailbox *src_mailbox, std::shared_ptr< FileLocation > dst_location, simgrid::s4u::Mailbox *answer_mailbox_if_read, simgrid::s4u::Mailbox *answer_mailbox_if_write, simgrid::s4u::Mailbox *answer_mailbox_if_copy, unsigned long buffer_size)
Constructor.
Definition: FileTransferThread.cpp:41
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:31
wrench::S4U_Daemon::mailbox
simgrid::s4u::Mailbox * mailbox
The daemon's mailbox.
Definition: S4U_Daemon.h:55