[1761] | 1 | #ifndef __SERVICES_MANAGER_HPP__ |
---|
| 2 | #define __SERVICES_MANAGER_HPP__ |
---|
| 3 | |
---|
| 4 | #include "xios_spl.hpp" |
---|
| 5 | #include "mpi.hpp" |
---|
| 6 | #include "buffer_in.hpp" |
---|
| 7 | #include "buffer_out.hpp" |
---|
| 8 | |
---|
| 9 | #include <string> |
---|
| 10 | #include <map> |
---|
| 11 | #include "window_manager.hpp" |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | namespace xios |
---|
| 16 | { |
---|
| 17 | class CServicesManager |
---|
| 18 | { |
---|
| 19 | |
---|
| 20 | public: |
---|
| 21 | static const int CLIENT=0 ; |
---|
| 22 | static const int GATHERER=1 ; |
---|
[2403] | 23 | static const int WRITER=2 ; |
---|
| 24 | static const int READER=3 ; |
---|
| 25 | static const int IO_SERVER=4 ; |
---|
| 26 | static const int OUT_SERVER=5 ; |
---|
| 27 | static const int ALL_SERVICES=6 ; |
---|
[1761] | 28 | |
---|
[2403] | 29 | private: |
---|
| 30 | const int NOTIFY_NOTHING=0 ; |
---|
| 31 | const int NOTIFY_CREATE_SERVICE=1 ; |
---|
| 32 | const int NOTIFY_CREATE_SERVICE_ONTO=2 ; |
---|
| 33 | |
---|
[1761] | 34 | public: |
---|
| 35 | |
---|
| 36 | CServicesManager(bool isXiosServer) ; |
---|
[1764] | 37 | ~CServicesManager() ; |
---|
| 38 | |
---|
[1761] | 39 | bool createServices(const std::string& poolId, const std::string& serviceId, int type, int size, int nbPartition, bool wait=true) ; |
---|
[2403] | 40 | bool createServicesOnto(const std::string& poolId, const std::string& serviceId, const std::string& onServiceId, bool wait=true) ; |
---|
| 41 | |
---|
[1761] | 42 | void eventLoop(void) ; |
---|
| 43 | |
---|
| 44 | void registerService(const std::string& poolId, const std::string& serviceId, const int& partitionId, int type, int size, int nbPartitions, int leader) ; |
---|
| 45 | bool getServiceInfo(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& type, int& size, int& nbPartition, int& leader) ; |
---|
| 46 | bool getServiceLeader(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& leader) ; |
---|
| 47 | bool getServiceType(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& type) ; |
---|
| 48 | bool getServiceNbPartitions(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& nbPartition) ; |
---|
| 49 | bool hasService(const std::string& poolId, const std::string& serviceId, const int& partitionId) ; |
---|
| 50 | void servicesDumpOut(CBufferOut& buffer) ; |
---|
| 51 | void servicesDumpIn(CBufferIn& buffer) ; |
---|
| 52 | |
---|
[2403] | 53 | private: |
---|
| 54 | |
---|
| 55 | void createService(void) ; |
---|
| 56 | void createServiceOnto(void) ; |
---|
| 57 | void createServicesNotify(int rank, const string& serviceId, int type, int size, int nbPartitions) ; |
---|
| 58 | void createServicesOntoNotify(int rank, const string& serviceId, const string& OnServiceId) ; |
---|
| 59 | void sendNotification(int rank) ; |
---|
| 60 | void checkNotifications(void) ; |
---|
| 61 | void notificationsDumpOut(CBufferOut& buffer) ; |
---|
| 62 | void notificationsDumpIn(CBufferIn& buffer) ; |
---|
| 63 | |
---|
| 64 | |
---|
[1761] | 65 | private : |
---|
| 66 | |
---|
| 67 | CWindowManager* winServices_ ; |
---|
| 68 | CWindowManager* winNotify_ ; |
---|
| 69 | const size_t maxBufferSize_=1024*1024 ; |
---|
| 70 | |
---|
| 71 | MPI_Comm xiosComm_ ; |
---|
| 72 | |
---|
[2403] | 73 | int notifyType_ ; |
---|
| 74 | tuple<std::string, int, int, int> notifyCreateService_ ; |
---|
| 75 | tuple<std::string, std::string> notifyCreateServiceOnto_ ; |
---|
| 76 | |
---|
[1761] | 77 | std::map<tuple<std::string, std::string, int>, std::tuple<int, int, int, int> > services_ ; |
---|
| 78 | |
---|
| 79 | int managerGlobalLeader_ ; |
---|
[2246] | 80 | |
---|
[2260] | 81 | const double eventLoopLatency_=0; |
---|
[2246] | 82 | double lastEventLoop_=0. ; |
---|
[1761] | 83 | |
---|
| 84 | friend class CWindowManager ; |
---|
| 85 | } ; |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | |
---|
[2335] | 92 | #endif |
---|