DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::snbmodules::TransferSession Class Reference

TransferSession class contained in a client, is a wrapper for a transfer. extend notification interface because the session can communicate with bookkeeper via client initialized connection. More...

#include <transfer_session.hpp>

Inheritance diagram for dunedaq::snbmodules::TransferSession:
[legend]
Collaboration diagram for dunedaq::snbmodules::TransferSession:
[legend]

Public Member Functions

bool update_metadatas_to_bookkeeper ()
 
bool update_metadata_to_bookkeeper (TransferMetadata &f_meta)
 
bool is_downloader ()
 Usefull to check if the session is a downloader.
 
bool is_uploader ()
 Usefull to check if the session is a uploader.
 
bool operator== (TransferSession const &other) const
 equal operator, used to compare sessions in a set (client)
 
bool operator< (TransferSession const &other) const
 Operator <, used to compare sessions in a set (client)
 
 TransferSession (TransferSession &&)=default
 
TransferSessionoperator= (TransferSession &&)=default
 
 TransferSession (GroupMetadata transfer_options, e_session_type type, std::string id, const IPFormat &ip, std::filesystem::path work_dir, std::vector< std::string > bk_conn=std::vector< std::string >(), std::set< std::string > client_conn=std::set< std::string >())
 Constructor.
 
virtual ~TransferSession ()
 Destructor Kill all threads created by the session (TODO : useless ?)
 
const GroupMetadataget_transfer_options () const
 
GroupMetadataget_transfer_options ()
 
std::filesystem::path get_work_dir () const
 
const std::set< std::string > & get_target_clients () const
 
IPFormat get_ip () const
 
std::string get_session_id () const
 
std::string to_string () const
 
void set_target_clients (std::set< std::string > clients)
 
void add_file (std::shared_ptr< TransferMetadata > fmeta)
 
bool pause_file (TransferMetadata &f_meta, bool is_multiple=false)
 
bool resume_file (TransferMetadata &f_meta, bool is_multiple=false)
 
bool hash_file (TransferMetadata &f_meta, bool is_multiple=false)
 
bool cancel_file (TransferMetadata &f_meta, bool is_multiple=false)
 
bool pause_all ()
 
bool resume_all ()
 
bool cancel_all ()
 
bool start_file (TransferMetadata &f_meta)
 Start the session by downloading or uploading files depending on the type of session TODO : separate thread ?
 
bool start_all ()
 
bool download_all (const std::filesystem::path &dest)
 
bool download_file (TransferMetadata &f_meta, std::filesystem::path dest, bool is_multiple=false)
 
bool upload_all ()
 
bool upload_file (TransferMetadata &f_meta, bool is_multiple=false)
 
- Public Member Functions inherited from dunedaq::snbmodules::NotificationInterface
 NotificationInterface (std::string connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100)
 
 NotificationInterface (std::vector< std::string > bk_conn, std::set< std::string > client_conn, const std::string &connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100)
 
virtual ~NotificationInterface ()=default
 
std::optional< NotificationDatalisten_for_notification (const std::string &id, const std::string &expected_from="", int timeout=-1, int tries=-1)
 Listen for a notification.
 
bool send_notification (const notification_type::e_notification_type &notif, const std::string &src, const std::string &dst, const std::string &id_conn, const std::string &data="", int tries=-1)
 Send a notification during m_timeout_send ms.
 
void lookups_connections ()
 Get the list of every connections, must have the prefix first in the name of the connection and the name of the connection must be in the format: prefix.*bookkeeper.* or prefix.*client.*.
 
const std::vector< std::string > & get_bookkeepers_conn () const
 Init the connection interface, Only used for standalone application.
 
const std::set< std::string > & get_clients_conn () const
 

Static Public Member Functions

static std::string session_type_to_string (e_session_type e)
 

Private Member Functions

bool action_on_receive_notification (NotificationData notif) override
 handle actions to be taken when a notification is received. The notification is passed as a parameter by the client because only 1 connection is opened (not possible to open connection after configuration)
 
bool send_notification_to_targets (notification_type::e_notification_type type, const std::string &data="")
 Send a notification to every targets of the session, generally for the uploader.
 

Private Attributes

e_session_type m_type
 Type of session, uploader or downloader. Used to block access to some functions.
 
std::string m_session_id
 Unique identifier of the session, used to identify the session in the client and to target notification.
 
IPFormat m_ip
 Ip of the client TODO : useless ? the session cannot have a unique connection.
 
std::unique_ptr< TransferInterfaceAbstractm_transfer_interface
 Abstract interface can reference to any protocol used to transfer data.
 
GroupMetadata m_transfer_options
 A session must contain a transfer matadata. The session is basically a transfer wrapper.
 
std::filesystem::path m_work_dir
 List of threads created by the session TODO : useless ? should be handle in client.
 
std::set< std::string > m_target_clients
 clients that dowload the files, only used by uploader
 

Detailed Description

TransferSession class contained in a client, is a wrapper for a transfer. extend notification interface because the session can communicate with bookkeeper via client initialized connection.

Definition at line 45 of file transfer_session.hpp.

Constructor & Destructor Documentation

◆ TransferSession() [1/2]

dunedaq::snbmodules::TransferSession::TransferSession ( TransferSession && )
default

◆ TransferSession() [2/2]

dunedaq::snbmodules::TransferSession::TransferSession ( GroupMetadata transfer_options,
e_session_type type,
std::string id,
const IPFormat & ip,
std::filesystem::path work_dir,
std::vector< std::string > bk_conn = std::vector<std::string>(),
std::set< std::string > client_conn = std::set<std::string>() )

Constructor.

Parameters
transfer_optionsgroup metadata
typetype of session
idunique identifier of the session
ipip of the client (TODO : useless ?)

Definition at line 21 of file transfer_session.cpp.

28 : NotificationInterface(std::move(bk_conn), std::move(client_conn))
29 , m_type(type)
30 , m_session_id(std::move(id))
31 , m_ip(ip)
32 , m_transfer_options(std::move(transfer_options))
33 ,
34 // m_threads(std::vector<pid_t>()),
35 m_work_dir(std::move(work_dir))
36{
37 std::filesystem::create_directories(m_work_dir);
38
39 // Init transfer interface with the right protocol
42
43 // check if port is set
44 if (!m_transfer_options.get_protocol_options().contains("port")) {
45 ers::fatal(ConfigError(ERS_HERE, "port is mandatory in Bittorrent protocol options"));
46 return;
47 }
48
49 m_transfer_interface = std::make_unique<TransferInterfaceBittorrent>(
51
52 // Generate torrent files and magnet links
53 if (type == e_session_type::Uploader) {
54 TLOG() << "Generating torrent files...";
55 dynamic_cast<TransferInterfaceBittorrent&>(*m_transfer_interface).generate_torrents_files(m_work_dir, "");
56
57 for (auto f_meta : m_transfer_options.get_transfers_meta()) {
58 TLOG() << "Writing magnet link data into transfer Metadata "
59 << get_work_dir().append(f_meta->get_file_name() + ".torrent");
60 lt::error_code ec;
61 lt::torrent_info t(get_work_dir().append(f_meta->get_file_name() + ".torrent").string(), ec);
62
63 if (ec) {
64 ers::error(BittorrentInvalidTorrentFileError(ERS_HERE, ec.message()));
65 }
66
67 TLOG() << "Magnet link: " << lt::make_magnet_uri(t);
68 f_meta->set_magnet_link(lt::make_magnet_uri(t) + "&x.pe=" + get_ip().get_ip() + ":" +
69 m_transfer_options.get_protocol_options()["port"].get<std::string>());
70 }
71 }
72 break;
73
76 std::make_unique<TransferInterfaceSCP>(m_transfer_options, type == e_session_type::Uploader);
77 break;
78
80 m_transfer_interface = std::make_unique<TransferInterfaceRClone>(m_transfer_options, get_work_dir());
81 break;
82 }
83
85 m_transfer_interface = std::make_unique<TransferInterfaceDummy>(m_transfer_options);
86 break;
87
88 default:
89 ers::error(InvalidProtocolError(
91 break;
92 }
93
94 TLOG() << "debug : Transfer session " << get_session_id() << " created";
96}
#define ERS_HERE
protocol_type::e_protocol_type get_protocol() const
std::vector< std::shared_ptr< TransferMetadata > > & get_transfers_meta()
nlohmann::json get_protocol_options() const
NotificationInterface(std::string connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100)
IPFormat m_ip
Ip of the client TODO : useless ? the session cannot have a unique connection.
GroupMetadata m_transfer_options
A session must contain a transfer matadata. The session is basically a transfer wrapper.
std::filesystem::path get_work_dir() const
e_session_type m_type
Type of session, uploader or downloader. Used to block access to some functions.
std::unique_ptr< TransferInterfaceAbstract > m_transfer_interface
Abstract interface can reference to any protocol used to transfer data.
std::string m_session_id
Unique identifier of the session, used to identify the session in the client and to target notificati...
std::filesystem::path m_work_dir
List of threads created by the session TODO : useless ? should be handle in client.
#define TLOG(...)
Definition macro.hpp:22
@ Downloader
TransferSession used to download files from uploaders client.
@ Uploader
TransferSession used to upload files to downloaders client.
void fatal(const Issue &issue)
Definition ers.hpp:88
void error(const Issue &issue)
Definition ers.hpp:81
static std::string protocols_to_string(e_protocol_type e)

◆ ~TransferSession()

dunedaq::snbmodules::TransferSession::~TransferSession ( )
virtual

Destructor Kill all threads created by the session (TODO : useless ?)

Definition at line 98 of file transfer_session.cpp.

99{
100 // TLOG() << "Reaping children";
101 // for (pid_t pid : m_threads)
102 // {
103 // TLOG() << "Killing pid " << pid;
104 // kill(pid, SIGINT);
105 // kill(pid, SIGKILL);
106 // }
107 // for (pid_t pid : m_threads)
108 // {
109 // TLOG() << "Waiting for pid " << pid;
110 // siginfo_t status;
111 // auto sts = waitid(P_PID, pid, &status, WEXITED);
112
113 // TLOG() << "Forked process " << pid << " exited with status " << status.si_status << " (wait status " << sts
114 // << ")";
115 // }
116
117 TLOG() << "DONE CLOSING SESSION " << get_session_id();
118}

Member Function Documentation

◆ action_on_receive_notification()

bool dunedaq::snbmodules::TransferSession::action_on_receive_notification ( NotificationData notif)
overrideprivatevirtual

handle actions to be taken when a notification is received. The notification is passed as a parameter by the client because only 1 connection is opened (not possible to open connection after configuration)

Parameters
notifcontain everything we need to know about the notification

Implements dunedaq::snbmodules::NotificationInterface.

Definition at line 121 of file transfer_session.cpp.

122{
123 (void)notif;
124 // TODO : now in client
125 return true;
126}

◆ add_file()

void dunedaq::snbmodules::TransferSession::add_file ( std::shared_ptr< TransferMetadata > fmeta)
inline

Definition at line 114 of file transfer_session.hpp.

115 {
116 TransferMetadata& moved_meta = get_transfer_options().add_file(std::move(fmeta));
118 }
TransferMetadata & add_file(std::shared_ptr< TransferMetadata > meta)
bool update_metadata_to_bookkeeper(TransferMetadata &f_meta)
const GroupMetadata & get_transfer_options() const

◆ cancel_all()

bool dunedaq::snbmodules::TransferSession::cancel_all ( )

Definition at line 422 of file transfer_session.cpp.

423{
424 bool result = true;
425 for (auto file : m_transfer_options.get_transfers_meta()) {
426 result = result && cancel_file(*file, true);
427 }
428
431 return result;
432}
bool cancel_file(TransferMetadata &f_meta, bool is_multiple=false)
bool send_notification_to_targets(notification_type::e_notification_type type, const std::string &data="")
Send a notification to every targets of the session, generally for the uploader.

◆ cancel_file()

bool dunedaq::snbmodules::TransferSession::cancel_file ( TransferMetadata & f_meta,
bool is_multiple = false )

Definition at line 287 of file transfer_session.cpp.

288{
289 if (f_meta.get_status() == status_type::e_status::FINISHED ||
290 f_meta.get_status() == status_type::e_status::CANCELLED) {
291 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
293 f_meta.get_file_name(),
294 status_type::status_to_string(f_meta.get_status()),
296 return false;
297 }
298
299 f_meta.set_status(status_type::e_status::CANCELLED);
300
301 bool res = m_transfer_interface->cancel_file(f_meta);
302 if (!res) {
303 f_meta.set_status(status_type::e_status::ERROR);
304 }
305
306 if (!is_multiple) {
309 }
310 return res;
311}
void warning(const Issue &issue)
Definition ers.hpp:115
static std::string status_to_string(e_status e)

◆ download_all()

bool dunedaq::snbmodules::TransferSession::download_all ( const std::filesystem::path & dest)

Definition at line 436 of file transfer_session.cpp.

437{
439 ers::warning(SessionAccessToIncorrectActionError(ERS_HERE, get_session_id(), "download_all"));
440 }
441
442 bool result = true;
443 for (auto file : m_transfer_options.get_transfers_meta()) {
444 result = result && download_file(*file, dest, true);
445 }
447 return result;
448}
bool download_file(TransferMetadata &f_meta, std::filesystem::path dest, bool is_multiple=false)

◆ download_file()

bool dunedaq::snbmodules::TransferSession::download_file ( TransferMetadata & f_meta,
std::filesystem::path dest,
bool is_multiple = false )

Definition at line 344 of file transfer_session.cpp.

345{
347 ers::warning(SessionAccessToIncorrectActionError(ERS_HERE, get_session_id(), "download_file"));
348 }
349
350 if (f_meta.get_status() != status_type::e_status::WAITING) {
351 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
353 f_meta.get_file_name(),
354 status_type::status_to_string(f_meta.get_status()),
356 return false;
357 }
358
359 // wait for the uploader to be ready
360 std::this_thread::sleep_for(std::chrono::seconds(1));
361
362 f_meta.set_status(status_type::e_status::DOWNLOADING);
363
364 bool res = m_transfer_interface->download_file(f_meta, std::move(dest));
365 if (!res) {
366 f_meta.set_status(status_type::e_status::ERROR);
367 }
368 if (!is_multiple) {
370 }
371 return res;
372}

◆ get_ip()

IPFormat dunedaq::snbmodules::TransferSession::get_ip ( ) const
inline

Definition at line 100 of file transfer_session.hpp.

100{ return m_ip; }

◆ get_session_id()

std::string dunedaq::snbmodules::TransferSession::get_session_id ( ) const
inline

Definition at line 101 of file transfer_session.hpp.

101{ return m_session_id; }

◆ get_target_clients()

const std::set< std::string > & dunedaq::snbmodules::TransferSession::get_target_clients ( ) const
inline

Definition at line 99 of file transfer_session.hpp.

99{ return m_target_clients; }
std::set< std::string > m_target_clients
clients that dowload the files, only used by uploader

◆ get_transfer_options() [1/2]

GroupMetadata & dunedaq::snbmodules::TransferSession::get_transfer_options ( )
inline

Definition at line 97 of file transfer_session.hpp.

97{ return m_transfer_options; }

◆ get_transfer_options() [2/2]

const GroupMetadata & dunedaq::snbmodules::TransferSession::get_transfer_options ( ) const
inline

Definition at line 96 of file transfer_session.hpp.

96{ return m_transfer_options; }

◆ get_work_dir()

std::filesystem::path dunedaq::snbmodules::TransferSession::get_work_dir ( ) const
inline

Definition at line 98 of file transfer_session.hpp.

98{ return m_work_dir; }

◆ hash_file()

bool dunedaq::snbmodules::TransferSession::hash_file ( TransferMetadata & f_meta,
bool is_multiple = false )

Definition at line 261 of file transfer_session.cpp.

262{
263 if (f_meta.get_status() != status_type::e_status::FINISHED) {
264 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
266 f_meta.get_file_name(),
267 status_type::status_to_string(f_meta.get_status()),
269 return false;
270 }
271
272 f_meta.set_status(status_type::e_status::HASHING);
273
274 bool res = m_transfer_interface->hash_file(f_meta);
275 if (!res) {
276 f_meta.set_status(status_type::e_status::ERROR);
277 }
278
279 if (!is_multiple) {
280 // send_notification_to_targets(notification_type::e_notification_type::HASH_TRANSFER, f_meta.get_file_path());
282 }
283 return res;
284}

◆ is_downloader()

bool dunedaq::snbmodules::TransferSession::is_downloader ( )
inline

Usefull to check if the session is a downloader.

Returns
true if the session is a downloader

Definition at line 59 of file transfer_session.hpp.

◆ is_uploader()

bool dunedaq::snbmodules::TransferSession::is_uploader ( )
inline

Usefull to check if the session is a uploader.

Returns
true if the session is an uploader

Definition at line 63 of file transfer_session.hpp.

◆ operator<()

bool dunedaq::snbmodules::TransferSession::operator< ( TransferSession const & other) const
inline

Operator <, used to compare sessions in a set (client)

Parameters
otherother session
Returns
is less than ?

Definition at line 73 of file transfer_session.hpp.

73{ return m_session_id.compare(other.m_session_id); }

◆ operator=()

TransferSession & dunedaq::snbmodules::TransferSession::operator= ( TransferSession && )
default

◆ operator==()

bool dunedaq::snbmodules::TransferSession::operator== ( TransferSession const & other) const
inline

equal operator, used to compare sessions in a set (client)

Parameters
otherother session
Returns
is equal ?

Definition at line 68 of file transfer_session.hpp.

68{ return m_session_id == other.m_session_id; }

◆ pause_all()

bool dunedaq::snbmodules::TransferSession::pause_all ( )

Definition at line 388 of file transfer_session.cpp.

389{
390
392
393 // wait 1 second
394 std::this_thread::sleep_for(std::chrono::seconds(1));
395
396 bool result = true;
397 for (auto file : m_transfer_options.get_transfers_meta()) {
398 result = result && pause_file(*file, true);
399 }
400
402 return result;
403}
bool pause_file(TransferMetadata &f_meta, bool is_multiple=false)

◆ pause_file()

bool dunedaq::snbmodules::TransferSession::pause_file ( TransferMetadata & f_meta,
bool is_multiple = false )

Definition at line 202 of file transfer_session.cpp.

203{
204 if (f_meta.get_status() != status_type::e_status::DOWNLOADING &&
205 f_meta.get_status() != status_type::e_status::UPLOADING) {
206 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
208 f_meta.get_file_name(),
209 status_type::status_to_string(f_meta.get_status()),
211 return false;
212 }
213
214 f_meta.set_status(status_type::e_status::PAUSED);
215
216 bool res = m_transfer_interface->pause_file(f_meta);
217 if (!res) {
218 f_meta.set_status(status_type::e_status::ERROR);
219 }
220
221 if (!is_multiple) {
224 }
225
226 return res;
227}

◆ resume_all()

bool dunedaq::snbmodules::TransferSession::resume_all ( )

Definition at line 406 of file transfer_session.cpp.

407{
408 bool result = true;
409 for (auto file : m_transfer_options.get_transfers_meta()) {
410 result = result && resume_file(*file, true);
411 }
412
413 // wait 1 second
414 std::this_thread::sleep_for(std::chrono::seconds(1));
415
418 return result;
419}
bool resume_file(TransferMetadata &f_meta, bool is_multiple=false)

◆ resume_file()

bool dunedaq::snbmodules::TransferSession::resume_file ( TransferMetadata & f_meta,
bool is_multiple = false )

Definition at line 230 of file transfer_session.cpp.

231{
232 if (f_meta.get_status() != status_type::e_status::PAUSED) {
233 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
235 f_meta.get_file_name(),
236 status_type::status_to_string(f_meta.get_status()),
237 "RESUMING"));
238 return false;
239 }
240
241 if (is_downloader()) {
242 f_meta.set_status(status_type::e_status::DOWNLOADING);
243 } else if (is_uploader()) {
244 f_meta.set_status(status_type::e_status::UPLOADING);
245 }
246
247 bool res = m_transfer_interface->resume_file(f_meta);
248 if (!res) {
249 f_meta.set_status(status_type::e_status::ERROR);
250 }
251
252 if (!is_multiple) {
255 }
256
257 return res;
258}
bool is_downloader()
Usefull to check if the session is a downloader.
bool is_uploader()
Usefull to check if the session is a uploader.

◆ send_notification_to_targets()

bool dunedaq::snbmodules::TransferSession::send_notification_to_targets ( notification_type::e_notification_type type,
const std::string & data = "" )
private

Send a notification to every targets of the session, generally for the uploader.

Parameters
typetype of notification to send
datadata to send, default empty
Returns
true if success

Definition at line 175 of file transfer_session.cpp.

177{
178 bool result = true;
179 for (const std::string& client : get_target_clients()) {
180 std::string session_name = client + "_ses" + m_transfer_options.get_group_id();
181 result &= send_notification(type, get_session_id(), session_name, client, data);
182 }
183 return result;
184}
bool send_notification(const notification_type::e_notification_type &notif, const std::string &src, const std::string &dst, const std::string &id_conn, const std::string &data="", int tries=-1)
Send a notification during m_timeout_send ms.
const std::set< std::string > & get_target_clients() const

◆ session_type_to_string()

static std::string dunedaq::snbmodules::TransferSession::session_type_to_string ( e_session_type e)
inlinestatic

Definition at line 103 of file transfer_session.hpp.

104 {
105 const std::map<e_session_type, std::string> MyEnumStrings{ { Downloader, "Downloader" }, { Uploader, "Uploader" } };
106 auto it = MyEnumStrings.find(e);
107 return it == MyEnumStrings.end() ? "Not supported" : it->second;
108 }

◆ set_target_clients()

void dunedaq::snbmodules::TransferSession::set_target_clients ( std::set< std::string > clients)
inline

Definition at line 111 of file transfer_session.hpp.

111{ m_target_clients = std::move(clients); }

◆ start_all()

bool dunedaq::snbmodules::TransferSession::start_all ( )

Definition at line 375 of file transfer_session.cpp.

376{
377 if (is_downloader()) {
378 return download_all(m_work_dir);
379 } else if (is_uploader()) {
380 return upload_all();
381 } else {
382 ers::error(SessionTypeNotSupportedError(ERS_HERE, get_session_id()));
383 return false;
384 }
385}
bool download_all(const std::filesystem::path &dest)

◆ start_file()

bool dunedaq::snbmodules::TransferSession::start_file ( TransferMetadata & f_meta)

Start the session by downloading or uploading files depending on the type of session TODO : separate thread ?

Definition at line 187 of file transfer_session.cpp.

188{
189 bool res = false;
190 if (is_downloader()) {
191 res = download_file(f_meta, m_work_dir);
192 } else if (is_uploader()) {
193 res = upload_file(f_meta);
194 } else {
195 ers::error(SessionTypeNotSupportedError(ERS_HERE, get_session_id()));
196 }
197
198 return res;
199}
bool upload_file(TransferMetadata &f_meta, bool is_multiple=false)

◆ to_string()

std::string dunedaq::snbmodules::TransferSession::to_string ( ) const

Definition at line 129 of file transfer_session.cpp.

130{
131 std::string str;
132 str += "Session " + get_session_id() + " ";
134 str += "listening on " + m_ip.get_ip_port() + "\n";
135
137
138 return str;
139}
std::string get_ip_port() const
Get the IP address and the port in the format "ip:port".
Definition ip_format.hpp:57
static std::string session_type_to_string(e_session_type e)

◆ update_metadata_to_bookkeeper()

bool dunedaq::snbmodules::TransferSession::update_metadata_to_bookkeeper ( TransferMetadata & f_meta)

Update the metadata of the given transfer metadata to the bookkeeper

Returns
true if success

Definition at line 161 of file transfer_session.cpp.

162{
163 bool result = true;
164 for (const std::string& bk : get_bookkeepers_conn()) {
167 bk,
168 bk,
169 f_meta.export_to_string_partial(false));
170 }
171 return result;
172}
const std::vector< std::string > & get_bookkeepers_conn() const
Init the connection interface, Only used for standalone application.

◆ update_metadatas_to_bookkeeper()

bool dunedaq::snbmodules::TransferSession::update_metadatas_to_bookkeeper ( )

Update the metadata of the session to the bookkeeper

Returns
true if success

Definition at line 142 of file transfer_session.cpp.

143{
144 bool result = true;
145 for (const std::string& bk : get_bookkeepers_conn()) {
148 bk,
149 bk,
150 get_transfer_options().export_to_string());
151 }
152
153 for (std::shared_ptr<TransferMetadata> f_meta : m_transfer_options.get_transfers_meta()) {
154 result = result && update_metadata_to_bookkeeper(*f_meta);
155 }
156
157 return result;
158}

◆ upload_all()

bool dunedaq::snbmodules::TransferSession::upload_all ( )

Definition at line 452 of file transfer_session.cpp.

453{
455 ers::warning(SessionAccessToIncorrectActionError(ERS_HERE, get_session_id(), "upload_all"));
456 }
457
458 bool result = true;
459 for (auto file : m_transfer_options.get_transfers_meta()) {
460 result = result && upload_file(*file, true);
461 }
464 return result;
465}

◆ upload_file()

bool dunedaq::snbmodules::TransferSession::upload_file ( TransferMetadata & f_meta,
bool is_multiple = false )

Definition at line 314 of file transfer_session.cpp.

315{
317 ers::warning(SessionAccessToIncorrectActionError(ERS_HERE, get_session_id(), "upload_file"));
318 }
319
320 if (f_meta.get_status() != status_type::e_status::WAITING) {
321 ers::warning(SessionWrongStateTransitionError(ERS_HERE,
323 f_meta.get_file_name(),
324 status_type::status_to_string(f_meta.get_status()),
326 return false;
327 }
328
329 f_meta.set_status(status_type::e_status::UPLOADING);
330
331 bool res = m_transfer_interface->upload_file(f_meta);
332 if (!res) {
333 f_meta.set_status(status_type::e_status::ERROR);
334 }
335
336 if (!is_multiple) {
339 }
340 return res;
341}

Member Data Documentation

◆ m_ip

IPFormat dunedaq::snbmodules::TransferSession::m_ip
private

Ip of the client TODO : useless ? the session cannot have a unique connection.

Definition at line 153 of file transfer_session.hpp.

◆ m_session_id

std::string dunedaq::snbmodules::TransferSession::m_session_id
private

Unique identifier of the session, used to identify the session in the client and to target notification.

Definition at line 149 of file transfer_session.hpp.

◆ m_target_clients

std::set<std::string> dunedaq::snbmodules::TransferSession::m_target_clients
private

clients that dowload the files, only used by uploader

Definition at line 170 of file transfer_session.hpp.

◆ m_transfer_interface

std::unique_ptr<TransferInterfaceAbstract> dunedaq::snbmodules::TransferSession::m_transfer_interface
private

Abstract interface can reference to any protocol used to transfer data.

Definition at line 156 of file transfer_session.hpp.

◆ m_transfer_options

GroupMetadata dunedaq::snbmodules::TransferSession::m_transfer_options
private

A session must contain a transfer matadata. The session is basically a transfer wrapper.

Definition at line 160 of file transfer_session.hpp.

◆ m_type

e_session_type dunedaq::snbmodules::TransferSession::m_type
private

Type of session, uploader or downloader. Used to block access to some functions.

Definition at line 145 of file transfer_session.hpp.

◆ m_work_dir

std::filesystem::path dunedaq::snbmodules::TransferSession::m_work_dir
private

List of threads created by the session TODO : useless ? should be handle in client.

Dir where the session write files

Definition at line 167 of file transfer_session.hpp.


The documentation for this class was generated from the following files: