CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/EventFilter/StorageManager/interface/DiskWriter.h

Go to the documentation of this file.
00001 // $Id: DiskWriter.h,v 1.15 2011/06/20 15:55:52 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_DiskWriter_h
00005 #define EventFilter_StorageManager_DiskWriter_h
00006 
00007 #include "boost/date_time/posix_time/posix_time_types.hpp"
00008 #include "boost/shared_ptr.hpp"
00009 
00010 #include <stdint.h>
00011 #include <vector>
00012 
00013 #include "toolbox/lang/Class.h"
00014 #include "toolbox/task/WaitingWorkLoop.h"
00015 #include "xdaq/Application.h"
00016 
00017 #include "EventFilter/StorageManager/interface/Configuration.h"
00018 #include "EventFilter/StorageManager/interface/DbFileHandler.h"
00019 #include "EventFilter/StorageManager/interface/ErrorStreamConfigurationInfo.h"
00020 #include "EventFilter/StorageManager/interface/EventStreamConfigurationInfo.h"
00021 #include "EventFilter/StorageManager/interface/SharedResources.h"
00022 #include "EventFilter/StorageManager/interface/StreamsMonitorCollection.h"
00023 #include "EventFilter/StorageManager/interface/Utils.h"
00024 
00025 
00026 namespace stor {
00027 
00028   class I2OChain;
00029   class StreamHandler;
00030 
00042   class DiskWriter : public toolbox::lang::Class
00043   {
00044   public:
00045 
00046 
00047     DiskWriter(xdaq::Application*, SharedResourcesPtr sr);
00048 
00049     ~DiskWriter();
00050 
00051 
00056     bool writeAction(toolbox::task::WorkLoop*);
00057 
00061     void startWorkLoop(std::string workloopName);
00062 
00063 
00064   private:
00065 
00066     //Prevent copying of the DiskWriter
00067     DiskWriter(DiskWriter const&);
00068     DiskWriter& operator=(DiskWriter const&);
00069 
00070 
00074     void writeNextEvent();
00075 
00079     void writeEventToStreams(const I2OChain&);
00080 
00084     void checkStreamChangeRequest();
00085 
00090     void checkForFileTimeOuts(const bool doItNow = false);
00091 
00095     void closeTimedOutFiles(const utils::TimePoint_t);
00096 
00100     void configureEventStreams(EvtStrConfigListPtr);
00101 
00105     void configureErrorStreams(ErrStrConfigListPtr);
00106 
00110     void makeFaultyEventStream();
00111 
00115     void makeEventStream(EventStreamConfigurationInfo&);
00116 
00120     void makeErrorStream(ErrorStreamConfigurationInfo&);
00121 
00125     void destroyStreams();
00126 
00131     void processEndOfLumiSection(const I2OChain&);
00132 
00136     void reportRemainingLumiSections();
00137 
00141     void writeEndOfRunMarker();
00142 
00143 
00144     xdaq::Application* app_;
00145     SharedResourcesPtr sharedResources_;
00146     DiskWritingParams dwParams_;
00147     const DbFileHandlerPtr dbFileHandler_;
00148 
00149     unsigned int runNumber_;
00150     boost::posix_time::time_duration timeout_; // Timeout on stream queue
00151     utils::TimePoint_t lastFileTimeoutCheckTime_; // Last time we checked for time-out files
00152 
00153     typedef boost::shared_ptr<StreamHandler> StreamHandlerPtr;
00154     typedef std::vector<StreamHandlerPtr> StreamHandlers;
00155     StreamHandlers streamHandlers_;
00156 
00157     StreamsMonitorCollection::EndOfRunReportPtr endOfRunReport_;
00158 
00159     bool actionIsActive_;
00160     toolbox::task::WorkLoop* writingWL_;      
00161 
00162   };
00163   
00164 } // namespace stor
00165 
00166 #endif // EventFilter_StorageManager_DiskWriter_h 
00167 
00168