CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
evf::EvFDaqDirector Class Reference

#include <EvFDaqDirector.h>

Public Types

enum  FileStatus {
  noFile, sameFile, newFile, newLumi,
  runEnded, runAbort
}
 

Public Member Functions

std::string & baseRunDir ()
 
std::string & buBaseRunDir ()
 
std::string & buBaseRunOpenDir ()
 
void checkMergeTypePSet (edm::ProcessContext const &pc)
 
void checkTransferSystemPSet (edm::ProcessContext const &pc)
 
void createProcessingNotificationMaybe () const
 
void createRunOpendirMaybe ()
 
 EvFDaqDirector (const edm::ParameterSet &pset, edm::ActivityRegistry &reg)
 
std::string findCurrentRunDir ()
 
std::string getBoLSFilePathOnFU (const unsigned int ls) const
 
std::string getDatFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getEoLSFilePathOnBU (const unsigned int ls) const
 
std::string getEoLSFilePathOnFU (const unsigned int ls) const
 
std::string getEoRFilePath () const
 
std::string getEoRFilePathOnFU () const
 
std::string getInitFilePath (std::string const &stream) const
 
std::string getInputJsonFilePath (const unsigned int ls, const unsigned int index) const
 
std::string getMergedDatChecksumFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getMergedDatFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getMergedProtocolBufferHistogramFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getMergedRootHistogramFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getOpenDatFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getOpenInitFilePath (std::string const &stream) const
 
std::string getOpenInputJsonFilePath (const unsigned int ls, const unsigned int index) const
 
std::string getOpenOutputJsonFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getOpenProtocolBufferHistogramFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getOpenRawFilePath (const unsigned int ls, const unsigned int index) const
 
std::string getOpenRootHistogramFilePath (const unsigned int ls, std::string const &stream) const
 
std::string getOutputJsonFilePath (const unsigned int ls, std::string const &stream) const
 
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 getRootHistogramFilePath (const unsigned int ls, std::string const &stream) const
 
unsigned int getRunNumber () const
 
std::string getRunOpenDirPath () const
 
std::string getStreamDestinations (std::string const &stream) const
 
std::string getStreamMergeType (std::string const &stream, MergeType defaultType)
 
void initRun ()
 
bool isSingleStreamThread ()
 
void lockFULocal ()
 
void lockFULocal2 ()
 
void lockInitLock ()
 
bool outputAdler32Recheck () const
 
void overrideRunNumber (unsigned int run)
 
void postEndRun (edm::GlobalContext const &globalContext)
 
void preallocate (edm::service::SystemBounds const &bounds)
 
void preBeginJob (edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
 
void preBeginRun (edm::GlobalContext const &globalContext)
 
void preGlobalEndLumi (edm::GlobalContext const &globalContext)
 
int readLastLSEntry (std::string const &file)
 
void removeFile (unsigned int ls, unsigned int index)
 
void removeFile (std::string)
 
void setDeleteTracking (std::mutex *fileDeleteLock, std::list< std::pair< int, InputFile * >> *filesToDelete)
 
void setFMS (evf::FastMonitoringService *fms)
 
void tryInitializeFuLockFile ()
 
void unlockFULocal ()
 
void unlockFULocal2 ()
 
void unlockInitLock ()
 
FileStatus updateFuLock (unsigned int &ls, std::string &nextFile, uint32_t &fsize, uint64_t &lockWaitTime)
 
 ~EvFDaqDirector ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static struct flock make_flock (short type, short whence, off_t start, off_t len, pid_t pid)
 

Private Member Functions

bool bumpFile (unsigned int &ls, unsigned int &index, std::string &nextFile, uint32_t &fsize, int maxLS)
 
std::string eolsFileName (const unsigned int ls) const
 
std::string eorFileName () const
 
int getNFilesFromEoLS (std::string BUEoLSFile)
 
std::string initFileName (std::string const &stream) const
 
std::string inputFileNameStem (const unsigned int ls, const unsigned int index) const
 
std::string mergedFileNameStem (const unsigned int ls, std::string const &stream) const
 
void openFULockfileStream (bool create)
 
std::string outputFileNameStem (const unsigned int ls, std::string const &stream) const
 

Private Attributes

std::string base_dir_
 
std::string bu_base_dir_
 
struct flock bu_r_flk
 
struct flock bu_r_fulk
 
FILE * bu_r_lock_stream
 
int bu_readlock_fd_
 
std::string bu_run_dir_
 
std::string bu_run_open_dir_
 
FILE * bu_t_monitor_stream
 
struct flock bu_w_flk
 
struct flock bu_w_fulk
 
FILE * bu_w_lock_stream
 
FILE * bu_w_monitor_stream
 
int bu_writelock_fd_
 
bool directorBu_
 
DirManager dirManager_
 
unsigned int eolsNFilesIndex_ = 1
 
std::mutexfileDeleteLockPtr_ = nullptr
 
std::list< std::pair< int, InputFile * > > * filesToDeletePtr_ = nullptr
 
evf::FastMonitoringServicefms_ = nullptr
 
int fu_readwritelock_fd_
 
struct flock fu_rw_flk
 
struct flock fu_rw_fulk
 
FILE * fu_rw_lock_stream
 
int fulocal_rwlock_fd2_
 
int fulocal_rwlock_fd_
 
std::string fulockfile_
 
unsigned int fuLockPollInterval_
 
std::string hltSourceDirectory_
 
std::string hostname_
 
pthread_mutex_t init_lock_ = PTHREAD_MUTEX_INITIALIZER
 
tbb::concurrent_hash_map< std::string, std::string > mergeTypeMap_
 
std::string mergeTypePset_
 
unsigned int nStreams_ =0
 
unsigned int nThreads_ =0
 
bool outputAdler32Recheck_
 
unsigned long previousFileSize_
 
bool readEolsDefinition_ = true
 
bool requireTSPSet_
 
unsigned int run_
 
std::string run_dir_
 
std::string run_string_
 
std::string selectedTransferMode_
 
unsigned int stop_ls_override_ = 0
 
std::string stopFilePath_
 
std::string stopFilePathPid_
 
std::shared_ptr< Json::ValuetransferSystemJson_
 

Static Private Attributes

static const std::vector< std::string > MergeTypeNames_ = {"","DAT","PB","JSNDATA"}
 

Detailed Description

Definition at line 56 of file EvFDaqDirector.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

evf::EvFDaqDirector::EvFDaqDirector ( const edm::ParameterSet pset,
edm::ActivityRegistry reg 
)
explicit

Definition at line 35 of file EvFDaqDirector.cc.

References fuLockPollInterval_, hostname_, postEndRun(), preallocate(), preBeginJob(), preBeginRun(), preGlobalEndLumi(), AlCaHLTBitMon_QueryRunRegistry::string, edm::ActivityRegistry::watchPostGlobalEndRun(), edm::ActivityRegistry::watchPreallocate(), edm::ActivityRegistry::watchPreBeginJob(), edm::ActivityRegistry::watchPreGlobalBeginRun(), and edm::ActivityRegistry::watchPreGlobalEndLumi().

36  :
37  base_dir_(pset.getUntrackedParameter<std::string> ("baseDir", ".")),
38  bu_base_dir_(pset.getUntrackedParameter<std::string> ("buBaseDir", ".")),
39  directorBu_(pset.getUntrackedParameter<bool> ("directorIsBu", false)),
40  run_(pset.getUntrackedParameter<unsigned int> ("runNumber",0)),
41  outputAdler32Recheck_(pset.getUntrackedParameter<bool>("outputAdler32Recheck",false)),
42  requireTSPSet_(pset.getUntrackedParameter<bool>("requireTransfersPSet",false)),
43  selectedTransferMode_(pset.getUntrackedParameter<std::string>("selectedTransferMode","")),
44  hltSourceDirectory_(pset.getUntrackedParameter<std::string>("hltSourceDirectory","")),
45  fuLockPollInterval_(pset.getUntrackedParameter<unsigned int>("fuLockPollInterval",2000)),
46  mergeTypePset_(pset.getUntrackedParameter<std::string>("mergeTypePset","")),
47  hostname_(""),
48  bu_readlock_fd_(-1),
49  bu_writelock_fd_(-1),
53  bu_w_lock_stream(nullptr),
54  bu_r_lock_stream(nullptr),
55  fu_rw_lock_stream(nullptr),
58  bu_w_flk( make_flock( F_WRLCK, SEEK_SET, 0, 0, 0 )),
59  bu_r_flk( make_flock( F_RDLCK, SEEK_SET, 0, 0, 0 )),
60  bu_w_fulk( make_flock( F_UNLCK, SEEK_SET, 0, 0, 0 )),
61  bu_r_fulk( make_flock( F_UNLCK, SEEK_SET, 0, 0, 0 )),
62  fu_rw_flk( make_flock ( F_WRLCK, SEEK_SET, 0, 0, getpid() )),
63  fu_rw_fulk( make_flock( F_UNLCK, SEEK_SET, 0, 0, getpid() ))
64  {
65 
71 
72  //save hostname for later
73  char hostname[33];
74  gethostname(hostname,32);
75  hostname_ = hostname;
76 
77  char * fuLockPollIntervalPtr = getenv("FFF_LOCKPOLLINTERVAL");
78  if (fuLockPollIntervalPtr) {
79  try {
80  fuLockPollInterval_=boost::lexical_cast<unsigned int>(std::string(fuLockPollIntervalPtr));
81  edm::LogInfo("EvFDaqDirector") << "Setting fu lock poll interval by environment string: " << fuLockPollInterval_ << " us";
82  }
83  catch( boost::bad_lexical_cast const& ) {
84  edm::LogWarning("EvFDaqDirector") << "Bad lexical cast in parsing: " << std::string(fuLockPollIntervalPtr);
85  }
86  }
87 
88  }
struct flock bu_w_fulk
T getUntrackedParameter(std::string const &, T const &) const
struct flock fu_rw_flk
static struct flock make_flock(short type, short whence, off_t start, off_t len, pid_t pid)
void watchPreallocate(Preallocate::slot_type const &iSlot)
void watchPreGlobalEndLumi(PreGlobalEndLumi::slot_type const &iSlot)
struct flock bu_r_fulk
unsigned long previousFileSize_
struct flock fu_rw_fulk
std::string hltSourceDirectory_
std::string mergeTypePset_
std::string bu_base_dir_
std::string selectedTransferMode_
void preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
struct flock bu_w_flk
void preBeginRun(edm::GlobalContext const &globalContext)
void preGlobalEndLumi(edm::GlobalContext const &globalContext)
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
void postEndRun(edm::GlobalContext const &globalContext)
void preallocate(edm::service::SystemBounds const &bounds)
unsigned int fuLockPollInterval_
struct flock bu_r_flk
evf::EvFDaqDirector::~EvFDaqDirector ( )

Definition at line 220 of file EvFDaqDirector.cc.

References fulocal_rwlock_fd2_, fulocal_rwlock_fd_, unlockFULocal(), and unlockFULocal2().

221  {
222  if (fulocal_rwlock_fd_!=-1) {
223  unlockFULocal();
224  close(fulocal_rwlock_fd_);
225  }
226 
227  if (fulocal_rwlock_fd2_!=-1) {
228  unlockFULocal2();
229  close(fulocal_rwlock_fd2_);
230  }
231 
232  }

Member Function Documentation

std::string& evf::EvFDaqDirector::baseRunDir ( )
inline

Definition at line 72 of file EvFDaqDirector.h.

72 {return run_dir_;}
std::string& evf::EvFDaqDirector::buBaseRunDir ( )
inline

Definition at line 73 of file EvFDaqDirector.h.

73 {return bu_run_dir_;}
std::string bu_run_dir_
std::string& evf::EvFDaqDirector::buBaseRunOpenDir ( )
inline

Definition at line 74 of file EvFDaqDirector.h.

74 {return bu_run_open_dir_;}
std::string bu_run_open_dir_
bool evf::EvFDaqDirector::bumpFile ( unsigned int &  ls,
unsigned int &  index,
std::string &  nextFile,
uint32_t &  fsize,
int  maxLS 
)
private

Definition at line 689 of file EvFDaqDirector.cc.

References evf::FastMonitoringService::accumulateFileSize(), fms_, getEoLSFilePathOnBU(), getInputJsonFilePath(), getNFilesFromEoLS(), eostools::ls(), previousFileSize_, trackingPlots::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by updateFuLock().

689  {
690 
691  if (previousFileSize_ != 0) {
692  if (!fms_) {
693  fms_ = (FastMonitoringService *) (edm::Service<evf::MicroStateService>().operator->());
694  }
696  previousFileSize_ = 0;
697  }
698 
699  //reached limit
700  if (maxLS>=0 && ls > (unsigned int)maxLS) return false;
701 
702  struct stat buf;
703  std::stringstream ss;
704  unsigned int nextIndex = index;
705  nextIndex++;
706 
707  // 1. Check suggested file
708  nextFile = getInputJsonFilePath(ls,index);
709  if (stat(nextFile.c_str(), &buf) == 0) {
710 
711  previousFileSize_ = buf.st_size;
712  fsize = buf.st_size;
713  return true;
714  }
715  // 2. No file -> lumi ended? (and how many?)
716  else {
717  std::string BUEoLSFile = getEoLSFilePathOnBU(ls);
718  bool eolFound = (stat(BUEoLSFile.c_str(), &buf) == 0);
719  while (eolFound) {
720 
721  // recheck that no raw file appeared in the meantime
722  if (stat(nextFile.c_str(), &buf) == 0) {
723  previousFileSize_ = buf.st_size;
724  fsize = buf.st_size;
725  return true;
726  }
727 
728  int indexFilesInLS = getNFilesFromEoLS(BUEoLSFile);
729  if (indexFilesInLS < 0)
730  //parsing failed
731  return false;
732  else {
733  //check index
734  if ((int)index<indexFilesInLS) {
735  //we have 2 files, and check for 1 failed... retry (2 will never be here)
736  edm::LogError("EvFDaqDirector") << "Potential miss of index file in LS -: " << ls << ". Missing "
737  << nextFile << " because " << indexFilesInLS-1 << " is the highest index expected. Will not update fu.lock file";
738  return false;
739  }
740  }
741  // this lumi ended, check for files
742  ++ls;
743  index = 0;
744 
745  //reached limit
746  if (maxLS>=0 && ls > (unsigned int)maxLS) return false;
747 
748  nextFile = getInputJsonFilePath(ls,0);
749  if (stat(nextFile.c_str(), &buf) == 0) {
750  // a new file was found at new lumisection, index 0
751  previousFileSize_ = buf.st_size;
752  fsize = buf.st_size;
753  return true;
754  }
755  else {
756  //change of policy: we need to cycle through each LS
757  return false;
758  }
759  BUEoLSFile = getEoLSFilePathOnBU(ls);
760  eolFound = (stat(BUEoLSFile.c_str(), &buf) == 0);
761  }
762  }
763  // no new file found
764  return false;
765  }
void accumulateFileSize(unsigned int lumi, unsigned long fileSize)
std::string getEoLSFilePathOnBU(const unsigned int ls) const
unsigned long previousFileSize_
int getNFilesFromEoLS(std::string BUEoLSFile)
def ls(path, rec=False)
Definition: eostools.py:348
evf::FastMonitoringService * fms_
std::string getInputJsonFilePath(const unsigned int ls, const unsigned int index) const
void evf::EvFDaqDirector::checkMergeTypePSet ( edm::ProcessContext const &  pc)

Definition at line 960 of file EvFDaqDirector.cc.

References edm::ParameterSet::existsAs(), edm::ParameterSet::getParameterSet(), edm::getParameterSet(), mergeTypeMap_, mergeTypePset_, edm::ProcessContext::parameterSetID(), BPhysicsValidation_cfi::pname, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by preBeginJob().

961  {
962  if (mergeTypePset_.empty()) return;
963  if(!mergeTypeMap_.empty()) return;
964  edm::ParameterSet const& topPset = edm::getParameterSet(pc.parameterSetID());
965  if (topPset.existsAs<edm::ParameterSet>(mergeTypePset_,true))
966  {
967  const edm::ParameterSet& tsPset(topPset.getParameterSet(mergeTypePset_));
968  for (std::string pname : tsPset.getParameterNames()) {
969  std::string streamType = tsPset.getParameter<std::string>(pname);
970  tbb::concurrent_hash_map<std::string,std::string>::accessor ac;
971  mergeTypeMap_.insert(ac,pname);
972  ac->second = streamType;
973  ac.release();
974  }
975  }
976  }
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
ParameterSet const & getParameterSet(ParameterSetID const &id)
tbb::concurrent_hash_map< std::string, std::string > mergeTypeMap_
std::string mergeTypePset_
ParameterSet const & getParameterSet(std::string const &) const
void evf::EvFDaqDirector::checkTransferSystemPSet ( edm::ProcessContext const &  pc)

Definition at line 857 of file EvFDaqDirector.cc.

References Json::Value::append(), Json::arrayValue, mps_fire::dest, myMessageLogger_cff::destinations, Exception, edm::ParameterSet::existsAs(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::getParameterSet(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, edm::ProcessContext::parameterSetID(), requireTSPSet_, and transferSystemJson_.

Referenced by preBeginJob().

858  {
859  if(transferSystemJson_) return;
860 
861  transferSystemJson_.reset(new Json::Value);
862  edm::ParameterSet const& topPset = edm::getParameterSet(pc.parameterSetID());
863  if (topPset.existsAs<edm::ParameterSet>("transferSystem",true))
864  {
865  const edm::ParameterSet& tsPset(topPset.getParameterSet("transferSystem"));
866 
867  Json::Value destinationsVal(Json::arrayValue);
868  std::vector<std::string> destinations = tsPset.getParameter<std::vector<std::string>>("destinations");
869  for (auto & dest: destinations) destinationsVal.append(dest);
870  (*transferSystemJson_)["destinations"]=destinationsVal;
871 
872  Json::Value modesVal(Json::arrayValue);
873  std::vector<std::string> modes = tsPset.getParameter< std::vector<std::string> >("transferModes");
874  for (auto & mode: modes) modesVal.append(mode);
875  (*transferSystemJson_)["transferModes"]=modesVal;
876 
877  for (auto psKeyItr =tsPset.psetTable().begin();psKeyItr!=tsPset.psetTable().end(); ++ psKeyItr) {
878  if (psKeyItr->first!="destinations" && psKeyItr->first!="transferModes") {
879  const edm::ParameterSet & streamDef = tsPset.getParameterSet(psKeyItr->first);
880  Json::Value streamVal;
881  for (auto & mode : modes) {
882  //validation
883  if (!streamDef.existsAs<std::vector<std::string>>(mode,true))
884  throw cms::Exception("EvFDaqDirector") << " Missing transfer system specification for -:" << psKeyItr->first << " (transferMode " << mode << ")";
885  std::vector<std::string> streamDestinations = streamDef.getParameter<std::vector<std::string>>(mode);
886 
887  Json::Value sDestsValue(Json::arrayValue);
888 
889  if (streamDestinations.empty())
890  throw cms::Exception("EvFDaqDirector") << " Missing transter system destination(s) for -: "<< psKeyItr->first << ", mode:" << mode;
891 
892  for (auto & sdest:streamDestinations) {
893  bool sDestValid=false;
894  sDestsValue.append(sdest);
895  for (auto & dest: destinations) {
896  if (dest==sdest) sDestValid=true;
897  }
898  if (!sDestValid)
899  throw cms::Exception("EvFDaqDirector") << " Invalid transter system destination specified for -: "<< psKeyItr->first << ", mode:" << mode << ", dest:"<<sdest;
900  }
901  streamVal[mode]=sDestsValue;
902  }
903  (*transferSystemJson_)[psKeyItr->first] = streamVal;
904  }
905  }
906  }
907  else {
908  if (requireTSPSet_)
909  throw cms::Exception("EvFDaqDirector") << "transferSystem PSet not found";
910  }
911  }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::shared_ptr< Json::Value > transferSystemJson_
ParameterSet const & getParameterSet(ParameterSetID const &id)
Represents a JSON value.
Definition: value.h:111
ParameterSet const & getParameterSet(std::string const &) const
array value (ordered list)
Definition: value.h:31
void evf::EvFDaqDirector::createProcessingNotificationMaybe ( ) const

Definition at line 993 of file EvFDaqDirector.cc.

References run_dir_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FedRawDataInputSource::checkNextEvent().

993  {
994  std::string proc_flag = run_dir_ + "/processing";
995  int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
996  close(proc_flag_fd);
997  }
void evf::EvFDaqDirector::createRunOpendirMaybe ( )

Definition at line 829 of file EvFDaqDirector.cc.

References getRunOpenDirPath(), LogDebug, and callgraph::path.

Referenced by initRun().

829  {
830  // create open dir if not already there
831 
833  if (!boost::filesystem::is_directory(openPath)) {
834  LogDebug("EvFDaqDirector") << "<open> FU dir not found. Creating... -:" << openPath.string();
835  boost::filesystem::create_directories(openPath);
836  }
837  }
#define LogDebug(id)
std::string getRunOpenDirPath() const
std::string evf::EvFDaqDirector::eolsFileName ( const unsigned int  ls) const
private
std::string evf::EvFDaqDirector::eorFileName ( ) const
private
void evf::EvFDaqDirector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 243 of file EvFDaqDirector.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::setAllowAnything(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

244  {
246  desc.setComment("Service used for file locking arbitration and for propagating information between other EvF components");
247  desc.addUntracked<std::string> ("baseDir", ".")->setComment("Local base directory for run output");
248  desc.addUntracked<std::string> ("buBaseDir", ".")->setComment("BU base ramdisk directory ");
249  desc.addUntracked<unsigned int> ("runNumber",0)->setComment("Run Number in ramdisk to open");
250  desc.addUntracked<bool>("outputAdler32Recheck",false)->setComment("Check Adler32 of per-process output files while micro-merging");
251  desc.addUntracked<bool>("requireTransfersPSet",false)->setComment("Require complete transferSystem PSet in the process configuration");
252  desc.addUntracked<std::string>("selectedTransferMode","")->setComment("Selected transfer mode (choice in Lvl0 propagated as Python parameter");
253  desc.addUntracked<unsigned int>("fuLockPollInterval",2000)->setComment("Lock polling interval in microseconds for the input directory file lock");
254  desc.addUntracked<std::string>("mergingPset","")->setComment("Name of merging PSet to look for merging type definitions for streams");
255  desc.setAllowAnything();
256  descriptions.add("EvFDaqDirector", desc);
257  }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setAllowAnything()
allow any parameter label/value pairs
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::string evf::EvFDaqDirector::findCurrentRunDir ( )
inline

Definition at line 76 of file EvFDaqDirector.h.

References eostools::ls(), and AlCaHLTBitMon_QueryRunRegistry::string.

76 { return dirManager_.findRunDir(run_);}
std::string findRunDir(unsigned int)
Definition: DirManager.cc:37
std::string evf::EvFDaqDirector::getBoLSFilePathOnFU ( const unsigned int  ls) const

Definition at line 410 of file EvFDaqDirector.cc.

References fffnaming::bolsFileName(), run_, and run_dir_.

Referenced by FedRawDataInputSource::createBoLSFile().

410  {
411  return run_dir_ + "/" + fffnaming::bolsFileName(run_,ls);
412  }
std::string bolsFileName(const unsigned int run, const unsigned int ls)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getDatFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 346 of file EvFDaqDirector.cc.

References run_, run_dir_, and fffnaming::streamerDataFileNameWithPid().

346  {
348  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string streamerDataFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getEoLSFilePathOnBU ( const unsigned int  ls) const

Definition at line 402 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::eolsFileName(), and run_.

Referenced by bumpFile(), and FedRawDataInputSource::checkNextEvent().

402  {
403  return bu_run_dir_ + "/" + fffnaming::eolsFileName(run_,ls);
404  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string eolsFileName(const unsigned int run, const unsigned int ls)
std::string evf::EvFDaqDirector::getEoLSFilePathOnFU ( const unsigned int  ls) const

Definition at line 406 of file EvFDaqDirector.cc.

References fffnaming::eolsFileName(), run_, and run_dir_.

Referenced by FedRawDataInputSource::checkNextEvent(), FedRawDataInputSource::maybeOpenNewLumiSection(), and updateFuLock().

406  {
407  return run_dir_ + "/" + fffnaming::eolsFileName(run_,ls);
408  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string eolsFileName(const unsigned int run, const unsigned int ls)
std::string evf::EvFDaqDirector::getEoRFilePath ( ) const

Definition at line 414 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::eorFileName(), and run_.

Referenced by updateFuLock().

414  {
415  return bu_run_dir_ + "/" + fffnaming::eorFileName(run_);
416  }
std::string eorFileName(const unsigned int run)
std::string bu_run_dir_
std::string evf::EvFDaqDirector::getEoRFilePathOnFU ( ) const

Definition at line 419 of file EvFDaqDirector.cc.

References fffnaming::eorFileName(), run_, and run_dir_.

Referenced by FedRawDataInputSource::checkNextEvent().

419  {
420  return run_dir_ + "/" + fffnaming::eorFileName(run_);
421  }
std::string eorFileName(const unsigned int run)
std::string evf::EvFDaqDirector::getInitFilePath ( std::string const &  stream) const

Definition at line 374 of file EvFDaqDirector.cc.

References fffnaming::initFileNameWithPid(), run_, and run_dir_.

Referenced by DQMFileSaver::globalBeginRun().

374  {
375  return run_dir_ + "/" + fffnaming::initFileNameWithPid(run_,0,stream);
376  }
std::string initFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getInputJsonFilePath ( const unsigned int  ls,
const unsigned int  index 
) const

Definition at line 330 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::inputJsonFileName(), and run_.

Referenced by bumpFile().

330  {
332  }
std::string inputJsonFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string evf::EvFDaqDirector::getMergedDatChecksumFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 366 of file EvFDaqDirector.cc.

References hostname_, run_, run_dir_, and fffnaming::streamerDataChecksumFileNameWithInstance().

366  {
368  }
std::string streamerDataChecksumFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getMergedDatFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 362 of file EvFDaqDirector.cc.

References hostname_, run_, run_dir_, and fffnaming::streamerDataFileNameWithInstance().

362  {
364  }
std::string streamerDataFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getMergedProtocolBufferHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 386 of file EvFDaqDirector.cc.

References hostname_, fffnaming::protocolBufferHistogramFileNameWithInstance(), run_, and run_dir_.

386  {
388  }
std::string protocolBufferHistogramFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getMergedRootHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 398 of file EvFDaqDirector.cc.

References hostname_, fffnaming::rootHistogramFileNameWithInstance(), run_, and run_dir_.

398  {
400  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string rootHistogramFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
int evf::EvFDaqDirector::getNFilesFromEoLS ( std::string  BUEoLSFile)
private

Definition at line 628 of file EvFDaqDirector.cc.

References bu_run_dir_, data, def, jsoncollector::DataPoint::deserialize(), reco::dp, eolsNFilesIndex_, jsoncollector::DataPoint::getData(), jsoncollector::DataPoint::getDefinition(), jsoncollector::DataPointDefinition::getNames(), mps_fire::i, Json::Reader::parse(), readEolsDefinition_, matplotRender::reader, trackingPlots::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by bumpFile().

628  {
629 
630  boost::filesystem::ifstream ij(BUEoLSFile);
631  Json::Value deserializeRoot;
633 
634  if (!reader.parse(ij, deserializeRoot)) {
635  edm::LogError("EvFDaqDirector") << "Cannot deserialize input JSON file -:" << BUEoLSFile;
636  return -1;
637  }
638 
640  DataPoint dp;
641  dp.deserialize(deserializeRoot);
642 
643  //read definition
644  if (readEolsDefinition_) {
645  //std::string def = boost::algorithm::trim(dp.getDefinition());
647  if (def.empty()) readEolsDefinition_=false;
648  while (!def.empty()) {
649  std::string fullpath;
650  if (def.find('/')==0)
651  fullpath = def;
652  else
653  fullpath = bu_run_dir_+'/'+def;
654  struct stat buf;
655  if (stat(fullpath.c_str(), &buf) == 0) {
656  DataPointDefinition eolsDpd;
657  std::string defLabel = "legend";
658  DataPointDefinition::getDataPointDefinitionFor(fullpath, &eolsDpd,&defLabel);
659  if (eolsDpd.getNames().empty()) {
660  //try with "data" label if "legend" format is not used
661  eolsDpd = DataPointDefinition();
662  defLabel="data";
663  DataPointDefinition::getDataPointDefinitionFor(fullpath, &eolsDpd,&defLabel);
664  }
665  for (unsigned int i=0;i<eolsDpd.getNames().size();i++)
666  if (eolsDpd.getNames().at(i)=="NFiles")
668  readEolsDefinition_=false;
669  break;
670  }
671  //check if we can still find definition
672  if (def.size()<=1 || def.find('/')==std::string::npos) {
673  readEolsDefinition_=false;
674  break;
675  }
676  def = def.substr(def.find('/')+1);
677  }
678  }
679 
680  if (dp.getData().size()>eolsNFilesIndex_)
681  data = dp.getData()[eolsNFilesIndex_];
682  else {
683  edm::LogError("EvFDaqDirector") << " error reading number of files from BU JSON -: " << BUEoLSFile;
684  return -1;
685  }
686  return boost::lexical_cast<int>(data);
687  }
std::vector< std::string > & getData()
Definition: DataPoint.h:58
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
Represents a JSON value.
Definition: value.h:111
unsigned int eolsNFilesIndex_
auto dp
Definition: deltaR.h:22
void deserialize(Json::Value &root) override
Definition: DataPoint.cc:56
std::string & getDefinition()
Definition: DataPoint.h:59
std::string bu_run_dir_
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Unserialize a JSON document into a Value.
Definition: reader.h:16
std::vector< std::string > const & getNames()
JetCorrectorParameters::Definitions def
Definition: classes.h:6
std::string evf::EvFDaqDirector::getOpenDatFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 350 of file EvFDaqDirector.cc.

References run_, run_dir_, and fffnaming::streamerDataFileNameWithPid().

350  {
351  return run_dir_ + "/open/" + fffnaming::streamerDataFileNameWithPid(run_,ls,stream);
352  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string streamerDataFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getOpenInitFilePath ( std::string const &  stream) const

Definition at line 370 of file EvFDaqDirector.cc.

References fffnaming::initFileNameWithPid(), run_, and run_dir_.

370  {
371  return run_dir_ + "/open/" + fffnaming::initFileNameWithPid(run_,0,stream);
372  }
std::string initFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getOpenInputJsonFilePath ( const unsigned int  ls,
const unsigned int  index 
) const

Definition at line 342 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::inputJsonFileName(), and run_.

342  {
344  }
std::string inputJsonFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string evf::EvFDaqDirector::getOpenOutputJsonFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 354 of file EvFDaqDirector.cc.

References run_, run_dir_, and fffnaming::streamerJsonFileNameWithPid().

354  {
355  return run_dir_ + "/open/" + fffnaming::streamerJsonFileNameWithPid(run_,ls,stream);
356  }
std::string streamerJsonFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getOpenProtocolBufferHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 378 of file EvFDaqDirector.cc.

References fffnaming::protocolBufferHistogramFileNameWithPid(), run_, and run_dir_.

378  {
380  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string protocolBufferHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getOpenRawFilePath ( const unsigned int  ls,
const unsigned int  index 
) const

Definition at line 338 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::inputRawFileName(), and run_.

338  {
339  return bu_run_dir_ + "/open/" + fffnaming::inputRawFileName(run_,ls,index);
340  }
std::string inputRawFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string evf::EvFDaqDirector::getOpenRootHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 390 of file EvFDaqDirector.cc.

References fffnaming::rootHistogramFileNameWithPid(), run_, and run_dir_.

390  {
391  return run_dir_ + "/open/" + fffnaming::rootHistogramFileNameWithPid(run_,ls,stream);
392  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string rootHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getOutputJsonFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 358 of file EvFDaqDirector.cc.

References run_, run_dir_, and fffnaming::streamerJsonFileNameWithPid().

358  {
360  }
std::string streamerJsonFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
def ls(path, rec=False)
Definition: eostools.py:348
std::string evf::EvFDaqDirector::getProtocolBufferHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 382 of file EvFDaqDirector.cc.

References fffnaming::protocolBufferHistogramFileNameWithPid(), run_, and run_dir_.

382  {
384  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string protocolBufferHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string evf::EvFDaqDirector::getRawFilePath ( const unsigned int  ls,
const unsigned int  index 
) const

Definition at line 334 of file EvFDaqDirector.cc.

References bu_run_dir_, fffnaming::inputRawFileName(), and run_.

Referenced by removeFile().

334  {
336  }
std::string inputRawFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string evf::EvFDaqDirector::getRootHistogramFilePath ( const unsigned int  ls,
std::string const &  stream 
) const

Definition at line 394 of file EvFDaqDirector.cc.

References fffnaming::rootHistogramFileNameWithPid(), run_, and run_dir_.

394  {
396  }
def ls(path, rec=False)
Definition: eostools.py:348
std::string rootHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
unsigned int evf::EvFDaqDirector::getRunNumber ( ) const
inline

Definition at line 107 of file EvFDaqDirector.h.

107 { return run_; }
std::string evf::EvFDaqDirector::getRunOpenDirPath ( ) const
inline

Definition at line 100 of file EvFDaqDirector.h.

Referenced by createRunOpendirMaybe(), and initRun().

100 {return run_dir_ +"/open";}
std::string evf::EvFDaqDirector::getStreamDestinations ( std::string const &  stream) const

Definition at line 913 of file EvFDaqDirector.cc.

References Json::Value::begin(), Json::Value::end(), Exception, mps_check::msg, requireTSPSet_, selectedTransferMode_, AlCaHLTBitMon_QueryRunRegistry::string, and transferSystemJson_.

914  {
915  std::string streamRequestName;
916  if (transferSystemJson_->isMember(stream.c_str()))
917  streamRequestName = stream;
918  else {
919  std::stringstream msg;
920  msg << "Transfer system mode definitions missing for -: " << stream;
921  if (requireTSPSet_)
922  throw cms::Exception("EvFDaqDirector") << msg.str();
923  else {
924  edm::LogWarning("EvFDaqDirector") << msg.str() << " (permissive mode)";
925  return std::string("Failsafe");
926  }
927  }
928  //return empty if strict check parameter is not on
929  if (!requireTSPSet_ && (selectedTransferMode_.empty() || selectedTransferMode_=="null")) {
930  edm::LogWarning("EvFDaqDirector") << "Selected mode string is not provided as DaqDirector parameter."
931  << "Switch on requireTSPSet parameter to enforce this requirement. Setting mode to empty string.";
932  return std::string("Failsafe");
933  }
934  if (requireTSPSet_ && (selectedTransferMode_.empty() || selectedTransferMode_=="null")) {
935  throw cms::Exception("EvFDaqDirector") << "Selected mode string is not provided as DaqDirector parameter.";
936  }
937  //check if stream has properly listed transfer stream
938  if (!transferSystemJson_->get(streamRequestName, "").isMember(selectedTransferMode_.c_str()))
939  {
940  std::stringstream msg;
941  msg << "Selected transfer mode " << selectedTransferMode_ << " is not specified for stream " << streamRequestName;
942  if (requireTSPSet_)
943  throw cms::Exception("EvFDaqDirector") << msg.str();
944  else
945  edm::LogWarning("EvFDaqDirector") << msg.str() << " (permissive mode)";
946  return std::string("Failsafe");
947  }
948  Json::Value destsVec = transferSystemJson_->get(streamRequestName, "").get(selectedTransferMode_,"");
949 
950  //flatten string json::Array into CSV std::string
951  std::string ret;
952  for (Json::Value::iterator it = destsVec.begin(); it!=destsVec.end(); it++)
953  {
954  if (!ret.empty()) ret +=",";
955  ret+=(*it).asString();
956  }
957  return ret;
958  }
const_iterator begin() const
std::shared_ptr< Json::Value > transferSystemJson_
Represents a JSON value.
Definition: value.h:111
std::string selectedTransferMode_
tuple msg
Definition: mps_check.py:277
const_iterator end() const
Iterator for object and array value.
Definition: value.h:1007
std::string evf::EvFDaqDirector::getStreamMergeType ( std::string const &  stream,
MergeType  defaultType 
)

Definition at line 978 of file EvFDaqDirector.cc.

References mergeTypeMap_, MergeTypeNames_, and AlCaHLTBitMon_QueryRunRegistry::string.

979  {
980  tbb::concurrent_hash_map<std::string,std::string>::const_accessor search_ac;
981  if (mergeTypeMap_.find(search_ac,stream))
982  return search_ac->second;
983 
984  edm::LogInfo("EvFDaqDirector") << " No merging type specified for stream " << stream << ". Using default value";
985  std::string defaultName = MergeTypeNames_[defaultType];
986  tbb::concurrent_hash_map<std::string,std::string>::accessor ac;
987  mergeTypeMap_.insert(ac,stream);
988  ac->second = defaultName;
989  ac.release();
990  return defaultName;
991  }
tbb::concurrent_hash_map< std::string, std::string > mergeTypeMap_
static const std::vector< std::string > MergeTypeNames_
std::string evf::EvFDaqDirector::initFileName ( std::string const &  stream) const
private
void evf::EvFDaqDirector::initRun ( )

Definition at line 90 of file EvFDaqDirector.cc.

References base_dir_, bu_base_dir_, bu_run_dir_, bu_run_open_dir_, bu_w_lock_stream, bu_writelock_fd_, eostools::chmod(), createRunOpendirMaybe(), directorBu_, Exception, fu_readwritelock_fd_, fu_rw_lock_stream, fulocal_rwlock_fd2_, fulocal_rwlock_fd_, fulockfile_, getRunOpenDirPath(), hltSourceDirectory_, init_lock_, eostools::mkdir(), openFULockfileStream(), run_, run_dir_, run_string_, trackingPlots::stat, stopFilePath_, stopFilePathPid_, AlCaHLTBitMon_QueryRunRegistry::string, and tryInitializeFuLockFile().

Referenced by preallocate().

91  {
92  std::stringstream ss;
93  ss << "run" << std::setfill('0') << std::setw(6) << run_;
94  run_string_ = ss.str();
96 
97  // check if base dir exists or create it accordingly
98  int retval = mkdir(base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
99  if (retval != 0 && errno != EEXIST) {
100  throw cms::Exception("DaqDirector") << " Error checking for base dir -: "
101  << base_dir_ << " mkdir error:" << strerror(errno);
102  }
103 
104  //create run dir in base dir
105  umask(0);
106  retval = mkdir(run_dir_.c_str(),
107  S_IRWXU | S_IRWXG | S_IROTH | S_IRWXO | S_IXOTH);
108  if (retval != 0 && errno != EEXIST) {
109  throw cms::Exception("DaqDirector") << " Error creating run dir -: "
110  << run_dir_ << " mkdir error:" << strerror(errno);
111  }
112 
113  //create fu-local.lock in run open dir
114  if (!directorBu_) {
115 
117  std::string fulocal_lock_ = getRunOpenDirPath() +"/fu-local.lock";
118  fulocal_rwlock_fd_ = open(fulocal_lock_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);//O_RDWR?
119  if (fulocal_rwlock_fd_==-1)
120  throw cms::Exception("DaqDirector") << " Error creating/opening a local lock file -: " << fulocal_lock_.c_str() << " : " << strerror(errno);
121  chmod(fulocal_lock_.c_str(),0777);
122  fsync(fulocal_rwlock_fd_);
123  //open second fd for another input source thread
124  fulocal_rwlock_fd2_ = open(fulocal_lock_.c_str(), O_RDWR, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);//O_RDWR?
125  if (fulocal_rwlock_fd2_==-1)
126  throw cms::Exception("DaqDirector") << " Error opening a local lock file -: " << fulocal_lock_.c_str() << " : " << strerror(errno);
127  }
128 
129  //bu_run_dir: for FU, for which the base dir is local and the BU is remote, it is expected to be there
130  //for BU, it is created at this point
131  if (directorBu_)
132  {
134  std::string bulockfile = bu_run_dir_ + "/bu.lock";
135  fulockfile_ = bu_run_dir_ + "/fu.lock";
136 
137  //make or find bu run dir
138  retval = mkdir(bu_run_dir_.c_str(),
139  S_IRWXU | S_IRWXG | S_IRWXO);
140  if (retval != 0 && errno != EEXIST) {
141  throw cms::Exception("DaqDirector")
142  << " Error creating bu run dir -: " << bu_run_dir_
143  << " mkdir error:" << strerror(errno) << "\n";
144  }
145  bu_run_open_dir_ = bu_run_dir_ + "/open";
146  retval = mkdir(bu_run_open_dir_.c_str(),
147  S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
148  if (retval != 0 && errno != EEXIST) {
149  throw cms::Exception("DaqDirector") << " Error creating bu run open dir -: "
150  << bu_run_open_dir_ << " mkdir error:" << strerror(errno)
151  << "\n";
152  }
153 
154  // the BU director does not need to know about the fu lock
155  bu_writelock_fd_ = open(bulockfile.c_str(),
156  O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
157  if (bu_writelock_fd_ == -1)
158  edm::LogWarning("EvFDaqDirector") << "problem with creating filedesc for buwritelock -: "
159  << strerror(errno);
160  else
161  edm::LogInfo("EvFDaqDirector") << "creating filedesc for buwritelock -: "
162  << bu_writelock_fd_;
163  bu_w_lock_stream = fdopen(bu_writelock_fd_, "w");
164  if (bu_w_lock_stream == nullptr)
165  edm::LogWarning("EvFDaqDirector")<< "Error creating write lock stream -: " << strerror(errno);
166 
167  // BU INITIALIZES LOCK FILE
168  // FU LOCK FILE OPEN
169  openFULockfileStream(true);
171  fflush(fu_rw_lock_stream);
172  close(fu_readwritelock_fd_);
173 
174  if (!hltSourceDirectory_.empty())
175  {
176  struct stat buf;
177  if (stat(hltSourceDirectory_.c_str(),&buf)==0) {
178  std::string hltdir=bu_run_dir_+"/hlt";
179  std::string tmphltdir=bu_run_open_dir_+"/hlt";
180  retval = mkdir(tmphltdir.c_str(),S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
181  if (retval != 0 && errno != EEXIST)
182  throw cms::Exception("DaqDirector")
183  << " Error creating bu run dir -: " << hltdir
184  << " mkdir error:" << strerror(errno) << "\n";
185 
186  boost::filesystem::copy_file(hltSourceDirectory_+"/HltConfig.py",tmphltdir+"/HltConfig.py");
187 
188  boost::filesystem::copy_file(hltSourceDirectory_+"/fffParameters.jsn",tmphltdir+"/fffParameters.jsn");
189 
190  boost::filesystem::rename(tmphltdir,hltdir);
191  }
192  else
193  throw cms::Exception("DaqDirector") << " Error looking for HLT configuration -: " << hltSourceDirectory_;
194  }
195  //else{}//no configuration specified
196  }
197  else
198  {
199  // for FU, check if bu base dir exists
200 
201  retval = mkdir(bu_base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
202  if (retval != 0 && errno != EEXIST) {
203  throw cms::Exception("DaqDirector") << " Error checking for bu base dir -: "
204  << bu_base_dir_ << " mkdir error:" << strerror(errno) << "\n";
205  }
206 
208  fulockfile_ = bu_run_dir_ + "/fu.lock";
209  openFULockfileStream(false);
210  }
211 
212  pthread_mutex_init(&init_lock_,nullptr);
213 
214  stopFilePath_ = run_dir_+"/CMSSW_STOP";
215  std::stringstream sstp;
216  sstp << stopFilePath_ << "_pid" << getpid();
217  stopFilePathPid_ = sstp.str();
218  }
std::string run_string_
std::string fulockfile_
pthread_mutex_t init_lock_
std::string hltSourceDirectory_
def chmod(path, mode)
Definition: eostools.py:293
std::string stopFilePath_
std::string bu_base_dir_
std::string stopFilePathPid_
void openFULockfileStream(bool create)
std::string bu_run_dir_
def mkdir(path)
Definition: eostools.py:250
std::string getRunOpenDirPath() const
std::string bu_run_open_dir_
std::string evf::EvFDaqDirector::inputFileNameStem ( const unsigned int  ls,
const unsigned int  index 
) const
private
bool evf::EvFDaqDirector::isSingleStreamThread ( )
inline
void evf::EvFDaqDirector::lockFULocal ( )

Definition at line 807 of file EvFDaqDirector.cc.

References fulocal_rwlock_fd_.

Referenced by updateFuLock().

807  {
808  //fcntl(fulocal_rwlock_fd_, F_SETLKW, &fulocal_rw_flk);
809  flock(fulocal_rwlock_fd_,LOCK_SH);
810  }
void evf::EvFDaqDirector::lockFULocal2 ( )

Definition at line 818 of file EvFDaqDirector.cc.

References fulocal_rwlock_fd2_.

Referenced by FedRawDataInputSource::checkNextEvent(), and FedRawDataInputSource::maybeOpenNewLumiSection().

818  {
819  //fcntl(fulocal_rwlock_fd2_, F_SETLKW, &fulocal_rw_flk2);
820  flock(fulocal_rwlock_fd2_,LOCK_EX);
821  }
void evf::EvFDaqDirector::lockInitLock ( )

Definition at line 799 of file EvFDaqDirector.cc.

References init_lock_.

799  {
800  pthread_mutex_lock(&init_lock_);
801  }
pthread_mutex_t init_lock_
struct flock evf::EvFDaqDirector::make_flock ( short  type,
short  whence,
off_t  start,
off_t  len,
pid_t  pid 
)
static

Definition at line 999 of file EvFDaqDirector.cc.

References sysUtil::pid, and command_line::start.

1000  {
1001 #ifdef __APPLE__
1002  return {start, len, pid, type, whence};
1003 #else
1004  return {type, whence, start, len, pid};
1005 #endif
1006  }
type
Definition: HCALResponse.h:21
std::string evf::EvFDaqDirector::mergedFileNameStem ( const unsigned int  ls,
std::string const &  stream 
) const
private
void evf::EvFDaqDirector::openFULockfileStream ( bool  create)
private

Definition at line 778 of file EvFDaqDirector.cc.

References eostools::chmod(), fu_readwritelock_fd_, fu_rw_lock_stream, fulockfile_, and LogDebug.

Referenced by initRun().

778  {
779  if (create) {
780  fu_readwritelock_fd_ = open(fulockfile_.c_str(), O_RDWR | O_CREAT,
781  S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
782  chmod(fulockfile_.c_str(),0766);
783  } else {
784  fu_readwritelock_fd_ = open(fulockfile_.c_str(), O_RDWR, S_IRWXU);
785  }
786  if (fu_readwritelock_fd_ == -1)
787  edm::LogError("EvFDaqDirector") << "problem with creating filedesc for fuwritelock -: " << fulockfile_
788  << " create:" << create << " error:" << strerror(errno);
789  else
790  LogDebug("EvFDaqDirector") << "creating filedesc for fureadwritelock -: "
792 
793  fu_rw_lock_stream = fdopen(fu_readwritelock_fd_, "r+");
794  if (fu_rw_lock_stream == nullptr)
795  edm::LogError("EvFDaqDirector") << "problem with opening fuwritelock file stream -: " << strerror(errno);
796 
797  }
#define LogDebug(id)
std::string fulockfile_
def create(alignables, pedeDump, additionalData, outputFile, config)
def chmod(path, mode)
Definition: eostools.py:293
bool evf::EvFDaqDirector::outputAdler32Recheck ( ) const
inline

Definition at line 101 of file EvFDaqDirector.h.

References AlCaHLTBitMon_QueryRunRegistry::string.

std::string evf::EvFDaqDirector::outputFileNameStem ( const unsigned int  ls,
std::string const &  stream 
) const
private
void evf::EvFDaqDirector::overrideRunNumber ( unsigned int  run)
inline

Definition at line 71 of file EvFDaqDirector.h.

References findQualityFiles::run.

void evf::EvFDaqDirector::postEndRun ( edm::GlobalContext const &  globalContext)

Definition at line 277 of file EvFDaqDirector.cc.

References bu_readlock_fd_, bu_run_dir_, bu_writelock_fd_, directorBu_, corrVsCorr::filename, removeFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by EvFDaqDirector().

277  {
278  close(bu_readlock_fd_);
279  close(bu_writelock_fd_);
280  if (directorBu_) {
281  std::string filename = bu_run_dir_ + "/bu.lock";
282  removeFile(filename);
283  }
284  }
void removeFile(unsigned int ls, unsigned int index)
std::string bu_run_dir_
void evf::EvFDaqDirector::preallocate ( edm::service::SystemBounds const &  bounds)

Definition at line 235 of file EvFDaqDirector.cc.

References initRun(), edm::service::SystemBounds::maxNumberOfStreams(), edm::service::SystemBounds::maxNumberOfThreads(), nStreams_, and nThreads_.

Referenced by EvFDaqDirector().

235  {
236 
237  initRun();
238 
239  nThreads_=bounds.maxNumberOfStreams();
240  nStreams_=bounds.maxNumberOfThreads();
241  }
unsigned int nThreads_
unsigned int nStreams_
void evf::EvFDaqDirector::preBeginJob ( edm::PathsAndConsumesOfModulesBase const &  ,
edm::ProcessContext const &  pc 
)

Definition at line 259 of file EvFDaqDirector.cc.

References checkMergeTypePSet(), and checkTransferSystemPSet().

Referenced by EvFDaqDirector().

260  {
262  checkMergeTypePSet(pc);
263  }
void checkMergeTypePSet(edm::ProcessContext const &pc)
void checkTransferSystemPSet(edm::ProcessContext const &pc)
void evf::EvFDaqDirector::preBeginRun ( edm::GlobalContext const &  globalContext)

Definition at line 265 of file EvFDaqDirector.cc.

References dirManager_, evf::DirManager::findHighestRunDir(), and run_dir_.

Referenced by EvFDaqDirector().

265  {
266 
267  //assert(run_ == id.run());
268 
269  // check if the requested run is the latest one - issue a warning if it isn't
271  edm::LogWarning("EvFDaqDirector") << "WARNING - checking run dir -: "
272  << run_dir_ << ". This is not the highest run "
274  }
275  }
std::string findHighestRunDir()
Definition: DirManager.cc:20
void evf::EvFDaqDirector::preGlobalEndLumi ( edm::GlobalContext const &  globalContext)

Definition at line 286 of file EvFDaqDirector.cc.

References cppFunctionSkipper::exception, fileDeleteLockPtr_, filesToDeletePtr_, LogDebug, eostools::ls(), edm::LuminosityBlockID::luminosityBlock(), edm::GlobalContext::luminosityBlockID(), callgraph::path, and MatrixUtil::remove().

Referenced by EvFDaqDirector().

287  {
288  //delete all files belonging to just closed lumi
289  unsigned int ls = globalContext.luminosityBlockID().luminosityBlock();
291  edm::LogWarning("EvFDaqDirector") << " Handles to check for files to delete were not set by the input source...";
292  return;
293  }
294 
295  std::unique_lock<std::mutex> lkw(*fileDeleteLockPtr_);
296  auto it = filesToDeletePtr_->begin();
297  while (it!=filesToDeletePtr_->end()) {
298  if (it->second->lumi_ == ls) {
299  const boost::filesystem::path filePath(it->second->fileName_);
300  LogDebug("EvFDaqDirector") << "Deleting input file -:" << it->second->fileName_;
301  try {
302  //rarely this fails but file gets deleted
303  boost::filesystem::remove(filePath);
304  }
305  catch (const boost::filesystem::filesystem_error& ex)
306  {
307  edm::LogError("EvFDaqDirector") << " - deleteFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what() << ". Trying again.";
308  usleep(10000);
309  try {
310  boost::filesystem::remove(filePath);
311  }
312  catch (const boost::filesystem::filesystem_error&) {/*file gets deleted first time but exception is still thrown*/}
313  }
314  catch (std::exception& ex)
315  {
316  edm::LogError("EvFDaqDirector") << " - deleteFile std::exception CAUGHT -: " << ex.what() << ". Trying again.";
317  usleep(10000);
318  try {
319  boost::filesystem::remove(filePath);
320  } catch (std::exception&) {/*file gets deleted first time but exception is still thrown*/}
321  }
322 
323  delete it->second;
324  it = filesToDeletePtr_->erase(it);
325  }
326  else it++;
327  }
328  }
#define LogDebug(id)
std::list< std::pair< int, InputFile * > > * filesToDeletePtr_
std::mutex * fileDeleteLockPtr_
def ls(path, rec=False)
Definition: eostools.py:348
def remove(d, key, TELL=False)
Definition: MatrixUtil.py:211
int evf::EvFDaqDirector::readLastLSEntry ( std::string const &  file)

Definition at line 840 of file EvFDaqDirector.cc.

References Json::Value::asInt(), FrontierConditions_GlobalTag_cff::file, Json::Value::get(), Json::Reader::parse(), and matplotRender::reader.

Referenced by updateFuLock().

840  {
841 
842  boost::filesystem::ifstream ij(file);
843  Json::Value deserializeRoot;
845 
846  if (!reader.parse(ij, deserializeRoot)) {
847  edm::LogError("EvFDaqDirector") << "Cannot deserialize input JSON file -:" << file;
848  return -1;
849  }
850 
851  int ret = deserializeRoot.get("lastLS","").asInt();
852  return ret;
853 
854  }
Value get(UInt index, const Value &defaultValue) const
bool parse(const std::string &document, Value &root, bool collectComments=true)
Read a Value from a JSON document.
Represents a JSON value.
Definition: value.h:111
Int asInt() const
Unserialize a JSON document into a Value.
Definition: reader.h:16
void evf::EvFDaqDirector::removeFile ( unsigned int  ls,
unsigned int  index 
)

Definition at line 430 of file EvFDaqDirector.cc.

References getRawFilePath().

Referenced by postEndRun().

430  {
432  }
std::string getRawFilePath(const unsigned int ls, const unsigned int index) const
void removeFile(unsigned int ls, unsigned int index)
def ls(path, rec=False)
Definition: eostools.py:348
void evf::EvFDaqDirector::removeFile ( std::string  filename)

Definition at line 423 of file EvFDaqDirector.cc.

423  {
424  int retval = remove(filename.c_str());
425  if (retval != 0)
426  edm::LogError("EvFDaqDirector") << "Could not remove used file -: " << filename << ". error = "
427  << strerror(errno);
428  }
void evf::EvFDaqDirector::setDeleteTracking ( std::mutex fileDeleteLock,
std::list< std::pair< int, InputFile * >> *  filesToDelete 
)
inline

Definition at line 119 of file EvFDaqDirector.h.

References beamerCreator::create(), fffnaming::eolsFileName(), fffnaming::eorFileName(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FedRawDataInputSource::FedRawDataInputSource().

119  {
120  fileDeleteLockPtr_=fileDeleteLock;
121  filesToDeletePtr_ = filesToDelete;
122  }
std::list< std::pair< int, InputFile * > > * filesToDeletePtr_
std::mutex * fileDeleteLockPtr_
void evf::EvFDaqDirector::setFMS ( evf::FastMonitoringService fms)
inline

Definition at line 110 of file EvFDaqDirector.h.

Referenced by FedRawDataInputSource::FedRawDataInputSource().

110 {fms_=fms;}
evf::FastMonitoringService * fms_
void evf::EvFDaqDirector::tryInitializeFuLockFile ( )

Definition at line 767 of file EvFDaqDirector.cc.

References fu_rw_lock_stream, and getHLTprescales::readIndex().

Referenced by initRun().

767  {
768  if (fu_rw_lock_stream == nullptr)
769  edm::LogError("EvFDaqDirector") << "Error creating fu read/write lock stream "
770  << strerror(errno);
771  else {
772  edm::LogInfo("EvFDaqDirector") << "Initializing FU LOCK FILE";
773  unsigned int readLs = 1, readIndex = 0;
774  fprintf(fu_rw_lock_stream, "%u %u", readLs, readIndex);
775  }
776  }
void evf::EvFDaqDirector::unlockFULocal ( )

Definition at line 812 of file EvFDaqDirector.cc.

References fulocal_rwlock_fd_.

Referenced by FedRawDataInputSource::grabNextJsonFile(), and ~EvFDaqDirector().

812  {
813  //fcntl(fulocal_rwlock_fd_, F_SETLKW, &fulocal_rw_fulk);
814  flock(fulocal_rwlock_fd_,LOCK_UN);
815  }
void evf::EvFDaqDirector::unlockFULocal2 ( )

Definition at line 823 of file EvFDaqDirector.cc.

References fulocal_rwlock_fd2_.

Referenced by FedRawDataInputSource::checkNextEvent(), FedRawDataInputSource::maybeOpenNewLumiSection(), and ~EvFDaqDirector().

823  {
824  //fcntl(fulocal_rwlock_fd2_, F_SETLKW, &fulocal_rw_fulk2);
825  flock(fulocal_rwlock_fd2_,LOCK_UN);
826  }
void evf::EvFDaqDirector::unlockInitLock ( )

Definition at line 803 of file EvFDaqDirector.cc.

References init_lock_.

803  {
804  pthread_mutex_unlock(&init_lock_);
805  }
pthread_mutex_t init_lock_
EvFDaqDirector::FileStatus evf::EvFDaqDirector::updateFuLock ( unsigned int &  ls,
std::string &  nextFile,
uint32_t &  fsize,
uint64_t &  lockWaitTime 
)

Definition at line 434 of file EvFDaqDirector.cc.

References bu_run_dir_, bumpFile(), trackerTree::check(), Exception, fu_readwritelock_fd_, fu_rw_flk, fu_rw_fulk, fulockfile_, fuLockPollInterval_, getEoLSFilePathOnFU(), getEoRFilePath(), lockFULocal(), LogDebug, eostools::ls(), newFile, noFile, getHLTprescales::readIndex(), readLastLSEntry(), runAbort, runEnded, trackingPlots::stat, stop_ls_override_, stopFilePath_, and stopFilePathPid_.

Referenced by FedRawDataInputSource::readSupervisor().

434  {
435  EvFDaqDirector::FileStatus fileStatus = noFile;
436 
437  int retval = -1;
438  int lock_attempts = 0;
439  long total_lock_attempts = 0;
440 
441  struct stat buf;
442  int stopFileLS = -1;
443  int stopFileCheck = stat(stopFilePath_.c_str(),&buf);
444  int stopFilePidCheck = stat(stopFilePathPid_.c_str(),&buf);
445  if (stopFileCheck==0 || stopFilePidCheck==0) {
446  if (stopFileCheck==0)
447  stopFileLS = readLastLSEntry(stopFilePath_);
448  else
449  stopFileLS = 1;//stop without drain if only pid is stopped
450  if (!stop_ls_override_) {
451  //if lumisection is higher than in stop file, should quit at next from current
452  if (stopFileLS>=0 && (int)ls>=stopFileLS) stopFileLS = stop_ls_override_ = ls;
453  }
454  else stopFileLS = stop_ls_override_;
455  edm::LogWarning("EvFDaqDirector") << "Detected stop request from hltd. Ending run for this process after LS -: " << stopFileLS;
456  //return runEnded;
457  }
458  else //if file was removed before reaching stop condition, reset this
459  stop_ls_override_ = 0;
460 
461  timeval ts_lockbegin;
462  gettimeofday(&ts_lockbegin,nullptr);
463 
464  while (retval==-1) {
465  retval = fcntl(fu_readwritelock_fd_, F_SETLK, &fu_rw_flk);
466  if (retval==-1) usleep(fuLockPollInterval_);
467  else continue;
468 
469  lock_attempts+=fuLockPollInterval_;
470  total_lock_attempts+=fuLockPollInterval_;
471  if (lock_attempts>5000000 || errno==116) {
472  if (errno==116)
473  edm::LogWarning("EvFDaqDirector") << "Stale lock file handle. Checking if run directory and fu.lock file are present" << std::endl;
474  else
475  edm::LogWarning("EvFDaqDirector") << "Unable to obtain a lock for 5 seconds. Checking if run directory and fu.lock file are present -: errno "
476  << errno <<":"<< strerror(errno) << std::endl;
477 
478 
479  if (stat(getEoLSFilePathOnFU(ls).c_str(),&buf)==0) {
480  edm::LogWarning("EvFDaqDirector") << "Detected local EoLS for lumisection "<< ls ;
481  ls++;
482  return noFile;
483  }
484 
485  if (stat(bu_run_dir_.c_str(), &buf)!=0) return runEnded;
486  if (stat(fulockfile_.c_str(), &buf)!=0) return runEnded;
487 
488  lock_attempts=0;
489  }
490  if (total_lock_attempts>5*60000000) {
491  edm::LogError("EvFDaqDirector") << "Unable to obtain a lock for 5 minutes. Stopping polling activity.";
492  return runAbort;
493  }
494  }
495 
496  timeval ts_lockend;
497  gettimeofday(&ts_lockend,nullptr);
498  long deltat = (ts_lockend.tv_usec-ts_lockbegin.tv_usec) + (ts_lockend.tv_sec-ts_lockbegin.tv_sec)*1000000;
499  if (deltat>0.) lockWaitTime=deltat;
500 
501  if(retval!=0) return fileStatus;
502 
503 #ifdef DEBUG
504  timeval ts_lockend;
505  gettimeofday(&ts_lockend,0);
506 #endif
507 
508  //open another lock file FD after the lock using main fd has been acquired
509  int fu_readwritelock_fd2 = open(fulockfile_.c_str(), O_RDWR, S_IRWXU);
510  if (fu_readwritelock_fd2 == -1)
511  edm::LogError("EvFDaqDirector") << "problem with creating filedesc for fuwritelock -: " << fulockfile_
512  << " create. error:" << strerror(errno);
513 
514  FILE * fu_rw_lock_stream2 = fdopen(fu_readwritelock_fd2, "r+");
515 
516  // if the stream is readable
517  if (fu_rw_lock_stream2 != nullptr) {
518  unsigned int readLs, readIndex;
519  int check = 0;
520  // rewind the stream
521  check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
522  // if rewinded ok
523  if (check == 0) {
524  // read its' values
525  fscanf(fu_rw_lock_stream2, "%u %u", &readLs, &readIndex);
526  edm::LogInfo("EvFDaqDirector") << "Read fu.lock file file -: " << readLs << ":" << readIndex;
527 
528  unsigned int currentLs = readLs;
529  bool bumpedOk = false;
530  //if next lumisection in a lock file is not +1 wrt. source, cycle through the next empty one, unless initial lumi not yet set
531  //no lock file write in this case
532  if (ls && ls+1 < currentLs) ls++;
533  else {
534  // try to bump (look for new index or EoLS file)
535  bumpedOk = bumpFile(readLs, readIndex, nextFile, fsize, stopFileLS);
536  //avoid 2 lumisections jump
537  if (ls && readLs>currentLs && currentLs > ls) {
538  ls++;
539  readLs=currentLs=ls;
540  readIndex=0;
541  bumpedOk=false;
542  //no write to lock file
543  }
544  else {
545  if (ls==0 && readLs>currentLs) {
546  //make sure to intialize always with LS found in the lock file, with possibility of grabbing index file immediately
547  //in this case there is no new file in the same LS
548  readLs=currentLs;
549  readIndex=0;
550  bumpedOk=false;
551  //no write to lock file
552  }
553  //update return LS value
554  ls = readLs;
555  }
556  }
557  if (bumpedOk) {
558  // there is a new index file to grab, lock file needs to be updated
559  check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
560  if (check == 0) {
561  ftruncate(fu_readwritelock_fd2, 0);
562  // write next index in the file, which is the file the next process should take
563  fprintf(fu_rw_lock_stream2, "%u %u", readLs, readIndex + 1);
564  fflush(fu_rw_lock_stream2);
565  fsync(fu_readwritelock_fd2);
566  fileStatus = newFile;
567  LogDebug("EvFDaqDirector") << "Written to file -: " << readLs << ":" << readIndex + 1;
568  }
569  else {
570  throw cms::Exception("EvFDaqDirector") << "seek on fu read/write lock for updating failed with error " << strerror(errno);
571  }
572  }
573  else if (currentLs < readLs) {
574  //there is no new file in next LS (yet), but lock file can be updated to the next LS
575  check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
576  if (check == 0) {
577  ftruncate(fu_readwritelock_fd2, 0);
578  // in this case LS was bumped, but no new file. Thus readIndex is 0 (set by bumpFile)
579  fprintf(fu_rw_lock_stream2, "%u %u", readLs, readIndex);
580  fflush(fu_rw_lock_stream2);
581  fsync(fu_readwritelock_fd2);
582  LogDebug("EvFDaqDirector") << "Written to file -: " << readLs << ":" << readIndex;
583  }
584  else {
585  throw cms::Exception("EvFDaqDirector") << "seek on fu read/write lock for updating failed with error " << strerror(errno);
586  }
587  }
588  } else {
589  edm::LogError("EvFDaqDirector") << "seek on fu read/write lock for reading failed with error " << strerror(errno);
590  }
591  } else {
592  edm::LogError("EvFDaqDirector") << "fu read/write lock stream is invalid " << strerror(errno);
593  }
594  fclose(fu_rw_lock_stream2);// = fdopen(fu_readwritelock_fd2, "r+");
595 
596 #ifdef DEBUG
597  timeval ts_preunlock;
598  gettimeofday(&ts_preunlock,0);
599  int locked_period_int = ts_preunlock.tv_sec - ts_lockend.tv_sec;
600  double locked_period=locked_period_int+double(ts_preunlock.tv_usec - ts_lockend.tv_usec)/1000000;
601 #endif
602 
603  //if new json is present, lock file which FedRawDataInputSource will later unlock
604  if (fileStatus==newFile) lockFULocal();
605 
606  //release lock at this point
607  int retvalu=-1;
608  retvalu=fcntl(fu_readwritelock_fd_, F_SETLKW, &fu_rw_fulk);
609  if (retvalu==-1) edm::LogError("EvFDaqDirector") << "Error unlocking the fu.lock " << strerror(errno);
610 
611 #ifdef DEBUG
612  edm::LogDebug("EvFDaqDirector") << "Waited during lock -: " << locked_period << " seconds";
613 #endif
614 
615  if ( fileStatus == noFile ) {
616  struct stat buf;
617  //edm::LogInfo("EvFDaqDirector") << " looking for EoR file: " << getEoRFilePath().c_str();
618  if ( stat(getEoRFilePath().c_str(), &buf) == 0 || stat(bu_run_dir_.c_str(), &buf)!=0)
619  fileStatus = runEnded;
620  if (stopFileLS>=0 && (int)ls > stopFileLS) {
621  edm::LogInfo("EvFDaqDirector") << "Reached maximum lumisection set by hltd";
622  fileStatus = runEnded;
623  }
624  }
625  return fileStatus;
626  }
#define LogDebug(id)
struct flock fu_rw_flk
std::string fulockfile_
std::string getEoRFilePath() const
struct flock fu_rw_fulk
std::string stopFilePath_
unsigned int stop_ls_override_
int readLastLSEntry(std::string const &file)
std::string stopFilePathPid_
def ls(path, rec=False)
Definition: eostools.py:348
std::string bu_run_dir_
std::string getEoLSFilePathOnFU(const unsigned int ls) const
bool bumpFile(unsigned int &ls, unsigned int &index, std::string &nextFile, uint32_t &fsize, int maxLS)
def check(config)
Definition: trackerTree.py:14
unsigned int fuLockPollInterval_

Member Data Documentation

std::string evf::EvFDaqDirector::base_dir_
private

Definition at line 140 of file EvFDaqDirector.h.

Referenced by initRun().

std::string evf::EvFDaqDirector::bu_base_dir_
private

Definition at line 141 of file EvFDaqDirector.h.

Referenced by initRun().

struct flock evf::EvFDaqDirector::bu_r_flk
private

Definition at line 175 of file EvFDaqDirector.h.

struct flock evf::EvFDaqDirector::bu_r_fulk
private

Definition at line 177 of file EvFDaqDirector.h.

FILE* evf::EvFDaqDirector::bu_r_lock_stream
private

Definition at line 165 of file EvFDaqDirector.h.

int evf::EvFDaqDirector::bu_readlock_fd_
private

Definition at line 158 of file EvFDaqDirector.h.

Referenced by postEndRun().

std::string evf::EvFDaqDirector::bu_run_dir_
private
std::string evf::EvFDaqDirector::bu_run_open_dir_
private

Definition at line 155 of file EvFDaqDirector.h.

Referenced by initRun().

FILE* evf::EvFDaqDirector::bu_t_monitor_stream
private

Definition at line 168 of file EvFDaqDirector.h.

struct flock evf::EvFDaqDirector::bu_w_flk
private

Definition at line 174 of file EvFDaqDirector.h.

struct flock evf::EvFDaqDirector::bu_w_fulk
private

Definition at line 176 of file EvFDaqDirector.h.

FILE* evf::EvFDaqDirector::bu_w_lock_stream
private

Definition at line 164 of file EvFDaqDirector.h.

Referenced by initRun().

FILE* evf::EvFDaqDirector::bu_w_monitor_stream
private

Definition at line 167 of file EvFDaqDirector.h.

int evf::EvFDaqDirector::bu_writelock_fd_
private

Definition at line 159 of file EvFDaqDirector.h.

Referenced by initRun(), and postEndRun().

bool evf::EvFDaqDirector::directorBu_
private

Definition at line 142 of file EvFDaqDirector.h.

Referenced by initRun(), and postEndRun().

DirManager evf::EvFDaqDirector::dirManager_
private

Definition at line 170 of file EvFDaqDirector.h.

Referenced by preBeginRun().

unsigned int evf::EvFDaqDirector::eolsNFilesIndex_ = 1
private

Definition at line 192 of file EvFDaqDirector.h.

Referenced by getNFilesFromEoLS().

std::mutex* evf::EvFDaqDirector::fileDeleteLockPtr_ = nullptr
private

Definition at line 183 of file EvFDaqDirector.h.

Referenced by preGlobalEndLumi().

std::list<std::pair<int,InputFile*> >* evf::EvFDaqDirector::filesToDeletePtr_ = nullptr
private

Definition at line 184 of file EvFDaqDirector.h.

Referenced by preGlobalEndLumi().

evf::FastMonitoringService* evf::EvFDaqDirector::fms_ = nullptr
private

Definition at line 181 of file EvFDaqDirector.h.

Referenced by bumpFile().

int evf::EvFDaqDirector::fu_readwritelock_fd_
private

Definition at line 160 of file EvFDaqDirector.h.

Referenced by initRun(), openFULockfileStream(), and updateFuLock().

struct flock evf::EvFDaqDirector::fu_rw_flk
private

Definition at line 178 of file EvFDaqDirector.h.

Referenced by updateFuLock().

struct flock evf::EvFDaqDirector::fu_rw_fulk
private

Definition at line 179 of file EvFDaqDirector.h.

Referenced by updateFuLock().

FILE* evf::EvFDaqDirector::fu_rw_lock_stream
private

Definition at line 166 of file EvFDaqDirector.h.

Referenced by initRun(), openFULockfileStream(), and tryInitializeFuLockFile().

int evf::EvFDaqDirector::fulocal_rwlock_fd2_
private

Definition at line 162 of file EvFDaqDirector.h.

Referenced by initRun(), lockFULocal2(), unlockFULocal2(), and ~EvFDaqDirector().

int evf::EvFDaqDirector::fulocal_rwlock_fd_
private

Definition at line 161 of file EvFDaqDirector.h.

Referenced by initRun(), lockFULocal(), unlockFULocal(), and ~EvFDaqDirector().

std::string evf::EvFDaqDirector::fulockfile_
private

Definition at line 156 of file EvFDaqDirector.h.

Referenced by initRun(), openFULockfileStream(), and updateFuLock().

unsigned int evf::EvFDaqDirector::fuLockPollInterval_
private

Definition at line 148 of file EvFDaqDirector.h.

Referenced by EvFDaqDirector(), and updateFuLock().

std::string evf::EvFDaqDirector::hltSourceDirectory_
private

Definition at line 147 of file EvFDaqDirector.h.

Referenced by initRun().

std::string evf::EvFDaqDirector::hostname_
private
pthread_mutex_t evf::EvFDaqDirector::init_lock_ = PTHREAD_MUTEX_INITIALIZER
private

Definition at line 186 of file EvFDaqDirector.h.

Referenced by initRun(), lockInitLock(), and unlockInitLock().

tbb::concurrent_hash_map<std::string,std::string> evf::EvFDaqDirector::mergeTypeMap_
private

Definition at line 198 of file EvFDaqDirector.h.

Referenced by checkMergeTypePSet(), and getStreamMergeType().

const std::vector< std::string > evf::EvFDaqDirector::MergeTypeNames_ = {"","DAT","PB","JSNDATA"}
staticprivate

Definition at line 201 of file EvFDaqDirector.h.

Referenced by getStreamMergeType().

std::string evf::EvFDaqDirector::mergeTypePset_
private

Definition at line 149 of file EvFDaqDirector.h.

Referenced by checkMergeTypePSet().

unsigned int evf::EvFDaqDirector::nStreams_ =0
private

Definition at line 188 of file EvFDaqDirector.h.

Referenced by preallocate().

unsigned int evf::EvFDaqDirector::nThreads_ =0
private

Definition at line 189 of file EvFDaqDirector.h.

Referenced by preallocate().

bool evf::EvFDaqDirector::outputAdler32Recheck_
private

Definition at line 144 of file EvFDaqDirector.h.

unsigned long evf::EvFDaqDirector::previousFileSize_
private

Definition at line 172 of file EvFDaqDirector.h.

Referenced by bumpFile().

bool evf::EvFDaqDirector::readEolsDefinition_ = true
private

Definition at line 191 of file EvFDaqDirector.h.

Referenced by getNFilesFromEoLS().

bool evf::EvFDaqDirector::requireTSPSet_
private

Definition at line 145 of file EvFDaqDirector.h.

Referenced by checkTransferSystemPSet(), and getStreamDestinations().

unsigned int evf::EvFDaqDirector::run_
private
std::string evf::EvFDaqDirector::run_dir_
private
std::string evf::EvFDaqDirector::run_string_
private

Definition at line 152 of file EvFDaqDirector.h.

Referenced by initRun().

std::string evf::EvFDaqDirector::selectedTransferMode_
private

Definition at line 146 of file EvFDaqDirector.h.

Referenced by getStreamDestinations().

unsigned int evf::EvFDaqDirector::stop_ls_override_ = 0
private

Definition at line 195 of file EvFDaqDirector.h.

Referenced by updateFuLock().

std::string evf::EvFDaqDirector::stopFilePath_
private

Definition at line 193 of file EvFDaqDirector.h.

Referenced by initRun(), and updateFuLock().

std::string evf::EvFDaqDirector::stopFilePathPid_
private

Definition at line 194 of file EvFDaqDirector.h.

Referenced by initRun(), and updateFuLock().

std::shared_ptr<Json::Value> evf::EvFDaqDirector::transferSystemJson_
private

Definition at line 197 of file EvFDaqDirector.h.

Referenced by checkTransferSystemPSet(), and getStreamDestinations().