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