xrootd
XrdClientUrlSet.hh
Go to the documentation of this file.
1 
2 // //
3 // XrdClientUrlSet //
4 // //
5 // Author: Fabrizio Furano (INFN Padova, 2004) //
6 // Adapted from TXNetFile (root.cern.ch) originally done by //
7 // Alvise Dorigo, Fabrizio Furano, INFN Padova, 2003 //
8 // Revised by G. Ganis, CERN, June 2005 //
9 // //
10 // A container for multiple urls to be resolved through DNS aliases //
11 // //
13 
14 // $Id$
15 
16 #ifndef _XRC_URLSET_H
17 #define _XRC_URLSET_H
18 
21 #include "XrdOuc/XrdOucString.hh"
22 
23 using namespace std;
24 
26 
28 
29 //
30 // Manages a set of XrdClientUrlInfo objects and provides a set
31 // of utilities to resolve multiple addresses from the dns
32 // and to pick urls sequentially and randomly an url
33 //
34 
36 private:
40 
41  bool fIsValid;
42  unsigned int fSeed;
43 
44  void CheckPort(int &port);
45  void ConvertDNSAlias(UrlArray& urls, XrdOucString proto,
46  XrdOucString host, XrdOucString file);
47  double GetRandom(int seed = 0);
48 
49 public:
51  ~XrdClientUrlSet();
52 
53  // Returns the final resolved list of servers
54  XrdOucString GetServers();
55 
56  // Gets the subsequent Url, the one after the last given
57  XrdClientUrlInfo *GetNextUrl();
58 
59  // From the remaining urls we pick a random one. Without reinsert.
60  // i.e. while there are not considered urls, never pick an already seen one
61  XrdClientUrlInfo *GetARandomUrl();
62  // Given a seed, use that to pick an url
63  // the effect will be that, given the same list, the same seed will pick the same url
64  XrdClientUrlInfo *GetARandomUrl(unsigned int seed);
65 
66  void Rewind();
67  void ShowUrls();
68  void EraseUrl(XrdClientUrlInfo *url);
69 
70  // Returns the number of urls
71  int Size() { return fUrlArray.GetSize(); }
72 
73  // Returns the pathfile extracted from the CTOR's argument
74  XrdOucString GetFile() { return fPathName; }
75 
76  bool IsValid() { return fIsValid; } // Spot malformations
77 
78 };
79 
80 #endif