CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FRDFileHandler.cc
Go to the documentation of this file.
1 // $Id: FRDFileHandler.cc,v 1.15.4.1 2011/03/07 11:33:05 mommsen Exp $
3 
8 
9 #include <iostream>
10 
11 
12 namespace stor {
13 
15  (
17  const DbFileHandlerPtr dbFileHandler,
18  const DiskWritingParams& dwParams,
19  const uint64_t& maxFileSize
20  ) :
21  FileHandler(fileRecord, dbFileHandler, dwParams, maxFileSize),
22  writer_(new FRDEventFileWriter(fileRecord->completeFileName()))
23  {}
24 
25 
27  {
28  unsigned int fragCount = chain.fragmentCount();
29  for (unsigned int idx = 0; idx < fragCount; ++idx)
30  {
31  writer_->doOutputEventFragment(
32  chain.dataLocation(idx),
33  chain.dataSize(idx));
34  }
35  }
36 
37 
39  {
40  if ( ! fileRecord_->isOpen ) return;
41 
42  if (writer_)
43  {
44  // if writer was reset, we already closed the stream but failed to move the file to the closed position
45  writer_->stop();
46  setAdler(writer_->adler32());
47  writer_.reset(); // Destruct the writer to flush the file stream
48  }
49  moveFileToClosed(reason);
52  }
53 
54 } // namespace stor
55 
void moveFileToClosed(const FilesMonitorCollection::FileRecord::ClosingReason &)
Definition: FileHandler.cc:210
unsigned int fragmentCount() const
Definition: I2OChain.cc:284
virtual void do_writeEvent(const I2OChain &)
FRDFileHandler(FilesMonitorCollection::FileRecordPtr, const DbFileHandlerPtr, const DiskWritingParams &, const uint64_t &maxFileSize)
string reason
Definition: Association.py:132
boost::shared_ptr< FileRecord > FileRecordPtr
void setAdler(uint32_t s)
Definition: FileHandler.h:109
boost::shared_ptr< DbFileHandler > DbFileHandlerPtr
Definition: DbFileHandler.h:65
void updateDatabase() const
Definition: FileHandler.cc:88
unsigned long long uint64_t
Definition: Time.h:15
FilesMonitorCollection::FileRecordPtr fileRecord_
Definition: FileHandler.h:198
boost::scoped_ptr< FRDEventFileWriter > writer_
unsigned long dataSize(int fragmentIndex) const
Definition: I2OChain.cc:416
virtual void closeFile(const FilesMonitorCollection::FileRecord::ClosingReason &)
void writeToSummaryCatalog() const
Definition: FileHandler.cc:69
unsigned char * dataLocation(int fragmentIndex) const
Definition: I2OChain.cc:422