XrdClientUrlSet.hh

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //                                                                      //
00003 // XrdClientUrlSet                                                      // 
00004 //                                                                      //
00005 // Author: Fabrizio Furano (INFN Padova, 2004)                          //
00006 // Adapted from TXNetFile (root.cern.ch) originally done by             //
00007 // Alvise Dorigo, Fabrizio Furano, INFN Padova, 2003                    //
00008 // Revised by G. Ganis, CERN, June 2005                                 //
00009 //                                                                      //
00010 // A container for multiple urls to be resolved through DNS aliases     //
00011 //                                                                      //
00012 //////////////////////////////////////////////////////////////////////////
00013 
00014 //       $Id: XrdClientUrlSet.hh 25932 2008-10-23 10:58:11Z ganis $
00015 
00016 #ifndef _XRC_URLSET_H
00017 #define _XRC_URLSET_H
00018 
00019 #include "XrdClient/XrdClientConst.hh"
00020 #include "XrdClient/XrdClientVector.hh"
00021 #include "XrdOuc/XrdOucString.hh"
00022 
00023 using namespace std;
00024 
00025 class XrdClientUrlInfo;
00026 
00027 typedef XrdClientVector<XrdClientUrlInfo*> UrlArray;
00028 
00029 //
00030 // Manages a set of XrdClientUrlInfo objects and provides a set
00031 // of utilities to resolve multiple addresses from the dns
00032 // and to pick urls sequentially and randomly an url
00033 //
00034 
00035 class XrdClientUrlSet {
00036 private:
00037    UrlArray        fUrlArray;
00038    UrlArray        fTmpUrlArray;
00039    XrdOucString    fPathName;
00040 
00041    bool            fIsValid;
00042    unsigned int    fSeed;
00043 
00044    void            CheckPort(int &port);
00045    void            ConvertDNSAlias(UrlArray& urls, XrdOucString proto,
00046                                    XrdOucString host, XrdOucString file);
00047    double          GetRandom(int seed = 0);
00048 
00049 public:
00050    XrdClientUrlSet(XrdOucString urls);
00051    ~XrdClientUrlSet();
00052 
00053    // Returns the final resolved list of servers
00054    XrdOucString   GetServers();
00055 
00056    // Gets the subsequent Url, the one after the last given
00057    XrdClientUrlInfo *GetNextUrl();
00058 
00059    // From the remaining urls we pick a random one. Without reinsert.
00060    //  i.e. while there are not considered urls, never pick an already seen one
00061    XrdClientUrlInfo *GetARandomUrl();
00062    // Given a seed, use that to pick an url
00063    // the effect will be that, given the same list, the same seed will pick the same url
00064    XrdClientUrlInfo *GetARandomUrl(unsigned int seed);
00065 
00066    void              Rewind();
00067    void              ShowUrls();
00068    void              EraseUrl(XrdClientUrlInfo *url);
00069 
00070    // Returns the number of urls
00071    int               Size() { return fUrlArray.GetSize(); }
00072 
00073    // Returns the pathfile extracted from the CTOR's argument
00074    XrdOucString      GetFile() { return fPathName; }
00075 
00076    bool              IsValid() { return fIsValid; } // Spot malformations
00077 
00078 };
00079 
00080 #endif

Generated on Tue Jul 5 14:46:20 2011 for ROOT_528-00b_version by  doxygen 1.5.1