CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EvFDaqDirector.h
Go to the documentation of this file.
1 #ifndef EVENTFILTER_UTILTIES_PLUGINS_EVFDAQDIRECTOR
2 #define EVENTFILTER_UTILTIES_PLUGINS_EVFDAQDIRECTOR
3 
7 
10 
11 //std headers
12 #include <string>
13 #include <sstream>
14 #include <iomanip>
15 #include <vector>
16 #include <list>
17 #include <mutex>
18 
19 //system headers
20 //#include <sys/types.h>
21 #include <sys/stat.h>
22 #include <fcntl.h>
23 #include <errno.h>
24 #include <string.h>
25 #include <stdio.h>
26 
27 class SystemBounds;
28 class GlobalContext;
29 class StreamID;
30 
31 class InputFile;
32 class InputChunk;
33 
34 namespace edm {
35  class PathsAndConsumesOfModulesBase;
36  class ProcessContext;
37 }
38 
39 namespace Json{
40  class Value;
41 }
42 
43 namespace evf{
44 
46 
48  {
49  public:
50 
52 
53  explicit EvFDaqDirector( const edm::ParameterSet &pset, edm::ActivityRegistry& reg );
55  void preallocate(edm::service::SystemBounds const& bounds);
57  void preBeginRun(edm::GlobalContext const& globalContext);
58  void postEndRun(edm::GlobalContext const& globalContext);
59  void preGlobalEndLumi(edm::GlobalContext const& globalContext);
60  void preSourceEvent(edm::StreamID const& streamID);
61  //std::string &baseDir(){return base_dir_;}
65 
67  std::string getInputJsonFilePath(const unsigned int ls, const unsigned int index) const;
68  std::string getRawFilePath(const unsigned int ls, const unsigned int index) const;
69  std::string getOpenRawFilePath(const unsigned int ls, const unsigned int index) const;
70  std::string getOpenInputJsonFilePath(const unsigned int ls, const unsigned int index) const;
71  std::string getOpenDatFilePath(const unsigned int ls, std::string const& stream) const;
72  std::string getOpenOutputJsonFilePath(const unsigned int ls, std::string const& stream) const;
73  std::string getOutputJsonFilePath(const unsigned int ls, std::string const& stream) const;
74  std::string getMergedDatFilePath(const unsigned int ls, std::string const& stream) const;
75  std::string getMergedDatChecksumFilePath(const unsigned int ls, std::string const& stream) const;
76  std::string getOpenInitFilePath(std::string const& stream) const;
77  std::string getInitFilePath(std::string const& stream) const;
78  std::string getOpenProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
79  std::string getProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
80  std::string getMergedProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
81  std::string getOpenRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
82  std::string getRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
83  std::string getMergedRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
84  std::string getEoLSFilePathOnBU(const unsigned int ls) const;
85  std::string getEoLSFilePathOnFU(const unsigned int ls) const;
86  std::string getBoLSFilePathOnFU(const unsigned int ls) const;
89  std::string getRunOpenDirPath() const {return run_dir_ +"/open";}
91  void removeFile(unsigned int ls, unsigned int index);
92  void removeFile(std::string );
93 
94  FileStatus updateFuLock(unsigned int& ls, std::string& nextFile, uint32_t& fsize, uint64_t& lockWaitTime);
96  unsigned int getRunNumber() const { return run_; }
97  FILE * maybeCreateAndLockFileHeadForStream(unsigned int ls, std::string &stream);
99  void lockInitLock();
100  void unlockInitLock();
102  void updateFileIndex(int const& fileIndex) {currentFileIndex_=fileIndex;}
103  std::vector<int>* getStreamFileTracker() {return &streamFileTracker_;}
104  bool isSingleStreamThread() {return nStreams_==1 && nThreads_==1;}
105  void lockFULocal();
106  void unlockFULocal();
107  void lockFULocal2();
108  void unlockFULocal2();
109  void createRunOpendirMaybe();
111  int readLastLSEntry(std::string const& file);
112  void setDeleteTracking( std::mutex* fileDeleteLock,std::list<std::pair<int,InputFile*>> *filesToDelete) {
113  fileDeleteLockPtr_=fileDeleteLock;
114  filesToDeletePtr_ = filesToDelete;
115  }
117  std::string getStreamDestinations(std::string const& stream) const;
119 
120 
121  private:
122  //bool bulock();
123  //bool fulock();
124  bool bumpFile(unsigned int& ls, unsigned int& index, std::string& nextFile, uint32_t& fsize, int maxLS);
125  void openFULockfileStream(std::string& fuLockFilePath, bool create);
126  std::string inputFileNameStem(const unsigned int ls, const unsigned int index) const;
127  std::string outputFileNameStem(const unsigned int ls, std::string const& stream) const;
128  std::string mergedFileNameStem(const unsigned int ls, std::string const& stream) const;
129  std::string initFileName(std::string const& stream) const;
130  std::string eolsFileName(const unsigned int ls) const;
131  std::string eorFileName() const;
132  int getNFilesFromEoLS(std::string BUEoLSFile);
133 
137  unsigned int run_;
142  unsigned int fuLockPollInterval_;
144 
150 
157 
164 
166 
167  unsigned long previousFileSize_;
168 
169  struct flock bu_w_flk;
170  struct flock bu_r_flk;
171  struct flock bu_w_fulk;
172  struct flock bu_r_fulk;
173  struct flock fu_rw_flk;
174  struct flock fu_rw_fulk;
175  struct flock data_rw_flk;
176  struct flock data_rw_fulk;
177  //struct flock fulocal_rw_flk;
178  //struct flock fulocal_rw_fulk;
179  //struct flock fulocal_rw_flk2;
180  //struct flock fulocal_rw_fulk2;
181 
183  std::vector<int> streamFileTracker_;
185 
187  std::list<std::pair<int,InputFile*>> *filesToDeletePtr_ = nullptr;
188 
189  pthread_mutex_t init_lock_ = PTHREAD_MUTEX_INITIALIZER;
190 
191  unsigned int nStreams_=0;
192  unsigned int nThreads_=0;
193 
194  bool readEolsDefinition_ = true;
195  unsigned int eolsNFilesIndex_ = 1;
197 
198  std::shared_ptr<Json::Value> transferSystemJson_;
199  };
200 }
201 
202 #endif
203 
std::string & buBaseRunDir()
struct flock bu_w_fulk
unsigned int nThreads_
std::string getStreamDestinations(std::string const &stream) const
struct flock fu_rw_flk
std::string run_string_
std::string getMergedProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::vector< int > streamFileTracker_
std::list< std::pair< int, InputFile * > > * filesToDeletePtr_
std::vector< int > * getStreamFileTracker()
std::string outputFileNameStem(const unsigned int ls, std::string const &stream) const
std::string getMergedDatChecksumFilePath(const unsigned int ls, std::string const &stream) const
static boost::mutex mutex
Definition: LHEProxy.cc:11
std::shared_ptr< Json::Value > transferSystemJson_
void openFULockfileStream(std::string &fuLockFilePath, bool create)
std::string getInitFilePath(std::string const &stream) const
std::string getMergedRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
pthread_mutex_t init_lock_
struct flock bu_r_fulk
def ls
Definition: eostools.py:348
std::string getProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::string getRawFilePath(const unsigned int ls, const unsigned int index) const
std::string getOpenInitFilePath(std::string const &stream) const
std::string getOpenRawFilePath(const unsigned int ls, const unsigned int index) const
struct flock data_rw_flk
void createProcessingNotificationMaybe() const
std::string eolsFileName(const unsigned int ls) const
Represents a JSON value.
Definition: value.h:111
std::string getEoLSFilePathOnBU(const unsigned int ls) const
std::string getEoRFilePath() const
unsigned long previousFileSize_
struct flock fu_rw_fulk
std::string hltSourceDirectory_
std::string getOpenProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::mutex * fileDeleteLockPtr_
void updateFileIndex(int const &fileIndex)
EvFDaqDirector(const edm::ParameterSet &pset, edm::ActivityRegistry &reg)
std::string getMergedDatFilePath(const unsigned int ls, std::string const &stream) const
FileStatus updateFuLock(unsigned int &ls, std::string &nextFile, uint32_t &fsize, uint64_t &lockWaitTime)
std::string getOpenOutputJsonFilePath(const unsigned int ls, std::string const &stream) const
std::string getOpenRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
bool outputAdler32Recheck() const
std::string getRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::string getOpenDatFilePath(const unsigned int ls, std::string const &stream) const
void setDeleteTracking(std::mutex *fileDeleteLock, std::list< std::pair< int, InputFile * >> *filesToDelete)
std::string stopFilePath_
std::string inputFileNameStem(const unsigned int ls, const unsigned int index) const
FILE * maybeCreateAndLockFileHeadForStream(unsigned int ls, std::string &stream)
std::string bu_base_dir_
std::string findCurrentRunDir()
void removeFile(unsigned int ls, unsigned int index)
std::string selectedTransferMode_
std::string & buBaseRunOpenDir()
std::string getOpenInputJsonFilePath(const unsigned int ls, const unsigned int index) const
int readLastLSEntry(std::string const &file)
unsigned int eolsNFilesIndex_
std::string & baseRunDir()
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
std::string getOutputJsonFilePath(const unsigned int ls, std::string const &stream) const
int getNFilesFromEoLS(std::string BUEoLSFile)
struct flock bu_w_flk
void preBeginRun(edm::GlobalContext const &globalContext)
void preSourceEvent(edm::StreamID const &streamID)
unsigned long long uint64_t
Definition: Time.h:15
void preGlobalEndLumi(edm::GlobalContext const &globalContext)
evf::FastMonitoringService * fms_
std::string bu_run_dir_
std::string eorFileName() const
std::string getBoLSFilePathOnFU(const unsigned int ls) const
std::string findRunDir(unsigned int)
Definition: DirManager.cc:37
void postEndRun(edm::GlobalContext const &globalContext)
void checkTransferSystemPSet(edm::ProcessContext const &pc)
unsigned int getRunNumber() const
bool emptyLumisectionMode() const
std::string getEoLSFilePathOnFU(const unsigned int ls) const
bool bumpFile(unsigned int &ls, unsigned int &index, std::string &nextFile, uint32_t &fsize, int maxLS)
void preallocate(edm::service::SystemBounds const &bounds)
struct flock data_rw_fulk
std::string getInputJsonFilePath(const unsigned int ls, const unsigned int index) const
std::string getRunOpenDirPath() const
void setFMS(evf::FastMonitoringService *fms)
unsigned int fuLockPollInterval_
SurfaceDeformation * create(int type, const std::vector< double > &params)
struct flock bu_r_flk
std::string mergedFileNameStem(const unsigned int ls, std::string const &stream) const
unsigned int nStreams_
std::string getEoRFilePathOnFU() const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
std::string bu_run_open_dir_
std::string initFileName(std::string const &stream) const