ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
48  fFile->SetAsyncOpenStatus(TFile::kAOSInProgress);
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 {
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  fFile->Close();
347  fOption = newOpt;
348  fMode = mode;
349 
350  XRootDStatus st = fFile->Open(fUrl->GetURL(), fMode);
351  if (!st.IsOK()) {
352  Error("ReOpen", "%s", st.ToStr().c_str());
353  return 1;
354  }
355 
356  return 0;
357 }
358 
359 ////////////////////////////////////////////////////////////////////////////////
360 /// Read a data chunk of the given size
361 ///
362 /// param buffer: a pointer to a buffer big enough to hold the data
363 /// param length: number of bytes to be read
364 /// returns: kTRUE in case of failure
365 
367 {
368  return ReadBuffer(buffer, GetRelOffset(), length);
369 }
370 
371 ////////////////////////////////////////////////////////////////////////////////
372 /// Read a data chunk of the given size, starting from the given offset
373 ///
374 /// param buffer: a pointer to a buffer big enough to hold the data
375 /// param position: offset from the beginning of the file
376 /// param length: number of bytes to be read
377 /// returns: kTRUE in case of failure
378 
380 {
381  using namespace XrdCl;
382  if (gDebug > 0)
383  Info("ReadBuffer", "offset: %lld length: %d", position, length);
384 
385  // Check the file isn't a zombie or closed
386  if (!IsUseable())
387  return kTRUE;
388 
389  // Try to read from cache
390  SetOffset(position);
391  Int_t status;
392  if ((status = ReadBufferViaCache(buffer, length))) {
393  if (status == 2)
394  return kTRUE;
395  return kFALSE;
396  }
397 
398  Double_t start = 0;
399  if (gPerfStats) start = TTimeStamp();
400 
401  // Read the data
402  uint32_t bytesRead = 0;
403  XRootDStatus st = fFile->Read(fOffset, length, buffer, bytesRead);
404  if (gDebug > 0)
405  Info("ReadBuffer", "%s bytes read: %d", st.ToStr().c_str(), bytesRead);
406 
407  if (!st.IsOK()) {
408  Error("ReadBuffer", "%s", st.ToStr().c_str());
409  return kTRUE;
410  }
411 
412  // Bump the globals
413  fOffset += bytesRead;
414  fBytesRead += bytesRead;
415  fgBytesRead += bytesRead;
416  fReadCalls ++;
417  fgReadCalls ++;
418 
419  if (gPerfStats)
420  gPerfStats->FileReadEvent(this, (Int_t)bytesRead, start);
421 
422  if (gMonitoringWriter)
424 
425  return kFALSE;
426 }
427 
428 ////////////////////////////////////////////////////////////////////////////////
429 /// Read scattered data chunks in one operation
430 ///
431 /// param buffer: a pointer to a buffer big enough to hold all of the
432 /// requested data
433 /// param position: position[i] is the seek position of chunk i of len
434 /// length[i]
435 /// param length: length[i] is the length of the chunk at offset
436 /// position[i]
437 /// param nbuffs: number of chunks
438 /// returns: kTRUE in case of failure
439 
441  Int_t nbuffs)
442 {
443  using namespace XrdCl;
444 
445  // Check the file isn't a zombie or closed
446  if (!IsUseable())
447  return kTRUE;
448 
449  std::vector<ChunkList> chunkLists;
450  ChunkList chunks;
451  std::vector<XRootDStatus*> *statuses;
452  TSemaphore *semaphore;
453  Int_t totalBytes = 0;
454  Long64_t offset = 0;
455  char *cursor = buffer;
456 
457  Double_t start = 0;
458  if (gPerfStats) start = TTimeStamp();
459 
460  if (fArchiveOffset)
461  for (Int_t i = 0; i < nbuffs; i++)
462  position[i] += fArchiveOffset;
463 
464  // Build a list of chunks. Put the buffers in the ChunkInfo's
465  for (Int_t i = 0; i < nbuffs; ++i) {
466  totalBytes += length[i];
467 
468  // If the length is bigger than max readv size, split into smaller chunks
469  if (length[i] > fReadvIorMax) {
470  Int_t nsplit = length[i] / fReadvIorMax;
471  Int_t rem = length[i] % fReadvIorMax;
472  Int_t j;
473 
474  // Add as many max-size chunks as are divisible
475  for (j = 0; j < nsplit; ++j) {
476  offset = position[i] + (j * fReadvIorMax);
477  chunks.push_back(ChunkInfo(offset, fReadvIorMax, cursor));
478  cursor += fReadvIorMax;
479  }
480 
481  // Add the remainder
482  offset = position[i] + (j * fReadvIorMax);
483  chunks.push_back(ChunkInfo(offset, rem, cursor));
484  cursor += rem;
485  } else {
486  chunks.push_back(ChunkInfo(position[i], length[i], cursor));
487  cursor += length[i];
488  }
489 
490  // If there are more than or equal to max chunks, make another chunk list
491  if ((Int_t) chunks.size() == fReadvIovMax) {
492  chunkLists.push_back(chunks);
493  chunks = ChunkList();
494  } else if ((Int_t) chunks.size() > fReadvIovMax) {
495  chunkLists.push_back(ChunkList(chunks.begin(),
496  chunks.begin() + fReadvIovMax));
497  chunks = ChunkList(chunks.begin() + fReadvIovMax, chunks.end());
498  }
499  }
500 
501  // Push back the last chunk list
502  if( !chunks.empty() )
503  chunkLists.push_back(chunks);
504 
505  TAsyncReadvHandler *handler;
506  XRootDStatus status;
507  semaphore = new TSemaphore(0);
508  statuses = new std::vector<XRootDStatus*>(chunkLists.size());
509 
510  // Read asynchronously but wait for all responses
511  std::vector<ChunkList>::iterator it;
512  for (it = chunkLists.begin(); it != chunkLists.end(); ++it)
513  {
514  handler = new TAsyncReadvHandler(statuses, it - chunkLists.begin(),
515  semaphore);
516  status = fFile->VectorRead(*it, 0, handler);
517 
518  if (!status.IsOK()) {
519  Error("ReadBuffers", "%s", status.ToStr().c_str());
520  return kTRUE;
521  }
522  }
523 
524  // Wait for all responses
525  for (it = chunkLists.begin(); it != chunkLists.end(); ++it) {
526  semaphore->Wait();
527  }
528 
529  // Check for errors
530  for (it = chunkLists.begin(); it != chunkLists.end(); ++it) {
531  XRootDStatus *st = statuses->at(it - chunkLists.begin());
532 
533  if (!st->IsOK()) {
534  Error("ReadBuffers", "%s", st->ToStr().c_str());
535  for( ; it != chunkLists.end(); ++it )
536  {
537  st = statuses->at( it - chunkLists.begin() );
538  delete st;
539  }
540  delete statuses;
541  delete semaphore;
542 
543  return kTRUE;
544  }
545  delete st;
546  }
547 
548  // Bump the globals
549  fBytesRead += totalBytes;
550  fgBytesRead += totalBytes;
551  fReadCalls ++;
552  fgReadCalls ++;
553 
554  if (gPerfStats) {
555  fOffset = position[0];
556  gPerfStats->FileReadEvent(this, totalBytes, start);
557  }
558 
559  if (gMonitoringWriter)
561 
562  delete statuses;
563  delete semaphore;
564  return kFALSE;
565 }
566 
567 ////////////////////////////////////////////////////////////////////////////////
568 /// Write a data chunk
569 ///
570 /// param buffer: the data to be written
571 /// param length: the size of the buffer
572 /// returns: kTRUE in case of failure
573 
575 {
576  using namespace XrdCl;
577 
578  // Check the file isn't a zombie or closed
579  if (!IsUseable())
580  return kTRUE;
581 
582  if (!fWritable) {
583  if (gDebug > 1)
584  Info("WriteBuffer", "file not writable");
585  return kTRUE;
586  }
587 
588  // Check the write cache
589  Int_t status;
590  if ((status = WriteBufferViaCache(buffer, length))) {
591  if (status == 2)
592  return kTRUE;
593  return kFALSE;
594  }
595 
596  // Write the data
597  XRootDStatus st = fFile->Write(fOffset, length, buffer);
598  if (!st.IsOK()) {
599  Error("WriteBuffer", "%s", st.ToStr().c_str());
600  return kTRUE;
601  }
602 
603  // Bump the globals
604  fOffset += length;
605  fBytesWrite += length;
606  fgBytesWrite += length;
607 
608  return kFALSE;
609 }
610 
611 ////////////////////////////////////////////////////////////////////////////////
612 
614 {
615  if (!IsUseable())
616  return;
617 
618  if (!fWritable) {
619  if (gDebug > 1)
620  Info("Flush", "file not writable - do nothing");
621  return;
622  }
623 
624  FlushWriteCache();
625 
626  //
627  // Flush via the remote xrootd
628  XrdCl::XRootDStatus status = fFile->Sync();
629  if( !status.IsOK() )
630  Error("Flush", "%s", status.ToStr().c_str());
631 
632  if (gDebug > 1)
633  Info("Flush", "XrdClient::Sync succeeded.");
634 }
635 
636 ////////////////////////////////////////////////////////////////////////////////
637 /// Set the position within the file
638 ///
639 /// param offset: the new offset relative to position
640 /// param position: the relative position, either kBeg, kCur or kEnd
641 
643 {
644  SetOffset(offset, position);
645 }
646 
647 ////////////////////////////////////////////////////////////////////////////////
648 /// Parse a file open mode given as a string into a canonically formatted
649 /// output mode string and an integer code that the xroot client can use
650 ///
651 /// param in: the file open mode as a string (in)
652 /// modestr: open mode string after parsing (out)
653 /// mode: correctly parsed option mode code (out)
654 /// assumeRead: if the open mode is not recognised assume read (in)
655 /// returns: 0 in case the mode was successfully parsed,
656 /// -1 in case of failure
657 
659  XrdCl::OpenFlags::Flags &mode,
660  Bool_t assumeRead)
661 {
662  using namespace XrdCl;
663  modestr = ToUpper(TString(in));
664 
665  if (modestr == "NEW" || modestr == "CREATE") mode = OpenFlags::New;
666  else if (modestr == "RECREATE") mode = OpenFlags::Delete;
667  else if (modestr == "UPDATE") mode = OpenFlags::Update;
668  else if (modestr == "READ") mode = OpenFlags::Read;
669  else {
670  if (!assumeRead) {
671  return -1;
672  }
673  modestr = "READ";
674  mode = OpenFlags::Read;
675  }
676 
677  return 0;
678 }
679 
680 ////////////////////////////////////////////////////////////////////////////////
681 /// Check the file is open and isn't a zombie
682 
684 {
685  if (IsZombie()) {
686  Error("TNetXNGFile", "Object is in 'zombie' state");
687  return kFALSE;
688  }
689 
690  if (!IsOpen()) {
691  Error("TNetXNGFile", "The remote file is not open");
692  return kFALSE;
693  }
694 
695  return kTRUE;
696 }
697 
698 ////////////////////////////////////////////////////////////////////////////////
699 /// Find the server-specific readv config params. Returns kFALSE in case of
700 /// error, kTRUE otherwise.
701 
703 {
704  using namespace XrdCl;
705 
706  // Check the file isn't a zombie or closed
707  if (!IsUseable())
708  return kFALSE;
709 
710  if (!fQueryReadVParams)
711  return kTRUE;
712 
713 #if XrdVNUMBER >= 40000
714  std::string dataServerStr;
715  if( !fFile->GetProperty( "DataServer", dataServerStr ) )
716  return kFALSE;
717  URL dataServer(dataServerStr);
718 #else
719  URL dataServer(fFile->GetDataServer());
720 #endif
721  FileSystem fs(dataServer);
722  Buffer arg;
723  Buffer *response;
724  arg.FromString(std::string("readv_ior_max readv_iov_max"));
725 
726  XRootDStatus status = fs.Query(QueryCode::Config, arg, response);
727  if (!status.IsOK())
728  return kFALSE;
729 
730  Ssiz_t from = 0;
731  TString token;
732 
733  std::vector<TString> resps;
734  while (TString(response->ToString()).Tokenize(token, from, "\n"))
735  resps.push_back(token);
736 
737  if (resps.size() != 2)
738  return kFALSE;
739 
740  if (resps[0].IsDigit())
741  fReadvIorMax = resps[0].Atoi();
742 
743  if (resps[1].IsDigit())
744  fReadvIovMax = resps[1].Atoi();
745 
746  delete response;
747 
748  // this is to workaround a dCache bug reported here:
749  // https://sft.its.cern.ch/jira/browse/ROOT-6639
750  if( fReadvIovMax == 0x7FFFFFFF )
751  {
752  fReadvIovMax = 1024;
753  fReadvIorMax = 2097136;
754  }
755 
756  return kTRUE;
757 }
758 
759 ////////////////////////////////////////////////////////////////////////////////
760 /// Map ROOT and xrootd environment variables
761 
763 {
764  XrdCl::Env *env = XrdCl::DefaultEnv::GetEnv();
765  const char *cenv = 0;
766  TString val;
767 
768  val = gEnv->GetValue("NetXNG.ConnectionWindow", "");
769  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CONNECTIONWINDOW"))
770  || strlen(cenv) <= 0))
771  env->PutInt("ConnectionWindow", val.Atoi());
772 
773  val = gEnv->GetValue("NetXNG.ConnectionRetry", "");
774  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CONNECTIONRETRY"))
775  || strlen(cenv) <= 0))
776  env->PutInt("RequestTimeout", val.Atoi());
777 
778  val = gEnv->GetValue("NetXNG.RequestTimeout", "");
779  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_REQUESTTIMEOUT"))
780  || strlen(cenv) <= 0))
781  env->PutInt("RequestTimeout", val.Atoi());
782 
783  val = gEnv->GetValue("NetXNG.SubStreamsPerChannel", "");
784  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_SUBSTREAMSPERCHANNEL"))
785  || strlen(cenv) <= 0))
786  env->PutInt("SubStreamsPerChannel", val.Atoi());
787 
788  val = gEnv->GetValue("NetXNG.TimeoutResolution", "");
789  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_TIMEOUTRESOLUTION"))
790  || strlen(cenv) <= 0))
791  env->PutInt("TimeoutResolution", val.Atoi());
792 
793  val = gEnv->GetValue("NetXNG.StreamErrorWindow", "");
794  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_STREAMERRORWINDOW"))
795  || strlen(cenv) <= 0))
796  env->PutInt("StreamErrorWindow", val.Atoi());
797 
798  val = gEnv->GetValue("NetXNG.RunForkHandler", "");
799  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_RUNFORKHANDLER"))
800  || strlen(cenv) <= 0))
801  env->PutInt("RunForkHandler", val.Atoi());
802 
803  val = gEnv->GetValue("NetXNG.RedirectLimit", "");
804  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_REDIRECTLIMIT"))
805  || strlen(cenv) <= 0))
806  env->PutInt("RedirectLimit", val.Atoi());
807 
808  val = gEnv->GetValue("NetXNG.WorkerThreads", "");
809  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_WORKERTHREADS"))
810  || strlen(cenv) <= 0))
811  env->PutInt("WorkerThreads", val.Atoi());
812 
813  val = gEnv->GetValue("NetXNG.CPChunkSize", "");
814  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CPCHUNKSIZE"))
815  || strlen(cenv) <= 0))
816  env->PutInt("CPChunkSize", val.Atoi());
817 
818  val = gEnv->GetValue("NetXNG.CPParallelChunks", "");
819  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CPPARALLELCHUNKS"))
820  || strlen(cenv) <= 0))
821  env->PutInt("CPParallelChunks", val.Atoi());
822 
823  val = gEnv->GetValue("NetXNG.PollerPreference", "");
824  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_POLLERPREFERENCE"))
825  || strlen(cenv) <= 0))
826  env->PutString("PollerPreference", val.Data());
827 
828  val = gEnv->GetValue("NetXNG.ClientMonitor", "");
829  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CLIENTMONITOR"))
830  || strlen(cenv) <= 0))
831  env->PutString("ClientMonitor", val.Data());
832 
833  val = gEnv->GetValue("NetXNG.ClientMonitorParam", "");
834  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XRD_CLIENTMONITORPARAM"))
835  || strlen(cenv) <= 0))
836  env->PutString("ClientMonitorParam", val.Data());
837 
838  fQueryReadVParams = gEnv->GetValue("NetXNG.QueryReadVParams", 1);
839  env->PutInt( "MultiProtocol", gEnv->GetValue("TFile.CrossProtocolRedirects", 1));
840 
841  // Old style netrc file
842  TString netrc;
843  netrc.Form("%s/.rootnetrc", gSystem->HomeDirectory());
844  gSystem->Setenv("XrdSecNETRC", netrc.Data());
845 
846  // For authentication
847  val = gEnv->GetValue("XSec.Pwd.ALogFile", "");
848  if (val.Length() > 0)
849  gSystem->Setenv("XrdSecPWDALOGFILE", val.Data());
850 
851  val = gEnv->GetValue("XSec.Pwd.ServerPuk", "");
852  if (val.Length() > 0)
853  gSystem->Setenv("XrdSecPWDSRVPUK", val.Data());
854 
855  val = gEnv->GetValue("XSec.GSI.CAdir", "");
856  if (val.Length() > 0)
857  gSystem->Setenv("XrdSecGSICADIR", val.Data());
858 
859  val = gEnv->GetValue("XSec.GSI.CRLdir", "");
860  if (val.Length() > 0)
861  gSystem->Setenv("XrdSecGSICRLDIR", val.Data());
862 
863  val = gEnv->GetValue("XSec.GSI.CRLextension", "");
864  if (val.Length() > 0)
865  gSystem->Setenv("XrdSecGSICRLEXT", val.Data());
866 
867  val = gEnv->GetValue("XSec.GSI.UserCert", "");
868  if (val.Length() > 0)
869  gSystem->Setenv("XrdSecGSIUSERCERT", val.Data());
870 
871  val = gEnv->GetValue("XSec.GSI.UserKey", "");
872  if (val.Length() > 0)
873  gSystem->Setenv("XrdSecGSIUSERKEY", val.Data());
874 
875  val = gEnv->GetValue("XSec.GSI.UserProxy", "");
876  if (val.Length() > 0)
877  gSystem->Setenv("XrdSecGSIUSERPROXY", val.Data());
878 
879  val = gEnv->GetValue("XSec.GSI.ProxyValid", "");
880  if (val.Length() > 0)
881  gSystem->Setenv("XrdSecGSIPROXYVALID", val.Data());
882 
883  val = gEnv->GetValue("XSec.GSI.ProxyKeyBits", "");
884  if (val.Length() > 0)
885  gSystem->Setenv("XrdSecGSIPROXYKEYBITS", val.Data());
886 
887  val = gEnv->GetValue("XSec.GSI.ProxyForward", "0");
888  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSIPROXYDEPLEN"))
889  || strlen(cenv) <= 0))
890  gSystem->Setenv("XrdSecGSIPROXYDEPLEN", val.Data());
891 
892  val = gEnv->GetValue("XSec.GSI.CheckCRL", "1");
893  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSICRLCHECK"))
894  || strlen(cenv) <= 0))
895  gSystem->Setenv("XrdSecGSICRLCHECK", val.Data());
896 
897  val = gEnv->GetValue("XSec.GSI.DelegProxy", "0");
898  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSIDELEGPROXY"))
899  || strlen(cenv) <= 0))
900  gSystem->Setenv("XrdSecGSIDELEGPROXY", val.Data());
901 
902  val = gEnv->GetValue("XSec.GSI.SignProxy", "1");
903  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecGSISIGNPROXY"))
904  || strlen(cenv) <= 0))
905  gSystem->Setenv("XrdSecGSISIGNPROXY", val.Data());
906 
907  val = gEnv->GetValue("XSec.Pwd.AutoLogin", "1");
908  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecPWDAUTOLOG"))
909  || strlen(cenv) <= 0))
910  gSystem->Setenv("XrdSecPWDAUTOLOG", val.Data());
911 
912  val = gEnv->GetValue("XSec.Pwd.VerifySrv", "1");
913  if (val.Length() > 0 && (!(cenv = gSystem->Getenv("XrdSecPWDVERIFYSRV"))
914  || strlen(cenv) <= 0))
915  gSystem->Setenv("XrdSecPWDVERIFYSRV", val.Data());
916 }
917 
virtual Long64_t GetSize() const
Get the file size.
tuple buffer
Definition: tree.py:99
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:62
EAsyncOpenStatus
Asynchronous open request status.
Definition: TFile.h:51
Long64_t GetRelOffset() const
Definition: TFile.h:211
static std::atomic< Long64_t > fgBytesRead
Number of bytes read by all TFile objects.
Definition: TFile.h:111
Ssiz_t Length() const
Definition: TString.h:390
const char Option_t
Definition: RtypesCore.h:62
tuple offset
Definition: tree.py:93
virtual void SetOffset(Long64_t offset, ERelativeTo pos=kBeg)
Set position from where to start reading.
Definition: TFile.cxx:2064
This class represents a WWW compatible URL.
Definition: TUrl.h:41
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.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual const char * HomeDirectory(const char *userName=0)
Return the user's home directory.
Definition: TSystem.cxx:873
virtual Bool_t IsUseable() const
Check the file is open and isn't a zombie.
Bool_t IsZombie() const
Definition: TObject.h:141
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t WriteBufferViaCache(const char *buf, Int_t len)
Write buffer via cache.
Definition: TFile.cxx:2331
ERelativeTo
Definition: TFile.h:160
Int_t fReadCalls
Number of read calls ( not counting the cache calls )
Definition: TFile.h:76
virtual void Close(const Option_t *option="")
Close the file.
const char * Data() const
Definition: TString.h:349
Int_t fReadvIorMax
Definition: TNetXNGFile.h:51
R__EXTERN TVirtualMonitoringWriter * gMonitoringWriter
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
Int_t Atoi() const
Return integer value of string.
Definition: TString.cxx:1951
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
XrdCl::File * fFile
Definition: TNetXNGFile.h:46
A doubly linked list.
Definition: TList.h:47
#define None
Definition: TGWin32.h:68
ClassImp(TNetXNGFile)
virtual void Setenv(const char *name, const char *value)
Set environment variable.
Definition: TSystem.cxx:1559
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
Int_t fReadvIovMax
Definition: TNetXNGFile.h:52
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
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:96
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2308
XrdCl::URL * fUrl
Definition: TNetXNGFile.h:47
static std::atomic< Long64_t > fgBytesWrite
Number of bytes written by all TFile objects.
Definition: TFile.h:110
static std::atomic< Int_t > fgReadCalls
Number of bytes read from all TFile objects.
Definition: TFile.h:113
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:581
XrdCl::OpenFlags::Flags fMode
Definition: TNetXNGFile.h:48
Int_t ReadBufferViaCache(char *buf, Int_t len)
Read buffer via cache.
Definition: TFile.cxx:1715
Bool_t fWritable
True if directory is writable.
#define gPerfStats
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:385
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:95
tuple file
Definition: fildir.py:20
double Double_t
Definition: RtypesCore.h:55
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
The TTimeStamp encapsulates seconds and ns since EPOCH.
Definition: TTimeStamp.h:76
TList * fOpenPhases
!Time info about open phases
Definition: TFile.h:100
virtual Bool_t GetVectorReadLimits()
Find the server-specific readv config params.
TString fOption
File options.
Definition: TFile.h:78
virtual Bool_t SendFileReadProgress(TFile *)
XrdSysCondVar * fInitCondVar
Definition: TNetXNGFile.h:49
TString fNewUrl
Definition: TNetXNGFile.h:54
virtual void Flush()
Synchronize a file's in-memory and on-disk states.
Bool_t FlushWriteCache()
Flush the write cache if active.
Definition: TFile.cxx:1097
void MakeZombie()
Definition: TObject.h:68
virtual void SetAsyncOpenStatus(EAsyncOpenStatus status)
Set the status of an asynchronous file open.
R__EXTERN Int_t gDebug
Definition: Rtypes.h:128
TString ToUpper(const TString &s)
Return an upper-case version of str.
Definition: TString.cxx:1394
Int_t fQueryReadVParams
Definition: TNetXNGFile.h:53
Long64_t fArchiveOffset
!Offset at which file starts in archive
Definition: TFile.h:88
Long64_t fOffset
!Seek offset cache
Definition: TFile.h:83
Bool_t fInitDone
!True if the file has been initialized
Definition: TFile.h:92
const Bool_t kTRUE
Definition: Rtypes.h:91
Long64_t fBytesRead
Number of bytes read from this file.
Definition: TFile.h:63
virtual void Close(Option_t *option="")
Close a file.
Definition: TFile.cxx:898