Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TNetXNGFile.cxx
Go to the documentation of this file.
1// @(#)root/netxng:$Id$
2/*************************************************************************
3 * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
4 * All rights reserved. *
5 * *
6 * For the licensing terms see $ROOTSYS/LICENSE. *
7 * For the list of contributors see $ROOTSYS/README/CREDITS. *
8 *************************************************************************/
9
10////////////////////////////////////////////////////////////////////////////////
11// //
12// TNetXNGFile //
13// //
14// Authors: Justin Salmon, Lukasz Janyst //
15// CERN, 2013 //
16// //
17// Enables access to XRootD files using the new client. //
18// //
19////////////////////////////////////////////////////////////////////////////////
20
21#include "TArchiveFile.h"
22#include "TNetXNGFile.h"
23#include "TEnv.h"
24#include "TSystem.h"
25#include "TTimeStamp.h"
26#include "TVirtualPerfStats.h"
27#include "TVirtualMonitoring.h"
28#include <XrdCl/XrdClURL.hh>
29#include <XrdCl/XrdClFile.hh>
30#include <XrdCl/XrdClXRootDResponses.hh>
31#include <XrdCl/XrdClDefaultEnv.hh>
32#include <XrdCl/XrdClFileSystem.hh>
33#include <XrdVersion.hh>
34#include <iostream>
35
36namespace {
37
38Int_t ParseOpenMode(Option_t *in, TString &modestr, int &mode, Bool_t assumeRead);
39
40} // namepsace
41
42//------------------------------------------------------------------------------
43// Open handler for async open requests
44////////////////////////////////////////////////////////////////////////////////
45
46class TAsyncOpenHandler: public XrdCl::ResponseHandler
47{
48 public:
49 //------------------------------------------------------------------------
50 // Constructor
51 //////////////////////////////////////////////////////////////////////////
52
54 {
55 fFile = file;
57 }
58
59 //------------------------------------------------------------------------
60 // Called when a response to open arrives
61 //////////////////////////////////////////////////////////////////////////
62
63 void HandleResponse(XrdCl::XRootDStatus *status,
64 XrdCl::AnyObject *response) override
65 {
66 if (status->IsOK())
67 {
69 }
70 else
71 {
73 }
74
75 delete response;
76 delete status;
77 delete this;
78 }
79
80 private:
82};
83
84//------------------------------------------------------------------------------
85// Async readv handler
86////////////////////////////////////////////////////////////////////////////////
87
88class TAsyncReadvHandler: public XrdCl::ResponseHandler
89{
90 public:
91 //------------------------------------------------------------------------
92 // Constructor
93 //////////////////////////////////////////////////////////////////////////
94
95 TAsyncReadvHandler(std::vector<XrdCl::XRootDStatus*> *statuses,
96 Int_t statusIndex,
97 TSemaphore *semaphore):
98 fStatuses(statuses), fStatusIndex(statusIndex), fSemaphore(semaphore) {}
99
100
101 //------------------------------------------------------------------------
102 // Handle readv response
103 //////////////////////////////////////////////////////////////////////////
104
105 void HandleResponse(XrdCl::XRootDStatus *status,
106 XrdCl::AnyObject *response) override
107 {
108 fStatuses->at(fStatusIndex) = status;
109 fSemaphore->Post();
110 delete response;
111 delete this;
112 }
113
114 private:
115 std::vector<XrdCl::XRootDStatus*> *fStatuses; // Pointer to status vector
116 Int_t fStatusIndex; // Index into status vector
117 TSemaphore *fSemaphore; // Synchronize the responses
118};
119
120
122
124 : TFile(),
125 fFile(nullptr),
126 fUrl(nullptr),
127 fMode(XrdCl::OpenFlags::None),
128 fInitCondVar(nullptr),
129 fReadvIorMax(0),
130 fReadvIovMax(0)
131{
132}
133
134////////////////////////////////////////////////////////////////////////////////
135/// Constructor
136///
137/// param url: URL of the entry-point server to be contacted
138/// param mode: initial file access mode
139/// param title: title of the file (shown by ROOT browser)
140/// param compress: compression level and algorithm
141/// param netopt: TCP window size in bytes (unused)
142/// param parallelopen: open asynchronously
143
145 Option_t *mode,
146 const char *title,
147 Int_t compress,
148 Int_t netopt,
149 Bool_t parallelopen) :
150 TNetXNGFile(url,0,mode,title,compress,netopt,parallelopen){}
151
152TNetXNGFile::TNetXNGFile(const char *url, const char *lurl, Option_t *mode, const char *title, Int_t compress,
153 Int_t /*netopt*/, Bool_t parallelopen)
154 : TFile((lurl ? lurl : url),
155 strstr(mode, "_WITHOUT_GLOBALREGISTRATION") != nullptr ? "NET_WITHOUT_GLOBALREGISTRATION" : "NET", title,
156 compress)
157{
158 using namespace XrdCl;
159
160 // Set the log level
161 TString val = gSystem->Getenv("XRD_LOGLEVEL");
162 if (val.IsNull()) val = gEnv->GetValue("NetXNG.Debug", "");
163 if (!val.IsNull()) XrdCl::DefaultEnv::SetLogLevel(val.Data());
164
165 // Remove any anchor from the url. It may have been used by the base TFile
166 // constructor to setup a TArchiveFile but we should not pass it to the xroot
167 // client as a part of the filename
168 {
169 TUrl urlnoanchor(url);
170 urlnoanchor.SetAnchor("");
171 fUrl = new URL(std::string(urlnoanchor.GetUrl()));
172 }
173
174 fFile = new File();
175 fInitCondVar = new XrdSysCondVar();
176 fUrl->SetProtocol(std::string("root"));
178 fReadvIorMax = 2097136;
179 fReadvIovMax = 1024;
180
181 if (ParseOpenMode(mode, fOption, fMode, kTRUE)<0) {
182 Error("Open", "could not parse open mode %s", mode);
183 MakeZombie();
184 return;
185 }
186
187 // Map ROOT and xrootd environment
188 SetEnv();
189
190 // Init the monitoring system
191 if (gMonitoringWriter) {
192 if (!fOpenPhases) {
193 fOpenPhases = new TList;
195 }
197 kFALSE);
198 }
199
200 XRootDStatus status;
201 if (parallelopen) {
202 // Open the file asynchronously
203 TAsyncOpenHandler *handler = new TAsyncOpenHandler(this);
204 status = fFile->Open(fUrl->GetURL(), static_cast<XrdCl::OpenFlags::Flags>(fMode), Access::None, handler);
205 if (!status.IsOK()) {
206 Error("Open", "%s", status.ToStr().c_str());
207 MakeZombie();
208 }
209 return;
210 }
211
212 // Open the file synchronously
213 status = fFile->Open(fUrl->GetURL(), static_cast<XrdCl::OpenFlags::Flags>(fMode));
214 if (!status.IsOK()) {
215#if XrdVNUMBER >= 40000
216 if( status.code == errRedirect )
217 fNewUrl = status.GetErrorMessage().c_str();
218 else
219 Error("Open", "%s", status.ToStr().c_str());
220#else
221 Error("Open", "%s", status.ToStr().c_str());
222#endif
223 MakeZombie();
224 return;
225 }
226
227 if( (fMode & OpenFlags::New) || (fMode & OpenFlags::Delete) ||
228 (fMode & OpenFlags::Update) )
229 fWritable = true;
230
231 // Initialize the file
232 bool create = false;
233 if( (fMode & OpenFlags::New) || (fMode & OpenFlags::Delete) )
234 create = true;
235 TFile::Init(create);
236
237 // Get the vector read limits
239}
240
241////////////////////////////////////////////////////////////////////////////////
242/// Destructor
243
245{
246 if (IsOpen())
247 Close();
248 delete fUrl;
249 delete fInitCondVar;
250}
251
252////////////////////////////////////////////////////////////////////////////////
253/// Initialize the file. Makes sure that the file is really open before
254/// calling TFile::Init. It may block.
255
257{
258 using namespace XrdCl;
259
260 if (fInitDone) {
261 if (gDebug > 1) Info("Init", "TFile::Init already called once");
262 return;
263 }
264
265 // If the async open didn't return yet, wait for it
267 fInitCondVar->Wait();
268 }
269
270 // Notify the monitoring system
273 kFALSE);
274
275 // Initialize the file
276 TFile::Init(create);
277
278 // Notify the monitoring system
281 kTRUE);
282
283 // Get the vector read limits
285}
286
287////////////////////////////////////////////////////////////////////////////////
288/// Get the file size. Returns -1 in the case that the file could not be
289/// stat'ed.
290
292{
293 if (fArchive && fArchive->GetMember()) {
295 }
296
297 using namespace XrdCl;
298
299 // Check the file isn't a zombie or closed
300 if (!IsUseable())
301 return -1;
302
303 bool forceStat = true;
304 if( fMode == XrdCl::OpenFlags::Read )
305 forceStat = false;
306
307 StatInfo *info = 0;
308 if( !fFile->Stat( forceStat, info ).IsOK() )
309 return -1;
310 Long64_t size = info->GetSize();
311 delete info;
312 return size;
313}
314
315////////////////////////////////////////////////////////////////////////////////
316/// Check if the file is open
317
319{
320 return fFile && fFile->IsOpen();
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Set the status of an asynchronous file open
325
327{
328 fAsyncOpenStatus = status;
329 // Unblock Init() if it is waiting
330 fInitCondVar->Signal();
331}
332
333////////////////////////////////////////////////////////////////////////////////
334/// Close the file
335///
336/// param option: if == "R", all TProcessIDs referenced by this file are
337/// deleted (is this valid in xrootd context?)
338
339void TNetXNGFile::Close(const Option_t */*option*/)
340{
341 TFile::Close();
342
343 if (!fFile) return;
344
345 XrdCl::XRootDStatus status = fFile->Close();
346 if (!status.IsOK()) {
347 Error("Close", "%s", status.ToStr().c_str());
348 MakeZombie();
349 }
350 delete fFile;
351 fFile = nullptr;
352}
353
354////////////////////////////////////////////////////////////////////////////////
355/// Reopen the file with the new access mode
356///
357/// param mode: the new access mode
358/// returns: 0 in case the mode was successfully modified, 1 in case
359/// the mode did not change (was already as requested or wrong
360/// input arguments) and -1 in case of failure, in which case
361/// the file cannot be used anymore
362
364{
365 using namespace XrdCl;
366 TString newOpt;
367 int mode;
368
369 Int_t parseres = ParseOpenMode(modestr, newOpt, mode, kFALSE);
370
371 // Only Read and Update are valid modes
372 if (parseres<0 || (mode != OpenFlags::Read && mode != OpenFlags::Update)) {
373 Error("ReOpen", "mode must be either READ or UPDATE, not %s", modestr);
374 return 1;
375 }
376
377 // The mode is not really changing
378 if (mode == fMode || (mode == OpenFlags::Update
379 && fMode == OpenFlags::New)) {
380 return 1;
381 }
382
383 XRootDStatus st = fFile->Close();
384 if (!st.IsOK()) {
385 Error("ReOpen", "%s", st.ToStr().c_str());
386 return 1;
387 }
388 fOption = newOpt;
389 fMode = mode;
390
391 st = fFile->Open(fUrl->GetURL(), static_cast<XrdCl::OpenFlags::Flags>(fMode));
392 if (!st.IsOK()) {
393 Error("ReOpen", "%s", st.ToStr().c_str());
394 return 1;
395 }
396
397 return 0;
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Read a data chunk of the given size
402///
403/// param buffer: a pointer to a buffer big enough to hold the data
404/// param length: number of bytes to be read
405/// returns: kTRUE in case of failure
406
408{
409 return ReadBuffer(buffer, GetRelOffset(), length);
410}
411
412////////////////////////////////////////////////////////////////////////////////
413/// Read a data chunk of the given size, starting from the given offset
414///
415/// param buffer: a pointer to a buffer big enough to hold the data
416/// param position: offset from the beginning of the file
417/// param length: number of bytes to be read
418/// returns: kTRUE in case of failure
419
421{
422 using namespace XrdCl;
423 if (gDebug > 0)
424 Info("ReadBuffer", "offset: %lld length: %d", position, length);
425
426 // Check the file isn't a zombie or closed
427 if (!IsUseable())
428 return kTRUE;
429
430 // Try to read from cache
431 SetOffset(position);
432 Int_t status;
433 if ((status = ReadBufferViaCache(buffer, length))) {
434 if (status == 2)
435 return kTRUE;
436 return kFALSE;
437 }
438
439 Double_t start = 0;
440 if (gPerfStats) start = TTimeStamp();
441
442 // Read the data
443 uint32_t bytesRead = 0;
444 XRootDStatus st = fFile->Read(fOffset, length, buffer, bytesRead);
445 if (gDebug > 0)
446 Info("ReadBuffer", "%s bytes read: %u", st.ToStr().c_str(), bytesRead);
447
448 if (!st.IsOK()) {
449 Error("ReadBuffer", "%s", st.ToStr().c_str());
450 return kTRUE;
451 }
452
453 if ((Int_t)bytesRead != length) {
454 Error("ReadBuffer", "error reading all requested bytes, got %u of %d",
455 bytesRead, length);
456 return kTRUE;
457 }
458
459 // Bump the globals
460 fOffset += bytesRead;
461 fBytesRead += bytesRead;
462 fgBytesRead += bytesRead;
463 fReadCalls ++;
464 fgReadCalls ++;
465
466 if (gPerfStats)
467 gPerfStats->FileReadEvent(this, (Int_t)bytesRead, start);
468
471
472 return kFALSE;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// Read scattered data chunks in one operation
477///
478/// param buffer: a pointer to a buffer big enough to hold all of the
479/// requested data
480/// param position: position[i] is the seek position of chunk i of len
481/// length[i]
482/// param length: length[i] is the length of the chunk at offset
483/// position[i]
484/// param nbuffs: number of chunks
485/// returns: kTRUE in case of failure
486
488 Int_t nbuffs)
489{
490 using namespace XrdCl;
491
492 // Check the file isn't a zombie or closed
493 if (!IsUseable())
494 return kTRUE;
495
496 std::vector<ChunkList> chunkLists;
497 ChunkList chunks;
498 std::vector<XRootDStatus*> *statuses;
499 TSemaphore *semaphore;
500 Int_t totalBytes = 0;
501 Long64_t offset = 0;
502 char *cursor = buffer;
503
504 Double_t start = 0;
505 if (gPerfStats) start = TTimeStamp();
506
507 if (fArchiveOffset)
508 for (Int_t i = 0; i < nbuffs; i++)
509 position[i] += fArchiveOffset;
510
511 // Build a list of chunks. Put the buffers in the ChunkInfo's
512 for (Int_t i = 0; i < nbuffs; ++i) {
513 totalBytes += length[i];
514
515 // If the length is bigger than max readv size, split into smaller chunks
516 if (length[i] > fReadvIorMax) {
517 Int_t nsplit = length[i] / fReadvIorMax;
518 Int_t rem = length[i] % fReadvIorMax;
519 Int_t j;
520
521 // Add as many max-size chunks as are divisible
522 for (j = 0; j < nsplit; ++j) {
523 offset = position[i] + (j * fReadvIorMax);
524 chunks.push_back(ChunkInfo(offset, fReadvIorMax, cursor));
526 }
527
528 // Add the remainder
529 offset = position[i] + (j * fReadvIorMax);
530 chunks.push_back(ChunkInfo(offset, rem, cursor));
531 cursor += rem;
532 } else {
533 chunks.push_back(ChunkInfo(position[i], length[i], cursor));
534 cursor += length[i];
535 }
536
537 // If there are more than or equal to max chunks, make another chunk list
538 if ((Int_t) chunks.size() == fReadvIovMax) {
539 chunkLists.push_back(chunks);
540 chunks = ChunkList();
541 } else if ((Int_t) chunks.size() > fReadvIovMax) {
542 chunkLists.push_back(ChunkList(chunks.begin(),
543 chunks.begin() + fReadvIovMax));
544 chunks = ChunkList(chunks.begin() + fReadvIovMax, chunks.end());
545 }
546 }
547
548 // Push back the last chunk list
549 if( !chunks.empty() )
550 chunkLists.push_back(chunks);
551
552 TAsyncReadvHandler *handler;
553 XRootDStatus status;
554 semaphore = new TSemaphore(0);
555 statuses = new std::vector<XRootDStatus*>(chunkLists.size());
556
557 // Read asynchronously but wait for all responses
558 std::vector<ChunkList>::iterator it;
559 for (it = chunkLists.begin(); it != chunkLists.end(); ++it)
560 {
561 handler = new TAsyncReadvHandler(statuses, it - chunkLists.begin(),
562 semaphore);
563 status = fFile->VectorRead(*it, 0, handler);
564
565 if (!status.IsOK()) {
566 Error("ReadBuffers", "%s", status.ToStr().c_str());
567 return kTRUE;
568 }
569 }
570
571 // Wait for all responses
572 for (it = chunkLists.begin(); it != chunkLists.end(); ++it) {
573 semaphore->Wait();
574 }
575
576 // Check for errors
577 for (it = chunkLists.begin(); it != chunkLists.end(); ++it) {
578 XRootDStatus *st = statuses->at(it - chunkLists.begin());
579
580 if (!st->IsOK()) {
581 Error("ReadBuffers", "%s", st->ToStr().c_str());
582 for( ; it != chunkLists.end(); ++it )
583 {
584 st = statuses->at( it - chunkLists.begin() );
585 delete st;
586 }
587 delete statuses;
588 delete semaphore;
589
590 return kTRUE;
591 }
592 delete st;
593 }
594
595 // Bump the globals
596 fBytesRead += totalBytes;
597 fgBytesRead += totalBytes;
598 fReadCalls ++;
599 fgReadCalls ++;
600
601 if (gPerfStats) {
602 fOffset = position[0];
603 gPerfStats->FileReadEvent(this, totalBytes, start);
604 }
605
608
609 delete statuses;
610 delete semaphore;
611 return kFALSE;
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Write a data chunk
616///
617/// param buffer: the data to be written
618/// param length: the size of the buffer
619/// returns: kTRUE in case of failure
620
622{
623 using namespace XrdCl;
624
625 // Check the file isn't a zombie or closed
626 if (!IsUseable())
627 return kTRUE;
628
629 if (!fWritable) {
630 if (gDebug > 1)
631 Info("WriteBuffer", "file not writable");
632 return kTRUE;
633 }
634
635 // Check the write cache
636 Int_t status;
637 if ((status = WriteBufferViaCache(buffer, length))) {
638 if (status == 2)
639 return kTRUE;
640 return kFALSE;
641 }
642
643 // Write the data
644 XRootDStatus st = fFile->Write(fOffset, length, buffer);
645 if (!st.IsOK()) {
646 Error("WriteBuffer", "%s", st.ToStr().c_str());
647 return kTRUE;
648 }
649
650 // Bump the globals
651 fOffset += length;
654
655 return kFALSE;
656}
657
658////////////////////////////////////////////////////////////////////////////////
659
661{
662 if (!IsUseable())
663 return;
664
665 if (!fWritable) {
666 if (gDebug > 1)
667 Info("Flush", "file not writable - do nothing");
668 return;
669 }
670
672
673 //
674 // Flush via the remote xrootd
675 XrdCl::XRootDStatus status = fFile->Sync();
676 if( !status.IsOK() )
677 Error("Flush", "%s", status.ToStr().c_str());
678
679 if (gDebug > 1)
680 Info("Flush", "XrdClient::Sync succeeded.");
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Set the position within the file
685///
686/// param offset: the new offset relative to position
687/// param position: the relative position, either kBeg, kCur or kEnd
688
690{
691 SetOffset(offset, position);
692}
693
694namespace {
695
696////////////////////////////////////////////////////////////////////////////////
697/// Parse a file open mode given as a string into a canonically formatted
698/// output mode string and an integer code that the xroot client can use
699///
700/// param in: the file open mode as a string (in)
701/// modestr: open mode string after parsing (out)
702/// mode: correctly parsed option mode code (out)
703/// assumeRead: if the open mode is not recognised assume read (in)
704/// returns: 0 in case the mode was successfully parsed,
705/// -1 in case of failure
706
707Int_t ParseOpenMode(Option_t *in, TString &modestr, int &mode, Bool_t assumeRead)
708{
709 using namespace XrdCl;
710 modestr = ToUpper(TString(in));
711
712 if (modestr == "NEW" || modestr == "CREATE") mode = OpenFlags::New;
713 else if (modestr == "RECREATE") mode = OpenFlags::Delete;
714 else if (modestr == "UPDATE") mode = OpenFlags::Update;
715 else if (modestr == "READ") mode = OpenFlags::Read;
716 else {
717 if (!assumeRead) {
718 return -1;
719 }
720 modestr = "READ";
721 mode = OpenFlags::Read;
722 }
723
724 return 0;
725}
726
727} // namespace
728
729////////////////////////////////////////////////////////////////////////////////
730/// Check the file is open and isn't a zombie
731
733{
734 if (IsZombie()) {
735 Error("TNetXNGFile", "Object is in 'zombie' state");
736 return kFALSE;
737 }
738
739 if (!IsOpen()) {
740 Error("TNetXNGFile", "The remote file is not open");
741 return kFALSE;
742 }
743
744 return kTRUE;
745}
746
747////////////////////////////////////////////////////////////////////////////////
748/// Find the server-specific readv config params. Returns kFALSE in case of
749/// error, kTRUE otherwise.
750
752{
753 using namespace XrdCl;
754
755 // Check the file isn't a zombie or closed
756 if (!IsUseable())
757 return kFALSE;
758
760 return kTRUE;
761
762#if XrdVNUMBER >= 40000
763 std::string lasturl;
764 fFile->GetProperty("LastURL",lasturl);
765 URL lrl(lasturl);
766 //local redirect will split vector reads into multiple local reads anyway,
767 // so we are fine with the default values
768 if(lrl.GetProtocol().compare("file") == 0 &&
769 lrl.GetHostId().compare("localhost") == 0){
770 if (gDebug >= 1)
771 Info("GetVectorReadLimits","Local redirect, using default values");
772 return kTRUE;
773 }
774
775 std::string dataServerStr;
776 if( !fFile->GetProperty( "DataServer", dataServerStr ) )
777 return kFALSE;
778 URL dataServer(dataServerStr);
779#else
780 URL dataServer(fFile->GetDataServer());
781#endif
782 FileSystem fs(dataServer);
783 Buffer arg;
784 Buffer *response;
785 arg.FromString(std::string("readv_ior_max readv_iov_max"));
786
787 XRootDStatus status = fs.Query(QueryCode::Config, arg, response);
788 if (!status.IsOK())
789 return kFALSE;
790
791 Ssiz_t from = 0;
792 TString token;
793
794 std::vector<TString> resps;
795 while (TString(response->ToString()).Tokenize(token, from, "\n"))
796 resps.push_back(token);
797
798 if (resps.size() != 2)
799 return kFALSE;
800
801 if (resps[0].IsDigit())
802 fReadvIorMax = resps[0].Atoi();
803
804 if (resps[1].IsDigit())
805 fReadvIovMax = resps[1].Atoi();
806
807 delete response;
808
809 // this is to workaround a dCache bug reported here:
810 // https://sft.its.cern.ch/jira/browse/ROOT-6639
811 if( fReadvIovMax == 0x7FFFFFFF )
812 {
813 fReadvIovMax = 1024;
814 fReadvIorMax = 2097136;
815 }
816
817 return kTRUE;
818}
819
820////////////////////////////////////////////////////////////////////////////////
821/// Map ROOT and xrootd environment variables
822
824{
825 XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
826 const char *cenv = 0;
827 TString val;
828
829 val = gEnv->GetValue("NetXNG.ConnectionWindow", "");
830 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CONNECTIONWINDOW"))
831 || strlen(cenv) <= 0))
832 env->PutInt("ConnectionWindow", val.Atoi());
833
834 val = gEnv->GetValue("NetXNG.ConnectionRetry", "");
835 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CONNECTIONRETRY"))
836 || strlen(cenv) <= 0))
837 env->PutInt("RequestTimeout", val.Atoi());
838
839 val = gEnv->GetValue("NetXNG.RequestTimeout", "");
840 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_REQUESTTIMEOUT"))
841 || strlen(cenv) <= 0))
842 env->PutInt("RequestTimeout", val.Atoi());
843
844 val = gEnv->GetValue("NetXNG.SubStreamsPerChannel", "");
845 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_SUBSTREAMSPERCHANNEL"))
846 || strlen(cenv) <= 0))
847 env->PutInt("SubStreamsPerChannel", val.Atoi());
848
849 val = gEnv->GetValue("NetXNG.TimeoutResolution", "");
850 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_TIMEOUTRESOLUTION"))
851 || strlen(cenv) <= 0))
852 env->PutInt("TimeoutResolution", val.Atoi());
853
854 val = gEnv->GetValue("NetXNG.StreamErrorWindow", "");
855 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_STREAMERRORWINDOW"))
856 || strlen(cenv) <= 0))
857 env->PutInt("StreamErrorWindow", val.Atoi());
858
859 val = gEnv->GetValue("NetXNG.RunForkHandler", "");
860 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_RUNFORKHANDLER"))
861 || strlen(cenv) <= 0))
862 env->PutInt("RunForkHandler", val.Atoi());
863
864 val = gEnv->GetValue("NetXNG.RedirectLimit", "");
865 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_REDIRECTLIMIT"))
866 || strlen(cenv) <= 0))
867 env->PutInt("RedirectLimit", val.Atoi());
868
869 val = gEnv->GetValue("NetXNG.WorkerThreads", "");
870 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_WORKERTHREADS"))
871 || strlen(cenv) <= 0))
872 env->PutInt("WorkerThreads", val.Atoi());
873
874 val = gEnv->GetValue("NetXNG.CPChunkSize", "");
875 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CPCHUNKSIZE"))
876 || strlen(cenv) <= 0))
877 env->PutInt("CPChunkSize", val.Atoi());
878
879 val = gEnv->GetValue("NetXNG.CPParallelChunks", "");
880 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CPPARALLELCHUNKS"))
881 || strlen(cenv) <= 0))
882 env->PutInt("CPParallelChunks", val.Atoi());
883
884 val = gEnv->GetValue("NetXNG.PollerPreference", "");
885 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_POLLERPREFERENCE"))
886 || strlen(cenv) <= 0))
887 env->PutString("PollerPreference", val.Data());
888
889 val = gEnv->GetValue("NetXNG.ClientMonitor", "");
890 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CLIENTMONITOR"))
891 || strlen(cenv) <= 0))
892 env->PutString("ClientMonitor", val.Data());
893
894 val = gEnv->GetValue("NetXNG.ClientMonitorParam", "");
895 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CLIENTMONITORPARAM"))
896 || strlen(cenv) <= 0))
897 env->PutString("ClientMonitorParam", val.Data());
898
899 fQueryReadVParams = gEnv->GetValue("NetXNG.QueryReadVParams", 1);
900 env->PutInt( "MultiProtocol", gEnv->GetValue("TFile.CrossProtocolRedirects", 1));
901
902 // Old style netrc file
903 TString netrc;
904 netrc.Form("%s/.rootnetrc", gSystem->HomeDirectory());
905 gSystem->Setenv("XrdSecNETRC", netrc.Data());
906
907 // For authentication
908 val = gEnv->GetValue("XSec.Pwd.ALogFile", "");
909 if (val.Length() > 0)
910 gSystem->Setenv("XrdSecPWDALOGFILE", val.Data());
911
912 val = gEnv->GetValue("XSec.Pwd.ServerPuk", "");
913 if (val.Length() > 0)
914 gSystem->Setenv("XrdSecPWDSRVPUK", val.Data());
915
916 val = gEnv->GetValue("XSec.GSI.CAdir", "");
917 if (val.Length() > 0)
918 gSystem->Setenv("XrdSecGSICADIR", val.Data());
919
920 val = gEnv->GetValue("XSec.GSI.CRLdir", "");
921 if (val.Length() > 0)
922 gSystem->Setenv("XrdSecGSICRLDIR", val.Data());
923
924 val = gEnv->GetValue("XSec.GSI.CRLextension", "");
925 if (val.Length() > 0)
926 gSystem->Setenv("XrdSecGSICRLEXT", val.Data());
927
928 val = gEnv->GetValue("XSec.GSI.UserCert", "");
929 if (val.Length() > 0)
930 gSystem->Setenv("XrdSecGSIUSERCERT", val.Data());
931
932 val = gEnv->GetValue("XSec.GSI.UserKey", "");
933 if (val.Length() > 0)
934 gSystem->Setenv("XrdSecGSIUSERKEY", val.Data());
935
936 val = gEnv->GetValue("XSec.GSI.UserProxy", "");
937 if (val.Length() > 0)
938 gSystem->Setenv("XrdSecGSIUSERPROXY", val.Data());
939
940 val = gEnv->GetValue("XSec.GSI.ProxyValid", "");
941 if (val.Length() > 0)
942 gSystem->Setenv("XrdSecGSIPROXYVALID", val.Data());
943
944 val = gEnv->GetValue("XSec.GSI.ProxyKeyBits", "");
945 if (val.Length() > 0)
946 gSystem->Setenv("XrdSecGSIPROXYKEYBITS", val.Data());
947
948 val = gEnv->GetValue("XSec.GSI.ProxyForward", "0");
949 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSIPROXYDEPLEN"))
950 || strlen(cenv) <= 0))
951 gSystem->Setenv("XrdSecGSIPROXYDEPLEN", val.Data());
952
953 val = gEnv->GetValue("XSec.GSI.CheckCRL", "1");
954 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSICRLCHECK"))
955 || strlen(cenv) <= 0))
956 gSystem->Setenv("XrdSecGSICRLCHECK", val.Data());
957
958 val = gEnv->GetValue("XSec.GSI.DelegProxy", "0");
959 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSIDELEGPROXY"))
960 || strlen(cenv) <= 0))
961 gSystem->Setenv("XrdSecGSIDELEGPROXY", val.Data());
962
963 val = gEnv->GetValue("XSec.GSI.SignProxy", "1");
964 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSISIGNPROXY"))
965 || strlen(cenv) <= 0))
966 gSystem->Setenv("XrdSecGSISIGNPROXY", val.Data());
967
968 val = gEnv->GetValue("XSec.Pwd.AutoLogin", "1");
969 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecPWDAUTOLOG"))
970 || strlen(cenv) <= 0))
971 gSystem->Setenv("XrdSecPWDAUTOLOG", val.Data());
972
973 val = gEnv->GetValue("XSec.Pwd.VerifySrv", "1");
974 if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecPWDVERIFYSRV"))
975 || strlen(cenv) <= 0))
976 gSystem->Setenv("XrdSecPWDVERIFYSRV", val.Data());
977}
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
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 offset
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 length
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 fs
Int_t gDebug
Definition TROOT.cxx:597
TString ToUpper(const TString &s)
Return an upper-case version of str.
Definition TString.cxx:1511
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
#define gPerfStats
TArchiveMember * GetMember() const
Long64_t GetDecompressedSize() const
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
TAsyncOpenHandler(TNetXNGFile *file)
TNetXNGFile * fFile
std::vector< XrdCl::XRootDStatus * > * fStatuses
TSemaphore * fSemaphore
TAsyncReadvHandler(std::vector< XrdCl::XRootDStatus * > *statuses, Int_t statusIndex, TSemaphore *semaphore)
void HandleResponse(XrdCl::XRootDStatus *status, XrdCl::AnyObject *response) override
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.
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:491
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
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
Long64_t fBytesRead
Number of bytes read from this file.
Definition TFile.h:76
TArchiveFile * fArchive
!Archive file from which we read this file
Definition TFile.h:97
TList * fOpenPhases
!Time info about open phases
Definition TFile.h:113
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition TFile.cxx:2519
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition TFile.cxx:1889
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
Long64_t GetRelOffset() const
Definition TFile.h:251
TString fOption
File options.
Definition TFile.h:91
EAsyncOpenStatus
Asynchronous open request status.
Definition TFile.h:64
@ kAOSSuccess
Definition TFile.h:65
@ kAOSInProgress
Definition TFile.h:65
@ kAOSFailure
Definition TFile.h:64
ERelativeTo
Definition TFile.h:199
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition TFile.cxx:1158
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
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition TFile.cxx:2253
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:950
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition TFile.h:133
A doubly linked list.
Definition TList.h:38
XrdCl::File * fFile
Definition TNetXNGFile.h:35
void Seek(Long64_t offset, ERelativeTo position=kBeg) override
Set the position within the file.
virtual void SetEnv()
Map ROOT and xrootd environment variables.
Int_t fReadvIovMax
Definition TNetXNGFile.h:41
XrdCl::URL * fUrl
Definition TNetXNGFile.h:36
virtual Bool_t IsUseable() const
Check the file is open and isn't a zombie.
virtual void SetAsyncOpenStatus(EAsyncOpenStatus status)
Set the status of an asynchronous file open.
Bool_t ReadBuffer(char *buffer, Int_t length) override
Read a data chunk of the given size.
void Close(const Option_t *option="") override
Close the file.
Bool_t ReadBuffers(char *buffer, Long64_t *position, Int_t *length, Int_t nbuffs) override
Read scattered data chunks in one operation.
void Flush() override
Synchronize a file's in-memory and on-disk states.
Bool_t WriteBuffer(const char *buffer, Int_t length) override
Write a data chunk.
TString fNewUrl
Definition TNetXNGFile.h:43
Int_t fQueryReadVParams
Definition TNetXNGFile.h:42
Int_t ReOpen(Option_t *modestr) override
Reopen the file with the new access mode.
XrdSysCondVar * fInitCondVar
Definition TNetXNGFile.h:38
Long64_t GetSize() const override
Get the file size.
virtual ~TNetXNGFile()
Destructor.
Int_t fReadvIorMax
Definition TNetXNGFile.h:40
void Init(Bool_t create) override
Initialize the file.
virtual Bool_t GetVectorReadLimits()
Find the server-specific readv config params.
Bool_t IsOpen() const override
Check if the file is open.
R__ALWAYS_INLINE Bool_t IsZombie() const
Definition TObject.h:153
void MakeZombie()
Definition TObject.h:53
Int_t Post()
Increment the value of the semaphore.
Int_t Wait()
If the semaphore value is > 0 then decrement it and carry on, else block, waiting on the condition un...
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
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
Definition TString.cxx:2264
Bool_t IsNull() const
Definition TString.h:414
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
virtual const char * Getenv(const char *env)
Get environment variable.
Definition TSystem.cxx:1665
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
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
virtual Bool_t SendFileOpenProgress(TFile *, TList *, const char *, Bool_t=kFALSE)
virtual Bool_t SendFileReadProgress(TFile *)