|
DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
TransferClient class, represent a client that can create session and communicate with Bookkeepers. extend NotificationInterface because the client can communicate and need to initialize the connection. More...
#include <transfer_client.hpp>
Public Member Functions | |
| TransferClient (const IPFormat &listening_ip, const std::string &client_id, const std::filesystem::path &listening_dir, const std::string &connection_prefix="snbmodules", int timeout_send=10, int timeout_receive=100) | |
| TransferClient constructor. | |
| ~TransferClient () | |
| bool | start (int timeout) |
| Start the client in curent thread. | |
| bool | do_work (std::atomic< bool > &running_flag) |
| Start function to use in a thread. | |
| void | create_new_transfer (const std::string &transfer_id, const std::string &protocol, const std::set< std::string > &dest_clients, const std::set< std::filesystem::path > &files, const nlohmann::json &protocol_options=nlohmann::json()) |
| Create a new transfer. | |
| void | start_transfer (const std::string &transfer_id) |
| Start, pause, resume or cancel a transfer. | |
| void | pause_transfer (const std::string &transfer_id) |
| void | resume_transfer (const std::string &transfer_id) |
| void | cancel_transfer (const std::string &transfer_id) |
| TransferSession & | create_session (GroupMetadata transfer_options, e_session_type type, std::string id, const std::filesystem::path &work_dir, IPFormat ip=IPFormat(), const std::set< std::string > &dest_clients=std::set< std::string >()) |
| Create a new session, you can precise the IP address of the session forcing to use a specific network interface and different port that the client. | |
| void | scan_available_files (std::set< std::filesystem::path > &previous_scan, bool nested=false, std::filesystem::path folder=std::filesystem::path()) |
| Scan available files in the listening directory. | |
| IPFormat | get_ip () const |
| std::string | get_client_id () const |
| std::filesystem::path | get_listening_dir () const |
| TransferSession * | get_session (std::string transfer_id) |
| std::vector< TransferSession > & | get_sessions () |
| const std::vector< TransferSession > & | get_sessions () const |
| std::string | get_my_conn () |
| void | set_ip (const std::string &ip) |
| void | set_port (int port) |
| void | set_client_id (std::string client_id) |
| void | set_listening_dir (const std::filesystem::path &listening_dir) |
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< NotificationData > | listen_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 ¬if, 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 |
Private Member Functions | |
| std::string | generate_session_id (const std::string &transferid, const std::string &dest="") |
| Function to generate session ID. | |
| void | remove_session (const std::string &session_id) |
| Add a session to the client. | |
| bool | action_on_receive_notification (NotificationData notif) override |
| Action to do when the client receive a notification. | |
| void | share_available_files (const std::set< std::filesystem::path > &to_share, const std::string &dest) |
| Share available files (in m_listening_dir) | |
| std::shared_ptr< TransferMetadata > | create_metadata_from_file (const std::filesystem::path &src) |
| Create a metadata from a file. | |
Private Attributes | |
| IPFormat | m_listening_ip |
| IP address of the client. | |
| std::string | m_client_id |
| TransferClient ID, unique identifier of the client. | |
| std::filesystem::path | m_listening_dir |
| Listening directory, directory where the client will listen for incoming files and files to share. | |
| std::vector< TransferSession > | m_sessions |
| Map of active sessions (key = session ID, value = session) | |
| std::map< std::string, std::shared_ptr< TransferMetadata > > | m_available_files |
| Map of available files (key = file path, value = file metadata) | |
| std::string | m_my_conn = "" |
| Connection uuid of the client, retrieved using the notification interface and calling get_my_conn() | |
TransferClient class, represent a client that can create session and communicate with Bookkeepers. extend NotificationInterface because the client can communicate and need to initialize the connection.
Definition at line 33 of file transfer_client.hpp.
| dunedaq::snbmodules::TransferClient::TransferClient | ( | const IPFormat & | listening_ip, |
| const std::string & | client_id, | ||
| const std::filesystem::path & | listening_dir, | ||
| const std::string & | connection_prefix = "snbmodules", | ||
| int | timeout_send = 10, | ||
| int | timeout_receive = 100 ) |
TransferClient constructor.
| listening_ip | Listening IP address |
| port | Listening port |
| client_id | Client ID |
| listening_dir | Listening directory (where the client will save incoming files and files to share with bookkeepers) |
Definition at line 18 of file transfer_client.cpp.
| dunedaq::snbmodules::TransferClient::~TransferClient | ( | ) |
Definition at line 53 of file transfer_client.cpp.
|
overrideprivatevirtual |
Action to do when the client receive a notification.
| notif | Notification received |
Implements dunedaq::snbmodules::NotificationInterface.
Definition at line 291 of file transfer_client.cpp.
| void dunedaq::snbmodules::TransferClient::cancel_transfer | ( | const std::string & | transfer_id | ) |
Definition at line 223 of file transfer_client.cpp.
|
private |
Create a metadata from a file.
| src | Path of the file |
Definition at line 560 of file transfer_client.cpp.
| void dunedaq::snbmodules::TransferClient::create_new_transfer | ( | const std::string & | transfer_id, |
| const std::string & | protocol, | ||
| const std::set< std::string > & | dest_clients, | ||
| const std::set< std::filesystem::path > & | files, | ||
| const nlohmann::json & | protocol_options = nlohmann::json() ) |
Create a new transfer.
| transfer_id | ID of the transfer |
| protocol | Protocol to use |
| dest_clients | Set of destination clients |
| files | Set of files to transfer |
| protocol_options | Protocol options |
Definition at line 103 of file transfer_client.cpp.
| TransferSession & dunedaq::snbmodules::TransferClient::create_session | ( | GroupMetadata | transfer_options, |
| e_session_type | type, | ||
| std::string | id, | ||
| const std::filesystem::path & | work_dir, | ||
| IPFormat | ip = IPFormat(), | ||
| const std::set< std::string > & | dest_clients = std::set<std::string>() ) |
Create a new session, you can precise the IP address of the session forcing to use a specific network interface and different port that the client.
| transfer_options | Transfer options for the protocol |
| type | Type of the session (upload or download) |
| id | ID of the session |
| listening_ip | Listening IP\:PORT address of the session |
Definition at line 253 of file transfer_client.cpp.
Start function to use in a thread.
| running_flag | Flag to stop the client |
Definition at line 79 of file transfer_client.cpp.
|
private |
Function to generate session ID.
Definition at line 477 of file transfer_client.cpp.
|
inline |
Definition at line 105 of file transfer_client.hpp.
|
inline |
Definition at line 104 of file transfer_client.hpp.
|
inline |
Definition at line 106 of file transfer_client.hpp.
| std::string dunedaq::snbmodules::TransferClient::get_my_conn | ( | ) |
Definition at line 566 of file transfer_client.cpp.
| TransferSession * dunedaq::snbmodules::TransferClient::get_session | ( | std::string | transfer_id | ) |
Definition at line 237 of file transfer_client.cpp.
|
inline |
Definition at line 108 of file transfer_client.hpp.
|
inline |
Definition at line 109 of file transfer_client.hpp.
| void dunedaq::snbmodules::TransferClient::pause_transfer | ( | const std::string & | transfer_id | ) |
Definition at line 196 of file transfer_client.cpp.
|
private |
Add a session to the client.
| session | Session to add |
Remove a session from the client
| session_id | ID of the session to remove |
Definition at line 461 of file transfer_client.cpp.
| void dunedaq::snbmodules::TransferClient::resume_transfer | ( | const std::string & | transfer_id | ) |
Definition at line 209 of file transfer_client.cpp.
| void dunedaq::snbmodules::TransferClient::scan_available_files | ( | std::set< std::filesystem::path > & | previous_scan, |
| bool | nested = false, | ||
| std::filesystem::path | folder = std::filesystem::path() ) |
Scan available files in the listening directory.
| previous_scan | Set of files already scanned |
| folder | Folder to scan |
| nested | True if the function is called recursively |
Definition at line 489 of file transfer_client.cpp.
|
inline |
Definition at line 115 of file transfer_client.hpp.
|
inline |
Definition at line 113 of file transfer_client.hpp.
|
inline |
Definition at line 116 of file transfer_client.hpp.
|
inline |
Definition at line 114 of file transfer_client.hpp.
|
private |
Share available files (in m_listening_dir)
| to_share | Set of files to share |
| dest | Destination of the files |
Definition at line 275 of file transfer_client.cpp.
| bool dunedaq::snbmodules::TransferClient::start | ( | int | timeout | ) |
Start the client in curent thread.
| timeout | Timeout in seconds, after this time the client will stop |
Definition at line 56 of file transfer_client.cpp.
| void dunedaq::snbmodules::TransferClient::start_transfer | ( | const std::string & | transfer_id | ) |
Start, pause, resume or cancel a transfer.
| transfer_id | ID of the transfer to start, pause, resume or cancel |
Definition at line 182 of file transfer_client.cpp.
|
private |
Map of available files (key = file path, value = file metadata)
Definition at line 149 of file transfer_client.hpp.
|
private |
TransferClient ID, unique identifier of the client.
Definition at line 140 of file transfer_client.hpp.
|
private |
Listening directory, directory where the client will listen for incoming files and files to share.
Definition at line 143 of file transfer_client.hpp.
|
private |
IP address of the client.
Definition at line 137 of file transfer_client.hpp.
|
private |
Connection uuid of the client, retrieved using the notification interface and calling get_my_conn()
Definition at line 152 of file transfer_client.hpp.
|
private |
Map of active sessions (key = session ID, value = session)
Definition at line 146 of file transfer_client.hpp.