26 #include <boost/algorithm/string.hpp> 27 #include <fmt/printf.h> 39 const std::vector<std::string> EvFDaqDirector::MergeTypeNames_ = {
"",
"DAT",
"PB",
"JSNDATA"};
42 : base_dir_(
pset.getUntrackedParameter<
std::
string>(
"baseDir")),
43 bu_base_dir_(
pset.getUntrackedParameter<
std::
string>(
"buBaseDir")),
45 bu_base_dirs_nSources_(
pset.getUntrackedParameter<
std::
vector<
int>>(
"buBaseDirsNumStreams")),
46 run_(
pset.getUntrackedParameter<unsigned
int>(
"runNumber")),
47 useFileBroker_(
pset.getUntrackedParameter<
bool>(
"useFileBroker")),
48 fileBrokerHostFromCfg_(
pset.getUntrackedParameter<
bool>(
"fileBrokerHostFromCfg",
false)),
49 fileBrokerHost_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerHost",
"InValid")),
50 fileBrokerPort_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerPort",
"8080")),
51 fileBrokerKeepAlive_(
pset.getUntrackedParameter<
bool>(
"fileBrokerKeepAlive",
true)),
52 fileBrokerUseLocalLock_(
pset.getUntrackedParameter<
bool>(
"fileBrokerUseLocalLock",
true)),
53 fuLockPollInterval_(
pset.getUntrackedParameter<unsigned
int>(
"fuLockPollInterval", 2000)),
54 outputAdler32Recheck_(
pset.getUntrackedParameter<
bool>(
"outputAdler32Recheck",
false)),
55 directorBU_(
pset.getUntrackedParameter<
bool>(
"directorIsBU",
false)),
56 hltSourceDirectory_(
pset.getUntrackedParameter<
std::
string>(
"hltSourceDirectory",
"")),
60 fu_readwritelock_fd_(-1),
61 fulocal_rwlock_fd_(-1),
62 fulocal_rwlock_fd2_(-1),
63 bu_w_lock_stream(nullptr),
64 bu_r_lock_stream(nullptr),
65 fu_rw_lock_stream(nullptr),
66 dirManager_(base_dir_),
68 bu_w_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, 0)),
69 bu_r_flk(make_flock(F_RDLCK, SEEK_SET, 0, 0, 0)),
70 bu_w_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
71 bu_r_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
72 fu_rw_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, getpid())),
73 fu_rw_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, getpid())) {
81 gethostname(hostname, 32);
84 char* fuLockPollIntervalPtr = std::getenv(
"FFF_LOCKPOLLINTERVAL");
85 if (fuLockPollIntervalPtr) {
96 char* fileBrokerParamPtr = std::getenv(
"FFF_USEFILEBROKER");
97 if (fileBrokerParamPtr) {
110 if (
stat(
"/etc/appliance/bus.config", &
buf) == 0) {
115 throw cms::Exception(
"EvFDaqDirector") <<
"No file service or BU data address information";
118 <<
"fileBrokerHostFromCfg must be set to true if fileBrokerHost parameter is not valid or empty";
126 char* startFromLSPtr = std::getenv(
"FFF_START_LUMISECTION");
127 if (startFromLSPtr) {
137 char* fileBrokerUseLockParamPtr = std::getenv(
"FFF_FILEBROKERUSELOCALLOCK");
138 if (fileBrokerUseLockParamPtr) {
141 edm::LogInfo(
"EvFDaqDirector") <<
"Setting fileBrokerUseLocalLock parameter by environment string: " 156 <<
" Error while setting number of sources: size mismatch with BU base directory vector";
165 std::stringstream
ss;
166 ss <<
"run" << std::setfill(
'0') << std::setw(6) <<
run_;
168 ss = std::stringstream();
174 ss = std::stringstream();
181 int retval =
mkdir(
base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
182 if (retval != 0 && errno != EEXIST) {
184 <<
" Error checking for base dir -: " <<
base_dir_ <<
" mkdir error:" << strerror(errno);
189 retval =
mkdir(
run_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IRWXO | S_IXOTH);
190 if (retval != 0 && errno != EEXIST) {
192 <<
" Error creating run dir -: " <<
run_dir_ <<
" mkdir error:" << strerror(errno);
200 open(fulocal_lock_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
203 <<
" Error creating/opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
204 chmod(fulocal_lock_.c_str(), 0777);
208 open(fulocal_lock_.c_str(), O_RDWR, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
211 <<
" Error opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
223 if (retval != 0 && errno != EEXIST) {
225 <<
" Error creating bu run dir -: " <<
bu_run_dir_ <<
" mkdir error:" << strerror(errno);
229 if (retval != 0 && errno != EEXIST) {
231 <<
" Error creating bu run open dir -: " <<
bu_run_open_dir_ <<
" mkdir error:" << strerror(errno);
235 bu_writelock_fd_ = open(bulockfile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
237 edm::LogWarning(
"EvFDaqDirector") <<
"problem with creating filedesc for buwritelock -: " << strerror(errno);
242 edm::LogWarning(
"EvFDaqDirector") <<
"Error creating write lock stream -: " << strerror(errno);
256 retval =
mkdir(tmphltdir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
257 if (retval != 0 && errno != EEXIST)
259 <<
" Error creating bu run dir -: " << hltdir <<
" mkdir error:" << strerror(errno);
261 std::filesystem::copy_file(
hltSourceDirectory_ +
"/HltConfig.py", tmphltdir +
"/HltConfig.py");
262 std::filesystem::copy_file(
hltSourceDirectory_ +
"/fffParameters.jsn", tmphltdir +
"/fffParameters.jsn");
264 std::string optfiles[3] = {
"hltinfo",
"blacklist",
"whitelist"};
265 for (
auto& optfile : optfiles) {
267 std::filesystem::copy_file(
hltSourceDirectory_ +
"/" + optfile, tmphltdir +
"/" + optfile);
272 std::filesystem::rename(tmphltdir, hltdir);
280 auto checkExists = [=](
std::string const& bu_base_dir) ->
void {
281 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
282 if (retval != 0 && errno != EEXIST) {
284 <<
" Error checking for bu base dir -: " << bu_base_dir <<
" mkdir error:" << strerror(errno);
288 auto waitForDir = [=](
std::string const& bu_base_dir) ->
void {
293 stat(bu_base_dir.c_str(), &statbuf);
294 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
295 if (retval != 0 && errno != EEXIST) {
301 throw cms::Exception(
"DaqDirector") <<
" Error checking for bu base dir after 1 minute -: " << bu_base_dir
302 <<
" mkdir error:" << strerror(errno);
311 checkExists(check_dir);
328 std::stringstream sstp;
335 if (!
stat(defPath.c_str(), &statbuf))
336 edm::LogInfo(
"EvFDaqDirector") <<
"found JSD file in ramdisk -: " << defPath;
339 std::string defPathSuffix =
"src/EventFilter/Utilities/plugins/budef.jsd";
340 defPath =
std::string(std::getenv(
"CMSSW_BASE")) +
"/" + defPathSuffix;
341 if (
stat(defPath.c_str(), &statbuf)) {
342 defPath =
std::string(std::getenv(
"CMSSW_RELEASE_BASE")) +
"/" + defPathSuffix;
343 if (
stat(defPath.c_str(), &statbuf)) {
344 defPath = defPathSuffix;
350 DataPointDefinition::getDataPointDefinitionFor(defPath,
dpd_, &defLabel);
357 boost::system::error_code ec;
358 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
384 "Service used for file locking arbitration and for propagating information between other EvF components");
385 desc.addUntracked<
std::string>(
"baseDir",
".")->setComment(
"Local base directory for run output");
386 desc.addUntracked<
std::string>(
"buBaseDir",
".")->setComment(
"BU base ramdisk directory ");
387 desc.addUntracked<std::vector<std::string>>(
"buBaseDirsAll", std::vector<std::string>())
388 ->setComment(
"BU base ramdisk directories for multi-file DAQSource models");
389 desc.addUntracked<std::vector<int>>(
"buBaseDirsNumStreams", std::vector<int>())
390 ->setComment(
"Number of streams for each BU base ramdisk directories for multi-file DAQSource models");
391 desc.addUntracked<
unsigned int>(
"runNumber", 0)->setComment(
"Run Number in ramdisk to open");
392 desc.addUntracked<
bool>(
"useFileBroker",
false)
393 ->setComment(
"Use BU file service to grab input data instead of NFS file locking");
394 desc.addUntracked<
bool>(
"fileBrokerHostFromCfg",
true)
395 ->setComment(
"Allow service to discover BU address from hltd configuration");
396 desc.addUntracked<
std::string>(
"fileBrokerHost",
"InValid")->setComment(
"BU file service host.");
397 desc.addUntracked<
std::string>(
"fileBrokerPort",
"8080")->setComment(
"BU file service port");
398 desc.addUntracked<
bool>(
"fileBrokerKeepAlive",
true)
399 ->setComment(
"Use keep alive to avoid using large number of sockets");
400 desc.addUntracked<
bool>(
"fileBrokerUseLocalLock",
true)
401 ->setComment(
"Use local lock file to synchronize appearance of index and EoLS file markers for hltd");
402 desc.addUntracked<
unsigned int>(
"fuLockPollInterval", 2000)
403 ->setComment(
"Lock polling interval in microseconds for the input directory file lock");
404 desc.addUntracked<
bool>(
"outputAdler32Recheck",
false)
405 ->setComment(
"Check Adler32 of per-process output files while micro-merging");
406 desc.addUntracked<
bool>(
"directorIsBU",
false)->setComment(
"BU director mode used for testing");
407 desc.addUntracked<
std::string>(
"hltSourceDirectory",
"")->setComment(
"BU director mode source directory");
409 ->setComment(
"Name of merging PSet to look for merging type definitions for streams");
410 descriptions.
add(
"EvFDaqDirector",
desc);
436 edm::LogWarning(
"EvFDaqDirector") <<
" Handles to check for files to delete were not set by the input source...";
550 int retval =
remove(
filename.c_str());
553 <<
". error = " << strerror(errno);
559 uint16_t& rawHeaderSize,
561 bool& setExceptionState) {
566 int lock_attempts = 0;
567 long total_lock_attempts = 0;
573 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
574 if (stopFileCheck == 0)
580 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
584 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 590 timeval ts_lockbegin;
591 gettimeofday(&ts_lockbegin,
nullptr);
593 while (retval == -1) {
602 if (lock_attempts > 5000000 || errno == 116) {
605 <<
"Stale lock file handle. Checking if run directory and fu.lock file are present" << std::endl;
607 edm::LogWarning(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 seconds. Checking if run directory and " 608 "fu.lock file are present -: errno " 609 << errno <<
":" << strerror(errno) << std::endl;
612 edm::LogWarning(
"EvFDaqDirector") <<
"Detected local EoLS for lumisection " <<
ls;
624 if (total_lock_attempts > 5 * 60000000) {
625 edm::LogError(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 minutes. Stopping polling activity.";
631 gettimeofday(&ts_lockend,
nullptr);
632 long deltat = (ts_lockend.tv_usec - ts_lockbegin.tv_usec) + (ts_lockend.tv_sec - ts_lockbegin.tv_sec) * 1000000;
634 lockWaitTime = deltat;
641 gettimeofday(&ts_lockend, 0);
645 int fu_readwritelock_fd2 = open(
fulockfile_.c_str(), O_RDWR, S_IRWXU);
646 if (fu_readwritelock_fd2 == -1)
648 <<
" create. error:" << strerror(errno);
650 FILE* fu_rw_lock_stream2 = fdopen(fu_readwritelock_fd2,
"r+");
653 if (fu_rw_lock_stream2 !=
nullptr) {
657 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
661 fscanf(fu_rw_lock_stream2,
"%u %u", &readLs, &
readIndex);
664 unsigned int currentLs = readLs;
665 bool bumpedOk =
false;
668 if (
ls &&
ls + 1 < currentLs)
672 bumpedOk =
bumpFile(readLs,
readIndex, nextFile, fsize, rawHeaderSize, stopFileLS, setExceptionState);
674 if (
ls && readLs > currentLs && currentLs >
ls) {
676 readLs = currentLs =
ls;
681 if (
ls == 0 && readLs > currentLs) {
696 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
698 ftruncate(fu_readwritelock_fd2, 0);
700 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex + 1);
701 fflush(fu_rw_lock_stream2);
702 fsync(fu_readwritelock_fd2);
704 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex + 1;
707 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
708 setExceptionState =
true;
711 }
else if (currentLs < readLs) {
713 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
715 ftruncate(fu_readwritelock_fd2, 0);
717 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex);
718 fflush(fu_rw_lock_stream2);
719 fsync(fu_readwritelock_fd2);
720 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex;
723 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
724 setExceptionState =
true;
729 edm::LogError(
"EvFDaqDirector") <<
"seek on fu read/write lock for reading failed with error " 733 edm::LogError(
"EvFDaqDirector") <<
"fu read/write lock stream is invalid " << strerror(errno);
735 fclose(fu_rw_lock_stream2);
738 timeval ts_preunlock;
739 gettimeofday(&ts_preunlock, 0);
740 int locked_period_int = ts_preunlock.tv_sec - ts_lockend.tv_sec;
741 double locked_period = locked_period_int + double(ts_preunlock.tv_usec - ts_lockend.tv_usec) / 1000000;
752 edm::LogError(
"EvFDaqDirector") <<
"Error unlocking the fu.lock " << strerror(errno);
755 edm::LogDebug(
"EvFDaqDirector") <<
"Waited during lock -: " << locked_period <<
" seconds";
758 if (fileStatus ==
noFile) {
763 if (stopFileLS >= 0 && (
int)
ls > stopFileLS) {
764 edm::LogInfo(
"EvFDaqDirector") <<
"Reached maximum lumisection set by hltd";
772 std::ifstream ij(BUEoLSFile);
776 if (!
reader.parse(ij, deserializeRoot)) {
777 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" << BUEoLSFile;
783 dp.deserialize(deserializeRoot);
791 while (!
def.empty()) {
793 if (
def.find(
'/') == 0)
801 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
806 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
808 for (
unsigned int i = 0;
i < eolsDpd.
getNames().size();
i++)
809 if (eolsDpd.
getNames().at(
i) ==
"NFiles")
815 if (
def.size() <= 1 ||
def.find(
'/') == std::string::npos) {
826 edm::LogError(
"EvFDaqDirector") <<
" error reading number of files from BU JSON -: " << BUEoLSFile;
829 return std::stoi(
data);
836 uint16_t& rawHeaderSize,
838 bool& setExceptionState) {
850 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
854 std::stringstream
ss;
858 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
860 nextFile = nextFileJson;
869 nextFile = nextFileRaw;
875 if (
stat(BUEoLSFile.c_str(), &
buf) == 0) {
877 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
879 nextFile = nextFileJson;
884 nextFile = nextFileRaw;
889 if (indexFilesInLS < 0)
894 if ((
int)
index < indexFilesInLS) {
897 <<
"Potential miss of index file in LS -: " <<
ls <<
". Missing " << nextFile <<
" because " 898 << indexFilesInLS - 1 <<
" is the highest index expected. Will not update fu.lock file";
899 setExceptionState =
true;
908 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
913 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
916 nextFile = nextFileJson;
921 nextFile = nextFileRaw;
933 edm::LogError(
"EvFDaqDirector") <<
"Error creating fu read/write lock stream " << strerror(errno);
935 edm::LogInfo(
"EvFDaqDirector") <<
"Initializing FU LOCK FILE";
944 open(
fulockfile_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
951 <<
" create:" <<
create <<
" error:" << strerror(errno);
957 edm::LogError(
"EvFDaqDirector") <<
"problem with opening fuwritelock file stream -: " << strerror(errno);
988 if (checkIfExists ==
false ||
stat(fuBoLS.c_str(), &
buf) != 0) {
989 int bol_fd = open(fuBoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
995 const uint32_t currentLumiSection,
998 if (currentLumiSection > 0) {
1005 open(fuEoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
1011 }
else if (doCreateBoLS) {
1018 uint16_t& rawHeaderSize,
1019 uint16_t& rawDataType,
1020 uint32_t& lsFromHeader,
1021 int32_t& eventsFromHeader,
1022 int64_t& fileSizeFromHeader,
1028 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1031 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1043 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1045 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1046 if (errno == ENOENT)
1062 if (frd_version == 0) {
1064 if (requireHeader) {
1065 edm::LogError(
"EvFDaqDirector") <<
"no header or invalid version string found in:" << rawSourcePath;
1070 lseek(
infile, 0, SEEK_SET);
1073 eventsFromHeader = -1;
1074 fileSizeFromHeader = -1;
1076 }
else if (frd_version == 1) {
1083 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1084 <<
" v:" << frd_version;
1091 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1092 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1095 }
else if (frd_version == 2) {
1102 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1103 <<
" v:" << frd_version;
1110 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1111 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1127 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unable to read " <<
path <<
" : " << strerror(errno);
1132 if ((
size_t)sz_read < buf_sz) {
1133 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - file smaller than header: " <<
path;
1143 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1144 edm::LogWarning(
"EvFDaqDirector") <<
"rawFileHasHeader - failed to open input file -: " << rawSourcePath <<
" : " 1155 if (frd_version == 1) {
1162 }
else if (frd_version == 2) {
1170 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unknown version: " << frd_version;
1179 uint16_t& rawHeaderSize,
1180 int64_t& fileSizeFromHeader,
1184 bool requireHeader) {
1189 size_t pos = 0, n_tokens = 0;
1190 while (n_tokens++ < 3 && (
pos = jsonStem.find(
'_',
pos + 1)) != std::string::npos) {
1194 std::ostringstream fileNameWithPID;
1196 fileNameWithPID << reducedJsonStem <<
"_pid" << std::setfill(
'0') << std::setw(5) <<
pid_ <<
".jsn";
1200 LogDebug(
"EvFDaqDirector") <<
"RAW parse -: " << rawSourcePath <<
" and JSON create " << jsonDestPath;
1204 int32_t nbEventsWrittenRaw;
1205 int64_t fileSizeFromRaw;
1206 uint16_t rawDataType;
1224 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1225 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1226 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1227 if (errno == EEXIST) {
1228 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - destination file already exists -: " << jsonDestPath
1232 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file -: " << jsonDestPath <<
" : " 1234 struct stat out_stat;
1235 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1237 <<
"grabNextJsonFromRaw - output file possibly got created with error, deleting and retry -: " 1239 if (unlink(jsonDestPath.c_str()) == -1) {
1241 <<
"grabNextJsonFromRaw - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1244 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1245 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file (on retry) -: " 1246 << jsonDestPath <<
" : " << strerror(errno);
1251 std::stringstream
ss;
1252 ss <<
"{\"data\":[" << nbEventsWrittenRaw <<
"," << fileSizeFromRaw <<
",\"" << rawSourcePath <<
"\"]}";
1256 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to write to output file file -: " << jsonDestPath
1257 <<
" : " << strerror(errno);
1261 if (serverLS && serverLS != lsFromRaw)
1262 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - mismatch in expected (server) LS " << serverLS
1263 <<
" and raw file header LS " << lsFromRaw;
1265 fileSizeFromHeader = fileSizeFromRaw;
1266 return nbEventsWrittenRaw;
1271 int64_t& fileSizeFromJson,
1276 std::ostringstream fileNameWithPID;
1277 fileNameWithPID <<
std::filesystem::path(rawSourcePath).stem().string() <<
"_pid" << std::setfill(
'0')
1278 << std::setw(5) <<
pid_ <<
".jsn";
1283 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1287 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1288 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file -: " << jsonSourcePath <<
" : " 1290 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1291 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file (on retry) -: " 1292 << jsonSourcePath <<
" : " << strerror(errno);
1293 if (errno == ENOENT)
1299 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1300 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1301 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1302 if (errno == EEXIST) {
1303 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - destination file already exists -: " << jsonDestPath
1308 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file -: " << jsonDestPath <<
" : " 1310 struct stat out_stat;
1311 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1313 <<
"grabNextJsonFile - output file possibly got created with error, deleting and retry -: " << jsonDestPath;
1314 if (unlink(jsonDestPath.c_str()) == -1) {
1316 <<
"grabNextJsonFile - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1319 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1320 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file (on retry) -: " 1321 << jsonDestPath <<
" : " << strerror(errno);
1327 const std::size_t buf_sz = 512;
1328 std::size_t tot_written = 0;
1329 std::unique_ptr<char[]>
buf(
new char[buf_sz]);
1331 ssize_t sz, sz_read = 1, sz_write;
1332 while (sz_read > 0 && (sz_read = ::
read(
infile,
buf.get(), buf_sz)) > 0) {
1335 assert(sz_read - sz_write > 0);
1336 if ((sz = ::
write(
outfile,
buf.get() + sz_write, sz_read - sz_write)) < 0) {
1343 }
while (sz_write < sz_read);
1348 if (tot_written > 0) {
1350 if (unlink(jsonSourcePath.c_str()) == -1) {
1351 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to remove -: " << jsonSourcePath <<
" : " 1356 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to copy json file or file was empty -: " 1365 std::stringstream
ss;
1368 if (tot_written <= buf_sz) {
1373 std::ifstream ij(jsonDestPath);
1375 }
catch (std::filesystem::filesystem_error
const& ex) {
1376 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - FILESYSTEM ERROR CAUGHT -: " << ex.what();
1382 if (tot_written <= buf_sz)
1384 edm::LogError(
"EvFDaqDirector") <<
"Failed to deserialize JSON file -: " << jsonDestPath <<
"\nERROR:\n" 1385 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1392 dp.deserialize(deserializeRoot);
1396 if (
i <
dp.getData().size()) {
1403 if (!
dp.getData().empty())
1407 <<
"grabNextJsonFile - " 1408 <<
" error reading number of events from BU JSON; No input value. data -: " <<
data;
1414 fileSizeFromJson = -1;
1417 if (
i <
dp.getData().size()) {
1420 fileSizeFromJson = std::stol(dataSize);
1423 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of Bytes from BU JSON. " 1424 <<
"Input value is -: " << dataSize;
1430 return std::stoi(
data);
1431 }
catch (
const std::out_of_range&
e) {
1432 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of events from BU JSON. " 1433 <<
"Input value is -: " <<
data;
1434 }
catch (
const std::invalid_argument&
e) {
1435 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - argument error parsing events from BU JSON. " 1436 <<
"Input value is -: " <<
data;
1437 }
catch (std::runtime_error
const&
e) {
1439 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - std::runtime_error exception -: " <<
e.what();
1443 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED! -: " <<
e.what();
1446 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED!";
1459 std::ostringstream fileNameWithPID;
1460 fileNameWithPID << jsonSourcePath.stem().string() <<
"_pid" << std::setfill(
'0') << std::setw(5) << getpid()
1462 jsonDestPath /= fileNameWithPID.str();
1464 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1467 }
catch (std::filesystem::filesystem_error
const& ex) {
1469 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1479 }
catch (std::filesystem::filesystem_error
const& ex) {
1481 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1484 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile std::exception CAUGHT -: " << ex.what();
1487 std::ifstream ij(jsonDestPath);
1491 std::stringstream
ss;
1493 if (!
reader.parse(
ss.str(), deserializeRoot)) {
1494 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile Failed to deserialize JSON file -: " << jsonDestPath
1496 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1498 throw std::runtime_error(
"Cannot deserialize input JSON file");
1504 dp.deserialize(deserializeRoot);
1508 if (
i <
dp.getData().size()) {
1514 if (!
dp.getData().empty())
1518 <<
" error reading number of events from BU JSON -: No input value " <<
data;
1520 return std::stoi(
data);
1521 }
catch (std::filesystem::filesystem_error
const& ex) {
1524 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1525 }
catch (std::runtime_error
const&
e) {
1528 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile runtime Exception -: " <<
e.what();
1529 }
catch (
const std::out_of_range&) {
1530 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile error parsing number of events from BU JSON. " 1531 <<
"Input value is -: " <<
data;
1532 }
catch (
const std::invalid_argument&) {
1533 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile argument error parsing events from BU JSON. " 1534 <<
"Input value is -: " <<
data;
1538 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile SOME OTHER EXCEPTION OCCURED!!!! -: " <<
e.what();
1547 uint32_t& closedServerLS,
1553 serverError =
false;
1556 boost::system::error_code ec;
1570 boost::asio::streambuf request;
1571 std::ostream request_stream(&request);
1574 std::stringstream spath;
1575 spath <<
path <<
"&stopls=" << maxLS;
1579 request_stream <<
"GET " <<
path <<
" HTTP/1.1\r\n";
1581 request_stream <<
"Accept: */*\r\n";
1582 request_stream <<
"Connection: keep-alive\r\n\r\n";
1587 edm::LogInfo(
"EvFDaqDirector") <<
"reconnecting socket on received connection_reset" <<
dest;
1602 boost::asio::streambuf response;
1603 boost::asio::read_until(*
socket_, response,
"\r\n", ec);
1610 std::istream response_stream(&response);
1613 response_stream >> http_version;
1615 response_stream >> serverHttpStatus;
1618 std::getline(response_stream, status_message);
1619 if (!response_stream || http_version.substr(0, 5) !=
"HTTP/") {
1624 if (serverHttpStatus != 200) {
1625 edm::LogWarning(
"EvFDaqDirector") <<
"Response returned with status code " << serverHttpStatus;
1632 while (std::getline(response_stream,
header) &&
header !=
"\r") {
1636 std::map<std::string, std::string> serverMap;
1637 while (std::getline(response_stream, fileInfo) && fileInfo !=
"\r") {
1638 auto pos = fileInfo.find(
'=');
1639 if (
pos == std::string::npos)
1641 auto stitle = fileInfo.substr(0,
pos);
1642 auto svalue = fileInfo.substr(
pos + 1);
1643 serverMap[stitle] = svalue;
1647 auto server_version = serverMap.find(
"version");
1648 assert(server_version != serverMap.end());
1650 auto server_run = serverMap.find(
"runnumber");
1651 assert(server_run != serverMap.end());
1654 auto server_state = serverMap.find(
"state");
1655 assert(server_state != serverMap.end());
1657 auto server_eols = serverMap.find(
"lasteols");
1658 assert(server_eols != serverMap.end());
1660 auto server_ls = serverMap.find(
"lumisection");
1662 int version_maj = 1;
1663 int version_min = 0;
1664 int version_rev = 0;
1666 auto* s_ptr = server_version->second.c_str();
1667 if (!server_version->second.empty() && server_version->second[0] ==
'"')
1669 auto res = sscanf(s_ptr,
"%d.%d.%d", &version_maj, &version_min, &version_rev);
1671 res = sscanf(s_ptr,
"%d.%d", &version_maj, &version_min);
1673 res = sscanf(s_ptr,
"%d", &version_maj);
1676 edm::LogWarning(
"EvFDaqDirector") <<
"Can not parse server version " << server_version->second;
1683 if (server_ls != serverMap.end())
1686 serverLS = closedServerLS + 1;
1689 if (s_state ==
"STARTING")
1691 auto server_file = serverMap.find(
"file");
1692 assert(server_file == serverMap.end());
1694 edm::LogInfo(
"EvFDaqDirector") <<
"Got STARTING notification with last EOLS " << closedServerLS;
1695 }
else if (s_state ==
"READY") {
1696 auto server_file = serverMap.find(
"file");
1697 if (server_file == serverMap.end()) {
1699 if (serverLS <= closedServerLS)
1700 serverLS = closedServerLS + 1;
1703 <<
"Got READY notification with last EOLS " << closedServerLS <<
" and no new file";
1707 auto server_fileprefix = serverMap.find(
"fileprefix");
1709 if (server_fileprefix != serverMap.end()) {
1710 auto pssize = server_fileprefix->second.size();
1711 if (pssize > 1 && server_fileprefix->second[0] ==
'"' && server_fileprefix->second[pssize - 1] ==
'"')
1712 fileprefix = server_fileprefix->second.substr(1, pssize - 2);
1714 fileprefix = server_fileprefix->second;
1718 auto ssize = server_file->second.size();
1719 if (ssize > 1 && server_file->second[0] ==
'"' && server_file->second[ssize - 1] ==
'"')
1720 filestem = server_file->second.substr(1, ssize - 2);
1722 filestem = server_file->second;
1723 assert(!filestem.empty());
1724 if (version_maj > 1) {
1725 nextFileRaw =
bu_run_dir_ +
"/" + fileprefix + filestem +
".raw";
1726 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1730 nextFileRaw =
bu_run_dir_ +
"/" + filestem +
".raw";
1731 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1732 nextFileJson = filestem +
".jsn";
1736 edm::LogInfo(
"EvFDaqDirector") <<
"Got READY notification with last EOLS " << closedServerLS <<
" new LS " 1737 << serverLS <<
" file:" << filestem;
1739 }
else if (s_state ==
"EOLS") {
1740 serverLS = closedServerLS + 1;
1741 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOLS notification with last EOLS " << closedServerLS;
1743 }
else if (s_state ==
"EOR") {
1745 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOR notification with last EOLS " << closedServerLS;
1747 }
else if (s_state ==
"NORUN") {
1748 auto err_msg = serverMap.find(
"errormessage");
1749 if (err_msg != serverMap.end())
1750 edm::LogWarning(
"EvFDaqDirector") <<
"Server NORUN -:" << server_state->second <<
" : " << err_msg->second;
1755 }
else if (s_state ==
"ERROR") {
1756 auto err_msg = serverMap.find(
"errormessage");
1757 if (err_msg != serverMap.end())
1758 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second <<
" : " << err_msg->second;
1760 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second;
1764 edm::LogWarning(
"EvFDaqDirector") <<
"Unknown Server state -:" << server_state->second;
1773 if (ec != boost::asio::error::eof) {
1788 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
1815 uint16_t& rawHeaderSize,
1816 int32_t& serverEventsInNewFile,
1817 int64_t& fileSizeFromMetadata,
1819 bool requireHeader) {
1827 int stopFileLS = -1;
1830 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
1831 if (stopFileCheck == 0)
1837 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
1841 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 1855 timeval ts_lockbegin;
1856 gettimeofday(&ts_lockbegin,
nullptr);
1859 uint32_t serverLS, closedServerLS;
1860 unsigned int serverHttpStatus;
1867 int maxLS = stopFileLS < 0 ? -1 :
std::max(stopFileLS, (
int)currentLumiSection);
1868 bool rawHeader =
false;
1870 serverHttpStatus, serverError, serverLS, closedServerLS, nextFileJson, nextFileRaw, rawHeader, maxLS);
1880 if (currentLumiSection == 0) {
1886 if (closedServerLS >= currentLumiSection) {
1888 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1893 bool fileFound =
true;
1898 nextFileRaw, rawFd, rawHeaderSize, fileSizeFromMetadata, fileFound, serverLS,
false, requireHeader);
1900 serverEventsInNewFile =
grabNextJsonFile(nextFileJson, nextFileRaw, fileSizeFromMetadata, fileFound);
1903 if (serverEventsInNewFile < 0 && rawFd != -1) {
1924 if (currentLumiSection == 0) {
1934 if (closedServerLS >= currentLumiSection) {
1937 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1945 else if (fileStatus ==
newFile) {
1948 }
else if (fileStatus ==
noFile) {
1952 edm::LogWarning(
"EvFDaqDirector") <<
"Server reported LS " << serverLS
1953 <<
" which is smaller than currently open LS " <<
ls <<
". Ignoring response";
1965 if (!std::filesystem::is_directory(openPath)) {
1966 LogDebug(
"EvFDaqDirector") <<
"<open> FU dir not found. Creating... -:" << openPath.string();
1967 std::filesystem::create_directories(openPath);
1972 std::ifstream ij(
file);
1976 if (!
reader.parse(ij, deserializeRoot)) {
1977 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" <<
file;
1981 int ret = deserializeRoot.
get(
"lastLS",
"").
asInt();
1989 unsigned int lscount = 1;
1991 std::stringstream
ss;
1992 ss << fileprefix << std::setfill(
'0') << std::setw(4) << lscount <<
"_EoLS.jsn";
2002 int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
2003 close(proc_flag_fd);
2006 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_
std::string getEoLSFilePathOnFU(const unsigned int ls) const
void removeFile(std::string)
bool lumisectionDiscarded(unsigned int ls)
Unserialize a JSON document into a Value.
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_
Value get(UInt index, const Value &defaultValue) const
void postEndRun(edm::GlobalContext const &globalContext)
uint16_t getFRDFileHeaderVersion(const std::array< uint8_t, 4 > &id, const std::array< uint8_t, 4 > &version)
std::string discard_ls_filestem_
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_
JSON (JavaScript Object Notation).
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_