00001 #ifndef NoXmlTreeReader
00002
00017 #ifndef StDbServiceBroker_h
00018 #define StDbServiceBroker_h
00019 #include <vector>
00020 #include <string>
00021
00022 #include "StlXmlTree.h"
00023 #include "ChapiDbHost.h"
00024 #ifdef __ROOT__
00025 #include "Rtypes.h"
00026 #endif
00027 namespace st_db_service_broker {
00028 const std::string MyScatalogVersion = "version=1.0.1;";
00029 const short NightEnds = 8;
00030 const short NightBegins = 22;
00031 const short DayBegins = NightEnds;
00032 const short DayEnds = NightBegins;
00033
00034 enum
00035 {
00036 NO_ERROR,
00037 NO_XML_BASE,
00038 NO_USER,
00039 NO_DOMAIN,
00040 NO_HOSTS,
00041 BAD_XML
00042 };
00043 }
00044
00045 namespace lb_error {
00046 enum
00047 {
00048 NO_ERROR,
00049 NO_LPD_ENV_VAR,
00050 NO_GPD_ENV_VAR,
00051 NO_WRITE_PERMISSION,
00052 NO_LPD_DIR,
00053 AFS_ERROR,
00054 WWW_ERROR
00055 };
00056 }
00057
00058
00059 class StDbServiceBroker
00060 {
00061 private:
00062
00063 StlXmlTree ParsedXml;
00064 std::vector<ChapiDbHost> MyHostList;
00065 std::vector<ChapiDbHost>::const_iterator MyBestHost;
00066 void FormHostList();
00067 void PrintHostList();
00068 int RecommendHost();
00069 short MyStatus;
00070
00071 public:
00072
00073 StDbServiceBroker(): MyStatus(st_db_service_broker::NO_XML_BASE){};
00074 StDbServiceBroker(const std::string xmlbase);
00075 StDbServiceBroker(const std::string xmlbase, const std::string xmlfilter);
00076 virtual ~StDbServiceBroker(){};
00077 void DoLoadBalancing();
00078
00079 std::string GiveHostName();
00080 short GiveHostPort();
00081
00082
00083 inline short GetStatus(){return MyStatus;};
00084 static int updateLocalLbPolicy();
00085 #ifdef __ROOT__
00086 ClassDef(StDbServiceBroker,0)
00087 #endif
00088 };
00089 #endif
00090 #endif