XrdClientAbs.cc

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////
00002 //                                                                      //
00003 // XrdClientAbs                                                         // 
00004 //                                                                      //
00005 // Author: Fabrizio Furano (INFN Padova, 2004)                          //
00006 // Adapted from TXNetFile (root.cern.ch) originally done by             //
00007 //  Alvise Dorigo, Fabrizio Furano                                      //
00008 //          INFN Padova, 2003                                           //
00009 //                                                                      //
00010 // Base class for objects who has to handle redirections with open files//
00011 //                                                                      //
00012 //////////////////////////////////////////////////////////////////////////
00013 
00014 //         $Id: XrdClientAbs.cc 30949 2009-11-02 16:37:58Z ganis $
00015 
00016 const char *XrdClientAbsCVSID = "$Id: XrdClientAbs.cc 30949 2009-11-02 16:37:58Z ganis $";
00017 
00018 #include "XrdClient/XrdClientAbs.hh"
00019 #include "XrdClient/XrdClientDebug.hh"
00020 #include "XrdClient/XrdClientEnv.hh"
00021 
00022 
00023 //_____________________________________________________________________________
00024 void XrdClientAbs::SetParm(const char *parm, int val) 
00025 {
00026    // This method configure TXNetFile's behaviour settings through the 
00027    // setting of special ROOT env vars via the TEnv facility.
00028    // A ROOT env var is not a environment variable (that you can get using 
00029    // getenv() syscall). It's an internal ROOT one (see TEnv documentation
00030    // for more details).
00031    // At the moment the following env vars are handled by TXNetFile
00032    // XNet.ConnectTimeout   - maximum time to wait before server's 
00033    //                                  response on a connect
00034    // XNet.RequestTimeout   - maximum time to wait before considering 
00035    //                                  a read/write failure
00036    // XNet.ConnectDomainAllowRE
00037    //                                - sequence of TRegexp regular expressions
00038    //                                  separated by a |.
00039    //                                  A domain (or w.x.y.z addr) is granted
00040    //                                  access to for the
00041    //                                  first connection if it matches one of these
00042    //                                  regexps. Example:
00043    //                                  slac.stanford.edu|pd.infn.it|fe.infn.it
00044    // XNet.ConnectDomainDenyRE
00045    //                                - sequence of TRegexp regular expressions
00046    //                                  separated by a |.
00047    //                                  A domain (or w.x.y.z addr) is denied
00048    //                                  access to for the
00049    //                                  first connection if it matches one of these
00050    //                                  regexps. Example:
00051    //                                  slac.stanford.edu|pd.infn.it|fe.infn.it
00052    // XNet.RedirDomainAllowRE
00053    //                                - sequence of TRegexp regular expressions
00054    //                                  separated by a |.
00055    //                                  A domain (or w.x.y.z addr) is granted
00056    //                                  access to for a
00057    //                                  redirection if it matches one of these
00058    //                                  regexps. Example:
00059    //                                  slac.stanford.edu|pd.infn.it|fe.infn.it
00060    // XNet.RedirDomainDenyRE
00061    //                                - sequence of TRegexp regular expressions
00062    //                                  separated by a |.
00063    //                                  A domain (or w.x.y.z addr) is denied
00064    //                                  access to for a
00065    //                                  redirection if it matches one of these
00066    //                                  regexps. Example:
00067    //                                  slac.stanford.edu|pd.infn.it|fe.infn.it
00068    //
00069    // XNet.MaxRedirectCount - maximum number of redirections from
00070    //                                  server
00071    // XNet.Debug            - log verbosity level
00072    //                                  (0=nothing,
00073    //                                   1=messages of interest to the user,
00074    //                                   2=messages of interest to the developers 
00075    //                                     (includes also user messages),
00076    //                                   3=dump of all sent/received data buffers
00077    //                                     (includes also user and developers 
00078    //                                      messages).
00079    // XNet.ReconnectTimeout - sleep-time before going back to the 
00080    //                                  load balancer (or rebouncing to the same
00081    //                                  failing host) after a read/write error
00082    // XNet.StartGarbageCollectorThread -
00083    //                                  for test/development purposes. Normally 
00084    //                                  nonzero (True), but as workaround for 
00085    //                                  external causes someone could be
00086    //                                  interested in not having the garbage 
00087    //                                  collector thread around.
00088    // XNet.TryConnect       - Number of tries connect to a single 
00089    //                                  server before giving up
00090    // XNet.TryConnectServersList
00091    //                                - Number of connect retries to the whole 
00092    //                                  server list given
00093    // XNet.PrintTAG         - Print a particular string the developers 
00094    //                                  can choose to quickly recognize the 
00095    //                                  version at run time
00096    // XNet.ReadCacheSize    - The size of the cache. One cache per instance!
00097    //                                  0 for no cache. The cache gets all the
00098    //                                  kxr_read positive responses received
00099    // XNet.ReadAheadSize    - The size of the read-ahead blocks. 
00100    //                                  0 for no read-ahead.
00101 
00102    if (DebugLevel() >= XrdClientDebug::kUSERDEBUG)
00103       Info(XrdClientDebug::kUSERDEBUG,
00104            "AbsNetCommon::SetParm",
00105            "Setting " << parm << " to " << val);
00106 
00107    EnvPutInt((char *)parm, val);
00108 }
00109 
00110 //_____________________________________________________________________________
00111 void XrdClientAbs::SetParm(const char *parm, double val) 
00112 {
00113    // Setting TXNetFile specific ROOT-env variables (see previous method
00114    // for details
00115 
00116    if (DebugLevel() >= XrdClientDebug::kUSERDEBUG)
00117       Info(XrdClientDebug::kUSERDEBUG,
00118            "TXAbsNetCommon::SetParm",
00119            "Setting " << parm << " to " << val);
00120 
00121    
00122    //EnvPutString(parm, val);
00123 }
00124 
00125 
00126 
00127 //_____________________________________________________________________________
00128 // Returns query information
00129 bool XrdClientAbs::Query(kXR_int16 ReqCode, const kXR_char *Args, kXR_char *Resp, kXR_int32 MaxResplen) {
00130    if (!fConnModule) return false;
00131    if (!fConnModule->IsConnected()) return false;
00132    if (!Resp) return false;
00133 
00134    ClientRequest qryRequest;
00135 
00136    memset( &qryRequest, 0, sizeof(qryRequest) );
00137 
00138    fConnModule->SetSID(qryRequest.header.streamid);
00139 
00140    qryRequest.query.requestid = kXR_query;
00141    qryRequest.query.infotype = ReqCode;
00142 
00143    if (Args)
00144       qryRequest.query.dlen = strlen((char *)Args);
00145 
00146    if (ReqCode == kXR_Qvisa)
00147       memcpy( qryRequest.query.fhandle, fHandle, sizeof(fHandle) );
00148 
00149    kXR_char *rsp = 0;
00150    bool ret = fConnModule->SendGenCommand(&qryRequest, (const char*)Args,
00151                                           (void **)&rsp, 0, true,
00152                                           (char *)"Query");
00153   
00154    if (ret) {
00155 
00156       if (Args) {
00157 
00158          if (rsp) {
00159             Info(XrdClientDebug::kHIDEBUG,
00160                  "XrdClientAdmin::Query",
00161                  "Query(" << ReqCode << ", '" << Args << "') returned '" << rsp << "'" );
00162          }
00163          else {
00164             Info(XrdClientDebug::kHIDEBUG,
00165                  "XrdClientAdmin::Query",
00166                  "Query(" << ReqCode << ", '" << Args << "') returned a null string" );
00167          }
00168 
00169       }
00170       else {
00171          Info(XrdClientDebug::kHIDEBUG,
00172               "XrdClientAdmin::Query",
00173               "Query(" << ReqCode << ", NULL') returned '" << rsp << "'" );
00174       }
00175       
00176       if ( rsp && (LastServerResp()->status == kXR_ok) ) {
00177          int l = xrdmin(MaxResplen, LastServerResp()->dlen);
00178          strncpy((char *)Resp, (char *)rsp, l);
00179          if (l >= 0) Resp[l-1] = '\0';
00180          free(rsp);
00181          rsp = 0;
00182       }
00183    }
00184 
00185    return ret;
00186 }
00187 

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