26 #include <boost/algorithm/string.hpp> 37 const std::vector<std::string> EvFDaqDirector::MergeTypeNames_ = {
"",
"DAT",
"PB",
"JSNDATA"};
40 : base_dir_(
pset.getUntrackedParameter<
std::
string>(
"baseDir")),
41 bu_base_dir_(
pset.getUntrackedParameter<
std::
string>(
"buBaseDir")),
43 bu_base_dirs_nSources_(
pset.getUntrackedParameter<
std::
vector<
int>>(
"buBaseDirsNumStreams")),
44 run_(
pset.getUntrackedParameter<unsigned
int>(
"runNumber")),
45 useFileBroker_(
pset.getUntrackedParameter<
bool>(
"useFileBroker")),
46 fileBrokerHostFromCfg_(
pset.getUntrackedParameter<
bool>(
"fileBrokerHostFromCfg",
false)),
47 fileBrokerHost_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerHost",
"InValid")),
48 fileBrokerPort_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerPort",
"8080")),
49 fileBrokerKeepAlive_(
pset.getUntrackedParameter<
bool>(
"fileBrokerKeepAlive",
true)),
50 fileBrokerUseLocalLock_(
pset.getUntrackedParameter<
bool>(
"fileBrokerUseLocalLock",
true)),
51 fuLockPollInterval_(
pset.getUntrackedParameter<unsigned
int>(
"fuLockPollInterval", 2000)),
52 outputAdler32Recheck_(
pset.getUntrackedParameter<
bool>(
"outputAdler32Recheck",
false)),
53 directorBU_(
pset.getUntrackedParameter<
bool>(
"directorIsBU",
false)),
54 hltSourceDirectory_(
pset.getUntrackedParameter<
std::
string>(
"hltSourceDirectory",
"")),
58 fu_readwritelock_fd_(-1),
59 fulocal_rwlock_fd_(-1),
60 fulocal_rwlock_fd2_(-1),
61 bu_w_lock_stream(nullptr),
62 bu_r_lock_stream(nullptr),
63 fu_rw_lock_stream(nullptr),
64 dirManager_(base_dir_),
66 bu_w_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, 0)),
67 bu_r_flk(make_flock(F_RDLCK, SEEK_SET, 0, 0, 0)),
68 bu_w_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
69 bu_r_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
70 fu_rw_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, getpid())),
71 fu_rw_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, getpid())) {
79 gethostname(hostname, 32);
82 char* fuLockPollIntervalPtr = std::getenv(
"FFF_LOCKPOLLINTERVAL");
83 if (fuLockPollIntervalPtr) {
94 char* fileBrokerParamPtr = std::getenv(
"FFF_USEFILEBROKER");
95 if (fileBrokerParamPtr) {
108 if (
stat(
"/etc/appliance/bus.config", &
buf) == 0) {
113 throw cms::Exception(
"EvFDaqDirector") <<
"No file service or BU data address information";
116 <<
"fileBrokerHostFromCfg must be set to true if fileBrokerHost parameter is not valid or empty";
124 char* startFromLSPtr = std::getenv(
"FFF_START_LUMISECTION");
125 if (startFromLSPtr) {
135 char* fileBrokerUseLockParamPtr = std::getenv(
"FFF_FILEBROKERUSELOCALLOCK");
136 if (fileBrokerUseLockParamPtr) {
139 edm::LogInfo(
"EvFDaqDirector") <<
"Setting fileBrokerUseLocalLock parameter by environment string: " 154 <<
" Error while setting number of sources: size mismatch with BU base directory vector";
163 std::stringstream
ss;
164 ss <<
"run" << std::setfill(
'0') << std::setw(6) <<
run_;
166 ss = std::stringstream();
172 ss = std::stringstream();
179 int retval =
mkdir(
base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
180 if (retval != 0 && errno != EEXIST) {
182 <<
" Error checking for base dir -: " <<
base_dir_ <<
" mkdir error:" << strerror(errno);
187 retval =
mkdir(
run_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IRWXO | S_IXOTH);
188 if (retval != 0 && errno != EEXIST) {
190 <<
" Error creating run dir -: " <<
run_dir_ <<
" mkdir error:" << strerror(errno);
198 open(fulocal_lock_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
201 <<
" Error creating/opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
202 chmod(fulocal_lock_.c_str(), 0777);
206 open(fulocal_lock_.c_str(), O_RDWR, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
209 <<
" Error opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
221 if (retval != 0 && errno != EEXIST) {
223 <<
" Error creating bu run dir -: " <<
bu_run_dir_ <<
" mkdir error:" << strerror(errno);
227 if (retval != 0 && errno != EEXIST) {
229 <<
" Error creating bu run open dir -: " <<
bu_run_open_dir_ <<
" mkdir error:" << strerror(errno);
233 bu_writelock_fd_ = open(bulockfile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
235 edm::LogWarning(
"EvFDaqDirector") <<
"problem with creating filedesc for buwritelock -: " << strerror(errno);
240 edm::LogWarning(
"EvFDaqDirector") <<
"Error creating write lock stream -: " << strerror(errno);
254 retval =
mkdir(tmphltdir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
255 if (retval != 0 && errno != EEXIST)
257 <<
" Error creating bu run dir -: " << hltdir <<
" mkdir error:" << strerror(errno);
259 std::filesystem::copy_file(
hltSourceDirectory_ +
"/HltConfig.py", tmphltdir +
"/HltConfig.py");
260 std::filesystem::copy_file(
hltSourceDirectory_ +
"/fffParameters.jsn", tmphltdir +
"/fffParameters.jsn");
262 std::string optfiles[3] = {
"hltinfo",
"blacklist",
"whitelist"};
263 for (
auto& optfile : optfiles) {
265 std::filesystem::copy_file(
hltSourceDirectory_ +
"/" + optfile, tmphltdir +
"/" + optfile);
270 std::filesystem::rename(tmphltdir, hltdir);
278 auto checkExists = [=](
std::string const& bu_base_dir) ->
void {
279 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
280 if (retval != 0 && errno != EEXIST) {
282 <<
" Error checking for bu base dir -: " << bu_base_dir <<
" mkdir error:" << strerror(errno);
286 auto waitForDir = [=](
std::string const& bu_base_dir) ->
void {
291 stat(bu_base_dir.c_str(), &statbuf);
292 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
293 if (retval != 0 && errno != EEXIST) {
299 throw cms::Exception(
"DaqDirector") <<
" Error checking for bu base dir after 1 minute -: " << bu_base_dir
300 <<
" mkdir error:" << strerror(errno);
309 checkExists(check_dir);
326 std::stringstream sstp;
333 if (!
stat(defPath.c_str(), &statbuf))
334 edm::LogInfo(
"EvFDaqDirector") <<
"found JSD file in ramdisk -: " << defPath;
337 std::string defPathSuffix =
"src/EventFilter/Utilities/plugins/budef.jsd";
338 defPath =
std::string(std::getenv(
"CMSSW_BASE")) +
"/" + defPathSuffix;
339 if (
stat(defPath.c_str(), &statbuf)) {
340 defPath =
std::string(std::getenv(
"CMSSW_RELEASE_BASE")) +
"/" + defPathSuffix;
341 if (
stat(defPath.c_str(), &statbuf)) {
342 defPath = defPathSuffix;
348 DataPointDefinition::getDataPointDefinitionFor(defPath,
dpd_, &defLabel);
355 boost::system::error_code ec;
356 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
382 "Service used for file locking arbitration and for propagating information between other EvF components");
383 desc.addUntracked<
std::string>(
"baseDir",
".")->setComment(
"Local base directory for run output");
384 desc.addUntracked<
std::string>(
"buBaseDir",
".")->setComment(
"BU base ramdisk directory ");
385 desc.addUntracked<std::vector<std::string>>(
"buBaseDirsAll", std::vector<std::string>())
386 ->setComment(
"BU base ramdisk directories for multi-file DAQSource models");
387 desc.addUntracked<std::vector<int>>(
"buBaseDirsNumStreams", std::vector<int>())
388 ->setComment(
"Number of streams for each BU base ramdisk directories for multi-file DAQSource models");
389 desc.addUntracked<
unsigned int>(
"runNumber", 0)->setComment(
"Run Number in ramdisk to open");
390 desc.addUntracked<
bool>(
"useFileBroker",
false)
391 ->setComment(
"Use BU file service to grab input data instead of NFS file locking");
392 desc.addUntracked<
bool>(
"fileBrokerHostFromCfg",
true)
393 ->setComment(
"Allow service to discover BU address from hltd configuration");
394 desc.addUntracked<
std::string>(
"fileBrokerHost",
"InValid")->setComment(
"BU file service host.");
395 desc.addUntracked<
std::string>(
"fileBrokerPort",
"8080")->setComment(
"BU file service port");
396 desc.addUntracked<
bool>(
"fileBrokerKeepAlive",
true)
397 ->setComment(
"Use keep alive to avoid using large number of sockets");
398 desc.addUntracked<
bool>(
"fileBrokerUseLocalLock",
true)
399 ->setComment(
"Use local lock file to synchronize appearance of index and EoLS file markers for hltd");
400 desc.addUntracked<
unsigned int>(
"fuLockPollInterval", 2000)
401 ->setComment(
"Lock polling interval in microseconds for the input directory file lock");
402 desc.addUntracked<
bool>(
"outputAdler32Recheck",
false)
403 ->setComment(
"Check Adler32 of per-process output files while micro-merging");
404 desc.addUntracked<
bool>(
"directorIsBU",
false)->setComment(
"BU director mode used for testing");
405 desc.addUntracked<
std::string>(
"hltSourceDirectory",
"")->setComment(
"BU director mode source directory");
407 ->setComment(
"Name of merging PSet to look for merging type definitions for streams");
408 descriptions.
add(
"EvFDaqDirector",
desc);
434 edm::LogWarning(
"EvFDaqDirector") <<
" Handles to check for files to delete were not set by the input source...";
548 int retval =
remove(
filename.c_str());
551 <<
". error = " << strerror(errno);
557 uint16_t& rawHeaderSize,
559 bool& setExceptionState) {
564 int lock_attempts = 0;
565 long total_lock_attempts = 0;
571 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
572 if (stopFileCheck == 0)
578 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
582 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 588 timeval ts_lockbegin;
589 gettimeofday(&ts_lockbegin,
nullptr);
591 while (retval == -1) {
600 if (lock_attempts > 5000000 || errno == 116) {
603 <<
"Stale lock file handle. Checking if run directory and fu.lock file are present" << std::endl;
605 edm::LogWarning(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 seconds. Checking if run directory and " 606 "fu.lock file are present -: errno " 607 << errno <<
":" << strerror(errno) << std::endl;
610 edm::LogWarning(
"EvFDaqDirector") <<
"Detected local EoLS for lumisection " <<
ls;
622 if (total_lock_attempts > 5 * 60000000) {
623 edm::LogError(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 minutes. Stopping polling activity.";
629 gettimeofday(&ts_lockend,
nullptr);
630 long deltat = (ts_lockend.tv_usec - ts_lockbegin.tv_usec) + (ts_lockend.tv_sec - ts_lockbegin.tv_sec) * 1000000;
632 lockWaitTime = deltat;
639 gettimeofday(&ts_lockend, 0);
643 int fu_readwritelock_fd2 = open(
fulockfile_.c_str(), O_RDWR, S_IRWXU);
644 if (fu_readwritelock_fd2 == -1)
646 <<
" create. error:" << strerror(errno);
648 FILE* fu_rw_lock_stream2 = fdopen(fu_readwritelock_fd2,
"r+");
651 if (fu_rw_lock_stream2 !=
nullptr) {
655 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
659 fscanf(fu_rw_lock_stream2,
"%u %u", &readLs, &
readIndex);
662 unsigned int currentLs = readLs;
663 bool bumpedOk =
false;
666 if (
ls &&
ls + 1 < currentLs)
670 bumpedOk =
bumpFile(readLs,
readIndex, nextFile, fsize, rawHeaderSize, stopFileLS, setExceptionState);
672 if (
ls && readLs > currentLs && currentLs >
ls) {
674 readLs = currentLs =
ls;
679 if (
ls == 0 && readLs > currentLs) {
694 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
696 ftruncate(fu_readwritelock_fd2, 0);
698 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex + 1);
699 fflush(fu_rw_lock_stream2);
700 fsync(fu_readwritelock_fd2);
702 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex + 1;
705 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
706 setExceptionState =
true;
709 }
else if (currentLs < readLs) {
711 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
713 ftruncate(fu_readwritelock_fd2, 0);
715 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex);
716 fflush(fu_rw_lock_stream2);
717 fsync(fu_readwritelock_fd2);
718 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex;
721 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
722 setExceptionState =
true;
727 edm::LogError(
"EvFDaqDirector") <<
"seek on fu read/write lock for reading failed with error " 731 edm::LogError(
"EvFDaqDirector") <<
"fu read/write lock stream is invalid " << strerror(errno);
733 fclose(fu_rw_lock_stream2);
736 timeval ts_preunlock;
737 gettimeofday(&ts_preunlock, 0);
738 int locked_period_int = ts_preunlock.tv_sec - ts_lockend.tv_sec;
739 double locked_period = locked_period_int + double(ts_preunlock.tv_usec - ts_lockend.tv_usec) / 1000000;
750 edm::LogError(
"EvFDaqDirector") <<
"Error unlocking the fu.lock " << strerror(errno);
753 edm::LogDebug(
"EvFDaqDirector") <<
"Waited during lock -: " << locked_period <<
" seconds";
756 if (fileStatus ==
noFile) {
761 if (stopFileLS >= 0 && (
int)
ls > stopFileLS) {
762 edm::LogInfo(
"EvFDaqDirector") <<
"Reached maximum lumisection set by hltd";
770 std::ifstream ij(BUEoLSFile);
774 if (!
reader.parse(ij, deserializeRoot)) {
775 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" << BUEoLSFile;
781 dp.deserialize(deserializeRoot);
789 while (!
def.empty()) {
791 if (
def.find(
'/') == 0)
799 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
804 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
806 for (
unsigned int i = 0;
i < eolsDpd.
getNames().size();
i++)
807 if (eolsDpd.
getNames().at(
i) ==
"NFiles")
813 if (
def.size() <= 1 ||
def.find(
'/') == std::string::npos) {
824 edm::LogError(
"EvFDaqDirector") <<
" error reading number of files from BU JSON -: " << BUEoLSFile;
827 return std::stoi(
data);
834 uint16_t& rawHeaderSize,
836 bool& setExceptionState) {
848 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
852 std::stringstream
ss;
856 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
858 nextFile = nextFileJson;
867 nextFile = nextFileRaw;
873 if (
stat(BUEoLSFile.c_str(), &
buf) == 0) {
875 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
877 nextFile = nextFileJson;
882 nextFile = nextFileRaw;
887 if (indexFilesInLS < 0)
892 if ((
int)
index < indexFilesInLS) {
895 <<
"Potential miss of index file in LS -: " <<
ls <<
". Missing " << nextFile <<
" because " 896 << indexFilesInLS - 1 <<
" is the highest index expected. Will not update fu.lock file";
897 setExceptionState =
true;
906 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
911 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
914 nextFile = nextFileJson;
919 nextFile = nextFileRaw;
931 edm::LogError(
"EvFDaqDirector") <<
"Error creating fu read/write lock stream " << strerror(errno);
933 edm::LogInfo(
"EvFDaqDirector") <<
"Initializing FU LOCK FILE";
942 open(
fulockfile_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
949 <<
" create:" <<
create <<
" error:" << strerror(errno);
955 edm::LogError(
"EvFDaqDirector") <<
"problem with opening fuwritelock file stream -: " << strerror(errno);
986 if (checkIfExists ==
false ||
stat(fuBoLS.c_str(), &
buf) != 0) {
987 int bol_fd = open(fuBoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
993 const uint32_t currentLumiSection,
996 if (currentLumiSection > 0) {
1003 open(fuEoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
1009 }
else if (doCreateBoLS) {
1016 uint16_t& rawHeaderSize,
1017 uint16_t& rawDataType,
1018 uint32_t& lsFromHeader,
1019 int32_t& eventsFromHeader,
1020 int64_t& fileSizeFromHeader,
1026 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1029 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1041 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1043 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1044 if (errno == ENOENT)
1060 if (frd_version == 0) {
1062 if (requireHeader) {
1063 edm::LogError(
"EvFDaqDirector") <<
"no header or invalid version string found in:" << rawSourcePath;
1068 lseek(
infile, 0, SEEK_SET);
1071 eventsFromHeader = -1;
1072 fileSizeFromHeader = -1;
1074 }
else if (frd_version == 1) {
1081 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1082 <<
" v:" << frd_version;
1089 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1090 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1093 }
else if (frd_version == 2) {
1100 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1101 <<
" v:" << frd_version;
1108 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1109 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1125 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unable to read " <<
path <<
" : " << strerror(errno);
1130 if ((
size_t)sz_read < buf_sz) {
1131 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - file smaller than header: " <<
path;
1141 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1142 edm::LogWarning(
"EvFDaqDirector") <<
"rawFileHasHeader - failed to open input file -: " << rawSourcePath <<
" : " 1153 if (frd_version == 1) {
1160 }
else if (frd_version == 2) {
1168 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unknown version: " << frd_version;
1177 uint16_t& rawHeaderSize,
1178 int64_t& fileSizeFromHeader,
1182 bool requireHeader) {
1187 size_t pos = 0, n_tokens = 0;
1188 while (n_tokens++ < 3 && (
pos = jsonStem.find(
'_',
pos + 1)) != std::string::npos) {
1192 std::ostringstream fileNameWithPID;
1194 fileNameWithPID << reducedJsonStem <<
"_pid" << std::setfill(
'0') << std::setw(5) <<
pid_ <<
".jsn";
1198 LogDebug(
"EvFDaqDirector") <<
"RAW parse -: " << rawSourcePath <<
" and JSON create " << jsonDestPath;
1202 int32_t nbEventsWrittenRaw;
1203 int64_t fileSizeFromRaw;
1204 uint16_t rawDataType;
1222 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1223 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1224 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1225 if (errno == EEXIST) {
1226 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - destination file already exists -: " << jsonDestPath
1230 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file -: " << jsonDestPath <<
" : " 1232 struct stat out_stat;
1233 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1235 <<
"grabNextJsonFromRaw - output file possibly got created with error, deleting and retry -: " 1237 if (unlink(jsonDestPath.c_str()) == -1) {
1239 <<
"grabNextJsonFromRaw - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1242 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1243 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file (on retry) -: " 1244 << jsonDestPath <<
" : " << strerror(errno);
1249 std::stringstream
ss;
1250 ss <<
"{\"data\":[" << nbEventsWrittenRaw <<
"," << fileSizeFromRaw <<
",\"" << rawSourcePath <<
"\"]}";
1254 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to write to output file file -: " << jsonDestPath
1255 <<
" : " << strerror(errno);
1259 if (serverLS && serverLS != lsFromRaw)
1260 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - mismatch in expected (server) LS " << serverLS
1261 <<
" and raw file header LS " << lsFromRaw;
1263 fileSizeFromHeader = fileSizeFromRaw;
1264 return nbEventsWrittenRaw;
1269 int64_t& fileSizeFromJson,
1274 std::ostringstream fileNameWithPID;
1275 fileNameWithPID <<
std::filesystem::path(rawSourcePath).stem().string() <<
"_pid" << std::setfill(
'0')
1276 << std::setw(5) <<
pid_ <<
".jsn";
1281 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1285 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1286 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file -: " << jsonSourcePath <<
" : " 1288 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1289 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file (on retry) -: " 1290 << jsonSourcePath <<
" : " << strerror(errno);
1291 if (errno == ENOENT)
1297 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1298 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1299 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1300 if (errno == EEXIST) {
1301 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - destination file already exists -: " << jsonDestPath
1306 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file -: " << jsonDestPath <<
" : " 1308 struct stat out_stat;
1309 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1311 <<
"grabNextJsonFile - output file possibly got created with error, deleting and retry -: " << jsonDestPath;
1312 if (unlink(jsonDestPath.c_str()) == -1) {
1314 <<
"grabNextJsonFile - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1317 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1318 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file (on retry) -: " 1319 << jsonDestPath <<
" : " << strerror(errno);
1325 const std::size_t buf_sz = 512;
1326 std::size_t tot_written = 0;
1327 std::unique_ptr<char[]>
buf(
new char[buf_sz]);
1329 ssize_t sz, sz_read = 1, sz_write;
1330 while (sz_read > 0 && (sz_read = ::
read(
infile,
buf.get(), buf_sz)) > 0) {
1333 assert(sz_read - sz_write > 0);
1334 if ((sz = ::
write(
outfile,
buf.get() + sz_write, sz_read - sz_write)) < 0) {
1341 }
while (sz_write < sz_read);
1346 if (tot_written > 0) {
1348 if (unlink(jsonSourcePath.c_str()) == -1) {
1349 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to remove -: " << jsonSourcePath <<
" : " 1354 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to copy json file or file was empty -: " 1363 std::stringstream
ss;
1366 if (tot_written <= buf_sz) {
1371 std::ifstream ij(jsonDestPath);
1373 }
catch (std::filesystem::filesystem_error
const& ex) {
1374 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - FILESYSTEM ERROR CAUGHT -: " << ex.what();
1380 if (tot_written <= buf_sz)
1382 edm::LogError(
"EvFDaqDirector") <<
"Failed to deserialize JSON file -: " << jsonDestPath <<
"\nERROR:\n" 1383 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1390 dp.deserialize(deserializeRoot);
1394 if (
i <
dp.getData().size()) {
1401 if (!
dp.getData().empty())
1405 <<
"grabNextJsonFile - " 1406 <<
" error reading number of events from BU JSON; No input value. data -: " <<
data;
1412 fileSizeFromJson = -1;
1415 if (
i <
dp.getData().size()) {
1418 fileSizeFromJson = std::stol(dataSize);
1421 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of Bytes from BU JSON. " 1422 <<
"Input value is -: " << dataSize;
1428 return std::stoi(
data);
1429 }
catch (
const std::out_of_range&
e) {
1430 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of events from BU JSON. " 1431 <<
"Input value is -: " <<
data;
1432 }
catch (
const std::invalid_argument&
e) {
1433 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - argument error parsing events from BU JSON. " 1434 <<
"Input value is -: " <<
data;
1435 }
catch (std::runtime_error
const&
e) {
1437 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - std::runtime_error exception -: " <<
e.what();
1441 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED! -: " <<
e.what();
1444 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED!";
1457 std::ostringstream fileNameWithPID;
1458 fileNameWithPID << jsonSourcePath.stem().string() <<
"_pid" << std::setfill(
'0') << std::setw(5) << getpid()
1460 jsonDestPath /= fileNameWithPID.str();
1462 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1465 }
catch (std::filesystem::filesystem_error
const& ex) {
1467 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1477 }
catch (std::filesystem::filesystem_error
const& ex) {
1479 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1482 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile std::exception CAUGHT -: " << ex.what();
1485 std::ifstream ij(jsonDestPath);
1489 std::stringstream
ss;
1491 if (!
reader.parse(
ss.str(), deserializeRoot)) {
1492 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile Failed to deserialize JSON file -: " << jsonDestPath
1494 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1496 throw std::runtime_error(
"Cannot deserialize input JSON file");
1502 dp.deserialize(deserializeRoot);
1506 if (
i <
dp.getData().size()) {
1512 if (!
dp.getData().empty())
1516 <<
" error reading number of events from BU JSON -: No input value " <<
data;
1518 return std::stoi(
data);
1519 }
catch (std::filesystem::filesystem_error
const& ex) {
1522 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1523 }
catch (std::runtime_error
const&
e) {
1526 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile runtime Exception -: " <<
e.what();
1527 }
catch (
const std::out_of_range&) {
1528 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile error parsing number of events from BU JSON. " 1529 <<
"Input value is -: " <<
data;
1530 }
catch (
const std::invalid_argument&) {
1531 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile argument error parsing events from BU JSON. " 1532 <<
"Input value is -: " <<
data;
1536 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile SOME OTHER EXCEPTION OCCURED!!!! -: " <<
e.what();
1545 uint32_t& closedServerLS,
1551 serverError =
false;
1553 boost::system::error_code ec;
1561 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1567 boost::asio::streambuf request;
1568 std::ostream request_stream(&request);
1571 std::stringstream spath;
1572 spath <<
path <<
"&stopls=" << maxLS;
1576 request_stream <<
"GET " <<
path <<
" HTTP/1.1\r\n";
1578 request_stream <<
"Accept: */*\r\n";
1579 request_stream <<
"Connection: keep-alive\r\n\r\n";
1584 edm::LogInfo(
"EvFDaqDirector") <<
"reconnecting socket on received connection_reset";
1588 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1594 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::write error -:" << ec;
1599 boost::asio::streambuf response;
1600 boost::asio::read_until(*
socket_, response,
"\r\n", ec);
1602 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1607 std::istream response_stream(&response);
1610 response_stream >> http_version;
1612 response_stream >> serverHttpStatus;
1615 std::getline(response_stream, status_message);
1616 if (!response_stream || http_version.substr(0, 5) !=
"HTTP/") {
1621 if (serverHttpStatus != 200) {
1622 edm::LogWarning(
"EvFDaqDirector") <<
"Response returned with status code " << serverHttpStatus;
1629 while (std::getline(response_stream,
header) &&
header !=
"\r") {
1633 std::map<std::string, std::string> serverMap;
1634 while (std::getline(response_stream, fileInfo) && fileInfo !=
"\r") {
1635 auto pos = fileInfo.find(
'=');
1636 if (
pos == std::string::npos)
1638 auto stitle = fileInfo.substr(0,
pos);
1639 auto svalue = fileInfo.substr(
pos + 1);
1640 serverMap[stitle] = svalue;
1644 auto server_version = serverMap.find(
"version");
1645 assert(server_version != serverMap.end());
1647 auto server_run = serverMap.find(
"runnumber");
1648 assert(server_run != serverMap.end());
1651 auto server_state = serverMap.find(
"state");
1652 assert(server_state != serverMap.end());
1654 auto server_eols = serverMap.find(
"lasteols");
1655 assert(server_eols != serverMap.end());
1657 auto server_ls = serverMap.find(
"lumisection");
1659 int version_maj = 1;
1660 int version_min = 0;
1661 int version_rev = 0;
1663 auto* s_ptr = server_version->second.c_str();
1664 if (!server_version->second.empty() && server_version->second[0] ==
'"')
1666 auto res = sscanf(s_ptr,
"%d.%d.%d", &version_maj, &version_min, &version_rev);
1668 res = sscanf(s_ptr,
"%d.%d", &version_maj, &version_min);
1670 res = sscanf(s_ptr,
"%d", &version_maj);
1673 edm::LogWarning(
"EvFDaqDirector") <<
"Can not parse server version " << server_version->second;
1680 if (server_ls != serverMap.end())
1683 serverLS = closedServerLS + 1;
1686 if (s_state ==
"STARTING")
1688 auto server_file = serverMap.find(
"file");
1689 assert(server_file == serverMap.end());
1691 edm::LogInfo(
"EvFDaqDirector") <<
"Got STARTING notification with last EOLS " << closedServerLS;
1692 }
else if (s_state ==
"READY") {
1693 auto server_file = serverMap.find(
"file");
1694 if (server_file == serverMap.end()) {
1696 if (serverLS <= closedServerLS)
1697 serverLS = closedServerLS + 1;
1700 <<
"Got READY notification with last EOLS " << closedServerLS <<
" and no new file";
1704 auto server_fileprefix = serverMap.find(
"fileprefix");
1706 if (server_fileprefix != serverMap.end()) {
1707 auto pssize = server_fileprefix->second.size();
1708 if (pssize > 1 && server_fileprefix->second[0] ==
'"' && server_fileprefix->second[pssize - 1] ==
'"')
1709 fileprefix = server_fileprefix->second.substr(1, pssize - 2);
1711 fileprefix = server_fileprefix->second;
1715 auto ssize = server_file->second.size();
1716 if (ssize > 1 && server_file->second[0] ==
'"' && server_file->second[ssize - 1] ==
'"')
1717 filestem = server_file->second.substr(1, ssize - 2);
1719 filestem = server_file->second;
1720 assert(!filestem.empty());
1721 if (version_maj > 1) {
1722 nextFileRaw =
bu_run_dir_ +
"/" + fileprefix + filestem +
".raw";
1723 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1727 nextFileRaw =
bu_run_dir_ +
"/" + filestem +
".raw";
1728 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1729 nextFileJson = filestem +
".jsn";
1733 edm::LogInfo(
"EvFDaqDirector") <<
"Got READY notification with last EOLS " << closedServerLS <<
" new LS " 1734 << serverLS <<
" file:" << filestem;
1736 }
else if (s_state ==
"EOLS") {
1737 serverLS = closedServerLS + 1;
1738 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOLS notification with last EOLS " << closedServerLS;
1740 }
else if (s_state ==
"EOR") {
1742 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOR notification with last EOLS " << closedServerLS;
1744 }
else if (s_state ==
"NORUN") {
1745 auto err_msg = serverMap.find(
"errormessage");
1746 if (err_msg != serverMap.end())
1747 edm::LogWarning(
"EvFDaqDirector") <<
"Server NORUN -:" << server_state->second <<
" : " << err_msg->second;
1752 }
else if (s_state ==
"ERROR") {
1753 auto err_msg = serverMap.find(
"errormessage");
1754 if (err_msg != serverMap.end())
1755 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second <<
" : " << err_msg->second;
1757 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second;
1761 edm::LogWarning(
"EvFDaqDirector") <<
"Unknown Server state -:" << server_state->second;
1770 if (ec != boost::asio::error::eof) {
1771 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1785 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
1787 edm::LogWarning(
"EvFDaqDirector") <<
"socket shutdown error -:" << ec;
1812 uint16_t& rawHeaderSize,
1813 int32_t& serverEventsInNewFile,
1814 int64_t& fileSizeFromMetadata,
1816 bool requireHeader) {
1824 int stopFileLS = -1;
1827 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
1828 if (stopFileCheck == 0)
1834 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
1838 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 1852 timeval ts_lockbegin;
1853 gettimeofday(&ts_lockbegin,
nullptr);
1856 uint32_t serverLS, closedServerLS;
1857 unsigned int serverHttpStatus;
1864 int maxLS = stopFileLS < 0 ? -1 :
std::max(stopFileLS, (
int)currentLumiSection);
1865 bool rawHeader =
false;
1867 serverHttpStatus, serverError, serverLS, closedServerLS, nextFileJson, nextFileRaw, rawHeader, maxLS);
1877 if (currentLumiSection == 0) {
1883 if (closedServerLS >= currentLumiSection) {
1885 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1890 bool fileFound =
true;
1895 nextFileRaw, rawFd, rawHeaderSize, fileSizeFromMetadata, fileFound, serverLS,
false, requireHeader);
1897 serverEventsInNewFile =
grabNextJsonFile(nextFileJson, nextFileRaw, fileSizeFromMetadata, fileFound);
1900 if (serverEventsInNewFile < 0 && rawFd != -1) {
1921 if (currentLumiSection == 0) {
1931 if (closedServerLS >= currentLumiSection) {
1934 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1942 else if (fileStatus ==
newFile) {
1945 }
else if (fileStatus ==
noFile) {
1949 edm::LogWarning(
"EvFDaqDirector") <<
"Server reported LS " << serverLS
1950 <<
" which is smaller than currently open LS " <<
ls <<
". Ignoring response";
1962 if (!std::filesystem::is_directory(openPath)) {
1963 LogDebug(
"EvFDaqDirector") <<
"<open> FU dir not found. Creating... -:" << openPath.string();
1964 std::filesystem::create_directories(openPath);
1969 std::ifstream ij(
file);
1973 if (!
reader.parse(ij, deserializeRoot)) {
1974 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" <<
file;
1978 int ret = deserializeRoot.
get(
"lastLS",
"").
asInt();
1986 unsigned int lscount = 1;
1988 std::stringstream
ss;
1989 ss << fileprefix << std::setfill(
'0') << std::setw(4) << lscount <<
"_EoLS.jsn";
1999 int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
2000 close(proc_flag_fd);
2003 struct flock
EvFDaqDirector::make_flock(short type, short whence, off_t start, off_t len, pid_t pid) {
int def(FILE *, FILE *, int)
unsigned int nConcurrentLumis_
std::vector< std::string > bu_base_dirs_all_
LuminosityBlockNumber_t luminosityBlock() const
std::string protocolBufferHistogramFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
std::string bolsFileName(const unsigned int run, const unsigned int ls)
std::string streamerDataChecksumFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
void watchPreallocate(Preallocate::slot_type const &iSlot)
boost::asio::io_service io_service_
bool rawFileHasHeader(std::string const &rawSourcePath, uint16_t &rawHeaderSize)
std::string getOpenInputJsonFilePath(const unsigned int ls, const unsigned int index) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
def create(alignables, pedeDump, additionalData, outputFile, config)
std::string getOpenOutputJsonFilePath(const unsigned int ls, std::string const &stream) const
std::string getInputJsonFilePath(const unsigned int ls, const unsigned int index) const
static bool checkFileRead(char *buf, int infile, std::size_t buf_sz, std::string const &path)
jsoncollector::DataPointDefinition * dpd_
std::string getOpenDatFilePath(const unsigned int ls, std::string const &stream) const
void accumulateFileSize(unsigned int lumi, unsigned long fileSize)
std::string getFFFParamsFilePathOnBU() const
std::unique_ptr< boost::asio::ip::tcp::resolver > resolver_
void watchPreGlobalEndLumi(PreGlobalEndLumi::slot_type const &iSlot)
ret
prodAgent to be discontinued
std::string getRawFilePath(const unsigned int ls, const unsigned int index) const
std::string inputRawFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
volatile std::atomic< bool > shutdown_flag
pthread_mutex_t init_lock_
Value get(UInt index, const Value &defaultValue) const
std::string getEoLSFilePathOnFU(const unsigned int ls) const
void removeFile(std::string)
bool lumisectionDiscarded(unsigned int ls)
Log< level::Error, false > LogError
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
std::string getOpenInitFilePath(std::string const &stream) const
std::string getRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
bool fileBrokerHostFromCfg_
bool isExceptionOnData(unsigned int ls)
std::string getOpenProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
unsigned long previousFileSize_
static std::string to_string(const XMLCh *ch)
std::unique_ptr< boost::asio::ip::tcp::resolver::iterator > endpoint_iterator_
void createRunOpendirMaybe()
std::string getInitTempFilePath(std::string const &stream) const
std::string getEoRFilePathOnFU() const
std::string hltSourceDirectory_
unsigned int startFromLS_
static int parseFRDFileHeader(std::string const &rawSourcePath, int &rawFd, uint16_t &rawHeaderSize, uint16_t &rawDataType, uint32_t &lsFromHeader, int32_t &eventsFromHeader, int64_t &fileSizeFromHeader, bool requireHeader, bool retry, bool closeFile)
std::string getEoLSFilePathOnBU(const unsigned int ls) const
std::mutex * fileDeleteLockPtr_
std::string getMergedDatFilePath(const unsigned int ls, std::string const &stream) const
FileStatus getNextFromFileBroker(const unsigned int currentLumiSection, unsigned int &ls, std::string &nextFile, int &rawFd, uint16_t &rawHeaderSize, int32_t &serverEventsInNewFile_, int64_t &fileSize, uint64_t &thisLockWaitTimeUs, bool requireHeader=true)
std::string streamerDataFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
std::string getRunOpenDirPath() const
std::string getDatFilePath(const unsigned int ls, std::string const &stream) const
std::string getMergedDatChecksumFilePath(const unsigned int ls, std::string const &stream) const
std::unique_ptr< boost::asio::ip::tcp::socket > socket_
std::string inputJsonFileName(const unsigned int run, const unsigned int ls, const unsigned int index)
std::string stopFilePath_
std::string getProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::string getMergedRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
void tryInitializeFuLockFile()
unsigned int stop_ls_override_
int grabNextJsonFileAndUnlock(std::filesystem::path const &jsonSourcePath)
std::string streamerJsonFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string input_throttled_file_
std::string getBoLSFilePathOnFU(const unsigned int ls) const
std::string eorFileName(const unsigned int run)
int readLastLSEntry(std::string const &file)
std::string getMergedProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
std::unique_ptr< boost::asio::ip::tcp::resolver::query > query_
std::string stopFilePathPid_
LuminosityBlockID const & luminosityBlockID() const
unsigned int eolsNFilesIndex_
std::string & baseRunDir()
void watchPreGlobalBeginRun(PreGlobalBeginRun::slot_type const &iSlot)
std::string getInitFilePath(std::string const &stream) const
void createProcessingNotificationMaybe() const
Log< level::Info, false > LogInfo
void openFULockfileStream(bool create)
std::string getOutputJsonFilePath(const unsigned int ls, std::string const &stream) const
int getNFilesFromEoLS(std::string BUEoLSFile)
FileStatus updateFuLock(unsigned int &ls, std::string &nextFile, uint32_t &fsize, uint16_t &rawHeaderSize, uint64_t &lockWaitTime, bool &setExceptionState)
void preBeginRun(edm::GlobalContext const &globalContext)
std::string rootHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string initFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
unsigned long long uint64_t
void preGlobalEndLumi(edm::GlobalContext const &globalContext)
std::vector< std::string > const & getNames() const
bool bumpFile(unsigned int &ls, unsigned int &index, std::string &nextFile, uint32_t &fsize, uint16_t &rawHeaderSize, int maxLS, bool &setExceptionState)
std::string getOpenRootHistogramFilePath(const unsigned int ls, std::string const &stream) const
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
std::string getEoRFileName() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
def remove(d, key, TELL=False)
evf::FastMonitoringService * fms_
std::string rootHistogramFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
std::list< std::pair< int, std::unique_ptr< InputFile > > > * filesToDeletePtr_
std::string getEoRFilePath() const
std::string getOpenRawFilePath(const unsigned int ls, const unsigned int index) const
std::string findHighestRunDir()
char data[epos_bytes_allocation]
bool fileBrokerUseLocalLock_
void postEndRun(edm::GlobalContext const &globalContext)
std::string discard_ls_filestem_
Unserialize a JSON document into a Value.
unsigned int getLumisectionToStart() const
int grabNextJsonFile(std::string const &jsonSourcePath, std::string const &rawSourcePath, int64_t &fileSizeFromJson, bool &fileFound)
std::string fileBrokerPort_
void createLumiSectionFiles(const uint32_t lumiSection, const uint32_t currentLumiSection, bool doCreateBoLS, bool doCreateEoLS)
std::string initTempFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
EvFDaqDirector::FileStatus contactFileBroker(unsigned int &serverHttpStatus, bool &serverState, uint32_t &serverLS, uint32_t &closedServerLS, std::string &nextFileJson, std::string &nextFileRaw, bool &rawHeader, int maxLS)
void preallocate(edm::service::SystemBounds const &bounds)
Log< level::Warning, false > LogWarning
std::vector< int > bu_base_dirs_nSources_
void createBoLSFile(const uint32_t lumiSection, bool checkIfExists) const
bool fileBrokerKeepAlive_
std::string fileBrokerHost_
std::string protocolBufferHistogramFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
unsigned int fuLockPollInterval_
int grabNextJsonFromRaw(std::string const &rawSourcePath, int &rawFd, uint16_t &rawHeaderSize, int64_t &fileSizeFromHeader, bool &fileFound, uint32_t serverLS, bool closeFile, bool requireHeader=true)
std::string eolsFileName(const unsigned int run, const unsigned int ls)
std::string streamerDataFileNameWithPid(const unsigned int run, const unsigned int ls, std::string const &stream)
std::string bu_run_open_dir_