Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TXNetFile.cxx
Go to the documentation of this file.
1// @(#)root/netx:$Id$
2// Author: Alvise Dorigo, Fabrizio Furano INFN Padova, 2003
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/**
13\file TXNetFile.cxx
14\class TXNetFile
15\ingroup IO
16
17TXNetFile is an extension of TNetFile able to deal with new xrootd server. Its
18new features are:
19- Automatic server kind recognition (xrootd load balancer, xrootd data server,
20 old rootd.
21- Backward compatibility with old rootd server (acts as an old TNetFile)
22- Fault tolerance for read/write operations (read/write timeouts and retry)
23- Internal connection timeout (tunable independently from the OS one) handled
24by threads.
25- Handling of redirections from server.
26- Single TCP physical channel for multiple TXNetFile's instances inside the
27 same application. So, each TXNetFile object client must send messages
28 containing its ID (streamid). The server, of course, will respond with
29 messages containing the client's ID, in order to make the client able to
30 recognize its message by matching its streamid with that one contained in
31 the server's response.
32- Tunable log verbosity level (0 = nothing, 3 = dump read/write buffers too!)
33- Many parameters configurable via TEnv facility (see SetParm() methods)
34
35Interfaced to the standalone client (XrdClient): G. Ganis, CERN
36**/
37
38#include "Bytes.h"
39
40#include "TError.h"
41#include "TEnv.h"
42#include "TSocket.h"
43#include "TXNetFile.h"
44#include "TROOT.h"
45#include "TVirtualMonitoring.h"
46#include "TFileStager.h"
47#include "TFileCacheRead.h"
48#include "TTimeStamp.h"
49#include "TVirtualPerfStats.h"
50
51#include <XrdClient/XrdClient.hh>
55#include <XProtocol/XProtocol.hh>
56
57#include "XpdSysPthread.h"
58#include "XrdSysToOuc.h"
59
61
65
66////////////////////////////////////////////////////////////////////////////////
67/// Create a TXNetFile object. A TXNetFile object is the same as a TNetFile
68/// (from which the former derives) except that the protocol is extended to
69/// support dealing with new xrootd data server or xrootd load balancer
70/// server.
71///
72/// The "url" argument must be of the form
73/// `root://server1:port1[,server2:port2,...,serverN:portN]/pathfile,`
74/// Note that this means that multiple servers (>= 1) can be specified in
75/// the url. The connection will try to connect to the first server:port
76/// and if that does not succeed, it will try the second one, and so on
77/// until it finds a server that will respond.
78///
79/// See the TNetFile documentation for the description of the other arguments.
80///
81/// The creation consists of internal variable settings (most important is
82/// the client's domain), creation of a TXUrl array containing all specified
83/// urls (a single url is serverX:portX/pathfile), trying to connect to the
84/// servers calling Connect() method, getting a valid access to the remote
85/// server the client is connected to using GetAccessToSrv() method,
86/// recognizing the remote server (if an old rootd the TNetFile's Create
87/// method will be called).
88///
89/// The options field of the URL can be used for the following purposes
90/// (multiple options can be set):
91/// 1. open a non-ROOT generic file
92/// `root://server1:port1[,server2:port2,...]/pathfile?filetype=raw`
93/// 2. re-check the environment variables
94/// `root://server1:port1[,server2:port2,...]/pathfile?checkenv`
95/// 3. set the cache size (in bytes)
96/// `root://server1:port1[,server2:port2,...]/pathfile?cachesz=20000000`
97/// 4. set the read-ahead size (in bytes)
98/// `root://server1:port1[,server2:port2,...]/pathfile?readaheadsz=100000`
99/// 5. set the cache remove policy
100/// `root://server1:port1[,server2:port2,...]/pathfile?rmpolicy=1`
101/// 6. set the max number of redirections
102/// `root://server1:port1[,server2:port2,...]/pathfile?mxredir=2`
103
104TXNetFile::TXNetFile(const char *url, Option_t *option, const char* ftitle,
105 Int_t compress, Int_t netopt, Bool_t parallelopen,
106 const char *logicalurl) :
107 TNetFile((logicalurl ? logicalurl : url), ftitle, compress, kFALSE)
108{
109 TUrl urlnoanchor(url);
110 // Set debug level
111 EnvPutInt(NAME_DEBUG, gEnv->GetValue("XNet.Debug", 0));
112
113 // Set environment, if needed
114 if (!fgInitDone || strstr(urlnoanchor.GetOptions(),"checkenv")) {
115 SetEnv();
117
118 // Print the tag, if required (only once)
119 if (gEnv->GetValue("XNet.PrintTAG",0) == 1)
120 Info("TXNetFile","(eXtended TNetFile) %s",
121 gROOT->GetVersion());
122 }
123
124 // Remove anchors from the URL!
125 urlnoanchor.SetAnchor("");
126
127 // Init mutex used in the asynchronous open machinery
128 fInitMtx = (void *) new XrdSysRecMutex();
129
130 if (gMonitoringWriter) {
131 // Init the monitoring system
132 if (!fOpenPhases) {
133 fOpenPhases = new TList;
135 }
136 // Should not be null instead of "xrdopen" to init the thing ?
138 }
139
140 // Create an instance
141 CreateXClient(urlnoanchor.GetUrl(), option, netopt, parallelopen);
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// Destructor.
146
148{
149 if (IsOpen())
150 Close(0);
151
154 if (mtx) delete mtx;
155 fInitMtx = 0;
156}
157
158////////////////////////////////////////////////////////////////////////////////
159/// Form url for rootd socket.
160
162{
163 // Protocol
164 uus = "root://";
165
166 // User, if any
167 if (strlen(uu.GetUser()) > 0) {
168 uus += uu.GetUser();
169 uus += "@";
170 }
171
172 // Host, if any
173 if (strlen(uu.GetHost()) > 0) {
174 uus += uu.GetHost();
175 }
176
177 // Port, if any
178 if (uu.GetPort() > 0) {
179 uus += ":";
180 uus += uu.GetPort();
181 }
182
183 // End of string
184 uus += "/";
185}
186
187////////////////////////////////////////////////////////////////////////////////
188/// Parse input options for cache parameters
189
191 Int_t &cachesz, Int_t &readaheadsz,
192 Int_t &rmpolicy, Int_t &mxredir, Int_t &rastrategy, Int_t &readtrimblksz)
193{
194 static const char *keys[6] = { "cachesz=", "readaheadsz=", "rmpolicy=",
195 "mxredir=", "readaheadstrategy=", "readtrimblksz=" };
196 Int_t fo = 0;
197 TString s(opts);
198
199 UInt_t i = 0;
200 for (i = 0; i < (sizeof(keys)/sizeof(keys[0])); i++) {
201 Int_t j = s.Index(keys[i]);
202 if (j != kNPOS) {
203 TString val(s(j+strlen(keys[i]), s.Length()));
204 // Cut of non digits
205 Int_t k = 0;
206 while (k < val.Length())
207 if (!TString(val(k++)).IsDigit())
208 break;
209 if (k < val.Length())
210 val.Remove(--k);
211 if (val.IsDigit()) {
212 fo++;
213 if (i == 0)
214 cachesz = val.Atoi();
215 else if (i == 1)
216 readaheadsz = val.Atoi();
217 else if (i == 2)
218 rmpolicy = val.Atoi();
219 else if (i == 3)
220 mxredir = val.Atoi();
221 else if (i == 4)
222 rastrategy = val.Atoi();
223 else if (i == 5)
224 readtrimblksz = val.Atoi();
225 }
226 }
227 }
228
229 // Notify
230 if (gDebug > 0)
231 Info("ParseCacheOptions","found: cachesz = %d, readaheadsz = %d, "
232 "rmpolicy = %d, mxredir = %d, rastrategy = %d, readtrimblksz = %d",
233 cachesz, readaheadsz, rmpolicy, mxredir, rastrategy, readtrimblksz);
234
235 // Done
236 return fo;
237}
238
239////////////////////////////////////////////////////////////////////////////////
240/// The real creation work is done here.
241
242void TXNetFile::CreateXClient(const char *url, Option_t *option, Int_t netopt,
243 Bool_t parallelopen)
244{
245 Int_t cachesz = -1, readaheadsz = -1, rmpolicy = -1, mxredir = -1, np = 0;
246 Int_t readaheadstrategy = -1, readtrimblksz = -1;
247
248 fClient = 0;
249 fNetopt = netopt;
250
251 // Set the timeout (default 999999999 secs, i.e. far, far in the future)
252 gSystem->Setenv("XRDCLIENTMAXWAIT", Form("%d",TFile::GetOpenTimeout()));
253
254 if (GetOnlyStaged()) {
255 // Check if the file is staged before opening it
256 if (!fgFileStager || !(fgFileStager->Matches(url))) {
259 }
260 if (fgFileStager) {
261 if (!(fgFileStager->IsStaged(url))) {
262 ::Warning("TXNetFile","<%s> is not staged - StageOnly flag is set!",url);
263 goto zombie;
264 }
265 }
266 }
267
268 // Init members
270
271 // The parallel open can be forced to true in the config
272 if (gEnv->GetValue("XNet.ForceParallelOpen", 0))
273 parallelopen = kTRUE;
275
276 Bool_t isRootd;
277 isRootd = kFALSE;
278 //
279 // Setup a client instance
280 fClient = new XrdClient(url);
281 if (!fClient) {
282 fAsyncOpenStatus = (parallelopen) ? kAOSFailure : fAsyncOpenStatus ;
283 Error("CreateXClient","fatal error: new object creation failed -"
284 " out of system resources.");
285 gSystem->Abort();
286 goto zombie;
287 }
288
289 // Get client (cache, redir) parameters, if any
290 np = ParseOptions(TUrl(url).GetOptions(),
291 cachesz, readaheadsz, rmpolicy, mxredir,
292 readaheadstrategy, readtrimblksz);
293
294 // Set max redir, if asked
295 if (mxredir > 0) {
296 if (fClient->GetClientConn()) {
297 if (gDebug > 0)
298 Info("CreateXClient", "setting maxredir = %d", mxredir);
299 fClient->GetClientConn()->SetMaxRedirCnt(mxredir);
300 }
301 np--;
302 }
303 // Set the cache parameters, if any
304 if (np > 0) {
305 if (gDebug > 0)
306 Info("CreateXClient", "setting cachesz = %d, readaheadsz = %d, "
307 "rmpolicy = %d",
308 cachesz, readaheadsz, rmpolicy);
309 fClient->SetCacheParameters(cachesz, readaheadsz, rmpolicy);
310
311 if (readaheadstrategy >= 0) {
312 if (gDebug > 0)
313 Info("CreateXClient", "setting readaheadstrategy = %d", readaheadstrategy);
314 fClient->SetReadAheadStrategy(readaheadstrategy);
315 }
316
317 if (readtrimblksz >= 0) {
318 if (gDebug > 0)
319 Info("CreateXClient", "setting readtrimblksz = %d", readtrimblksz);
320 fClient->SetBlockReadTrimming(readtrimblksz);
321 }
322
323 }
324
325 //
326 // Now try opening the file
327 if (!Open(option, parallelopen)) {
328 if (!fClient->IsOpen_wait()) {
329 if (gDebug > 1)
330 Info("CreateXClient", "remote file could not be open");
331
332 // If the server is a rootd we need to create a TNetFile
333 isRootd = (fClient->GetClientConn()->GetServerType() == kSTRootd);
334
335 if (isRootd) {
336 if (fgRootdBC) {
337
338 Int_t sd = fClient->GetClientConn()->GetOpenSockFD();
339 if (sd > -1) {
340 //
341 // Create a TSocket on the open connection
342 TSocket *s = new TSocket(sd);
343
344 s->SetOption(kNoBlock, 0);
345
346 // Find out the remote protocol (send the client protocol first)
347 Int_t rproto = GetRootdProtocol(s);
348 if (rproto < 0) {
349 Error("CreateXClient", "getting rootd server protocol");
350 goto zombie;
351 }
352
353 // Finalize TSocket initialization
354 s->SetRemoteProtocol(rproto);
355 TUrl uut((fClient->GetClientConn()
356 ->GetCurrentUrl()).GetUrl().c_str());
357 TString uu;
358 FormUrl(uut,uu);
359
360 if (gDebug > 2)
361 Info("CreateXClient"," url: %s",uu.Data());
362 s->SetUrl(uu.Data());
363 s->SetService("rootd");
365 //
366 // Set rootd flag
367 fIsRootd = kTRUE;
368 //
369 // Now we can check if we can create a TNetFile on the
370 // open connection
371 if (rproto > 13) {
372 //
373 // Remote support for reuse of open connection
374 TNetFile::Create(s, option, netopt);
375 } else {
376 //
377 // Open connection has been closed because could
378 // not be reused; TNetFile will open a new connection
379 TNetFile::Create(uu.Data(), option, netopt);
380 }
381
382 return;
383 } else {
384 Error("CreateXClient", "rootd: underlying socket undefined");
385 goto zombie;
386 }
387 } else {
388 if (gDebug > 0)
389 Info("CreateXClient", "rootd: fall back not enabled - closing");
390 goto zombie;
391 }
392 } else {
393 Error("CreateXClient", "open attempt failed on %s", fUrl.GetUrl());
394 goto zombie;
395 }
396 }
397 }
398
399 return;
400
401zombie:
402 // error in file opening occured, make this object a zombie
404 MakeZombie();
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// Find out the remote rootd protocol version.
410/// Returns -1 in case of error.
411
413{
414 Int_t rproto = -1;
415
416 UInt_t cproto = 0;
417 Int_t len = sizeof(cproto);
418 memcpy((char *)&cproto,
420 Int_t ns = s->SendRaw(&cproto, len);
421 if (ns != len) {
422 ::Error("TXNetFile::GetRootdProtocol",
423 "sending %d bytes to rootd server [%s:%d]",
424 len, (s->GetInetAddress()).GetHostName(), s->GetPort());
425 return -1;
426 }
427
428 // Get the remote protocol
429 Int_t ibuf[2] = {0};
430 len = sizeof(ibuf);
431 Int_t nr = s->RecvRaw(ibuf, len);
432 if (nr != len) {
433 ::Error("TXNetFile::GetRootdProtocol",
434 "reading %d bytes from rootd server [%s:%d]",
435 len, (s->GetInetAddress()).GetHostName(), s->GetPort());
436 return -1;
437 }
438 Int_t kind = net2host(ibuf[0]);
439 if (kind == kROOTD_PROTOCOL) {
440 rproto = net2host(ibuf[1]);
441 } else {
442 kind = net2host(ibuf[1]);
443 if (kind == kROOTD_PROTOCOL) {
444 len = sizeof(rproto);
445 nr = s->RecvRaw(&rproto, len);
446 if (nr != len) {
447 ::Error("TXNetFile::GetRootdProtocol",
448 "reading %d bytes from rootd server [%s:%d]",
449 len, (s->GetInetAddress()).GetHostName(), s->GetPort());
450 return -1;
451 }
452 rproto = net2host(rproto);
453 }
454 }
455 if (gDebug > 2)
456 ::Info("TXNetFile::GetRootdProtocol",
457 "remote rootd: buf1: %d, buf2: %d rproto: %d",
458 net2host(ibuf[0]),net2host(ibuf[1]),rproto);
459
460 // We are done
461 return rproto;
462}
463
464////////////////////////////////////////////////////////////////////////////////
465/// The real creation work is done here.
466
468{
469 //
470 // Parse options
471 kXR_unt16 openOpt = 0;
472 memset(&openOpt, 0, sizeof(openOpt));
473 TString opt = option;
474 opt.ToUpper();
475 //
476 // Check force, accepting 'f'/'F' for backward compatibility,
477 // and special read syntax
478 if (opt.BeginsWith("-") || opt.BeginsWith("F") || (opt == "+READ")) {
479 opt.Remove(0,1);
480 openOpt |= kXR_force;
481 }
482 //
483 // Read flag
484 Bool_t read = (opt == "READ");
485 //
486 // Create flag ("NEW" == "CREATE")
487 Bool_t create = (opt == "CREATE" || opt == "NEW");
488 //
489 // Recreate flag
490 Bool_t recreate = (opt == "RECREATE");
491 //
492 // Update flag
493 Bool_t update = (opt == "UPDATE");
494 //
495 // Default is Read
496 if (!create && !recreate && !update && !read) {
497 read = kTRUE;
498 opt = "READ";
499 }
500 //
501 // Save effective options
502 fOption = opt;
503 if (create || update || recreate)
504 fWritable = 1;
505 //
506 // Update requires the file existing: check that and switch to create,
507 // if the file is not found.
508 if (update) {
510 update = kFALSE;
511 create = kTRUE;
512 }
513 if (update) {
515 Error("Open", "no write permission, could not open file %s",
516 fUrl.GetUrl());
517 fAsyncOpenStatus = (doitparallel) ? kAOSFailure : fAsyncOpenStatus ;
518 return kFALSE;
519 }
520 openOpt |= kXR_open_updt;
521 }
522 }
523
524 //
525 // Create and Recreate are correlated
526 if (create)
527 openOpt |= kXR_new;
528 if (recreate) {
529 openOpt |= kXR_delete;
530 create = kTRUE;
531 }
532
533 Bool_t mkpath = (gEnv->GetValue("XNet.Mkpath", 0) == 1) ? kTRUE : kFALSE;
534 char *p = (char*)strstr(fUrl.GetOptions(), "mkpath=");
535 if (p)
536 mkpath = (*(p + strlen("mkpath=")) == '1') ? kTRUE : kFALSE;
537 if (mkpath)
538 openOpt |= kXR_mkpath;
539
540 if (read)
541 openOpt |= kXR_open_read;
542
543 //
544 // Set open mode to rw-r-r
545 kXR_unt16 openMode = kXR_or | kXR_gr | kXR_ur | kXR_uw;
546
547 //
548 // Open file (FileOpenerThread disabled for the time being)
549 if (!fClient->Open(openMode, openOpt, doitparallel)) {
550 if (gDebug > 1)
551 Info("Open", "remote file could not be open");
552 fAsyncOpenStatus = (doitparallel) ? kAOSFailure : fAsyncOpenStatus ;
553 return kFALSE;
554 } else {
555 // Initialize the file
556 // If we are using the parallel open, the init phase is
557 // performed later. In checking for the IsOpen or
558 // asynchronously in a callback func
559 if (!doitparallel) {
560 // Mutex serialization is done inside
561 Init(create);
562 // If initialization failed close everything
563 if (TFile::IsZombie()) {
564 fClient->Close();
565 // To avoid problems in final deletion of object not completely
566 // initialized
567 fWritable = 0;
568 // Notify failure
569 return kFALSE;
570 }
571 }
572 }
573
574 // We are done
575 return kTRUE;
576}
577
578////////////////////////////////////////////////////////////////////////////////
579/// Override TNetFile::ReadBuffer to deal with the xrootd server.
580/// Returns kTRUE in case of errors.
581
582Bool_t TXNetFile::ReadBuffer(char *buffer, Int_t bufferLength)
583{
584 if (IsZombie()) {
585 Error("ReadBuffer", "ReadBuffer is not possible because object"
586 " is in 'zombie' state");
587 return kTRUE;
588 }
589
590 if (fIsRootd) {
591 if (gDebug > 1)
592 Info("ReadBuffer","Calling TNetFile::ReadBuffer");
593 return TNetFile::ReadBuffer(buffer, bufferLength);
594 }
595
596 if (!IsOpen()) {
597 Error("ReadBuffer","The remote file is not open");
598 return kTRUE;
599 }
600
602
603 if (bufferLength==0)
604 return 0;
605
606 // This returns:
607 // 2 if errors
608 // 1 it looks like the block has already been prefetched
609 // 0 it looks like the block has not been prefetched
610 // But we don't want it to return the buffer, to avoid recursion
611 Int_t st = 0;
612
613 //using the new method to read
614 if (GetCacheRead() && GetCacheRead()->IsEnablePrefetching()) {
615 st = ReadBufferViaCache(buffer, bufferLength); //modify to "buffer" so that it work with the ne version!!!
616 if (st == 1){
617 fOffset -= bufferLength;
618 return kFALSE;
619 }
620 }
621 else{ //using the old method to read
622 if (GetCacheRead() && GetCacheRead()->IsAsyncReading()) {
623 st = ReadBufferViaCache(0, bufferLength);
624 if (st == 1)
625 fOffset -= bufferLength;
626 } else {
627 if (GetCacheRead()) {
628 st = ReadBufferViaCache(buffer, bufferLength);
629 if (st == 1)
630 return kFALSE;
631 }
632 }
633 }
634
635 Double_t start = 0;
636 if (gPerfStats) start = TTimeStamp();
637
638 // Read from the remote xrootd
639 Int_t nr = fClient->Read(buffer, fOffset, bufferLength);
640
641 if (nr != bufferLength) {
642 Error("ReadBuffer", "error reading all requested bytes, got %d of %d",
643 nr, bufferLength);
644 return kTRUE;
645 }
646
647 if (gDebug > 1)
648 Info("ReadBuffer", "%d bytes of data read from offset"
649 " %lld (%d requested)", nr, fOffset, bufferLength);
650
651 fOffset += bufferLength;
652
653 fBytesRead += nr;
654 fReadCalls++;
655#ifdef WIN32
658#else
659 fgBytesRead += nr;
660 fgReadCalls++;
661#endif
662
663 if (gPerfStats)
664 gPerfStats->FileReadEvent(this, bufferLength, start);
665
668
669 return result;
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// Pass through to TNetFile implementation which will call back eventually
674/// to our ReadBuffer with 2 arguments to deal with xrootd errors.
675
676Bool_t TXNetFile::ReadBuffer(char *buffer, Long64_t pos, Int_t bufferLength)
677{
678 return TNetFile::ReadBuffer(buffer, pos, bufferLength);
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Implementation dealing with the xrootd server.
683/// Returns kTRUE in case of errors.
684/// This is the same as TXNetFile::ReadBuffer but using the async
685/// call from xrootd
686
688{
689 if (IsZombie()) {
690 Error("ReadBuffer", "ReadBuffer is not possible because object"
691 " is in 'zombie' state");
692 return kTRUE;
693 }
694
695 if (fIsRootd) {
696 if (gDebug > 1)
697 Error("ReadBufferAsync","Not supported for rootd");
698 return kTRUE;
699 }
700
701 if (!IsOpen()) {
702 Error("ReadBuffer","The remote file is not open");
703 return kTRUE;
704 }
705
706 Double_t start = 0;
707 if (gPerfStats) start = TTimeStamp();
708
710
711 if (bufferLength==0)
712 return 0;
713
715
716 // Read for the remote xrootd
717 // This doesnt return the number of bytes read...
718 // and even if it did we dont want to update fBytesRead
719 // because that would be updated in the real read
720 XReqErrorType nr = fClient->Read_Async(offs+fArchiveOffset, bufferLength);
721
722 if (nr != kOK)
723 return kTRUE;
724
725 fBytesRead += bufferLength;
726 fReadCalls++;
727#ifdef WIN32
728 SetFileBytesRead(GetFileBytesRead() + bufferLength);
730#else
731 fgBytesRead += bufferLength;
732 fgReadCalls++;
733#endif
734
735 if (gPerfStats)
736 gPerfStats->FileReadEvent(this, bufferLength, start);
737
738 if (gDebug > 1)
739 Info("ReadBufferAsync", "%d bytes of data read request from offset"
740 " %lld", bufferLength, offs);
741 return result;
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Read the nbuf blocks described in arrays pos and len,
746/// where pos[i] is the seek position of block i of length len[i].
747/// Note that for nbuf=1, this call is equivalent to TFile::ReadBuffer
748/// This function is overloaded by TNetFile, TWebFile, etc.
749/// Returns kTRUE in case of failure.
750/// Note: This is the overloading made in TXNetFile. If ReadBuffers
751/// is supported by xrootd it will try to get the whole list from one single
752/// call avoiding the latency of multiple calls
753
755{
756 if (IsZombie()) {
757 Error("ReadBuffers", "ReadBuffers is not possible because object"
758 " is in 'zombie' state");
759 return kTRUE;
760 }
761
762 if (fIsRootd) {
763 if (gDebug > 1)
764 Info("ReadBuffers","Calling TNetFile::ReadBuffers");
765 return TNetFile::ReadBuffers(buf, pos, len, nbuf);
766 }
767
768 if (!IsOpen()) {
769 Error("ReadBuffers","The remote file is not open");
770 return kTRUE;
771 }
772
773 Double_t start = 0;
774 if (gPerfStats) start = TTimeStamp();
775
776 if (fArchiveOffset) {
777 for (Int_t i = 0; i < nbuf; i++)
778 pos[i] += fArchiveOffset;
779 }
780
781 Long64_t expected_nr = 0;
782 for (Int_t i = 0; i < nbuf; i++) {
783 expected_nr += len[i];
784 }
785
786 // A null buffer means that we want to use the async stuff
787 // hence we have to sync the cache size in XrdClient with the supposed
788 // size in TFile.
789 if (!buf) {
790 // Null buffer + 0 blocks means 'reset cache'
791 if (!nbuf) ResetCache();
793 }
794
795 // Read for the remote xrootd
796 Long64_t nr = fClient->ReadV(buf, pos, len, nbuf);
797
798 if (gDebug > 1)
799 Info("ReadBuffers", "response from ReadV(%d) nr: %lld", nbuf, nr);
800
801 if (nr == expected_nr) {
802
803 if (gDebug > 1)
804 Info("ReadBuffers", "%lld bytes of data read from a list of %d buffers",
805 nr, nbuf);
806
807 if (GetCacheRead() && GetCacheRead()->GetBufferSize() < nr)
808 Info("ReadBuffers", "%lld bytes of data read with a smaller (%d) TFileCacheRead buffer size?",
809 nr, GetCacheRead()->GetBufferSize());
810
811 // Where should we leave the offset ?
812 // fOffset += bufferLength;
813 fBytesRead += nr;
814 fReadCalls++;
815#ifdef WIN32
818#else
819 fgBytesRead += nr;
820 fgReadCalls++;
821#endif
822
823 if (gPerfStats) {
824 fOffset = pos[0];
825 gPerfStats->FileReadEvent(this, (Int_t)nr, start);
826 }
827
830
831 return kFALSE;
832 }
833
834 if (gDebug > 1)
835 Info("ReadBuffers", "XrdClient->ReadV failed, executing TFile::ReadBuffers");
836
837 // If it wasnt able to use the specialized call
838 // then use the generic one that is a plain loop
839 // of individual requests
840 if (buf && nbuf)
841 return TFile::ReadBuffers(buf, pos, len, nbuf);
842 // If the async call was needed (buf == 0) and it got an error,
843 // just return error
844 else return kTRUE;
845}
846
847////////////////////////////////////////////////////////////////////////////////
848/// Override TNetFile::WriteBuffer to deal with the xrootd server.
849/// Returns kTRUE in case of errors.
850
851Bool_t TXNetFile::WriteBuffer(const char *buffer, Int_t bufferLength)
852{
853 if (IsZombie()) {
854 Error("WriteBuffer", "WriteBuffer is not possible because object"
855 " is in 'zombie' state");
856 return kTRUE;
857 }
858
859 if (!fWritable) {
860 if (gDebug > 1)
861 Info("WriteBuffer","file not writable");
862 return kTRUE;
863 }
864
865 if (fIsRootd) {
866 if (gDebug > 1)
867 Info("WriteBuffer","Calling TNetFile::WriteBuffer");
868 return TNetFile::WriteBuffer(buffer, bufferLength );
869 }
870
871 if (!IsOpen()) {
872 Error("WriteBuffer","The remote file is not open");
873 return kTRUE;
874 }
875
876 Int_t st;
877 if ((st = WriteBufferViaCache(buffer, bufferLength))) {
878 if (st == 2)
879 return kTRUE;
880 return kFALSE;
881 }
882
883 // Read for the remote xrootd
884 if (!fClient->Write(buffer, fOffset, bufferLength)) {
885 if (gDebug > 0)
886 Info("WriteBuffer",
887 "error writing %d bytes of data wrote to offset %lld",
888 bufferLength , fOffset);
889 return kTRUE;
890 }
891
892 if (gDebug > 1)
893 Info("WriteBuffer", " %d bytes of data wrote to offset"
894 " %lld", bufferLength , fOffset);
895
896 fOffset += bufferLength;
897 fBytesWrite += bufferLength;
898#ifdef WIN32
900#else
901 fgBytesWrite += bufferLength;
902#endif
903
904 return kFALSE;
905}
906
907////////////////////////////////////////////////////////////////////////////////
908/// Initialize the file. Makes sure that the file is really open before
909/// calling TFile::Init. It may block.
910
912{
913 if (fInitDone) {
914 // TFile::Init already called once
915 if (gDebug > 1)
916 Info("Init","TFile::Init already called once");
917 return;
918 }
919
920 if (fIsRootd) {
921 if (gDebug > 1)
922 Info("Init","rootd: calling directly TFile::Init");
923 return TNetFile::Init(create);
924 }
925
926 if (fClient) {
927 // A mutex serializes this very delicate section
929
930 // To safely perform the Init() we must make sure that
931 // the file is successfully open; this call may block
932 if (fClient->IsOpen_wait()) {
933
934 // Notify the monitoring system
937
938 // Avoid big transfers at this level
939 bool usecachesave = fClient->UseCache(0);
940 // Note that Init will trigger recursive calls
942 // so TFile::IsOpen() returns true when in TFile::~TFile
943 fD = -2;
944 // Restore requested behaviour
945 fClient->UseCache(usecachesave);
946
947 // Notify the monitoring system
950
951 // Set the Endpoint Url we are now connected to. Unless there was some opaque info
952 // which cannot be re-used
953 if (fClient->GetClientConn() && fClient->GetClientConn()->fRedirOpaque.length() <= 0) {
954 fEndpointUrl = fClient->GetClientConn()->GetCurrentUrl().GetUrl().c_str();
955 // Check equivalence of initial and end-point Url to see whether we have
956 // been redirected
957 if (fEndpointUrl.GetPort() != fUrl.GetPort() ||
960 }
961 } else {
962 if (gDebug > 0)
963 Info("Init","open request failed!");
965 MakeZombie();
967 }
968 }
969}
970
971////////////////////////////////////////////////////////////////////////////////
972/// Return kTRUE if the file is open, kFALSE otherwise.
973
975{
976 if (fIsRootd) {
977 if (gDebug > 1)
978 Info("IsOpen","Calling TNetFile::IsOpen");
979 return TNetFile::IsOpen();
980 }
981
982 if (!fClient)
983 return kFALSE;
984
985 // We are done
986 return ((fClient && fInitDone) ? fClient->IsOpen() : kFALSE);
987}
988
989////////////////////////////////////////////////////////////////////////////////
990/// Return status of asynchronous request
991
993{
995 if (fClient->IsOpen_inprogress()) {
997 } else {
998 if (fClient->IsOpen())
999 return TFile::kAOSSuccess;
1000 else
1001 return TFile::kAOSFailure;
1002 }
1003 }
1004
1005 // Not asynchronous
1006 return TFile::kAOSNotAsync;
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010/// Re-open the file (see TNetFile::ReOpen() or TFile::ReOpen()
1011/// for more details).
1012
1014{
1015 if (fIsRootd) {
1016 if (gDebug > 1)
1017 Info("ReOpen","Calling TNetFile::ReOpen");
1018 return TNetFile::ReOpen(Mode);
1019 }
1020
1021 return TFile::ReOpen(Mode);
1022}
1023
1024////////////////////////////////////////////////////////////////////////////////
1025/// Close the file (see TNetFile::Close() or TFile::Close()
1026/// for more details).
1027
1029{
1030 if (fIsRootd) {
1031 if (gDebug > 1)
1032 Info("Close","Calling TNetFile::Close");
1033 TNetFile::Close(opt);
1034 return;
1035 }
1036
1037 if (!fClient) return;
1038
1039 TFile::Close(opt);
1040
1041 fIsRootd = kFALSE;
1042
1043 if (IsOpen())
1044 fClient->Close();
1045
1046 fD = -1; // so TFile::IsOpen() returns false when in TFile::~TFile
1047}
1048
1049////////////////////////////////////////////////////////////////////////////////
1050/// Flushes un-written data.
1051
1053{
1054 if (IsZombie()) {
1055 Error("Flush", "Flush is not possible because object is"
1056 " in 'zombie' state");
1057 return;
1058 }
1059
1060 if (!fWritable) {
1061 if (gDebug > 1)
1062 Info("Flush", "file not writable - do nothing");
1063 return;
1064 }
1065
1066 if (fIsRootd) {
1067 if (gDebug > 1)
1068 Info("Flush","Calling TNetFile::Flush");
1070 return;
1071 }
1072
1073 if (!IsOpen()) {
1074 Error("Flush","The remote file is not open");
1075 return;
1076 }
1077
1079
1080 //
1081 // Flush via the remote xrootd
1082 fClient->Sync();
1083 if (gDebug > 1)
1084 Info("Flush", "XrdClient::Sync called.");
1085}
1086
1087////////////////////////////////////////////////////////////////////////////////
1088/// Override TNetFile::SysStat (see parent's method for more details).
1089
1091 Long_t *modtime)
1092{
1093 if (IsZombie()) {
1094 Error("SysStat", "SysStat is not possible because object is"
1095 " in 'zombie' state");
1096 *size = 0;
1097 return 1;
1098 }
1099
1100 if (fIsRootd) {
1101 if (gDebug > 1)
1102 Info("SysStat", "calling TNetFile::SysStat");
1103 return TNetFile::SysStat(fd, id, size, flags, modtime);
1104 }
1105
1106 // Return file stat information. The interface and return value is
1107 // identical to TSystem::GetPathInfo().
1108 struct XrdClientStatInfo stinfo;
1109 if (fClient && fClient->Stat(&stinfo)) {
1110 *id = (Long_t)(stinfo.id);
1111 *size = (Long64_t)(stinfo.size);
1112 *flags = (Long_t)(stinfo.flags);
1113 *modtime = (Long_t)(stinfo.modtime);
1114 if (gDebug > 1)
1115 Info("SysStat", "got stats = %ld %lld %ld %ld",
1116 *id, *size, *flags, *modtime);
1117 } else {
1118
1119 if (gDebug > 1) {
1120 if (!IsOpen()) Info("SysStat", "could not stat remote file. Not opened.");
1121 else
1122 Info("SysStat", "could not stat remote file");
1123 }
1124
1125
1126 *id = -1;
1127 return 1;
1128 }
1129
1130 // We are done
1131 return 0;
1132}
1133
1134////////////////////////////////////////////////////////////////////////////////
1135/// Override TNetFile::SysClose (see parent's method for more details).
1136
1138{
1139 if (IsZombie()) {
1140 Error("SysClose", "SysClose is not possible because object is"
1141 " in 'zombie' state");
1142 return 0;
1143 }
1144
1145 if (fIsRootd) {
1146 if (gDebug > 1)
1147 Info("SysClose","Calling TNetFile::SysClose");
1148 return TNetFile::SysClose(fd);
1149 }
1150
1151 // Send close to remote xrootd
1152 if (IsOpen())
1153 fClient->Close();
1154
1155 return 0;
1156}
1157
1158////////////////////////////////////////////////////////////////////////////////
1159/// Override TNetFile::SysOpen (see parent's method for more details).
1160
1161Int_t TXNetFile::SysOpen(const char* pathname, Int_t flags, UInt_t mode)
1162{
1163 if (fIsRootd) {
1164 if (gDebug > 1)
1165 Info("SysOpen", "Calling TNetFile::SysOpen");
1166 return TNetFile::SysOpen(pathname, flags, mode);
1167 }
1168
1169 if (!fClient) {
1170
1171 // Create an instance of XrdClient
1173
1174 } else {
1175
1176 // url is not needed because already stored
1177 // fOption is set in TFile::ReOpen
1178 Open(fOption.Data(), kFALSE);
1179 }
1180
1181 // If not successful, flag it
1182 if (!IsOpen())
1183 return -1;
1184
1185 // This means ok for net files
1186 return -2; // set as fD in ReOpen
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Set the relevant environment variables
1191
1193{
1194 // List of domains where redirection is allowed
1195 TString allowRE = gEnv->GetValue("XNet.RedirDomainAllowRE", "");
1196 if (allowRE.Length() > 0)
1198
1199 // List of domains where redirection is denied
1200 TString denyRE = gEnv->GetValue("XNet.RedirDomainDenyRE", "");
1201 if (denyRE.Length() > 0)
1203
1204 // List of domains where connection is allowed
1205 TString allowCO = gEnv->GetValue("XNet.ConnectDomainAllowRE", "");
1206 if (allowCO.Length() > 0)
1208
1209 // List of domains where connection is denied
1210 TString denyCO = gEnv->GetValue("XNet.ConnectDomainDenyRE", "");
1211 if (denyCO.Length() > 0)
1213
1214 // Connect Timeout
1215 Int_t connTO = gEnv->GetValue("XNet.ConnectTimeout",
1218
1219 // Reconnect Timeout
1220 Int_t recoTO = gEnv->GetValue("XNet.ReconnectWait",
1222 if (recoTO == DFLT_RECONNECTWAIT) {
1223 // Check also the old variable name
1224 recoTO = gEnv->GetValue("XNet.ReconnectTimeout",
1226 }
1228
1229 // Request Timeout
1230 Int_t requTO = gEnv->GetValue("XNet.RequestTimeout",
1233
1234 // Max number of redirections
1235 Int_t maxRedir = gEnv->GetValue("XNet.MaxRedirectCount",
1238
1239
1240 // Read ahead size
1241 Int_t rAheadsiz = gEnv->GetValue("XNet.ReadAheadSize",
1243 EnvPutInt(NAME_READAHEADSIZE, rAheadsiz);
1244
1245
1246 // Cache size (<= 0 disables cache)
1247 Int_t rCachesiz = gEnv->GetValue("XNet.ReadCacheSize",
1249
1250 EnvPutInt(NAME_READCACHESIZE, rCachesiz);
1251
1252 // Max number of retries on first connect
1253 Int_t maxRetries = gEnv->GetValue("XNet.FirstConnectMaxCnt",
1256
1257 // Parallel stream count
1258 Int_t parStreamsCnt = gEnv->GetValue("XNet.ParStreamsPerPhyConn",
1260 EnvPutInt(NAME_MULTISTREAMCNT, parStreamsCnt);
1261
1262 // Change the TCP window size (0 means 'scaling' on some platforms)
1263 Int_t tcpWindowSize = gEnv->GetValue("XNet.DfltTcpWindowSize",
1265 EnvPutInt(NAME_DFLTTCPWINDOWSIZE, tcpWindowSize);
1266
1267 // Change the transaction timeout
1268 Int_t transactionTimeout = gEnv->GetValue("XNet.TransactionTimeout",
1270 EnvPutInt(NAME_TRANSACTIONTIMEOUT, transactionTimeout);
1271
1272 // Whether to activate automatic rootd backward-compatibility
1273 // (We override XrdClient default)
1274 fgRootdBC = gEnv->GetValue("XNet.RootdFallback", 1);
1276
1277 // Dynamic forwarding (SOCKS4)
1278 TString socks4Host = gEnv->GetValue("XNet.SOCKS4Host","");
1279 Int_t socks4Port = gEnv->GetValue("XNet.SOCKS4Port",-1);
1280 if (socks4Port > 0) {
1281 if (socks4Host.IsNull())
1282 // Default
1283 socks4Host = "127.0.0.1";
1284 EnvPutString(NAME_SOCKS4HOST, socks4Host.Data());
1285 EnvPutInt(NAME_SOCKS4PORT, socks4Port);
1286 }
1287
1288 const char *cenv = 0;
1289
1290 // For password-based authentication
1291 TString autolog = gEnv->GetValue("XSec.Pwd.AutoLogin","1");
1292 if (autolog.Length() > 0 &&
1293 (!(cenv = gSystem->Getenv("XrdSecPWDAUTOLOG")) || strlen(cenv) <= 0))
1294 gSystem->Setenv("XrdSecPWDAUTOLOG",autolog.Data());
1295
1296 // Old style netrc file
1297 TString netrc;
1298 netrc.Form("%s/.rootnetrc",gSystem->HomeDirectory());
1299 gSystem->Setenv("XrdSecNETRC", netrc.Data());
1300
1301 TString alogfile = gEnv->GetValue("XSec.Pwd.ALogFile","");
1302 if (alogfile.Length() > 0)
1303 gSystem->Setenv("XrdSecPWDALOGFILE",alogfile.Data());
1304
1305 TString verisrv = gEnv->GetValue("XSec.Pwd.VerifySrv","1");
1306 if (verisrv.Length() > 0 &&
1307 (!(cenv = gSystem->Getenv("XrdSecPWDVERIFYSRV")) || strlen(cenv) <= 0))
1308 gSystem->Setenv("XrdSecPWDVERIFYSRV",verisrv.Data());
1309
1310 TString srvpuk = gEnv->GetValue("XSec.Pwd.ServerPuk","");
1311 if (srvpuk.Length() > 0)
1312 gSystem->Setenv("XrdSecPWDSRVPUK",srvpuk.Data());
1313
1314 // For GSI authentication
1315 TString cadir = gEnv->GetValue("XSec.GSI.CAdir","");
1316 if (cadir.Length() > 0)
1317 gSystem->Setenv("XrdSecGSICADIR",cadir.Data());
1318
1319 TString crldir = gEnv->GetValue("XSec.GSI.CRLdir","");
1320 if (crldir.Length() > 0)
1321 gSystem->Setenv("XrdSecGSICRLDIR",crldir.Data());
1322
1323 TString crlext = gEnv->GetValue("XSec.GSI.CRLextension","");
1324 if (crlext.Length() > 0)
1325 gSystem->Setenv("XrdSecGSICRLEXT",crlext.Data());
1326
1327 TString ucert = gEnv->GetValue("XSec.GSI.UserCert","");
1328 if (ucert.Length() > 0)
1329 gSystem->Setenv("XrdSecGSIUSERCERT",ucert.Data());
1330
1331 TString ukey = gEnv->GetValue("XSec.GSI.UserKey","");
1332 if (ukey.Length() > 0)
1333 gSystem->Setenv("XrdSecGSIUSERKEY",ukey.Data());
1334
1335 TString upxy = gEnv->GetValue("XSec.GSI.UserProxy","");
1336 if (upxy.Length() > 0)
1337 gSystem->Setenv("XrdSecGSIUSERPROXY",upxy.Data());
1338
1339 TString valid = gEnv->GetValue("XSec.GSI.ProxyValid","");
1340 if (valid.Length() > 0)
1341 gSystem->Setenv("XrdSecGSIPROXYVALID",valid.Data());
1342
1343 TString deplen = gEnv->GetValue("XSec.GSI.ProxyForward","0");
1344 if (deplen.Length() > 0 &&
1345 (!(cenv = gSystem->Getenv("XrdSecGSIPROXYDEPLEN")) || strlen(cenv) <= 0))
1346 gSystem->Setenv("XrdSecGSIPROXYDEPLEN",deplen.Data());
1347
1348 TString pxybits = gEnv->GetValue("XSec.GSI.ProxyKeyBits","");
1349 if (pxybits.Length() > 0)
1350 gSystem->Setenv("XrdSecGSIPROXYKEYBITS",pxybits.Data());
1351
1352 TString crlcheck = gEnv->GetValue("XSec.GSI.CheckCRL","1");
1353 if (crlcheck.Length() > 0 &&
1354 (!(cenv = gSystem->Getenv("XrdSecGSICRLCHECK")) || strlen(cenv) <= 0))
1355 gSystem->Setenv("XrdSecGSICRLCHECK",crlcheck.Data());
1356
1357 TString delegpxy = gEnv->GetValue("XSec.GSI.DelegProxy","0");
1358 if (delegpxy.Length() > 0 &&
1359 (!(cenv = gSystem->Getenv("XrdSecGSIDELEGPROXY")) || strlen(cenv) <= 0))
1360 gSystem->Setenv("XrdSecGSIDELEGPROXY",delegpxy.Data());
1361
1362 TString signpxy = gEnv->GetValue("XSec.GSI.SignProxy","1");
1363 if (signpxy.Length() > 0 &&
1364 (!(cenv = gSystem->Getenv("XrdSecGSISIGNPROXY")) || strlen(cenv) <= 0))
1365 gSystem->Setenv("XrdSecGSISIGNPROXY",signpxy.Data());
1366
1367 // Using ROOT mechanism to IGNORE SIGPIPE signal
1369}
1370
1371////////////////////////////////////////////////////////////////////////////////
1372/// Synchronize the cache size
1373/// Alternative purging policy
1374
1376{
1377 if (fClient == 0) return;
1378
1379 fClient->UseCache(TRUE);
1380 Int_t size;
1381 Long64_t bytessubmitted, byteshit, misscount, readreqcnt;
1382 Float_t missrate, bytesusefulness;
1383 int newbsz = -1;
1384 if (fClient->GetCacheInfo(size, bytessubmitted,
1385 byteshit, misscount,
1386 missrate, readreqcnt,
1387 bytesusefulness) ) {
1388
1389 // To allow for some space for outstanding data
1390 TFileCacheRead *cacheRead = GetCacheRead();
1391 if (cacheRead) {
1392 newbsz = GetBufferSize() / 2 * 3;
1393 newbsz = std::max(newbsz, size);
1394 } else {
1395 newbsz = size;
1396 }
1397
1398 }
1399
1400 if (newbsz > 0)
1401 fClient->SetCacheParameters(newbsz, 0, XrdClientReadCache::kRmBlk_FIFO);
1402}
1403
1404////////////////////////////////////////////////////////////////////////////////
1405/// Reset the cache
1406
1408{
1409 if (fClient)
1410 fClient->RemoveAllDataFromCache();
1411}
1412
1413////////////////////////////////////////////////////////////////////////////////
1414/// Max number of bytes to prefetch.
1415
1417{
1418 Int_t size;
1419 Long64_t bytessubmitted, byteshit, misscount, readreqcnt;
1420 Float_t missrate, bytesusefulness;
1421 Int_t bytes = 0;
1422 if (fClient && fClient->GetCacheInfo(size, bytessubmitted,
1423 byteshit, misscount,
1424 missrate, readreqcnt,
1425 bytesusefulness) )
1426 bytes = size;
1427 return ((bytes < 0) ? 0 : bytes);
1428}
1429
1430////////////////////////////////////////////////////////////////////////////////
1431/// Print the local statistics.
1432
1434{
1435 Printf("TXNetFile caching information:");
1436
1437 Int_t size;
1438 Long64_t bytessubmitted, byteshit, misscount, readreqcnt;
1439 Float_t missrate, bytesusefulness;
1440
1441 if (fClient && fClient->GetCacheInfo(size, bytessubmitted,
1442 byteshit, misscount,
1443 missrate, readreqcnt,
1444 bytesusefulness)) {
1445 Printf(" Max size: %d", size);
1446 Printf(" Bytes submitted: %lld", bytessubmitted);
1447 Printf(" Bytes hit (estimation): %lld", byteshit);
1448 Printf(" Miss count: %lld", misscount);
1449 Printf(" Miss rate: %f", missrate);
1450 Printf(" Read requests count: %lld", readreqcnt);
1451 Printf(" Bytes usefulness: %f\n", bytesusefulness);
1452 } else
1453 Printf(" -- No Xrd client instance allocated --\n");
1454
1456}
UShort_t net2host(UShort_t x)
Definition Bytes.h:575
@ kROOTD_PROTOCOL
#define SafeDelete(p)
Definition RConfig.hxx:542
virtual RooAbsTestStatistic * create(const char *name, const char *title, RooAbsReal &real, RooAbsData &data, const RooArgSet &projDeps, Configuration const &cfg)=0
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
long Long_t
Definition RtypesCore.h:54
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
long long Long64_t
Definition RtypesCore.h:80
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define gDirectory
Definition TDirectory.h:384
R__EXTERN TEnv * gEnv
Definition TEnv.h:170
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:218
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:185
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Definition TError.cxx:229
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t bytes
Int_t gDebug
Definition TROOT.cxx:595
#define gROOT
Definition TROOT.h:406
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
@ kSigPipe
@ kNoBlock
Definition TSystem.h:220
@ kFileExists
Definition TSystem.h:42
@ kWritePermission
Definition TSystem.h:44
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
#define gPerfStats
#define NAME_TRANSACTIONTIMEOUT
#define NAME_SOCKS4PORT
#define NAME_CONNECTTIMEOUT
#define DFLT_REQUESTTIMEOUT
#define NAME_READCACHESIZE
#define NAME_REQUESTTIMEOUT
#define DFLT_DFLTTCPWINDOWSIZE
#define DFLT_FIRSTCONNECTMAXCNT
#define DFLT_MAXREDIRECTCOUNT
#define NAME_DEBUG
#define NAME_SOCKS4HOST
#define NAME_REDIRDOMAINDENY_RE
#define NAME_MAXREDIRECTCOUNT
#define NAME_FIRSTCONNECTMAXCNT
#define DFLT_TRANSACTIONTIMEOUT
#define NAME_RECONNECTWAIT
#define NAME_REDIRDOMAINALLOW_RE
#define DFLT_READAHEADSIZE
#define NAME_DFLTTCPWINDOWSIZE
#define NAME_CONNECTDOMAINDENY_RE
#define NAME_READAHEADSIZE
#define NAME_MULTISTREAMCNT
#define NAME_CONNECTDOMAINALLOW_RE
#define DFLT_READCACHESIZE
#define DFLT_CONNECTTIMEOUT
#define NAME_KEEPSOCKOPENIFNOTXRD
#define DFLT_MULTISTREAMCNT
#define DFLT_RECONNECTWAIT
#define EnvPutInt(name, val)
#define EnvPutString(name, val)
#define XrdSysMutexHelper
Definition XrdSysToOuc.h:17
#define XrdSysRecMutex
Definition XrdSysToOuc.h:18
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Bool_t fWritable
True if directory is writable.
Int_t GetBufferSize() const override
Return the buffer size to create new TKeys.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
A cache when reading files over the network.
virtual Bool_t Matches(const char *s)
Definition TFileStager.h:46
virtual Bool_t IsStaged(const char *)
Just check if the file exists locally.
static TFileStager * Open(const char *stager)
Open a stager, after having loaded the relevant plug-in.
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition TFile.h:131
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition TFile.h:89
static void SetFileBytesWritten(Long64_t bytes=0)
Definition TFile.cxx:4603
Long64_t fBytesRead
Number of bytes read from this file.
Definition TFile.h:76
static Bool_t GetOnlyStaged()
Returns staged only flag.
Definition TFile.cxx:4746
virtual Int_t ReOpen(Option_t *mode)
Reopen a file with a different access mode.
Definition TFile.cxx:2155
static Long64_t GetFileBytesWritten()
Static function returning the total number of bytes written to all files.
Definition TFile.cxx:4575
static void SetFileBytesRead(Long64_t bytes=0)
Definition TFile.cxx:4600
TList * fOpenPhases
!Time info about open phases
Definition TFile.h:113
static void SetFileReadCalls(Int_t readcalls=0)
Definition TFile.cxx:4606
void Print(Option_t *option="") const override
Print all objects in the file.
Definition TFile.cxx:1699
static UInt_t GetOpenTimeout()
Returns open timeout (in ms).
Definition TFile.cxx:4726
TUrl fUrl
!URL of file
Definition TFile.h:110
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition TFile.cxx:2512
static Long64_t GetFileBytesRead()
Static function returning the total number of bytes read from all files.
Definition TFile.cxx:4566
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition TFile.cxx:1882
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
Definition TFile.cxx:1814
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition TFile.h:101
virtual void Init(Bool_t create)
Initialize a TFile object.
Definition TFile.cxx:613
TString fOption
File options.
Definition TFile.h:91
EAsyncOpenStatus
Asynchronous open request status.
Definition TFile.h:64
@ kAOSSuccess
Definition TFile.h:65
@ kAOSNotAsync
Definition TFile.h:64
@ kAOSInProgress
Definition TFile.h:65
@ kAOSFailure
Definition TFile.h:64
Int_t fD
File descriptor.
Definition TFile.h:82
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition TFile.cxx:1151
Long64_t fBytesWrite
Number of bytes written to this file.
Definition TFile.h:75
Bool_t fInitDone
!True if the file has been initialized
Definition TFile.h:105
Long64_t fOffset
!Seek offset cache
Definition TFile.h:96
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition TFile.h:130
EAsyncOpenStatus fAsyncOpenStatus
!Status of an asynchronous open request
Definition TFile.h:109
void Close(Option_t *option="") override
Close a file.
Definition TFile.cxx:943
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition TFile.h:133
@ kRedirected
Definition TFile.h:196
static Int_t GetFileReadCalls()
Static function returning the total number of read calls from all files.
Definition TFile.cxx:4583
TFileCacheRead * GetCacheRead(const TObject *tree=nullptr) const
Return a pointer to the current read cache.
Definition TFile.cxx:1255
A doubly linked list.
Definition TList.h:38
A TNetFile is like a normal TFile except that it reads and writes its data via a rootd server (for mo...
Definition TNetFile.h:34
void Init(Bool_t create) override
Initialize a TNetFile object.
Definition TNetFile.cxx:236
Bool_t ReadBuffer(char *buf, Int_t len) override
Read specified byte range from remote file via rootd daemon.
Definition TNetFile.cxx:300
Bool_t WriteBuffer(const char *buf, Int_t len) override
Write specified byte range to remote file via rootd daemon.
Definition TNetFile.cxx:488
virtual void Create(const char *url, Option_t *option, Int_t netopt)
Create a NetFile object.
Definition TNetFile.cxx:659
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime) override
Return file stat information.
Definition TNetFile.cxx:156
Int_t SysClose(Int_t fd) override
Close currently open file.
Definition TNetFile.cxx:144
Bool_t IsOpen() const override
Retruns kTRUE if file is open, kFALSE otherwise.
Definition TNetFile.cxx:247
Int_t ReOpen(Option_t *mode) override
Reopen a file with a different access mode, like from READ to UPDATE or from NEW, CREATE,...
Definition TNetFile.cxx:285
TUrl fEndpointUrl
Definition TNetFile.h:37
Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf) override
Read a list of buffers given in pos[] and len[] and return it in a single buffer.
Definition TNetFile.cxx:384
void Flush() override
Flush file to disk.
Definition TNetFile.cxx:225
Int_t fNetopt
Definition TNetFile.h:42
void Close(Option_t *option="") override
Close remote file.
Definition TNetFile.cxx:208
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode) override
Open a remote file. Requires fOption to be set correctly.
Definition TNetFile.cxx:109
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:153
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:780
void MakeZombie()
Definition TObject.h:53
virtual Int_t SetOption(ESockOptions opt, Int_t val)
Set socket options.
Definition TSocket.cxx:1013
void SetServType(Int_t st)
Definition TSocket.h:154
void SetRemoteProtocol(Int_t rproto)
Definition TSocket.h:151
static Int_t GetClientProtocol()
Static method returning supported client protocol.
Definition TSocket.cxx:1469
void SetService(const char *service)
Definition TSocket.h:153
void SetUrl(const char *url)
Definition TSocket.h:155
TInetAddress GetInetAddress() const
Definition TSocket.h:113
virtual Int_t RecvRaw(void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Receive a raw buffer of specified length bytes.
Definition TSocket.cxx:898
virtual Int_t SendRaw(const void *buffer, Int_t length, ESendRecvOptions opt=kDefault)
Send a raw buffer of specified length.
Definition TSocket.cxx:620
@ kROOTD
Definition TSocket.h:52
Int_t GetPort() const
Definition TSocket.h:115
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Int_t Atoi() const
Return integer value of string.
Definition TString.cxx:1988
const char * Data() const
Definition TString.h:376
Bool_t IsDigit() const
Returns true if all characters in string are digits (0-9) or white spaces, i.e.
Definition TString.cxx:1830
void ToUpper()
Change string to upper case.
Definition TString.cxx:1195
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition TString.h:623
Bool_t IsNull() const
Definition TString.h:414
TString & Remove(Ssiz_t pos)
Definition TString.h:685
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1665
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1296
virtual void IgnoreSignal(ESignals sig, Bool_t ignore=kTRUE)
If ignore is true ignore the specified signal, else restore previous behaviour.
Definition TSystem.cxx:593
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition TSystem.cxx:1649
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Definition TSystem.cxx:887
virtual void Abort(int code=0)
Abort the application.
Definition TSystem.cxx:725
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition TTimeStamp.h:45
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetUrl(Bool_t withDeflt=kFALSE) const
Return full URL.
Definition TUrl.cxx:390
void SetAnchor(const char *anchor)
Definition TUrl.h:86
const char * GetUser() const
Definition TUrl.h:65
const char * GetHost() const
Definition TUrl.h:67
const char * GetHostFQDN() const
Return fully qualified domain name of url host.
Definition TUrl.cxx:472
const char * GetOptions() const
Definition TUrl.h:71
Int_t GetPort() const
Definition TUrl.h:78
virtual Bool_t SendFileOpenProgress(TFile *, TList *, const char *, Bool_t=kFALSE)
virtual Bool_t SendFileReadProgress(TFile *)
TXNetFile is an extension of TNetFile able to deal with new xrootd server.
Definition TXNetFile.h:55
Int_t ParseOptions(const char *opts, Int_t &cachesz, Int_t &readaheadsz, Int_t &rmpolicy, Int_t &mxredir, Int_t &rastrategy, Int_t &readtrimblksz)
Parse input options for cache parameters.
virtual void Print(Option_t *option="") const
Print the local statistics.
void SynchronizeCacheSize()
Synchronize the cache size Alternative purging policy.
static TFileStager * fgFileStager
Definition TXNetFile.h:63
Int_t SysStat(Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
Override TNetFile::SysStat (see parent's method for more details).
static Bool_t fgInitDone
Definition TXNetFile.h:61
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len, where pos[i] is the seek position of block i of...
virtual Int_t ReOpen(const Option_t *mode)
Re-open the file (see TNetFile::ReOpen() or TFile::ReOpen() for more details).
virtual ~TXNetFile()
Destructor.
void Init(Bool_t create)
Initialize the file.
static void SetEnv()
Set the relevant environment variables.
virtual void ResetCache()
Reset the cache.
Bool_t fIsRootd
Definition TXNetFile.h:67
static void FormUrl(TUrl uut, TString &uu)
Form url for rootd socket.
Int_t SysOpen(const char *pathname, Int_t flags, UInt_t mode)
Override TNetFile::SysOpen (see parent's method for more details).
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Override TNetFile::ReadBuffer to deal with the xrootd server.
virtual Bool_t ReadBufferAsync(Long64_t offs, Int_t len)
Implementation dealing with the xrootd server.
virtual Bool_t WriteBuffer(const char *buffer, Int_t BufferLength)
Override TNetFile::WriteBuffer to deal with the xrootd server.
void * fInitMtx
Definition TXNetFile.h:68
XrdClient * fClient
Definition TXNetFile.h:66
virtual void Close(const Option_t *opt="")
Close the file (see TNetFile::Close() or TFile::Close() for more details).
virtual Int_t GetBytesToPrefetch() const
Max number of bytes to prefetch.
void CreateXClient(const char *url, Option_t *option, Int_t netopt, Bool_t parallelopen)
The real creation work is done here.
virtual void Flush()
Flushes un-written data.
Int_t SysClose(Int_t fd)
Override TNetFile::SysClose (see parent's method for more details).
Bool_t Open(Option_t *option, Bool_t parallelopen)
The real creation work is done here.
virtual Bool_t IsOpen() const
Return kTRUE if the file is open, kFALSE otherwise.
static Int_t GetRootdProtocol(TSocket *s)
Find out the remote rootd protocol version.
virtual TFile::EAsyncOpenStatus GetAsyncOpenStatus()
Return status of asynchronous request.
static Bool_t fgRootdBC
Definition TXNetFile.h:62
#define TRUE
Definition mesh.c:42
TMarker m
Definition textangle.C:8