StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbServiceBroker.h
1 #ifndef NoXmlTreeReader
2 
17 #ifndef StDbServiceBroker_h
18 #define StDbServiceBroker_h
19 #include <vector>
20 #include <string>
21 
22 #include "StlXmlTree.h"
23 #include "ChapiDbHost.h"
24 #ifdef __ROOT__
25 #include "Rtypes.h"
26 #endif
27 namespace st_db_service_broker {
28  const std::string MyScatalogVersion = "version=1.0.1;";
29  const short NightEnds = 8;
30  const short NightBegins = 22;
31  const short DayBegins = NightEnds;
32  const short DayEnds = NightBegins;
33 
34  enum
35  {
36  NO_ERROR, // 0
37  NO_XML_BASE,// 1
38  NO_USER, // 2
39  NO_DOMAIN, // 3
40  NO_HOSTS, // 4
41  BAD_XML // 5, introduced by Dmitry, to propagate errors correctly
42  };
43 }
44 
45 namespace lb_error {
46  enum
47  {
48  NO_ERROR, // 0
49  NO_LPD_ENV_VAR, // 1
50  NO_GPD_ENV_VAR, // 2
51  NO_WRITE_PERMISSION,// 3
52  NO_LPD_DIR, // 4
53  AFS_ERROR, // 5
54  WWW_ERROR // 6
55  };
56 }
57 
58 
60 {
61  private:
62 
63  StlXmlTree ParsedXml;
64  std::vector<ChapiDbHost> MyHostList;
65  std::vector<ChapiDbHost>::const_iterator MyBestHost;
66  void FormHostList();
67  void PrintHostList();
68  int RecommendHost();
69  void SendEmail(time_t timediff);
70  short MyStatus; // see namespace st_db_service_broker
71  time_t last_succeeded_connect_time = 0;
72  time_t seconds_to_reach_for_connect = 1800;
73 
74  public:
75 
76  StDbServiceBroker(): MyStatus(st_db_service_broker::NO_XML_BASE){};
77  StDbServiceBroker(const std::string xmlbase);
78  StDbServiceBroker(const std::string xmlbase, const std::string xmlfilter);
79  virtual ~StDbServiceBroker(){};
80  void DoLoadBalancing();
81 
82  std::string GiveHostName();
83  short GiveHostPort();
84 // std::string GiveUserName();
85 // std::string GiveUserPassword();
86  inline short GetStatus(){return MyStatus;};
87  static int updateLocalLbPolicy(); // returns an lb_error:: error
88 #ifdef __ROOT__
89  ClassDef(StDbServiceBroker,0)
90 #endif
91 };
92 #endif
93 #endif