00001 // $Id: FilesMonitorCollection.h,v 1.16 2011/03/07 15:31:32 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 std::string closingReason(); // reason why file was closed 00067 std::string fileName(); // full file name 00068 std::string filePath(FileStatus status=current); // complete file path for the given file status 00069 std::string completeFileName(FileStatus status=current) 00070 { return ( filePath(status) + "/" + fileName() ); } 00071 00072 }; 00073 00074 // We do not know how many files there will be. 00075 // Thus, we need a vector of them. 00076 typedef boost::shared_ptr<FileRecord> FileRecordPtr; 00077 typedef boost::circular_buffer<FileRecordPtr> FileRecordList; 00078 00079 00080 explicit FilesMonitorCollection(const utils::Duration_t& updateInterval); 00081 00082 const FileRecordPtr getNewFileRecord(); 00083 00084 void getFileRecords(FileRecordList&) const; 00085 00086 00087 private: 00088 00089 //Prevent copying of the FilesMonitorCollection 00090 FilesMonitorCollection(FilesMonitorCollection const&); 00091 FilesMonitorCollection& operator=(FilesMonitorCollection const&); 00092 00093 virtual void do_calculateStatistics(); 00094 virtual void do_reset(); 00095 virtual void do_appendInfoSpaceItems(InfoSpaceItems&); 00096 virtual void do_updateInfoSpaceItems(); 00097 00098 FileRecordList fileRecords_; 00099 mutable boost::mutex fileRecordsMutex_; 00100 00101 const unsigned int maxFileEntries_; // maximum number of files to remember 00102 uint32_t entryCounter_; 00103 00104 xdata::UnsignedInteger32 closedFiles_; // number of closed files 00105 xdata::UnsignedInteger32 openFiles_; // number of open files 00106 00107 }; 00108 00109 } // namespace stor 00110 00111 #endif // EventFilter_StorageManager_FilesMonitorCollection_h 00112 00113