CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/EventFilter/StorageManager/interface/FilesMonitorCollection.h

Go to the documentation of this file.
00001 // $Id: FilesMonitorCollection.h,v 1.17 2011/07/07 09:22:44 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_FilesMonitorCollection_h
00005 #define EventFilter_StorageManager_FilesMonitorCollection_h
00006 
00007 #include <iomanip>
00008 #include <sstream>
00009 #include <stdint.h>
00010 #include <vector>
00011 
00012 #include <boost/circular_buffer.hpp>
00013 #include <boost/thread/mutex.hpp>
00014 #include <boost/shared_ptr.hpp>
00015 
00016 #include "xdata/UnsignedInteger32.h"
00017 
00018 #include "EventFilter/StorageManager/interface/MonitorCollection.h"
00019 
00020 
00021 namespace stor {
00022 
00031   class FilesMonitorCollection : public MonitorCollection
00032   {
00033   public:
00034 
00035     struct FileRecord
00036     {
00037       enum ClosingReason
00038       {
00039         notClosed = 0,
00040         runEnded,
00041         LSended,
00042         timeout,
00043         size,
00044         truncated,
00045         inaccessible
00046       };
00047 
00048       enum FileStatus
00049       {
00050         open,
00051         closed,
00052         current
00053       };
00054 
00055       uint32_t           entryCounter;      // file counter
00056       uint32_t           runNumber;         // run number
00057       uint32_t           lumiSection;       // luminosity section 
00058       std::string        streamLabel;       // datastream label
00059       std::string        baseFilePath;      // file path w/o the working directory
00060       std::string        coreFileName;      // file name w/o instance & file ending
00061       uint32_t           fileCounter;       // counter of number of coreFileNames used
00062       ClosingReason      whyClosed;         // reason why the given file was closed
00063       bool               isOpen;            // true if file is in open directory
00064       uint64_t           fileSize;          // file size in bytes
00065       uint32_t           eventCount;        // number of events
00066       uint32_t           adler32;           // Adler32 checksum
00067       std::string closingReason();          // reason why file was closed
00068       std::string fileName();               // full file name
00069       std::string filePath(FileStatus status=current); // complete file path for the given file status
00070       std::string completeFileName(FileStatus status=current)
00071       { return ( filePath(status) + "/" + fileName() ); }
00072 
00073     };
00074 
00075     // We do not know how many files there will be.
00076     // Thus, we need a vector of them.
00077     typedef boost::shared_ptr<FileRecord> FileRecordPtr;
00078     typedef boost::circular_buffer<FileRecordPtr> FileRecordList;
00079 
00080 
00081     explicit FilesMonitorCollection(const utils::Duration_t& updateInterval);
00082 
00083     const FileRecordPtr getNewFileRecord();
00084 
00085     void getFileRecords(FileRecordList&) const;
00086 
00087 
00088   private:
00089 
00090     //Prevent copying of the FilesMonitorCollection
00091     FilesMonitorCollection(FilesMonitorCollection const&);
00092     FilesMonitorCollection& operator=(FilesMonitorCollection const&);
00093 
00094     virtual void do_calculateStatistics();
00095     virtual void do_reset();
00096     virtual void do_appendInfoSpaceItems(InfoSpaceItems&);
00097     virtual void do_updateInfoSpaceItems();
00098 
00099     FileRecordList fileRecords_;
00100     mutable boost::mutex fileRecordsMutex_;
00101 
00102     const unsigned int maxFileEntries_; // maximum number of files to remember
00103     uint32_t entryCounter_;
00104 
00105     xdata::UnsignedInteger32 closedFiles_;                 // number of closed files
00106     xdata::UnsignedInteger32 openFiles_;                   // number of open files
00107 
00108   };
00109   
00110 } // namespace stor
00111 
00112 #endif // EventFilter_StorageManager_FilesMonitorCollection_h 
00113 
00114