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