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