xrootd
XrdClientUrlSet.hh
Go to the documentation of this file.
1 #ifndef _XRC_URLSET_H
2 #define _XRC_URLSET_H
3 /******************************************************************************/
4 /* */
5 /* X r d C l i e n t U r l S e t . h h */
6 /* */
7 /* Author: Fabrizio Furano (INFN Padova, 2004) */
8 /* Adapted from TXNetFile (root.cern.ch) originally done by */
9 /* Alvise Dorigo, Fabrizio Furano, INFN Padova, 2003 */
10 /* Revised by G. Ganis, CERN, June 2005 */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
34 // //
35 // A container for multiple urls to be resolved through DNS aliases //
36 // //
38 
41 #include "XrdOuc/XrdOucString.hh"
42 
43 using namespace std;
44 
46 
48 
49 //
50 // Manages a set of XrdClientUrlInfo objects and provides a set
51 // of utilities to resolve multiple addresses from the dns
52 // and to pick urls sequentially and randomly an url
53 //
54 
56 private:
60 
61  bool fIsValid;
62  unsigned int fSeed;
63 
64  void CheckPort(int &port);
65  void ConvertDNSAlias(UrlArray& urls, XrdOucString proto,
66  XrdOucString host, XrdOucString file);
67  double GetRandom(int seed = 0);
68 
69 public:
71  ~XrdClientUrlSet();
72 
73  // Returns the final resolved list of servers
74  XrdOucString GetServers();
75 
76  // Gets the subsequent Url, the one after the last given
77  XrdClientUrlInfo *GetNextUrl();
78 
79  // From the remaining urls we pick a random one. Without reinsert.
80  // i.e. while there are not considered urls, never pick an already seen one
81  XrdClientUrlInfo *GetARandomUrl();
82  // Given a seed, use that to pick an url
83  // the effect will be that, given the same list, the same seed will pick the same url
84  XrdClientUrlInfo *GetARandomUrl(unsigned int seed);
85 
86  void Rewind();
87  void ShowUrls();
88  void EraseUrl(XrdClientUrlInfo *url);
89 
90  // Returns the number of urls
91  int Size() { return fUrlArray.GetSize(); }
92 
93  // Returns the pathfile extracted from the CTOR's argument
94  XrdOucString GetFile() { return fPathName; }
95 
96  bool IsValid() { return fIsValid; } // Spot malformations
97 
98 };
99 #endif
Definition: XrdClientUrlInfo.hh:50
XrdOucString GetFile()
Definition: XrdClientUrlSet.hh:94
unsigned int fSeed
Definition: XrdClientUrlSet.hh:62
bool IsValid()
Definition: XrdClientUrlSet.hh:96
XrdClientVector< XrdClientUrlInfo * > UrlArray
Definition: XrdClientUrlSet.hh:45
int Size()
Definition: XrdClientUrlSet.hh:91
bool fIsValid
Definition: XrdClientUrlSet.hh:61
Definition: XrdClientUrlSet.hh:55
XrdOucString fPathName
Definition: XrdClientUrlSet.hh:59
UrlArray fUrlArray
Definition: XrdClientUrlSet.hh:57
UrlArray fTmpUrlArray
Definition: XrdClientUrlSet.hh:58
Definition: XrdOucString.hh:254