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