CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
TStorageFactoryFile Class Reference

#include <TStorageFactoryFile.h>

Inheritance diagram for TStorageFactoryFile:

Public Member Functions

 ClassDef (TStorageFactoryFile, 0)
 
virtual Bool_t ReadBuffer (char *buf, Int_t len)
 
virtual Bool_t ReadBuffer (char *buf, Long64_t pos, Int_t len)
 
virtual Bool_t ReadBufferAsync (Long64_t off, Int_t len)
 
virtual Bool_t ReadBuffers (char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
 
void ResetErrno (void) const
 
 TStorageFactoryFile (const char *name, Option_t *option, const char *ftitle, Int_t compress, Int_t netopt, Bool_t parallelopen=kFALSE)
 
 TStorageFactoryFile (const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1)
 
virtual Bool_t WriteBuffer (const char *buf, Int_t len)
 
 ~TStorageFactoryFile (void)
 

Protected Member Functions

virtual Int_t SysClose (Int_t fd)
 
virtual Int_t SysOpen (const char *pathname, Int_t flags, UInt_t mode)
 
virtual Long64_t SysSeek (Int_t fd, Long64_t offset, Int_t whence)
 
virtual Int_t SysStat (Int_t fd, Long_t *id, Long64_t *size, Long_t *flags, Long_t *modtime)
 
virtual Int_t SysSync (Int_t fd)
 

Private Member Functions

void Initialize (const char *name, Option_t *option="")
 
Bool_t ReadBuffersSync (char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
 
void releaseStorage ()
 
 TStorageFactoryFile (void)
 

Private Attributes

edm::propagate_const< std::unique_ptr< Storage > > storage_
 

Detailed Description

TFile wrapper around StorageFactory and Storage.

Definition at line 16 of file TStorageFactoryFile.h.

Constructor & Destructor Documentation

TStorageFactoryFile::TStorageFactoryFile ( const char *  name,
Option_t *  option,
const char *  ftitle,
Int_t  compress,
Int_t  netopt,
Bool_t  parallelopen = kFALSE 
)

Definition at line 108 of file TStorageFactoryFile.cc.

References Initialize(), and edm::threadLocalException::setException().

114  : TFile(path, "NET", ftitle, compress), // Pass "NET" to prevent local access in base class
115  storage_()
116 {
117  try {
119  } catch (...) {
120  edm::threadLocalException::setException(std::current_exception()); // capture
121  }
122 }
edm::propagate_const< std::unique_ptr< Storage > > storage_
void setException(std::exception_ptr e)
void Initialize(const char *name, Option_t *option="")
TStorageFactoryFile::TStorageFactoryFile ( const char *  name,
Option_t *  option = "",
const char *  ftitle = "",
Int_t  compress = 1 
)

Definition at line 124 of file TStorageFactoryFile.cc.

References Initialize(), and edm::threadLocalException::setException().

128  : TFile(path, "NET", ftitle, compress), // Pass "NET" to prevent local access in base class
129  storage_()
130 {
131  try {
133  } catch (...) {
134  edm::threadLocalException::setException(std::current_exception()); // capture
135  }
136 }
edm::propagate_const< std::unique_ptr< Storage > > storage_
void setException(std::exception_ptr e)
void Initialize(const char *name, Option_t *option="")
TStorageFactoryFile::~TStorageFactoryFile ( void  )

Definition at line 225 of file TStorageFactoryFile.cc.

226 {
227  Close();
228 }
TStorageFactoryFile::TStorageFactoryFile ( void  )
private

Definition at line 97 of file TStorageFactoryFile.cc.

References StorageAccount::construct, storageCounter(), and StorageAccount::Stamp::tick().

Referenced by releaseStorage().

98  : storage_()
99 {
101  stats.tick(0);
102 }
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)

Member Function Documentation

TStorageFactoryFile::ClassDef ( TStorageFactoryFile  ,
 
)
void TStorageFactoryFile::Initialize ( const char *  name,
Option_t *  option = "" 
)
private

Definition at line 139 of file TStorageFactoryFile.cc.

References edm::Exception::categoryCode(), StorageAccount::construct, beamerCreator::create(), MillePedeFileConverter_cfg::e, Exception, StorageFactory::get(), edm::Service< T >::isAvailable(), edm::errors::NotFound, IOFlags::OpenCreate, IOFlags::OpenRead, IOFlags::OpenWrap, IOFlags::OpenWrite, TSGForRoadSearch_cfi::option, callgraph::path, edm::storage::StatisticsSenderService::setSize(), storage_, storageCounter(), StorageAccount::Stamp::tick(), and update.

Referenced by TStorageFactoryFile().

141 {
143 
144  // Enable AsyncReading.
145  // This was the default for 5.27, but turned off by default for 5.32.
146  // In our testing, AsyncReading is the fastest mechanism available.
147  // In 5.32, the AsyncPrefetching mechanism is preferred, but has been a
148  // performance hit in our "average case" tests.
149  gEnv->SetValue("TFile.AsyncReading", 1);
150 
151  // Parse options; at the moment we only accept read!
152  fOption = option;
153  fOption.ToUpper();
154 
155  if (fOption == "NEW")
156  fOption = "CREATE";
157 
158  Bool_t create = (fOption == "CREATE");
159  Bool_t recreate = (fOption == "RECREATE");
160  Bool_t update = (fOption == "UPDATE");
161  Bool_t read = (fOption == "READ") || (fOption == "READWRAP");
162  Bool_t readwrap = (fOption == "READWRAP");
163 
164  if (!create && !recreate && !update && !read)
165  {
166  read = true;
167  fOption = "READ";
168  }
169 
170  if (recreate)
171  {
172  if (!gSystem->AccessPathName(path, kFileExists))
173  gSystem->Unlink(path);
174 
175  recreate = false;
176  create = true;
177  fOption = "CREATE";
178  }
179  assert(!recreate);
180 
181  if (update && gSystem->AccessPathName(path, kFileExists))
182  {
183  update = kFALSE;
184  create = kTRUE;
185  }
186 
187  assert(read || update || create);
188 
189  int openFlags = IOFlags::OpenRead;
190  if (!read) openFlags |= IOFlags::OpenWrite;
191  if (create) openFlags |= IOFlags::OpenCreate;
192  //if (recreate) openFlags |= IOFlags::OpenCreate | IOFlags::OpenTruncate;
193  if (readwrap) openFlags |= IOFlags::OpenWrap;
194 
195  // Open storage
196  if (! (storage_ = StorageFactory::get()->open(path, openFlags)))
197  {
198  MakeZombie();
199  gDirectory = gROOT;
200  throw cms::Exception("TStorageFactoryFile::TStorageFactoryFile()")
201  << "Cannot open file '" << path << "'";
202  }
203 
204  // Record the statistics.
205  try {
207  if (statsService.isAvailable()) {
208  statsService->setSize(storage_->size());
209  }
210  } catch (edm::Exception const& e) {
211  if (e.categoryCode() != edm::errors::NotFound) {
212  throw;
213  }
214  }
215 
216  fRealName = path;
217  fD = 0; // sorry, meaningless
218  fWritable = read ? kFALSE : kTRUE;
219 
220  Init(create);
221 
222  stats.tick(0);
223 }
Code categoryCode() const
Definition: EDMException.h:98
def create(alignables, pedeDump, additionalData, outputFile, config)
edm::propagate_const< std::unique_ptr< Storage > > storage_
static const StorageFactory * get(void)
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
bool isAvailable() const
Definition: Service.h:46
#define update(a, b)
Bool_t TStorageFactoryFile::ReadBuffer ( char *  buf,
Int_t  len 
)
virtual

Definition at line 244 of file TStorageFactoryFile.cc.

References EnergyCorrector::c, gen::n, StorageAccount::read, StorageAccount::readActual, StorageAccount::readPrefetchToCache, StorageAccount::readViaCache, s_statsCPrefetch, s_statsCRead, s_statsRead, s_statsXRead, storage_, storageCounter(), and StorageAccount::Stamp::tick().

Referenced by ReadBuffer().

245 {
246  // Check that it's valid to access this file.
247  if (IsZombie())
248  {
249  Error("ReadBuffer", "Cannot read from a zombie file");
250  return kTRUE;
251  }
252 
253  if (! IsOpen())
254  {
255  Error("ReadBuffer", "Cannot read from a file that is not open");
256  return kTRUE;
257  }
258 
259  // Read specified byte range from the storage. Returns kTRUE in
260  // case of error. Note that ROOT uses this function recursively
261  // to fill the cache; we use a flag to make sure our accounting
262  // is reflected in a comprehensible manner. The "read" counter
263  // will include both, "readc" indicates how much read from the
264  // cache, "readu" indicates how much we failed to read from the
265  // cache (excluding those recursive reads), and "readx" counts
266  // the amount actually passed to read from the storage object.
268 
269  // If we have a cache, read from there first. This returns 0
270  // if the block hasn't been prefetched, 1 if it was in cache,
271  // and 2 if there was an error.
272  if (TFileCacheRead *c = GetCacheRead())
273  {
274  Long64_t here = GetRelOffset();
275  Bool_t async = c->IsAsyncReading();
276 
277  StorageAccount::Stamp cstats(async
280 
281  Int_t st = ReadBufferViaCache(async ? nullptr : buf, len);
282 
283  if (st == 2) {
284  Error("ReadBuffer","ReadBufferViaCache failed. Asked to read nBytes: %d from offset: %lld with file size: %lld",len, here, GetSize());
285  return kTRUE;
286  }
287 
288  if (st == 1) {
289  if (async) {
290  cstats.tick(len);
291  Seek(here);
292  } else {
293  cstats.tick(len);
294  stats.tick(len);
295  return kFALSE;
296  }
297  }
298  }
299 
300  // FIXME: Re-enable read-ahead if the data wasn't in cache.
301  // if (! st) storage_->caching(true, -1, s_readahead);
302 
303  // A real read
305  IOSize n = storage_->xread(buf, len);
306  xstats.tick(n);
307  stats.tick(n);
308  if(n < static_cast<IOSize>(len)) {
309  Error("ReadBuffer", "read from Storage::xread returned %ld. Asked to read n bytes: %d from offset: %lld with file size: %lld",n, len, GetRelOffset(), GetSize());
310  }
311  return n ? kFALSE : kTRUE;
312 }
edm::ErrorSummaryEntry Error
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
static StorageAccount::Counter * s_statsRead
static StorageAccount::Counter * s_statsXRead
size_t IOSize
Definition: IOTypes.h:14
static StorageAccount::Counter * s_statsCPrefetch
static StorageAccount::Counter * s_statsCRead
Bool_t TStorageFactoryFile::ReadBuffer ( char *  buf,
Long64_t  pos,
Int_t  len 
)
virtual

Definition at line 235 of file TStorageFactoryFile.cc.

References ReadBuffer().

236 {
237  // This function needs to be optimized to minimize seeks.
238  // See TFile::ReadBuffer(char *buf, Long64_t pos, Int_t len) in ROOT 5.27.06.
239  Seek(pos);
240  return ReadBuffer(buf, len);
241 }
virtual Bool_t ReadBuffer(char *buf, Int_t len)
Bool_t TStorageFactoryFile::ReadBufferAsync ( Long64_t  off,
Int_t  len 
)
virtual

Definition at line 315 of file TStorageFactoryFile.cc.

References StorageFactory::CACHE_HINT_APPLICATION, StorageFactory::CACHE_HINT_STORAGE, StorageFactory::cacheHint(), f, StorageFactory::get(), PREFETCH_PROBE_LENGTH, StorageAccount::readAsync, s_statsARead, storage_, storageCounter(), and StorageAccount::Stamp::tick().

316 {
317  // Check that it's valid to access this file.
318  if (IsZombie())
319  {
320  Error("ReadBufferAsync", "Cannot read from a zombie file");
321  return kTRUE;
322  }
323 
324  if (! IsOpen())
325  {
326  Error("ReadBufferAsync", "Cannot read from a file that is not open");
327  return kTRUE;
328  }
329 
331 
332  // If asynchronous reading is disabled, bail out now, regardless
333  // whether the underlying storage supports prefetching. If it is
334  // forced on, pretend it's on, even if the storage doesn't support
335  // it, as this turns off the caching in ROOT's side.
337 
338  // Verify that we never using async reads in app-only mode
340  return kTRUE;
341 
342  // Let the I/O method indicate if it can do client-side prefetch.
343  // If it does, then for example TTreeCache will drop its own cache
344  // and will use the client-side cache of the actual I/O layer.
345  // If len is zero ROOT is probing for prefetch support.
346  if (len) {
347  // FIXME: Synchronise caching.
348  // storage_->caching(true, -1, 0);
349  ;
350  }
351 
352  IOPosBuffer iov(off, (void *) nullptr, len ? len : PREFETCH_PROBE_LENGTH);
353  if (storage_->prefetch(&iov, 1))
354  {
355  stats.tick(len);
356  return kFALSE;
357  }
358 
359  // Always ask ROOT to use async reads in storage-only mode,
360  // regardless of whether the storage system supports it.
362  return kFALSE;
363 
364  // Prefetching not available right now.
365  return kTRUE;
366 }
edm::ErrorSummaryEntry Error
CacheHint cacheHint(void) const
#define PREFETCH_PROBE_LENGTH
Definition: Storage.h:18
edm::propagate_const< std::unique_ptr< Storage > > storage_
static const StorageFactory * get(void)
static StorageAccount::Counter * s_statsARead
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
double f[11][100]
Bool_t TStorageFactoryFile::ReadBuffers ( char *  buf,
Long64_t *  pos,
Int_t *  len,
Int_t  nbuf 
)
virtual

Definition at line 437 of file TStorageFactoryFile.cc.

References mps_fire::i, StorageAccount::readAsync, ReadBuffersSync(), s_statsARead, storage_, storageCounter(), summarizeEdmComparisonLogfiles::success, StorageAccount::Stamp::tick(), and pileupDistInMC::total.

438 {
439  // Check that it's valid to access this file.
440  if (IsZombie())
441  {
442  Error("ReadBuffers", "Cannot read from a zombie file");
443  return kTRUE;
444  }
445 
446  if (! IsOpen())
447  {
448  Error("ReadBuffers", "Cannot read from a file that is not open");
449  return kTRUE;
450  }
451 
452  // For synchronous reads, we have special logic to optimize the I/O requests
453  // from ROOT before handing it to the storage.
454  if (buf)
455  {
456  return ReadBuffersSync(buf, pos, len, nbuf);
457  }
458  // For an async read, we assume the storage system is smart enough to do the
459  // optimization itself.
460 
461  // Read from underlying storage.
462  void* const nobuf = nullptr;
463  Int_t total = 0;
464  std::vector<IOPosBuffer> iov;
465  iov.reserve(nbuf);
466  for (Int_t i = 0; i < nbuf; ++i)
467  {
468  iov.push_back(IOPosBuffer(pos[i], nobuf, len[i]));
469  total += len[i];
470  }
471 
472  // Null buffer means asynchronous reads into I/O system's cache.
473  bool success;
475  // Synchronise low-level cache with the supposed cache in TFile.
476  // storage_->caching(true, -1, 0);
477  success = storage_->prefetch(&iov[0], nbuf);
478  astats.tick(total);
479 
480  // If it didn't suceeed, pass down to the base class.
481  if(not success) {
482  if(TFile::ReadBuffers(buf, pos, len, nbuf)) {
483  Error("ReadBuffers", "call to TFile::ReadBuffers failed after prefetch already failed.");
484  return kTRUE;
485  }
486  }
487  return kFALSE;
488 }
edm::ErrorSummaryEntry Error
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter * s_statsARead
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
Bool_t ReadBuffersSync(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Bool_t TStorageFactoryFile::ReadBuffersSync ( char *  buf,
Long64_t *  pos,
Int_t *  len,
Int_t  nbuf 
)
private

Most storage systems are not prepared for the onslaught of small reads that ROOT will perform, even if they implement a vectored read interface.

Typically, on the server side, the loop is unrolled and the reads are issued sequentially - giving the OS no hint that you're about to read a very close-by byte in the near future. Normally, OS read-ahead takes care of such situations; because the storage server has so many clients, and ROOT reads look random to the OS, the read-ahead becomes disabled.

Hence, this function will repack the application-layer request into an optimized storage-layer request. The resulting request to the storage layer typically has a slightly larger number of bytes, but far less individual reads.

On average, the server's disks see a smaller number of overall reads, the number of bytes transferred over the network increases modestly (around 10%), and the single application request becomes one-to-two I/O transactions. A clear win for all cases except high-latency WAN.

Definition at line 369 of file TStorageFactoryFile.cc.

References ReadRepacker::bufferUsed(), mps_fire::i, ReadRepacker::iov(), ReadRepacker::pack(), StorageAccount::readActual, ReadRepacker::realBytesProcessed(), mps_fire::result, s_statsXRead, storage_, storageCounter(), StorageAccount::Stamp::tick(), and ReadRepacker::unpack().

Referenced by ReadBuffers().

370 {
391  Int_t remaining = nbuf; // Number of read requests left to process.
392  Int_t pack_count; // Number of read requests processed by this iteration.
393 
394  IOSize remaining_buffer_size=0;
395  // Calculate the remaining buffer size for the ROOT-owned buffer by adding
396  // the size of the various requests.
397  for (Int_t i=0; i<nbuf; i++) remaining_buffer_size+=len[i];
398 
399  char *current_buffer = buf;
400  Long64_t *current_pos = pos;
401  Int_t *current_len = len;
402 
403  ReadRepacker repacker;
404 
405  while (remaining > 0) {
406 
407  pack_count = repacker.pack(static_cast<long long int *>(current_pos), current_len, remaining, current_buffer, remaining_buffer_size);
408 
409  int real_bytes_processed = repacker.realBytesProcessed();
410  IOSize io_buffer_used = repacker.bufferUsed();
411 
412  // Issue readv, then unpack buffers.
414  std::vector<IOPosBuffer> &iov = repacker.iov();
415  IOSize result = storage_->readv(&iov[0], iov.size());
416  if (result != io_buffer_used) {
417  Error("ReadBuffersSync","Storage::readv returned different size result=%ld expected=%ld",result,io_buffer_used);
418  return kTRUE;
419  }
420  xstats.tick(io_buffer_used);
421  repacker.unpack(current_buffer);
422 
423  // Update the location of the unused part of the input buffer.
424  remaining_buffer_size -= real_bytes_processed;
425  current_buffer += real_bytes_processed;
426 
427  current_pos += pack_count;
428  current_len += pack_count;
429  remaining -= pack_count;
430 
431  }
432  assert(remaining_buffer_size == 0);
433  return kFALSE;
434 }
edm::ErrorSummaryEntry Error
edm::propagate_const< std::unique_ptr< Storage > > storage_
IOSize realBytesProcessed() const
Definition: ReadRepacker.h:53
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
int pack(long long int *pos, int *len, int nbuf, char *buf, IOSize buffer_size)
Definition: ReadRepacker.cc:22
void unpack(char *buf)
static StorageAccount::Counter * s_statsXRead
IOSize bufferUsed() const
Definition: ReadRepacker.h:50
std::vector< IOPosBuffer > & iov()
Definition: ReadRepacker.h:48
size_t IOSize
Definition: IOTypes.h:14
void TStorageFactoryFile::releaseStorage ( )
inlineprivate

Definition at line 56 of file TStorageFactoryFile.h.

References edm::get_underlying_safe(), storage_, and TStorageFactoryFile().

Referenced by SysClose().

56 {get_underlying_safe(storage_).release();}
edm::propagate_const< std::unique_ptr< Storage > > storage_
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
void TStorageFactoryFile::ResetErrno ( void  ) const

Definition at line 636 of file TStorageFactoryFile.cc.

637 {
638  TSystem::ResetErrno();
639 }
Int_t TStorageFactoryFile::SysClose ( Int_t  fd)
protectedvirtual

Definition at line 585 of file TStorageFactoryFile.cc.

References StorageAccount::close, releaseStorage(), s_statsClose, storage_, storageCounter(), and StorageAccount::Stamp::tick().

586 {
588 
589  if (storage_)
590  {
591  storage_->close();
592  releaseStorage();
593  }
594 
595  stats.tick();
596  return 0;
597 }
static StorageAccount::Counter * s_statsClose
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
Int_t TStorageFactoryFile::SysOpen ( const char *  pathname,
Int_t  flags,
UInt_t  mode 
)
protectedvirtual

Definition at line 554 of file TStorageFactoryFile.cc.

References Exception, StorageFactory::get(), O_NONBLOCK, StorageAccount::open, IOFlags::OpenAppend, IOFlags::OpenCreate, IOFlags::OpenExclusive, IOFlags::OpenNonBlock, IOFlags::OpenRead, IOFlags::OpenTruncate, IOFlags::OpenWrite, s_statsOpen, storage_, storageCounter(), and StorageAccount::Stamp::tick().

555 {
557 
558  if (storage_)
559  {
560  storage_->close();
561  }
562 
563  int openFlags = IOFlags::OpenRead;
564  if (flags & O_WRONLY) openFlags = IOFlags::OpenWrite;
565  else if (flags & O_RDWR) openFlags |= IOFlags::OpenWrite;
566  if (flags & O_CREAT) openFlags |= IOFlags::OpenCreate;
567  if (flags & O_APPEND) openFlags |= IOFlags::OpenAppend;
568  if (flags & O_EXCL) openFlags |= IOFlags::OpenExclusive;
569  if (flags & O_TRUNC) openFlags |= IOFlags::OpenTruncate;
570  if (flags & O_NONBLOCK) openFlags |= IOFlags::OpenNonBlock;
571 
572  if (! (storage_ = StorageFactory::get()->open(pathname, openFlags)))
573  {
574  MakeZombie();
575  gDirectory = gROOT;
576  throw cms::Exception("TStorageFactoryFile::SysOpen()")
577  << "Cannot open file '" << pathname << "'";
578  }
579 
580  stats.tick();
581  return 0;
582 }
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
edm::propagate_const< std::unique_ptr< Storage > > storage_
static const StorageFactory * get(void)
static ClassImp(TStorageFactoryFile) static StorageAccount StorageAccount::Counter * s_statsOpen
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
#define O_NONBLOCK
Definition: SysFile.h:21
Long64_t TStorageFactoryFile::SysSeek ( Int_t  fd,
Long64_t  offset,
Int_t  whence 
)
protectedvirtual

Definition at line 600 of file TStorageFactoryFile.cc.

References Storage::CURRENT, Storage::END, PFRecoTauDiscriminationByIsolation_cfi::offset, RefreshWebPage::rel, s_statsSeek, StorageAccount::seek, Storage::SET, storage_, storageCounter(), and StorageAccount::Stamp::tick().

601 {
603  Storage::Relative rel = (whence == SEEK_SET ? Storage::SET
604  : whence == SEEK_CUR ? Storage::CURRENT
605  : Storage::END);
606 
607  offset = storage_->position(offset, rel);
608  stats.tick();
609  return offset;
610 }
edm::propagate_const< std::unique_ptr< Storage > > storage_
Relative
Definition: Storage.h:23
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
static StorageAccount::Counter * s_statsSeek
Int_t TStorageFactoryFile::SysStat ( Int_t  fd,
Long_t *  id,
Long64_t *  size,
Long_t *  flags,
Long_t *  modtime 
)
protectedvirtual

Definition at line 622 of file TStorageFactoryFile.cc.

References s_statsStat, StorageAccount::stat, storage_, storageCounter(), and StorageAccount::Stamp::tick().

624 {
626  // FIXME: Most of this is unsupported or makes no sense with Storage
627  *id = ::Hash(fRealName);
628  *size = storage_->size();
629  *flags = 0;
630  *modtime = 0;
631  stats.tick();
632  return 0;
633 }
size
Write out results.
static StorageAccount::Counter * s_statsStat
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
std::string Hash
Definition: Types.h:45
Int_t TStorageFactoryFile::SysSync ( Int_t  fd)
protectedvirtual

Definition at line 613 of file TStorageFactoryFile.cc.

References StorageAccount::flush, s_statsFlush, storage_, storageCounter(), and StorageAccount::Stamp::tick().

614 {
616  storage_->flush();
617  stats.tick();
618  return 0;
619 }
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
static StorageAccount::Counter * s_statsFlush
Bool_t TStorageFactoryFile::WriteBuffer ( const char *  buf,
Int_t  len 
)
virtual

Definition at line 491 of file TStorageFactoryFile.cc.

References gen::n, s_statsCWrite, s_statsWrite, s_statsXWrite, storage_, storageCounter(), StorageAccount::Stamp::tick(), StorageAccount::write, StorageAccount::writeActual, and StorageAccount::writeViaCache.

492 {
493  // Check that it's valid to access this file.
494  if (IsZombie())
495  {
496  Error("WriteBuffer", "Cannot write to a zombie file");
497  return kTRUE;
498  }
499 
500  if (! IsOpen())
501  {
502  Error("WriteBuffer", "Cannot write to a file that is not open");
503  return kTRUE;
504  }
505 
506  if (! fWritable)
507  {
508  Error("WriteBuffer", "File is not writable");
509  return kTRUE;
510  }
511 
514 
515  // Try first writing via a cache, and if that's not possible, directly.
516  Int_t st;
517  switch ((st = WriteBufferViaCache(buf, len)))
518  {
519  case 0:
520  // Actual write.
521  {
523  IOSize n = storage_->xwrite(buf, len);
524  xstats.tick(n);
525  stats.tick(n);
526 
527  // FIXME: What if it's a short write?
528  return n > 0 ? kFALSE : kTRUE;
529  }
530 
531  case 1:
532  cstats.tick(len);
533  stats.tick(len);
534  return kFALSE;
535 
536  case 2:
537  default:
538  Error("WriteBuffer", "Error writing to cache");
539  return kTRUE;
540  }
541 }
edm::ErrorSummaryEntry Error
static StorageAccount::Counter * s_statsWrite
static StorageAccount::Counter * s_statsXWrite
edm::propagate_const< std::unique_ptr< Storage > > storage_
static StorageAccount::Counter & storageCounter(StorageAccount::Counter *&c, StorageAccount::Operation operation)
static StorageAccount::Counter * s_statsCWrite
size_t IOSize
Definition: IOTypes.h:14

Member Data Documentation

edm::propagate_const<std::unique_ptr<Storage> > TStorageFactoryFile::storage_
private