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