26 #include <boost/algorithm/string.hpp> 27 #include <fmt/printf.h> 38 const std::vector<std::string> EvFDaqDirector::MergeTypeNames_ = {
"",
"DAT",
"PB",
"JSNDATA"};
41 : base_dir_(
pset.getUntrackedParameter<
std::
string>(
"baseDir")),
42 bu_base_dir_(
pset.getUntrackedParameter<
std::
string>(
"buBaseDir")),
44 bu_base_dirs_nSources_(
pset.getUntrackedParameter<
std::
vector<
int>>(
"buBaseDirsNumStreams")),
45 run_(
pset.getUntrackedParameter<unsigned
int>(
"runNumber")),
46 useFileBroker_(
pset.getUntrackedParameter<
bool>(
"useFileBroker")),
47 fileBrokerHostFromCfg_(
pset.getUntrackedParameter<
bool>(
"fileBrokerHostFromCfg",
false)),
48 fileBrokerHost_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerHost",
"InValid")),
49 fileBrokerPort_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerPort",
"8080")),
50 fileBrokerKeepAlive_(
pset.getUntrackedParameter<
bool>(
"fileBrokerKeepAlive",
true)),
51 fileBrokerUseLocalLock_(
pset.getUntrackedParameter<
bool>(
"fileBrokerUseLocalLock",
true)),
52 fuLockPollInterval_(
pset.getUntrackedParameter<unsigned
int>(
"fuLockPollInterval", 2000)),
53 outputAdler32Recheck_(
pset.getUntrackedParameter<
bool>(
"outputAdler32Recheck",
false)),
54 directorBU_(
pset.getUntrackedParameter<
bool>(
"directorIsBU",
false)),
55 hltSourceDirectory_(
pset.getUntrackedParameter<
std::
string>(
"hltSourceDirectory",
"")),
59 fu_readwritelock_fd_(-1),
60 fulocal_rwlock_fd_(-1),
61 fulocal_rwlock_fd2_(-1),
62 bu_w_lock_stream(nullptr),
63 bu_r_lock_stream(nullptr),
64 fu_rw_lock_stream(nullptr),
65 dirManager_(base_dir_),
67 bu_w_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, 0)),
68 bu_r_flk(make_flock(F_RDLCK, SEEK_SET, 0, 0, 0)),
69 bu_w_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
70 bu_r_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, 0)),
71 fu_rw_flk(make_flock(F_WRLCK, SEEK_SET, 0, 0, getpid())),
72 fu_rw_fulk(make_flock(F_UNLCK, SEEK_SET, 0, 0, getpid())) {
80 gethostname(hostname, 32);
83 char* fuLockPollIntervalPtr = std::getenv(
"FFF_LOCKPOLLINTERVAL");
84 if (fuLockPollIntervalPtr) {
95 char* fileBrokerParamPtr = std::getenv(
"FFF_USEFILEBROKER");
96 if (fileBrokerParamPtr) {
109 if (
stat(
"/etc/appliance/bus.config", &
buf) == 0) {
114 throw cms::Exception(
"EvFDaqDirector") <<
"No file service or BU data address information";
117 <<
"fileBrokerHostFromCfg must be set to true if fileBrokerHost parameter is not valid or empty";
125 char* startFromLSPtr = std::getenv(
"FFF_START_LUMISECTION");
126 if (startFromLSPtr) {
136 char* fileBrokerUseLockParamPtr = std::getenv(
"FFF_FILEBROKERUSELOCALLOCK");
137 if (fileBrokerUseLockParamPtr) {
140 edm::LogInfo(
"EvFDaqDirector") <<
"Setting fileBrokerUseLocalLock parameter by environment string: " 155 <<
" Error while setting number of sources: size mismatch with BU base directory vector";
164 std::stringstream
ss;
165 ss <<
"run" << std::setfill(
'0') << std::setw(6) <<
run_;
167 ss = std::stringstream();
173 ss = std::stringstream();
180 int retval =
mkdir(
base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
181 if (retval != 0 && errno != EEXIST) {
183 <<
" Error checking for base dir -: " <<
base_dir_ <<
" mkdir error:" << strerror(errno);
188 retval =
mkdir(
run_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IRWXO | S_IXOTH);
189 if (retval != 0 && errno != EEXIST) {
191 <<
" Error creating run dir -: " <<
run_dir_ <<
" mkdir error:" << strerror(errno);
199 open(fulocal_lock_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
202 <<
" Error creating/opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
203 chmod(fulocal_lock_.c_str(), 0777);
207 open(fulocal_lock_.c_str(), O_RDWR, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
210 <<
" Error opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
222 if (retval != 0 && errno != EEXIST) {
224 <<
" Error creating bu run dir -: " <<
bu_run_dir_ <<
" mkdir error:" << strerror(errno);
228 if (retval != 0 && errno != EEXIST) {
230 <<
" Error creating bu run open dir -: " <<
bu_run_open_dir_ <<
" mkdir error:" << strerror(errno);
234 bu_writelock_fd_ = open(bulockfile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
236 edm::LogWarning(
"EvFDaqDirector") <<
"problem with creating filedesc for buwritelock -: " << strerror(errno);
241 edm::LogWarning(
"EvFDaqDirector") <<
"Error creating write lock stream -: " << strerror(errno);
255 retval =
mkdir(tmphltdir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
256 if (retval != 0 && errno != EEXIST)
258 <<
" Error creating bu run dir -: " << hltdir <<
" mkdir error:" << strerror(errno);
260 std::filesystem::copy_file(
hltSourceDirectory_ +
"/HltConfig.py", tmphltdir +
"/HltConfig.py");
261 std::filesystem::copy_file(
hltSourceDirectory_ +
"/fffParameters.jsn", tmphltdir +
"/fffParameters.jsn");
263 std::string optfiles[3] = {
"hltinfo",
"blacklist",
"whitelist"};
264 for (
auto& optfile : optfiles) {
266 std::filesystem::copy_file(
hltSourceDirectory_ +
"/" + optfile, tmphltdir +
"/" + optfile);
271 std::filesystem::rename(tmphltdir, hltdir);
279 auto checkExists = [=](
std::string const& bu_base_dir) ->
void {
280 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
281 if (retval != 0 && errno != EEXIST) {
283 <<
" Error checking for bu base dir -: " << bu_base_dir <<
" mkdir error:" << strerror(errno);
287 auto waitForDir = [=](
std::string const& bu_base_dir) ->
void {
292 stat(bu_base_dir.c_str(), &statbuf);
293 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
294 if (retval != 0 && errno != EEXIST) {
300 throw cms::Exception(
"DaqDirector") <<
" Error checking for bu base dir after 1 minute -: " << bu_base_dir
301 <<
" mkdir error:" << strerror(errno);
310 checkExists(check_dir);
327 std::stringstream sstp;
334 if (!
stat(defPath.c_str(), &statbuf))
335 edm::LogInfo(
"EvFDaqDirector") <<
"found JSD file in ramdisk -: " << defPath;
338 std::string defPathSuffix =
"src/EventFilter/Utilities/plugins/budef.jsd";
339 defPath =
std::string(std::getenv(
"CMSSW_BASE")) +
"/" + defPathSuffix;
340 if (
stat(defPath.c_str(), &statbuf)) {
341 defPath =
std::string(std::getenv(
"CMSSW_RELEASE_BASE")) +
"/" + defPathSuffix;
342 if (
stat(defPath.c_str(), &statbuf)) {
343 defPath = defPathSuffix;
349 DataPointDefinition::getDataPointDefinitionFor(defPath,
dpd_, &defLabel);
356 boost::system::error_code ec;
357 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
383 "Service used for file locking arbitration and for propagating information between other EvF components");
384 desc.addUntracked<
std::string>(
"baseDir",
".")->setComment(
"Local base directory for run output");
385 desc.addUntracked<
std::string>(
"buBaseDir",
".")->setComment(
"BU base ramdisk directory ");
386 desc.addUntracked<std::vector<std::string>>(
"buBaseDirsAll", std::vector<std::string>())
387 ->setComment(
"BU base ramdisk directories for multi-file DAQSource models");
388 desc.addUntracked<std::vector<int>>(
"buBaseDirsNumStreams", std::vector<int>())
389 ->setComment(
"Number of streams for each BU base ramdisk directories for multi-file DAQSource models");
390 desc.addUntracked<
unsigned int>(
"runNumber", 0)->setComment(
"Run Number in ramdisk to open");
391 desc.addUntracked<
bool>(
"useFileBroker",
false)
392 ->setComment(
"Use BU file service to grab input data instead of NFS file locking");
393 desc.addUntracked<
bool>(
"fileBrokerHostFromCfg",
true)
394 ->setComment(
"Allow service to discover BU address from hltd configuration");
395 desc.addUntracked<
std::string>(
"fileBrokerHost",
"InValid")->setComment(
"BU file service host.");
396 desc.addUntracked<
std::string>(
"fileBrokerPort",
"8080")->setComment(
"BU file service port");
397 desc.addUntracked<
bool>(
"fileBrokerKeepAlive",
true)
398 ->setComment(
"Use keep alive to avoid using large number of sockets");
399 desc.addUntracked<
bool>(
"fileBrokerUseLocalLock",
true)
400 ->setComment(
"Use local lock file to synchronize appearance of index and EoLS file markers for hltd");
401 desc.addUntracked<
unsigned int>(
"fuLockPollInterval", 2000)
402 ->setComment(
"Lock polling interval in microseconds for the input directory file lock");
403 desc.addUntracked<
bool>(
"outputAdler32Recheck",
false)
404 ->setComment(
"Check Adler32 of per-process output files while micro-merging");
405 desc.addUntracked<
bool>(
"directorIsBU",
false)->setComment(
"BU director mode used for testing");
406 desc.addUntracked<
std::string>(
"hltSourceDirectory",
"")->setComment(
"BU director mode source directory");
408 ->setComment(
"Name of merging PSet to look for merging type definitions for streams");
409 descriptions.
add(
"EvFDaqDirector",
desc);
435 edm::LogWarning(
"EvFDaqDirector") <<
" Handles to check for files to delete were not set by the input source...";
549 int retval =
remove(
filename.c_str());
552 <<
". error = " << strerror(errno);
558 uint16_t& rawHeaderSize,
560 bool& setExceptionState) {
565 int lock_attempts = 0;
566 long total_lock_attempts = 0;
572 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
573 if (stopFileCheck == 0)
579 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
583 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 589 timeval ts_lockbegin;
590 gettimeofday(&ts_lockbegin,
nullptr);
592 while (retval == -1) {
601 if (lock_attempts > 5000000 || errno == 116) {
604 <<
"Stale lock file handle. Checking if run directory and fu.lock file are present" << std::endl;
606 edm::LogWarning(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 seconds. Checking if run directory and " 607 "fu.lock file are present -: errno " 608 << errno <<
":" << strerror(errno) << std::endl;
611 edm::LogWarning(
"EvFDaqDirector") <<
"Detected local EoLS for lumisection " <<
ls;
623 if (total_lock_attempts > 5 * 60000000) {
624 edm::LogError(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 minutes. Stopping polling activity.";
630 gettimeofday(&ts_lockend,
nullptr);
631 long deltat = (ts_lockend.tv_usec - ts_lockbegin.tv_usec) + (ts_lockend.tv_sec - ts_lockbegin.tv_sec) * 1000000;
633 lockWaitTime = deltat;
640 gettimeofday(&ts_lockend, 0);
644 int fu_readwritelock_fd2 = open(
fulockfile_.c_str(), O_RDWR, S_IRWXU);
645 if (fu_readwritelock_fd2 == -1)
647 <<
" create. error:" << strerror(errno);
649 FILE* fu_rw_lock_stream2 = fdopen(fu_readwritelock_fd2,
"r+");
652 if (fu_rw_lock_stream2 !=
nullptr) {
656 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
660 fscanf(fu_rw_lock_stream2,
"%u %u", &readLs, &
readIndex);
663 unsigned int currentLs = readLs;
664 bool bumpedOk =
false;
667 if (
ls &&
ls + 1 < currentLs)
671 bumpedOk =
bumpFile(readLs,
readIndex, nextFile, fsize, rawHeaderSize, stopFileLS, setExceptionState);
673 if (
ls && readLs > currentLs && currentLs >
ls) {
675 readLs = currentLs =
ls;
680 if (
ls == 0 && readLs > currentLs) {
695 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
697 ftruncate(fu_readwritelock_fd2, 0);
699 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex + 1);
700 fflush(fu_rw_lock_stream2);
701 fsync(fu_readwritelock_fd2);
703 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex + 1;
706 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
707 setExceptionState =
true;
710 }
else if (currentLs < readLs) {
712 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
714 ftruncate(fu_readwritelock_fd2, 0);
716 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex);
717 fflush(fu_rw_lock_stream2);
718 fsync(fu_readwritelock_fd2);
719 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex;
722 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
723 setExceptionState =
true;
728 edm::LogError(
"EvFDaqDirector") <<
"seek on fu read/write lock for reading failed with error " 732 edm::LogError(
"EvFDaqDirector") <<
"fu read/write lock stream is invalid " << strerror(errno);
734 fclose(fu_rw_lock_stream2);
737 timeval ts_preunlock;
738 gettimeofday(&ts_preunlock, 0);
739 int locked_period_int = ts_preunlock.tv_sec - ts_lockend.tv_sec;
740 double locked_period = locked_period_int + double(ts_preunlock.tv_usec - ts_lockend.tv_usec) / 1000000;
751 edm::LogError(
"EvFDaqDirector") <<
"Error unlocking the fu.lock " << strerror(errno);
754 edm::LogDebug(
"EvFDaqDirector") <<
"Waited during lock -: " << locked_period <<
" seconds";
757 if (fileStatus ==
noFile) {
762 if (stopFileLS >= 0 && (
int)
ls > stopFileLS) {
763 edm::LogInfo(
"EvFDaqDirector") <<
"Reached maximum lumisection set by hltd";
771 std::ifstream ij(BUEoLSFile);
775 if (!
reader.parse(ij, deserializeRoot)) {
776 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" << BUEoLSFile;
782 dp.deserialize(deserializeRoot);
790 while (!
def.empty()) {
792 if (
def.find(
'/') == 0)
800 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
805 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
807 for (
unsigned int i = 0;
i < eolsDpd.
getNames().size();
i++)
808 if (eolsDpd.
getNames().at(
i) ==
"NFiles")
814 if (
def.size() <= 1 ||
def.find(
'/') == std::string::npos) {
825 edm::LogError(
"EvFDaqDirector") <<
" error reading number of files from BU JSON -: " << BUEoLSFile;
828 return std::stoi(
data);
835 uint16_t& rawHeaderSize,
837 bool& setExceptionState) {
849 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
853 std::stringstream
ss;
857 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
859 nextFile = nextFileJson;
868 nextFile = nextFileRaw;
874 if (
stat(BUEoLSFile.c_str(), &
buf) == 0) {
876 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
878 nextFile = nextFileJson;
883 nextFile = nextFileRaw;
888 if (indexFilesInLS < 0)
893 if ((
int)
index < indexFilesInLS) {
896 <<
"Potential miss of index file in LS -: " <<
ls <<
". Missing " << nextFile <<
" because " 897 << indexFilesInLS - 1 <<
" is the highest index expected. Will not update fu.lock file";
898 setExceptionState =
true;
907 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
912 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
915 nextFile = nextFileJson;
920 nextFile = nextFileRaw;
932 edm::LogError(
"EvFDaqDirector") <<
"Error creating fu read/write lock stream " << strerror(errno);
934 edm::LogInfo(
"EvFDaqDirector") <<
"Initializing FU LOCK FILE";
943 open(
fulockfile_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
950 <<
" create:" <<
create <<
" error:" << strerror(errno);
956 edm::LogError(
"EvFDaqDirector") <<
"problem with opening fuwritelock file stream -: " << strerror(errno);
987 if (checkIfExists ==
false ||
stat(fuBoLS.c_str(), &
buf) != 0) {
988 int bol_fd = open(fuBoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
994 const uint32_t currentLumiSection,
997 if (currentLumiSection > 0) {
1004 open(fuEoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
1010 }
else if (doCreateBoLS) {
1017 uint16_t& rawHeaderSize,
1018 uint16_t& rawDataType,
1019 uint32_t& lsFromHeader,
1020 int32_t& eventsFromHeader,
1021 int64_t& fileSizeFromHeader,
1027 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1030 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1042 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1044 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1045 if (errno == ENOENT)
1061 if (frd_version == 0) {
1063 if (requireHeader) {
1064 edm::LogError(
"EvFDaqDirector") <<
"no header or invalid version string found in:" << rawSourcePath;
1069 lseek(
infile, 0, SEEK_SET);
1072 eventsFromHeader = -1;
1073 fileSizeFromHeader = -1;
1075 }
else if (frd_version == 1) {
1082 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1083 <<
" v:" << frd_version;
1090 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1091 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1094 }
else if (frd_version == 2) {
1101 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1102 <<
" v:" << frd_version;
1109 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1110 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1126 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unable to read " <<
path <<
" : " << strerror(errno);
1131 if ((
size_t)sz_read < buf_sz) {
1132 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - file smaller than header: " <<
path;
1142 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1143 edm::LogWarning(
"EvFDaqDirector") <<
"rawFileHasHeader - failed to open input file -: " << rawSourcePath <<
" : " 1154 if (frd_version == 1) {
1161 }
else if (frd_version == 2) {
1169 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unknown version: " << frd_version;
1178 uint16_t& rawHeaderSize,
1179 int64_t& fileSizeFromHeader,
1183 bool requireHeader) {
1188 size_t pos = 0, n_tokens = 0;
1189 while (n_tokens++ < 3 && (
pos = jsonStem.find(
'_',
pos + 1)) != std::string::npos) {
1193 std::ostringstream fileNameWithPID;
1195 fileNameWithPID << reducedJsonStem <<
"_pid" << std::setfill(
'0') << std::setw(5) <<
pid_ <<
".jsn";
1199 LogDebug(
"EvFDaqDirector") <<
"RAW parse -: " << rawSourcePath <<
" and JSON create " << jsonDestPath;
1203 int32_t nbEventsWrittenRaw;
1204 int64_t fileSizeFromRaw;
1205 uint16_t rawDataType;
1223 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1224 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1225 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1226 if (errno == EEXIST) {
1227 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - destination file already exists -: " << jsonDestPath
1231 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file -: " << jsonDestPath <<
" : " 1233 struct stat out_stat;
1234 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1236 <<
"grabNextJsonFromRaw - output file possibly got created with error, deleting and retry -: " 1238 if (unlink(jsonDestPath.c_str()) == -1) {
1240 <<
"grabNextJsonFromRaw - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1243 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1244 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file (on retry) -: " 1245 << jsonDestPath <<
" : " << strerror(errno);
1250 std::stringstream
ss;
1251 ss <<
"{\"data\":[" << nbEventsWrittenRaw <<
"," << fileSizeFromRaw <<
",\"" << rawSourcePath <<
"\"]}";
1255 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to write to output file file -: " << jsonDestPath
1256 <<
" : " << strerror(errno);
1260 if (serverLS && serverLS != lsFromRaw)
1261 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - mismatch in expected (server) LS " << serverLS
1262 <<
" and raw file header LS " << lsFromRaw;
1264 fileSizeFromHeader = fileSizeFromRaw;
1265 return nbEventsWrittenRaw;
1270 int64_t& fileSizeFromJson,
1275 std::ostringstream fileNameWithPID;
1276 fileNameWithPID <<
std::filesystem::path(rawSourcePath).stem().string() <<
"_pid" << std::setfill(
'0')
1277 << std::setw(5) <<
pid_ <<
".jsn";
1282 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1286 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1287 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file -: " << jsonSourcePath <<
" : " 1289 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1290 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file (on retry) -: " 1291 << jsonSourcePath <<
" : " << strerror(errno);
1292 if (errno == ENOENT)
1298 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1299 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1300 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1301 if (errno == EEXIST) {
1302 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - destination file already exists -: " << jsonDestPath
1307 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file -: " << jsonDestPath <<
" : " 1309 struct stat out_stat;
1310 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1312 <<
"grabNextJsonFile - output file possibly got created with error, deleting and retry -: " << jsonDestPath;
1313 if (unlink(jsonDestPath.c_str()) == -1) {
1315 <<
"grabNextJsonFile - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1318 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1319 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file (on retry) -: " 1320 << jsonDestPath <<
" : " << strerror(errno);
1326 const std::size_t buf_sz = 512;
1327 std::size_t tot_written = 0;
1328 std::unique_ptr<char[]>
buf(
new char[buf_sz]);
1330 ssize_t sz, sz_read = 1, sz_write;
1331 while (sz_read > 0 && (sz_read = ::
read(
infile,
buf.get(), buf_sz)) > 0) {
1334 assert(sz_read - sz_write > 0);
1335 if ((sz = ::
write(
outfile,
buf.get() + sz_write, sz_read - sz_write)) < 0) {
1342 }
while (sz_write < sz_read);
1347 if (tot_written > 0) {
1349 if (unlink(jsonSourcePath.c_str()) == -1) {
1350 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to remove -: " << jsonSourcePath <<
" : " 1355 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to copy json file or file was empty -: " 1364 std::stringstream
ss;
1367 if (tot_written <= buf_sz) {
1372 std::ifstream ij(jsonDestPath);
1374 }
catch (std::filesystem::filesystem_error
const& ex) {
1375 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - FILESYSTEM ERROR CAUGHT -: " << ex.what();
1381 if (tot_written <= buf_sz)
1383 edm::LogError(
"EvFDaqDirector") <<
"Failed to deserialize JSON file -: " << jsonDestPath <<
"\nERROR:\n" 1384 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1391 dp.deserialize(deserializeRoot);
1395 if (
i <
dp.getData().size()) {
1402 if (!
dp.getData().empty())
1406 <<
"grabNextJsonFile - " 1407 <<
" error reading number of events from BU JSON; No input value. data -: " <<
data;
1413 fileSizeFromJson = -1;
1416 if (
i <
dp.getData().size()) {
1419 fileSizeFromJson = std::stol(dataSize);
1422 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of Bytes from BU JSON. " 1423 <<
"Input value is -: " << dataSize;
1429 return std::stoi(
data);
1430 }
catch (
const std::out_of_range&
e) {
1431 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of events from BU JSON. " 1432 <<
"Input value is -: " <<
data;
1433 }
catch (
const std::invalid_argument&
e) {
1434 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - argument error parsing events from BU JSON. " 1435 <<
"Input value is -: " <<
data;
1436 }
catch (std::runtime_error
const&
e) {
1438 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - std::runtime_error exception -: " <<
e.what();
1442 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED! -: " <<
e.what();
1445 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED!";
1458 std::ostringstream fileNameWithPID;
1459 fileNameWithPID << jsonSourcePath.stem().string() <<
"_pid" << std::setfill(
'0') << std::setw(5) << getpid()
1461 jsonDestPath /= fileNameWithPID.str();
1463 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1466 }
catch (std::filesystem::filesystem_error
const& ex) {
1468 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1478 }
catch (std::filesystem::filesystem_error
const& ex) {
1480 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1483 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile std::exception CAUGHT -: " << ex.what();
1486 std::ifstream ij(jsonDestPath);
1490 std::stringstream
ss;
1492 if (!
reader.parse(
ss.str(), deserializeRoot)) {
1493 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile Failed to deserialize JSON file -: " << jsonDestPath
1495 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1497 throw std::runtime_error(
"Cannot deserialize input JSON file");
1503 dp.deserialize(deserializeRoot);
1507 if (
i <
dp.getData().size()) {
1513 if (!
dp.getData().empty())
1517 <<
" error reading number of events from BU JSON -: No input value " <<
data;
1519 return std::stoi(
data);
1520 }
catch (std::filesystem::filesystem_error
const& ex) {
1523 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1524 }
catch (std::runtime_error
const&
e) {
1527 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile runtime Exception -: " <<
e.what();
1528 }
catch (
const std::out_of_range&) {
1529 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile error parsing number of events from BU JSON. " 1530 <<
"Input value is -: " <<
data;
1531 }
catch (
const std::invalid_argument&) {
1532 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile argument error parsing events from BU JSON. " 1533 <<
"Input value is -: " <<
data;
1537 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile SOME OTHER EXCEPTION OCCURED!!!! -: " <<
e.what();
1546 uint32_t& closedServerLS,
1552 serverError =
false;
1555 boost::system::error_code ec;
1569 boost::asio::streambuf request;
1570 std::ostream request_stream(&request);
1573 std::stringstream spath;
1574 spath <<
path <<
"&stopls=" << maxLS;
1578 request_stream <<
"GET " <<
path <<
" HTTP/1.1\r\n";
1580 request_stream <<
"Accept: */*\r\n";
1581 request_stream <<
"Connection: keep-alive\r\n\r\n";
1586 edm::LogInfo(
"EvFDaqDirector") <<
"reconnecting socket on received connection_reset" <<
dest;
1601 boost::asio::streambuf response;
1602 boost::asio::read_until(*
socket_, response,
"\r\n", ec);
1609 std::istream response_stream(&response);
1612 response_stream >> http_version;
1614 response_stream >> serverHttpStatus;
1617 std::getline(response_stream, status_message);
1618 if (!response_stream || http_version.substr(0, 5) !=
"HTTP/") {
1623 if (serverHttpStatus != 200) {
1624 edm::LogWarning(
"EvFDaqDirector") <<
"Response returned with status code " << serverHttpStatus;
1631 while (std::getline(response_stream,
header) &&
header !=
"\r") {
1635 std::map<std::string, std::string> serverMap;
1636 while (std::getline(response_stream, fileInfo) && fileInfo !=
"\r") {
1637 auto pos = fileInfo.find(
'=');
1638 if (
pos == std::string::npos)
1640 auto stitle = fileInfo.substr(0,
pos);
1641 auto svalue = fileInfo.substr(
pos + 1);
1642 serverMap[stitle] = svalue;
1646 auto server_version = serverMap.find(
"version");
1647 assert(server_version != serverMap.end());
1649 auto server_run = serverMap.find(
"runnumber");
1650 assert(server_run != serverMap.end());
1653 auto server_state = serverMap.find(
"state");
1654 assert(server_state != serverMap.end());
1656 auto server_eols = serverMap.find(
"lasteols");
1657 assert(server_eols != serverMap.end());
1659 auto server_ls = serverMap.find(
"lumisection");
1661 int version_maj = 1;
1662 int version_min = 0;
1663 int version_rev = 0;
1665 auto* s_ptr = server_version->second.c_str();
1666 if (!server_version->second.empty() && server_version->second[0] ==
'"')
1668 auto res = sscanf(s_ptr,
"%d.%d.%d", &version_maj, &version_min, &version_rev);
1670 res = sscanf(s_ptr,
"%d.%d", &version_maj, &version_min);
1672 res = sscanf(s_ptr,
"%d", &version_maj);
1675 edm::LogWarning(
"EvFDaqDirector") <<
"Can not parse server version " << server_version->second;
1682 if (server_ls != serverMap.end())
1685 serverLS = closedServerLS + 1;
1688 if (s_state ==
"STARTING")
1690 auto server_file = serverMap.find(
"file");
1691 assert(server_file == serverMap.end());
1693 edm::LogInfo(
"EvFDaqDirector") <<
"Got STARTING notification with last EOLS " << closedServerLS;
1694 }
else if (s_state ==
"READY") {
1695 auto server_file = serverMap.find(
"file");
1696 if (server_file == serverMap.end()) {
1698 if (serverLS <= closedServerLS)
1699 serverLS = closedServerLS + 1;
1702 <<
"Got READY notification with last EOLS " << closedServerLS <<
" and no new file";
1706 auto server_fileprefix = serverMap.find(
"fileprefix");
1708 if (server_fileprefix != serverMap.end()) {
1709 auto pssize = server_fileprefix->second.size();
1710 if (pssize > 1 && server_fileprefix->second[0] ==
'"' && server_fileprefix->second[pssize - 1] ==
'"')
1711 fileprefix = server_fileprefix->second.substr(1, pssize - 2);
1713 fileprefix = server_fileprefix->second;
1717 auto ssize = server_file->second.size();
1718 if (ssize > 1 && server_file->second[0] ==
'"' && server_file->second[ssize - 1] ==
'"')
1719 filestem = server_file->second.substr(1, ssize - 2);
1721 filestem = server_file->second;
1722 assert(!filestem.empty());
1723 if (version_maj > 1) {
1724 nextFileRaw =
bu_run_dir_ +
"/" + fileprefix + filestem +
".raw";
1725 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1729 nextFileRaw =
bu_run_dir_ +
"/" + filestem +
".raw";
1730 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1731 nextFileJson = filestem +
".jsn";
1735 edm::LogInfo(
"EvFDaqDirector") <<
"Got READY notification with last EOLS " << closedServerLS <<
" new LS " 1736 << serverLS <<
" file:" << filestem;
1738 }
else if (s_state ==
"EOLS") {
1739 serverLS = closedServerLS + 1;
1740 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOLS notification with last EOLS " << closedServerLS;
1742 }
else if (s_state ==
"EOR") {
1744 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOR notification with last EOLS " << closedServerLS;
1746 }
else if (s_state ==
"NORUN") {
1747 auto err_msg = serverMap.find(
"errormessage");
1748 if (err_msg != serverMap.end())
1749 edm::LogWarning(
"EvFDaqDirector") <<
"Server NORUN -:" << server_state->second <<
" : " << err_msg->second;
1754 }
else if (s_state ==
"ERROR") {
1755 auto err_msg = serverMap.find(
"errormessage");
1756 if (err_msg != serverMap.end())
1757 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second <<
" : " << err_msg->second;
1759 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second;
1763 edm::LogWarning(
"EvFDaqDirector") <<
"Unknown Server state -:" << server_state->second;
1772 if (ec != boost::asio::error::eof) {
1787 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
1814 uint16_t& rawHeaderSize,
1815 int32_t& serverEventsInNewFile,
1816 int64_t& fileSizeFromMetadata,
1818 bool requireHeader) {
1826 int stopFileLS = -1;
1829 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
1830 if (stopFileCheck == 0)
1836 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
1840 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 1854 timeval ts_lockbegin;
1855 gettimeofday(&ts_lockbegin,
nullptr);
1858 uint32_t serverLS, closedServerLS;
1859 unsigned int serverHttpStatus;
1866 int maxLS = stopFileLS < 0 ? -1 :
std::max(stopFileLS, (
int)currentLumiSection);
1867 bool rawHeader =
false;
1869 serverHttpStatus, serverError, serverLS, closedServerLS, nextFileJson, nextFileRaw, rawHeader, maxLS);
1879 if (currentLumiSection == 0) {
1885 if (closedServerLS >= currentLumiSection) {
1887 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1892 bool fileFound =
true;
1897 nextFileRaw, rawFd, rawHeaderSize, fileSizeFromMetadata, fileFound, serverLS,
false, requireHeader);
1899 serverEventsInNewFile =
grabNextJsonFile(nextFileJson, nextFileRaw, fileSizeFromMetadata, fileFound);
1902 if (serverEventsInNewFile < 0 && rawFd != -1) {
1923 if (currentLumiSection == 0) {
1933 if (closedServerLS >= currentLumiSection) {
1936 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1944 else if (fileStatus ==
newFile) {
1947 }
else if (fileStatus ==
noFile) {
1951 edm::LogWarning(
"EvFDaqDirector") <<
"Server reported LS " << serverLS
1952 <<
" which is smaller than currently open LS " <<
ls <<
". Ignoring response";
1964 if (!std::filesystem::is_directory(openPath)) {
1965 LogDebug(
"EvFDaqDirector") <<
"<open> FU dir not found. Creating... -:" << openPath.string();
1966 std::filesystem::create_directories(openPath);
1971 std::ifstream ij(
file);
1975 if (!
reader.parse(ij, deserializeRoot)) {
1976 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" <<
file;
1980 int ret = deserializeRoot.
get(
"lastLS",
"").
asInt();
1988 unsigned int lscount = 1;
1990 std::stringstream
ss;
1991 ss << fileprefix << std::setfill(
'0') << std::setw(4) << lscount <<
"_EoLS.jsn";
2001 int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
2002 close(proc_flag_fd);
2005 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)
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_