CMS 3D CMS Logo

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 <map>
17 #include <list>
18 #include <mutex>
19 
20 //system headers
21 #include <sys/stat.h>
22 #include <sys/file.h>
23 #include <fcntl.h>
24 #include <cerrno>
25 #include <cstring>
26 #include <cstdio>
27 
28 #include <tbb/concurrent_hash_map.h>
29 
30 class SystemBounds;
31 class GlobalContext;
32 class StreamID;
33 
34 struct InputFile;
35 struct InputChunk;
36 
37 namespace edm {
38  class PathsAndConsumesOfModulesBase;
39  class ProcessContext;
40 }
41 
42 namespace Json{
43  class Value;
44 }
45 
46 namespace edm {
48 }
49 
50 namespace evf{
51 
53 
55 
57  {
58  public:
59 
60  enum FileStatus { noFile, sameFile, newFile, newLumi, runEnded, runAbort };
61 
63  ~EvFDaqDirector();
64  void initRun();
65  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
66  void preallocate(edm::service::SystemBounds const& bounds);
67  void preBeginJob(edm::PathsAndConsumesOfModulesBase const&, edm::ProcessContext const&);
68  void preBeginRun(edm::GlobalContext const& globalContext);
69  void postEndRun(edm::GlobalContext const& globalContext);
70  void preGlobalEndLumi(edm::GlobalContext const& globalContext);
71  void overrideRunNumber(unsigned int run) {run_=run;}
72  std::string &baseRunDir(){return run_dir_;}
73  std::string &buBaseRunDir(){return bu_run_dir_;}
74  std::string &buBaseRunOpenDir(){return bu_run_open_dir_;}
75 
76  std::string findCurrentRunDir(){ return dirManager_.findRunDir(run_);}
77  std::string getInputJsonFilePath(const unsigned int ls, const unsigned int index) const;
78  std::string getRawFilePath(const unsigned int ls, const unsigned int index) const;
79  std::string getOpenRawFilePath(const unsigned int ls, const unsigned int index) const;
80  std::string getOpenInputJsonFilePath(const unsigned int ls, const unsigned int index) const;
81  std::string getDatFilePath(const unsigned int ls, std::string const& stream) const;
82  std::string getOpenDatFilePath(const unsigned int ls, std::string const& stream) const;
83  std::string getOpenOutputJsonFilePath(const unsigned int ls, std::string const& stream) const;
84  std::string getOutputJsonFilePath(const unsigned int ls, std::string const& stream) const;
85  std::string getMergedDatFilePath(const unsigned int ls, std::string const& stream) const;
86  std::string getMergedDatChecksumFilePath(const unsigned int ls, std::string const& stream) const;
87  std::string getOpenInitFilePath(std::string const& stream) const;
88  std::string getInitFilePath(std::string const& stream) const;
89  std::string getOpenProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
90  std::string getProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
91  std::string getMergedProtocolBufferHistogramFilePath(const unsigned int ls, std::string const& stream) const;
92  std::string getOpenRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
93  std::string getRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
94  std::string getMergedRootHistogramFilePath(const unsigned int ls, std::string const& stream) const;
95  std::string getEoLSFilePathOnBU(const unsigned int ls) const;
96  std::string getEoLSFilePathOnFU(const unsigned int ls) const;
97  std::string getBoLSFilePathOnFU(const unsigned int ls) const;
98  std::string getEoRFilePath() const;
99  std::string getEoRFilePathOnFU() const;
100  std::string getRunOpenDirPath() const {return run_dir_ +"/open";}
101  bool outputAdler32Recheck() const {return outputAdler32Recheck_;}
102  void removeFile(unsigned int ls, unsigned int index);
103  void removeFile(std::string );
104 
105  FileStatus updateFuLock(unsigned int& ls, std::string& nextFile, uint32_t& fsize, uint64_t& lockWaitTime);
106  void tryInitializeFuLockFile();
107  unsigned int getRunNumber() const { return run_; }
108  void lockInitLock();
109  void unlockInitLock();
110  void setFMS(evf::FastMonitoringService* fms) {fms_=fms;}
111  bool isSingleStreamThread() {return nStreams_==1 && nThreads_==1;}
112  void lockFULocal();
113  void unlockFULocal();
114  void lockFULocal2();
115  void unlockFULocal2();
116  void createRunOpendirMaybe();
117  void createProcessingNotificationMaybe() const;
118  int readLastLSEntry(std::string const& file);
119  void setDeleteTracking( std::mutex* fileDeleteLock,std::list<std::pair<int,InputFile*>> *filesToDelete) {
120  fileDeleteLockPtr_=fileDeleteLock;
121  filesToDeletePtr_ = filesToDelete;
122  }
123  void checkTransferSystemPSet(edm::ProcessContext const& pc);
124  void checkMergeTypePSet(edm::ProcessContext const& pc);
125  std::string getStreamDestinations(std::string const& stream) const;
126  std::string getStreamMergeType(std::string const& stream, MergeType defaultType);
127  static struct flock make_flock(short type, short whence, off_t start, off_t len, pid_t pid);
128 
129  private:
130  bool bumpFile(unsigned int& ls, unsigned int& index, std::string& nextFile, uint32_t& fsize, int maxLS);
131  void openFULockfileStream(bool create);
132  std::string inputFileNameStem(const unsigned int ls, const unsigned int index) const;
133  std::string outputFileNameStem(const unsigned int ls, std::string const& stream) const;
134  std::string mergedFileNameStem(const unsigned int ls, std::string const& stream) const;
135  std::string initFileName(std::string const& stream) const;
136  std::string eolsFileName(const unsigned int ls) const;
137  std::string eorFileName() const;
138  int getNFilesFromEoLS(std::string BUEoLSFile);
139 
143  unsigned int run_;
148  unsigned int fuLockPollInterval_;
150 
157 
163 
169 
171 
172  unsigned long previousFileSize_;
173 
174  struct flock bu_w_flk;
175  struct flock bu_r_flk;
176  struct flock bu_w_fulk;
177  struct flock bu_r_fulk;
178  struct flock fu_rw_flk;
179  struct flock fu_rw_fulk;
180 
181  evf::FastMonitoringService * fms_ = nullptr;
182 
183  std::mutex *fileDeleteLockPtr_ = nullptr;
184  std::list<std::pair<int,InputFile*>> *filesToDeletePtr_ = nullptr;
185 
186  pthread_mutex_t init_lock_ = PTHREAD_MUTEX_INITIALIZER;
187 
188  unsigned int nStreams_=0;
189  unsigned int nThreads_=0;
190 
191  bool readEolsDefinition_ = true;
192  unsigned int eolsNFilesIndex_ = 1;
195  unsigned int stop_ls_override_ = 0;
196 
197  std::shared_ptr<Json::Value> transferSystemJson_;
198  tbb::concurrent_hash_map<std::string,std::string> mergeTypeMap_;
199 
200  //values initialized in .cc file
201  static const std::vector<std::string> MergeTypeNames_;
202  };
203 }
204 
205 #endif
206 
std::string & buBaseRunDir()
static boost::mutex mutex
Definition: Proxy.cc:11
std::string run_string_
std::string fulockfile_
def create(alignables, pedeDump, additionalData, outputFile, config)
std::shared_ptr< Json::Value > transferSystemJson_
Represents a JSON value.
Definition: value.h:111
unsigned long previousFileSize_
void overrideRunNumber(unsigned int run)
std::string hltSourceDirectory_
tbb::concurrent_hash_map< std::string, std::string > mergeTypeMap_
std::string mergeTypePset_
bool outputAdler32Recheck() const
void setDeleteTracking(std::mutex *fileDeleteLock, std::list< std::pair< int, InputFile * >> *filesToDelete)
std::string stopFilePath_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string bu_base_dir_
std::string findCurrentRunDir()
std::string selectedTransferMode_
std::string & buBaseRunOpenDir()
JSON (JavaScript Object Notation).
std::string eorFileName(const unsigned int run)
std::string stopFilePathPid_
std::string & baseRunDir()
def ls(path, rec=False)
Definition: eostools.py:348
unsigned long long uint64_t
Definition: Time.h:15
std::string bu_run_dir_
HLT enums.
static const std::vector< std::string > MergeTypeNames_
unsigned int getRunNumber() const
std::string getRunOpenDirPath() const
void setFMS(evf::FastMonitoringService *fms)
unsigned int fuLockPollInterval_
std::string eolsFileName(const unsigned int run, const unsigned int ls)
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_