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 
45 class XrdClientUrlInfo;
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);
66  XrdOucString host, XrdOucString file);
67  double GetRandom(int seed = 0);
68 
69 public:
72 
73  // Returns the final resolved list of servers
75 
76  // Gets the subsequent Url, the one after the last given
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
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();
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
UrlArray
XrdClientVector< XrdClientUrlInfo * > UrlArray
Definition: XrdClientUrlSet.hh:45
XrdClientUrlSet::fPathName
XrdOucString fPathName
Definition: XrdClientUrlSet.hh:59
XrdClientUrlSet::Size
int Size()
Definition: XrdClientUrlSet.hh:91
XrdClientUrlSet::IsValid
bool IsValid()
Definition: XrdClientUrlSet.hh:96
XrdClientVector::GetSize
int GetSize() const
Definition: XrdClientVector.hh:142
XrdClientUrlSet::GetRandom
double GetRandom(int seed=0)
XrdClientUrlSet::fIsValid
bool fIsValid
Definition: XrdClientUrlSet.hh:61
XrdClientUrlSet::GetARandomUrl
XrdClientUrlInfo * GetARandomUrl(unsigned int seed)
XrdOucString.hh
XrdClientUrlSet::GetARandomUrl
XrdClientUrlInfo * GetARandomUrl()
XrdClientUrlSet::GetServers
XrdOucString GetServers()
XrdClientUrlSet::ShowUrls
void ShowUrls()
XrdClientUrlSet::fUrlArray
UrlArray fUrlArray
Definition: XrdClientUrlSet.hh:57
XrdClientUrlSet::ConvertDNSAlias
void ConvertDNSAlias(UrlArray &urls, XrdOucString proto, XrdOucString host, XrdOucString file)
XrdClientUrlSet::Rewind
void Rewind()
XrdClientVector< XrdClientUrlInfo * >
XrdClientUrlSet::GetNextUrl
XrdClientUrlInfo * GetNextUrl()
XrdClientUrlSet
Definition: XrdClientUrlSet.hh:55
XrdClientUrlSet::fSeed
unsigned int fSeed
Definition: XrdClientUrlSet.hh:62
XrdClientUrlInfo
Definition: XrdClientUrlInfo.hh:50
XrdClientUrlSet::CheckPort
void CheckPort(int &port)
XrdClientVector.hh
XrdClientUrlSet::fTmpUrlArray
UrlArray fTmpUrlArray
Definition: XrdClientUrlSet.hh:58
XrdClientUrlSet::XrdClientUrlSet
XrdClientUrlSet(XrdOucString urls)
XrdClientUrlSet::EraseUrl
void EraseUrl(XrdClientUrlInfo *url)
XrdOucString
Definition: XrdOucString.hh:254
XrdClientConst.hh
XrdClientUrlSet::~XrdClientUrlSet
~XrdClientUrlSet()
XrdClientUrlSet::GetFile
XrdOucString GetFile()
Definition: XrdClientUrlSet.hh:94