source: XIOS3/dev/XIOS_FILE_SERVICES/src/manager/services_manager.hpp @ 2453

Last change on this file since 2453 was 2453, checked in by ymipsl, 18 months ago

Implementation of files service on dev branch

YM

  • Property svn:executable set to *
File size: 3.3 KB
Line 
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
15namespace xios
16{
17  class CServicesManager
18  {
19
20    public: 
21    static const int CLIENT=0 ;
22    static const int GATHERER=1 ;
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 ;
28
29    private:
30    const int NOTIFY_NOTHING=0 ;
31    const int NOTIFY_CREATE_SERVICE=1 ;
32    const int NOTIFY_CREATE_SERVICE_ONTO=2 ;
33   
34    public:
35   
36    CServicesManager(bool isXiosServer) ;
37    ~CServicesManager() ;
38   
39    bool createServices(const std::string& poolId, const std::string& serviceId, int type, int size, int nbPartition, bool wait=true) ;
40    bool createServicesOnto(const std::string& poolId, const std::string& serviceId, int type, const std::string& onServiceId, bool wait=true) ;
41   
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, bool wait=false) ;
46    bool getServiceLeader(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& leader, bool wait=false) ;
47    bool getServiceType(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& type, bool wait=false) ;
48    bool getServiceNbPartitions(const std::string& poolId, const std::string& serviceId, const int& partitionId, int& nbPartition, bool wait=false) ;
49    bool hasService(const std::string& poolId, const std::string& serviceId, const int& partitionId) ;
50    bool waitServiceRegistration(const std::string& poolId, const std::string& serviceId, const int& partitionId);
51    void servicesDumpOut(CBufferOut& buffer) ;
52    void servicesDumpIn(CBufferIn& buffer) ;
53    int  getRessourcesSize(const std::string& poolId) ;
54    int  getFreeRessourcesSize(const std::string& poolId) ;
55
56    private:
57
58    void createService(void) ;
59    void createServiceOnto(void) ;   
60    void createServicesNotify(int rank, const string& serviceId, int type, int size, int nbPartitions) ;
61    void createServicesOntoNotify(int rank, const string& serviceId, int type, const string& OnServiceId) ;
62    void sendNotification(int rank) ;
63    void checkNotifications(void) ;
64    void notificationsDumpOut(CBufferOut& buffer) ;
65    void notificationsDumpIn(CBufferIn& buffer) ;
66
67
68    private :
69   
70    CWindowManager* winServices_ ;
71    CWindowManager* winNotify_ ;
72    const size_t maxBufferSize_=1024*1024 ;
73
74    MPI_Comm xiosComm_ ;
75
76    int notifyType_ ;
77    tuple<std::string, int, int, int> notifyCreateService_ ;
78    tuple<std::string, int, std::string> notifyCreateServiceOnto_ ;
79   
80    std::map<tuple<std::string, std::string, int>, std::tuple<int, int, int, int> > services_ ;
81
82    int managerGlobalLeader_ ;
83
84    const double eventLoopLatency_=0; 
85    double lastEventLoop_=0. ;
86   
87    friend class CWindowManager ;
88  } ;
89
90
91}
92
93
94
95#endif
Note: See TracBrowser for help on using the repository browser.