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