2525#if HAVE_ETCD
2626#include < etcd/Client.hpp>
2727
28- namespace etcd {
28+ namespace etcd
29+ {
2930 class Client ;
3031}
3132
3233#define NIXL_ETCD_NAMESPACE_DEFAULT " /nixl/agents/"
3334#endif // HAVE_ETCD
3435
35- using backend_list_t = std::vector<nixlBackendEngine*>;
36+ using backend_list_t = std::vector<nixlBackendEngine *>;
3637
37- // Internal typedef to define metadata communication request types
38- // To be extended with ETCD operations
38+ // Internal typedef to define metadata communication request types
39+ // To be extended with ETCD operations
3940enum nixl_comm_t {
4041 SOCK_SEND,
4142 SOCK_FETCH,
@@ -47,78 +48,82 @@ enum nixl_comm_t {
4748#endif // HAVE_ETCD
4849};
4950
50- // Command to be sent to listener thread from NIXL API
51- // 1) Command type
52- // 2) IP Address
53- // 3) Port
54- // 4) Metadata to send (for sendLocalMD calls)
51+ // Command to be sent to listener thread from NIXL API
52+ // 1) Command type
53+ // 2) IP Address
54+ // 3) Port
55+ // 4) Metadata to send (for sendLocalMD calls)
5556using nixl_comm_req_t = std::tuple<nixl_comm_t , std::string, int , nixl_blob_t >;
5657
5758using nixl_socket_peer_t = std::pair<std::string, int >;
5859
59- class nixlAgentData {
60- private:
61- std::string name;
62- nixlAgentConfig config;
63- nixlLock lock;
64-
65- // some handle that can be used to instantiate an object from the lib
66- std::map<std::string, void *> backendLibs;
67-
68- // Bookkeeping from backend type and memory type to backend engine
69- backend_list_t notifEngines;
70- backend_map_t backendEngines;
71- std::array<backend_list_t , FILE_SEG+1 > memToBackend;
72-
73- // Bookkeping for local connection metadata and user handles per backend
74- std::unordered_map<nixl_backend_t , nixlBackendH*> backendHandles;
75- std::unordered_map<nixl_backend_t , nixl_blob_t > connMD;
76-
77- // Local section, and Remote sections and their available common backends
78- nixlLocalSection* memorySection;
79-
80- std::unordered_map<std::string,
81- std::unordered_map<nixl_backend_t , nixl_blob_t >,
82- std::hash<std::string>, strEqual> remoteBackends;
83- std::unordered_map<std::string, nixlRemoteSection*,
84- std::hash<std::string>, strEqual> remoteSections;
85-
86- // State/methods for listener thread
87- nixlMDStreamListener *listener;
88- std::map<nixl_socket_peer_t , int > remoteSockets;
89- std::thread commThread;
90- std::vector<nixl_comm_req_t > commQueue;
91- std::mutex commLock;
92- bool commThreadStop;
93- bool useEtcd;
94-
95- void commWorker (nixlAgent* myAgent);
96- void enqueueCommWork (nixl_comm_req_t request);
97- void getCommWork (std::vector<nixl_comm_req_t > &req_list);
98-
99- public:
100- nixlAgentData (const std::string &name, const nixlAgentConfig &cfg);
101- ~nixlAgentData ();
60+ class nixlAgentData
61+ {
62+ private:
63+ std::string name;
64+ nixlAgentConfig config;
65+ nixlLock lock;
66+
67+ // some handle that can be used to instantiate an object from the lib
68+ std::map<std::string, void *> backendLibs;
69+
70+ // Bookkeeping from backend type and memory type to backend engine
71+ backend_list_t notifEngines;
72+ backend_map_t backendEngines;
73+ std::array<backend_list_t , FILE_SEG + 1 > memToBackend;
74+
75+ // Bookkeping for local connection metadata and user handles per backend
76+ std::unordered_map<nixl_backend_t , nixlBackendH *> backendHandles;
77+ std::unordered_map<nixl_backend_t , nixl_blob_t > connMD;
78+
79+ // Local section, and Remote sections and their available common backends
80+ nixlLocalSection *memorySection;
81+
82+ std::unordered_map<std::string,
83+ std::unordered_map<nixl_backend_t , nixl_blob_t >,
84+ std::hash<std::string>,
85+ strEqual>
86+ remoteBackends;
87+ std::unordered_map<std::string, nixlRemoteSection *, std::hash<std::string>, strEqual>
88+ remoteSections;
89+
90+ // State/methods for listener thread
91+ nixlMDStreamListener *listener;
92+ std::map<nixl_socket_peer_t , int > remoteSockets;
93+ std::thread commThread;
94+ std::vector<nixl_comm_req_t > commQueue;
95+ std::mutex commLock;
96+ bool commThreadStop;
97+ bool useEtcd;
98+
99+ void commWorker (nixlAgent *myAgent);
100+ void enqueueCommWork (nixl_comm_req_t request);
101+ void getCommWork (std::vector<nixl_comm_req_t > &req_list);
102+
103+ public:
104+ nixlAgentData (const std::string &name, const nixlAgentConfig &cfg);
105+ ~nixlAgentData ();
102106
103107 friend class nixlAgent ;
104108};
105109
106110class nixlBackendEngine ;
107111// This class hides away the nixlBackendEngine from user of the Agent API
108- class nixlBackendH {
109- private:
110- nixlBackendEngine* engine;
112+ class nixlBackendH
113+ {
114+ private:
115+ nixlBackendEngine *engine;
111116
112- nixlBackendH (nixlBackendEngine* &engine) { this ->engine = engine; }
113- ~nixlBackendH () {}
117+ nixlBackendH (nixlBackendEngine * &engine) { this ->engine = engine; }
118+ ~nixlBackendH () {}
114119
115- public:
116- nixl_backend_t getType () const { return engine->getType (); }
120+ public:
121+ nixl_backend_t getType () const { return engine->getType (); }
117122
118- bool supportsRemote () const { return engine->supportsRemote (); }
119- bool supportsLocal () const { return engine->supportsLocal (); }
120- bool supportsNotif () const { return engine->supportsNotif (); }
121- bool supportsProgTh () const { return engine->supportsProgTh (); }
123+ bool supportsRemote () const { return engine->supportsRemote (); }
124+ bool supportsLocal () const { return engine->supportsLocal (); }
125+ bool supportsNotif () const { return engine->supportsNotif (); }
126+ bool supportsProgTh () const { return engine->supportsProgTh (); }
122127
123128 friend class nixlAgentData ;
124129 friend class nixlAgent ;
0 commit comments