CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/EventFilter/StorageManager/interface/StreamHandler.h

Go to the documentation of this file.
00001 // $Id: StreamHandler.h,v 1.14 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_StreamHandler_h
00005 #define EventFilter_StorageManager_StreamHandler_h
00006 
00007 #include <stdint.h>
00008 
00009 #include <boost/shared_ptr.hpp>
00010 
00011 #include "EventFilter/StorageManager/interface/FilesMonitorCollection.h"
00012 #include "EventFilter/StorageManager/interface/SharedResources.h"
00013 #include "EventFilter/StorageManager/interface/StatisticsReporter.h"
00014 #include "EventFilter/StorageManager/interface/StreamsMonitorCollection.h"
00015 
00016 
00017 namespace stor {
00018 
00019   class FileHandler;
00020   class I2OChain;
00021 
00022 
00031   class StreamHandler
00032   {
00033   public:
00034     
00035     StreamHandler(const SharedResourcesPtr, const DbFileHandlerPtr);
00036 
00037     virtual ~StreamHandler() {};
00038 
00039 
00043     void closeAllFiles();
00044 
00048     void closeTimedOutFiles(utils::TimePoint_t currentTime =
00049                             utils::getCurrentTime());
00050 
00054     void closeFilesForLumiSection(const uint32_t lumiSection);
00055 
00061     void closeFilesForLumiSection(const uint32_t& lumiSection, std::string&);
00062 
00066     void writeEvent(const I2OChain& event);
00067 
00068 
00069   protected:
00070 
00071     typedef boost::shared_ptr<FileHandler> FileHandlerPtr;
00072 
00076     virtual std::string streamLabel() const = 0;
00077 
00081     virtual double fractionToDisk() const = 0;
00082 
00086     virtual FileHandlerPtr newFileHandler(const I2OChain& event) = 0;
00087 
00091     FilesMonitorCollection::FileRecordPtr getNewFileRecord(const I2OChain& event);
00092 
00096     virtual int getStreamMaxFileSize() const = 0;
00097 
00101     unsigned long long getMaxFileSize() const;
00102 
00103 
00107     virtual FileHandlerPtr getFileHandler(const I2OChain& event);
00108 
00109   private:
00110 
00115     bool fileTooLarge(const FileHandlerPtr, const unsigned long& dataSize) const;
00116 
00120     std::string getBaseFilePath(const uint32_t& runNumber, uint32_t fileCount) const;
00121 
00125     std::string getFileSystem(const uint32_t& runNumber, uint32_t fileCount) const;
00126 
00130     std::string getCoreFileName(const uint32_t& runNumber, const uint32_t& lumiSection) const;
00131     
00135     unsigned int getFileCounter(const std::string& coreFileName);
00136 
00137 
00138   protected:
00139 
00140     const SharedResourcesPtr sharedResources_;
00141     const StatisticsReporterPtr statReporter_;
00142     const StreamsMonitorCollection::StreamRecordPtr streamRecord_;
00143     const DiskWritingParams diskWritingParams_;
00144     const DbFileHandlerPtr dbFileHandler_;
00145 
00146     typedef std::vector<FileHandlerPtr> FileHandlers;
00147     FileHandlers fileHandlers_;
00148 
00149     typedef std::map<std::string, unsigned int> CoreFileNamesMap;
00150     CoreFileNamesMap usedCoreFileNames_;
00151     
00152 
00153   private:
00154 
00155     //Prevent copying of the StreamHandler
00156     StreamHandler(StreamHandler const&);
00157     StreamHandler& operator=(StreamHandler const&);
00158 
00159   };
00160   
00161 } // namespace stor
00162 
00163 #endif // EventFilter_StorageManager_StreamHandler_h 
00164 
00165