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 run_(
pset.getUntrackedParameter<unsigned
int>(
"runNumber")),
44 useFileBroker_(
pset.getUntrackedParameter<
bool>(
"useFileBroker")),
45 fileBrokerHostFromCfg_(
pset.getUntrackedParameter<
bool>(
"fileBrokerHostFromCfg",
true)),
46 fileBrokerHost_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerHost",
"InValid")),
47 fileBrokerPort_(
pset.getUntrackedParameter<
std::
string>(
"fileBrokerPort",
"8080")),
48 fileBrokerKeepAlive_(
pset.getUntrackedParameter<
bool>(
"fileBrokerKeepAlive",
true)),
49 fileBrokerUseLocalLock_(
pset.getUntrackedParameter<
bool>(
"fileBrokerUseLocalLock",
true)),
50 fuLockPollInterval_(
pset.getUntrackedParameter<unsigned
int>(
"fuLockPollInterval", 2000)),
51 outputAdler32Recheck_(
pset.getUntrackedParameter<
bool>(
"outputAdler32Recheck",
false)),
52 requireTSPSet_(
pset.getUntrackedParameter<
bool>(
"requireTransfersPSet",
false)),
53 selectedTransferMode_(
pset.getUntrackedParameter<
std::
string>(
"selectedTransferMode",
"")),
54 mergeTypePset_(
pset.getUntrackedParameter<
std::
string>(
"mergingPset",
"")),
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())) {
82 gethostname(hostname, 32);
85 char* fuLockPollIntervalPtr = std::getenv(
"FFF_LOCKPOLLINTERVAL");
86 if (fuLockPollIntervalPtr) {
97 char* fileBrokerParamPtr = std::getenv(
"FFF_USEFILEBROKER");
98 if (fileBrokerParamPtr) {
111 if (
stat(
"/etc/appliance/bus.config", &
buf) == 0) {
116 throw cms::Exception(
"EvFDaqDirector") <<
"No file service or BU data address information";
119 <<
"fileBrokerHostFromCfg must be set to true if fileBrokerHost parameter is not valid or empty";
127 char* startFromLSPtr = std::getenv(
"FFF_START_LUMISECTION");
128 if (startFromLSPtr) {
138 char* fileBrokerUseLockParamPtr = std::getenv(
"FFF_FILEBROKERUSELOCALLOCK");
139 if (fileBrokerUseLockParamPtr) {
142 edm::LogInfo(
"EvFDaqDirector") <<
"Setting fileBrokerUseLocalLock parameter by environment string: " 149 std::stringstream
ss;
150 ss <<
"run" << std::setfill(
'0') << std::setw(6) <<
run_;
152 ss = std::stringstream();
158 ss = std::stringstream();
165 int retval =
mkdir(
base_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
166 if (retval != 0 && errno != EEXIST) {
168 <<
" Error checking for base dir -: " <<
base_dir_ <<
" mkdir error:" << strerror(errno);
173 retval =
mkdir(
run_dir_.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IRWXO | S_IXOTH);
174 if (retval != 0 && errno != EEXIST) {
176 <<
" Error creating run dir -: " <<
run_dir_ <<
" mkdir error:" << strerror(errno);
184 open(fulocal_lock_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
187 <<
" Error creating/opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
188 chmod(fulocal_lock_.c_str(), 0777);
192 open(fulocal_lock_.c_str(), O_RDWR, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
195 <<
" Error opening a local lock file -: " << fulocal_lock_.c_str() <<
" : " << strerror(errno);
207 if (retval != 0 && errno != EEXIST) {
209 <<
" Error creating bu run dir -: " <<
bu_run_dir_ <<
" mkdir error:" << strerror(errno);
213 if (retval != 0 && errno != EEXIST) {
215 <<
" Error creating bu run open dir -: " <<
bu_run_open_dir_ <<
" mkdir error:" << strerror(errno);
219 bu_writelock_fd_ = open(bulockfile.c_str(), O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
221 edm::LogWarning(
"EvFDaqDirector") <<
"problem with creating filedesc for buwritelock -: " << strerror(errno);
226 edm::LogWarning(
"EvFDaqDirector") <<
"Error creating write lock stream -: " << strerror(errno);
240 retval =
mkdir(tmphltdir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
241 if (retval != 0 && errno != EEXIST)
243 <<
" Error creating bu run dir -: " << hltdir <<
" mkdir error:" << strerror(errno);
245 std::filesystem::copy_file(
hltSourceDirectory_ +
"/HltConfig.py", tmphltdir +
"/HltConfig.py");
246 std::filesystem::copy_file(
hltSourceDirectory_ +
"/fffParameters.jsn", tmphltdir +
"/fffParameters.jsn");
248 std::string optfiles[3] = {
"hltinfo",
"blacklist",
"whitelist"};
249 for (
auto& optfile : optfiles) {
251 std::filesystem::copy_file(
hltSourceDirectory_ +
"/" + optfile, tmphltdir +
"/" + optfile);
256 std::filesystem::rename(tmphltdir, hltdir);
264 auto checkExists = [=](
std::string const& bu_base_dir) ->
void {
265 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
266 if (retval != 0 && errno != EEXIST) {
268 <<
" Error checking for bu base dir -: " << bu_base_dir <<
" mkdir error:" << strerror(errno);
272 auto waitForDir = [=](
std::string const& bu_base_dir) ->
void {
275 int retval =
mkdir(bu_base_dir.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
276 if (retval != 0 && errno != EEXIST) {
282 throw cms::Exception(
"DaqDirector") <<
" Error checking for bu base dir after 1 minute -: " << bu_base_dir
283 <<
" mkdir error:" << strerror(errno);
307 std::stringstream sstp;
314 if (!
stat(defPath.c_str(), &statbuf))
315 edm::LogInfo(
"EvFDaqDirector") <<
"found JSD file in ramdisk -: " << defPath;
318 std::string defPathSuffix =
"src/EventFilter/Utilities/plugins/budef.jsd";
319 defPath =
std::string(std::getenv(
"CMSSW_BASE")) +
"/" + defPathSuffix;
320 if (
stat(defPath.c_str(), &statbuf)) {
321 defPath =
std::string(std::getenv(
"CMSSW_RELEASE_BASE")) +
"/" + defPathSuffix;
322 if (
stat(defPath.c_str(), &statbuf)) {
323 defPath = defPathSuffix;
329 DataPointDefinition::getDataPointDefinitionFor(defPath,
dpd_, &defLabel);
336 boost::system::error_code ec;
337 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
363 "Service used for file locking arbitration and for propagating information between other EvF components");
364 desc.addUntracked<
std::string>(
"baseDir",
".")->setComment(
"Local base directory for run output");
365 desc.addUntracked<
std::string>(
"buBaseDir",
".")->setComment(
"BU base ramdisk directory ");
366 desc.addUntracked<std::vector<std::string>>(
"buBaseDirsAll", std::vector<std::string>())
367 ->setComment(
"BU base ramdisk directories for multi-file DAQSource models");
368 desc.addUntracked<
unsigned int>(
"runNumber", 0)->setComment(
"Run Number in ramdisk to open");
369 desc.addUntracked<
bool>(
"useFileBroker",
false)
370 ->setComment(
"Use BU file service to grab input data instead of NFS file locking");
371 desc.addUntracked<
bool>(
"fileBrokerHostFromCfg",
true)
372 ->setComment(
"Allow service to discover BU address from hltd configuration");
373 desc.addUntracked<
std::string>(
"fileBrokerHost",
"InValid")->setComment(
"BU file service host.");
374 desc.addUntracked<
std::string>(
"fileBrokerPort",
"8080")->setComment(
"BU file service port");
375 desc.addUntracked<
bool>(
"fileBrokerKeepAlive",
true)
376 ->setComment(
"Use keep alive to avoid using large number of sockets");
377 desc.addUntracked<
bool>(
"fileBrokerUseLocalLock",
true)
378 ->setComment(
"Use local lock file to synchronize appearance of index and EoLS file markers for hltd");
379 desc.addUntracked<
unsigned int>(
"fuLockPollInterval", 2000)
380 ->setComment(
"Lock polling interval in microseconds for the input directory file lock");
381 desc.addUntracked<
bool>(
"outputAdler32Recheck",
false)
382 ->setComment(
"Check Adler32 of per-process output files while micro-merging");
383 desc.addUntracked<
bool>(
"requireTransfersPSet",
false)
384 ->setComment(
"Require complete transferSystem PSet in the process configuration");
386 ->setComment(
"Selected transfer mode (choice in Lvl0 propagated as Python parameter");
387 desc.addUntracked<
bool>(
"directorIsBU",
false)->setComment(
"BU director mode used for testing");
388 desc.addUntracked<
std::string>(
"hltSourceDirectory",
"")->setComment(
"BU director mode source directory");
390 ->setComment(
"Name of merging PSet to look for merging type definitions for streams");
391 descriptions.
add(
"EvFDaqDirector",
desc);
422 edm::LogWarning(
"EvFDaqDirector") <<
" Handles to check for files to delete were not set by the input source...";
536 int retval =
remove(
filename.c_str());
539 <<
". error = " << strerror(errno);
545 uint16_t& rawHeaderSize,
547 bool& setExceptionState) {
552 int lock_attempts = 0;
553 long total_lock_attempts = 0;
559 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
560 if (stopFileCheck == 0)
566 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
570 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 576 timeval ts_lockbegin;
577 gettimeofday(&ts_lockbegin,
nullptr);
579 while (retval == -1) {
588 if (lock_attempts > 5000000 || errno == 116) {
591 <<
"Stale lock file handle. Checking if run directory and fu.lock file are present" << std::endl;
593 edm::LogWarning(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 seconds. Checking if run directory and " 594 "fu.lock file are present -: errno " 595 << errno <<
":" << strerror(errno) << std::endl;
598 edm::LogWarning(
"EvFDaqDirector") <<
"Detected local EoLS for lumisection " <<
ls;
610 if (total_lock_attempts > 5 * 60000000) {
611 edm::LogError(
"EvFDaqDirector") <<
"Unable to obtain a lock for 5 minutes. Stopping polling activity.";
617 gettimeofday(&ts_lockend,
nullptr);
618 long deltat = (ts_lockend.tv_usec - ts_lockbegin.tv_usec) + (ts_lockend.tv_sec - ts_lockbegin.tv_sec) * 1000000;
620 lockWaitTime = deltat;
627 gettimeofday(&ts_lockend, 0);
631 int fu_readwritelock_fd2 = open(
fulockfile_.c_str(), O_RDWR, S_IRWXU);
632 if (fu_readwritelock_fd2 == -1)
634 <<
" create. error:" << strerror(errno);
636 FILE* fu_rw_lock_stream2 = fdopen(fu_readwritelock_fd2,
"r+");
639 if (fu_rw_lock_stream2 !=
nullptr) {
643 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
647 fscanf(fu_rw_lock_stream2,
"%u %u", &readLs, &
readIndex);
650 unsigned int currentLs = readLs;
651 bool bumpedOk =
false;
654 if (
ls &&
ls + 1 < currentLs)
658 bumpedOk =
bumpFile(readLs,
readIndex, nextFile, fsize, rawHeaderSize, stopFileLS, setExceptionState);
660 if (
ls && readLs > currentLs && currentLs >
ls) {
662 readLs = currentLs =
ls;
667 if (
ls == 0 && readLs > currentLs) {
682 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
684 ftruncate(fu_readwritelock_fd2, 0);
686 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex + 1);
687 fflush(fu_rw_lock_stream2);
688 fsync(fu_readwritelock_fd2);
690 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex + 1;
693 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
694 setExceptionState =
true;
697 }
else if (currentLs < readLs) {
699 check = fseek(fu_rw_lock_stream2, 0, SEEK_SET);
701 ftruncate(fu_readwritelock_fd2, 0);
703 fprintf(fu_rw_lock_stream2,
"%u %u", readLs,
readIndex);
704 fflush(fu_rw_lock_stream2);
705 fsync(fu_readwritelock_fd2);
706 LogDebug(
"EvFDaqDirector") <<
"Written to file -: " << readLs <<
":" <<
readIndex;
709 <<
"seek on fu read/write lock for updating failed with error " << strerror(errno);
710 setExceptionState =
true;
715 edm::LogError(
"EvFDaqDirector") <<
"seek on fu read/write lock for reading failed with error " 719 edm::LogError(
"EvFDaqDirector") <<
"fu read/write lock stream is invalid " << strerror(errno);
721 fclose(fu_rw_lock_stream2);
724 timeval ts_preunlock;
725 gettimeofday(&ts_preunlock, 0);
726 int locked_period_int = ts_preunlock.tv_sec - ts_lockend.tv_sec;
727 double locked_period = locked_period_int + double(ts_preunlock.tv_usec - ts_lockend.tv_usec) / 1000000;
738 edm::LogError(
"EvFDaqDirector") <<
"Error unlocking the fu.lock " << strerror(errno);
741 edm::LogDebug(
"EvFDaqDirector") <<
"Waited during lock -: " << locked_period <<
" seconds";
744 if (fileStatus ==
noFile) {
749 if (stopFileLS >= 0 && (
int)
ls > stopFileLS) {
750 edm::LogInfo(
"EvFDaqDirector") <<
"Reached maximum lumisection set by hltd";
758 std::ifstream ij(BUEoLSFile);
762 if (!
reader.parse(ij, deserializeRoot)) {
763 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" << BUEoLSFile;
769 dp.deserialize(deserializeRoot);
777 while (!
def.empty()) {
779 if (
def.find(
'/') == 0)
787 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
792 DataPointDefinition::getDataPointDefinitionFor(
fullpath, &eolsDpd, &defLabel);
794 for (
unsigned int i = 0;
i < eolsDpd.
getNames().size();
i++)
795 if (eolsDpd.
getNames().at(
i) ==
"NFiles")
801 if (
def.size() <= 1 ||
def.find(
'/') == std::string::npos) {
812 edm::LogError(
"EvFDaqDirector") <<
" error reading number of files from BU JSON -: " << BUEoLSFile;
815 return std::stoi(
data);
822 uint16_t& rawHeaderSize,
824 bool& setExceptionState) {
836 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
840 std::stringstream
ss;
841 unsigned int nextIndex =
index;
846 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
848 nextFile = nextFileJson;
857 nextFile = nextFileRaw;
863 if (
stat(BUEoLSFile.c_str(), &
buf) == 0) {
865 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
867 nextFile = nextFileJson;
872 nextFile = nextFileRaw;
877 if (indexFilesInLS < 0)
882 if ((
int)
index < indexFilesInLS) {
885 <<
"Potential miss of index file in LS -: " <<
ls <<
". Missing " << nextFile <<
" because " 886 << indexFilesInLS - 1 <<
" is the highest index expected. Will not update fu.lock file";
887 setExceptionState =
true;
896 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
901 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
904 nextFile = nextFileJson;
909 nextFile = nextFileRaw;
921 edm::LogError(
"EvFDaqDirector") <<
"Error creating fu read/write lock stream " << strerror(errno);
923 edm::LogInfo(
"EvFDaqDirector") <<
"Initializing FU LOCK FILE";
932 open(
fulockfile_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
939 <<
" create:" <<
create <<
" error:" << strerror(errno);
945 edm::LogError(
"EvFDaqDirector") <<
"problem with opening fuwritelock file stream -: " << strerror(errno);
976 if (checkIfExists ==
false ||
stat(fuBoLS.c_str(), &
buf) != 0) {
977 int bol_fd = open(fuBoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
983 const uint32_t currentLumiSection,
986 if (currentLumiSection > 0) {
993 open(fuEoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
999 }
else if (doCreateBoLS) {
1006 uint16_t& rawHeaderSize,
1007 uint16_t& rawDataType,
1008 uint32_t& lsFromHeader,
1009 int32_t& eventsFromHeader,
1010 int64_t& fileSizeFromHeader,
1016 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1019 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1031 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1033 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1034 if (errno == ENOENT)
1050 if (frd_version == 0) {
1052 if (requireHeader) {
1053 edm::LogError(
"EvFDaqDirector") <<
"no header or invalid version string found in:" << rawSourcePath;
1058 lseek(
infile, 0, SEEK_SET);
1061 eventsFromHeader = -1;
1062 fileSizeFromHeader = -1;
1064 }
else if (frd_version == 1) {
1071 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1072 <<
" v:" << frd_version;
1079 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1080 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1083 }
else if (frd_version == 2) {
1090 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1091 <<
" v:" << frd_version;
1098 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1099 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1115 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unable to read " <<
path <<
" : " << strerror(errno);
1120 if ((
size_t)sz_read < buf_sz) {
1121 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - file smaller than header: " <<
path;
1131 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1132 edm::LogWarning(
"EvFDaqDirector") <<
"rawFileHasHeader - failed to open input file -: " << rawSourcePath <<
" : " 1143 if (frd_version == 1) {
1150 }
else if (frd_version == 2) {
1158 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unknown version: " << frd_version;
1167 uint16_t& rawHeaderSize,
1168 int64_t& fileSizeFromHeader,
1172 bool requireHeader) {
1177 size_t pos = 0, n_tokens = 0;
1178 while (n_tokens++ < 3 && (
pos = jsonStem.find(
'_',
pos + 1)) != std::string::npos) {
1182 std::ostringstream fileNameWithPID;
1184 fileNameWithPID << reducedJsonStem <<
"_pid" << std::setfill(
'0') << std::setw(5) <<
pid_ <<
".jsn";
1188 LogDebug(
"EvFDaqDirector") <<
"RAW parse -: " << rawSourcePath <<
" and JSON create " << jsonDestPath;
1192 int32_t nbEventsWrittenRaw;
1193 int64_t fileSizeFromRaw;
1194 uint16_t rawDataType;
1212 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1213 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1214 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1215 if (errno == EEXIST) {
1216 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - destination file already exists -: " << jsonDestPath
1220 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file -: " << jsonDestPath <<
" : " 1222 struct stat out_stat;
1223 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1225 <<
"grabNextJsonFromRaw - output file possibly got created with error, deleting and retry -: " 1227 if (unlink(jsonDestPath.c_str()) == -1) {
1229 <<
"grabNextJsonFromRaw - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1232 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1233 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file (on retry) -: " 1234 << jsonDestPath <<
" : " << strerror(errno);
1239 std::stringstream
ss;
1240 ss <<
"{\"data\":[" << nbEventsWrittenRaw <<
"," << fileSizeFromRaw <<
",\"" << rawSourcePath <<
"\"]}";
1244 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to write to output file file -: " << jsonDestPath
1245 <<
" : " << strerror(errno);
1249 if (serverLS && serverLS != lsFromRaw)
1250 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - mismatch in expected (server) LS " << serverLS
1251 <<
" and raw file header LS " << lsFromRaw;
1253 fileSizeFromHeader = fileSizeFromRaw;
1254 return nbEventsWrittenRaw;
1259 int64_t& fileSizeFromJson,
1264 std::ostringstream fileNameWithPID;
1265 fileNameWithPID <<
std::filesystem::path(rawSourcePath).stem().string() <<
"_pid" << std::setfill(
'0')
1266 << std::setw(5) <<
pid_ <<
".jsn";
1271 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1275 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1276 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file -: " << jsonSourcePath <<
" : " 1278 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1279 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file (on retry) -: " 1280 << jsonSourcePath <<
" : " << strerror(errno);
1281 if (errno == ENOENT)
1287 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1288 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1289 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1290 if (errno == EEXIST) {
1291 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - destination file already exists -: " << jsonDestPath
1296 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file -: " << jsonDestPath <<
" : " 1298 struct stat out_stat;
1299 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1301 <<
"grabNextJsonFile - output file possibly got created with error, deleting and retry -: " << jsonDestPath;
1302 if (unlink(jsonDestPath.c_str()) == -1) {
1304 <<
"grabNextJsonFile - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1307 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1308 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file (on retry) -: " 1309 << jsonDestPath <<
" : " << strerror(errno);
1315 const std::size_t buf_sz = 512;
1316 std::size_t tot_written = 0;
1317 std::unique_ptr<char[]>
buf(
new char[buf_sz]);
1319 ssize_t sz, sz_read = 1, sz_write;
1320 while (sz_read > 0 && (sz_read = ::
read(
infile,
buf.get(), buf_sz)) > 0) {
1323 assert(sz_read - sz_write > 0);
1324 if ((sz = ::
write(
outfile,
buf.get() + sz_write, sz_read - sz_write)) < 0) {
1331 }
while (sz_write < sz_read);
1336 if (tot_written > 0) {
1338 if (unlink(jsonSourcePath.c_str()) == -1) {
1339 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to remove -: " << jsonSourcePath <<
" : " 1344 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to copy json file or file was empty -: " 1353 std::stringstream
ss;
1356 if (tot_written <= buf_sz) {
1361 std::ifstream ij(jsonDestPath);
1363 }
catch (std::filesystem::filesystem_error
const& ex) {
1364 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - FILESYSTEM ERROR CAUGHT -: " << ex.what();
1370 if (tot_written <= buf_sz)
1372 edm::LogError(
"EvFDaqDirector") <<
"Failed to deserialize JSON file -: " << jsonDestPath <<
"\nERROR:\n" 1373 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1380 dp.deserialize(deserializeRoot);
1384 if (
i <
dp.getData().size()) {
1391 if (!
dp.getData().empty())
1395 <<
"grabNextJsonFile - " 1396 <<
" error reading number of events from BU JSON; No input value. data -: " <<
data;
1402 fileSizeFromJson = -1;
1405 if (
i <
dp.getData().size()) {
1408 fileSizeFromJson = std::stol(dataSize);
1411 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of Bytes from BU JSON. " 1412 <<
"Input value is -: " << dataSize;
1418 return std::stoi(
data);
1419 }
catch (
const std::out_of_range&
e) {
1420 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of events from BU JSON. " 1421 <<
"Input value is -: " <<
data;
1422 }
catch (
const std::invalid_argument&
e) {
1423 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - argument error parsing events from BU JSON. " 1424 <<
"Input value is -: " <<
data;
1425 }
catch (std::runtime_error
const&
e) {
1427 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - std::runtime_error exception -: " <<
e.what();
1431 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED! -: " <<
e.what();
1434 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED!";
1447 std::ostringstream fileNameWithPID;
1448 fileNameWithPID << jsonSourcePath.stem().string() <<
"_pid" << std::setfill(
'0') << std::setw(5) << getpid()
1450 jsonDestPath /= fileNameWithPID.str();
1452 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1455 }
catch (std::filesystem::filesystem_error
const& ex) {
1457 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1467 }
catch (std::filesystem::filesystem_error
const& ex) {
1469 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1472 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile std::exception CAUGHT -: " << ex.what();
1475 std::ifstream ij(jsonDestPath);
1479 std::stringstream
ss;
1481 if (!
reader.parse(
ss.str(), deserializeRoot)) {
1482 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile Failed to deserialize JSON file -: " << jsonDestPath
1484 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1486 throw std::runtime_error(
"Cannot deserialize input JSON file");
1492 dp.deserialize(deserializeRoot);
1496 if (
i <
dp.getData().size()) {
1502 if (!
dp.getData().empty())
1506 <<
" error reading number of events from BU JSON -: No input value " <<
data;
1508 return std::stoi(
data);
1509 }
catch (std::filesystem::filesystem_error
const& ex) {
1512 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1513 }
catch (std::runtime_error
const&
e) {
1516 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile runtime Exception -: " <<
e.what();
1517 }
catch (
const std::out_of_range&) {
1518 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile error parsing number of events from BU JSON. " 1519 <<
"Input value is -: " <<
data;
1520 }
catch (
const std::invalid_argument&) {
1521 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile argument error parsing events from BU JSON. " 1522 <<
"Input value is -: " <<
data;
1526 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile SOME OTHER EXCEPTION OCCURED!!!! -: " <<
e.what();
1535 uint32_t& closedServerLS,
1541 serverError =
false;
1543 boost::system::error_code ec;
1551 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1557 boost::asio::streambuf request;
1558 std::ostream request_stream(&request);
1561 std::stringstream spath;
1562 spath <<
path <<
"&stopls=" << maxLS;
1566 request_stream <<
"GET " <<
path <<
" HTTP/1.1\r\n";
1568 request_stream <<
"Accept: */*\r\n";
1569 request_stream <<
"Connection: keep-alive\r\n\r\n";
1574 edm::LogInfo(
"EvFDaqDirector") <<
"reconnecting socket on received connection_reset";
1578 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1584 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::write error -:" << ec;
1589 boost::asio::streambuf response;
1590 boost::asio::read_until(*
socket_, response,
"\r\n", ec);
1592 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1597 std::istream response_stream(&response);
1600 response_stream >> http_version;
1602 response_stream >> serverHttpStatus;
1605 std::getline(response_stream, status_message);
1606 if (!response_stream || http_version.substr(0, 5) !=
"HTTP/") {
1611 if (serverHttpStatus != 200) {
1612 edm::LogWarning(
"EvFDaqDirector") <<
"Response returned with status code " << serverHttpStatus;
1619 while (std::getline(response_stream,
header) &&
header !=
"\r") {
1623 std::map<std::string, std::string> serverMap;
1624 while (std::getline(response_stream, fileInfo) && fileInfo !=
"\r") {
1625 auto pos = fileInfo.find(
'=');
1626 if (
pos == std::string::npos)
1628 auto stitle = fileInfo.substr(0,
pos);
1629 auto svalue = fileInfo.substr(
pos + 1);
1630 serverMap[stitle] = svalue;
1634 auto server_version = serverMap.find(
"version");
1635 assert(server_version != serverMap.end());
1637 auto server_run = serverMap.find(
"runnumber");
1638 assert(server_run != serverMap.end());
1641 auto server_state = serverMap.find(
"state");
1642 assert(server_state != serverMap.end());
1644 auto server_eols = serverMap.find(
"lasteols");
1645 assert(server_eols != serverMap.end());
1647 auto server_ls = serverMap.find(
"lumisection");
1649 int version_maj = 1;
1650 int version_min = 0;
1651 int version_rev = 0;
1653 auto* s_ptr = server_version->second.c_str();
1654 if (!server_version->second.empty() && server_version->second[0] ==
'"')
1656 auto res = sscanf(s_ptr,
"%d.%d.%d", &version_maj, &version_min, &version_rev);
1658 res = sscanf(s_ptr,
"%d.%d", &version_maj, &version_min);
1660 res = sscanf(s_ptr,
"%d", &version_maj);
1663 edm::LogWarning(
"EvFDaqDirector") <<
"Can not parse server version " << server_version->second;
1670 if (server_ls != serverMap.end())
1673 serverLS = closedServerLS + 1;
1676 if (s_state ==
"STARTING")
1678 auto server_file = serverMap.find(
"file");
1679 assert(server_file == serverMap.end());
1681 edm::LogInfo(
"EvFDaqDirector") <<
"Got STARTING notification with last EOLS " << closedServerLS;
1682 }
else if (s_state ==
"READY") {
1683 auto server_file = serverMap.find(
"file");
1684 if (server_file == serverMap.end()) {
1686 if (serverLS <= closedServerLS)
1687 serverLS = closedServerLS + 1;
1690 <<
"Got READY notification with last EOLS " << closedServerLS <<
" and no new file";
1694 auto server_fileprefix = serverMap.find(
"fileprefix");
1696 if (server_fileprefix != serverMap.end()) {
1697 auto pssize = server_fileprefix->second.size();
1698 if (pssize > 1 && server_fileprefix->second[0] ==
'"' && server_fileprefix->second[pssize - 1] ==
'"')
1699 fileprefix = server_fileprefix->second.substr(1, pssize - 2);
1701 fileprefix = server_fileprefix->second;
1705 auto ssize = server_file->second.size();
1706 if (ssize > 1 && server_file->second[0] ==
'"' && server_file->second[ssize - 1] ==
'"')
1707 filestem = server_file->second.substr(1, ssize - 2);
1709 filestem = server_file->second;
1710 assert(!filestem.empty());
1711 if (version_maj > 1) {
1712 nextFileRaw =
bu_run_dir_ +
"/" + fileprefix + filestem +
".raw";
1713 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1717 nextFileRaw =
bu_run_dir_ +
"/" + filestem +
".raw";
1718 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1719 nextFileJson = filestem +
".jsn";
1723 edm::LogInfo(
"EvFDaqDirector") <<
"Got READY notification with last EOLS " << closedServerLS <<
" new LS " 1724 << serverLS <<
" file:" << filestem;
1726 }
else if (s_state ==
"EOLS") {
1727 serverLS = closedServerLS + 1;
1728 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOLS notification with last EOLS " << closedServerLS;
1730 }
else if (s_state ==
"EOR") {
1732 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOR notification with last EOLS " << closedServerLS;
1734 }
else if (s_state ==
"NORUN") {
1735 auto err_msg = serverMap.find(
"errormessage");
1736 if (err_msg != serverMap.end())
1737 edm::LogWarning(
"EvFDaqDirector") <<
"Server NORUN -:" << server_state->second <<
" : " << err_msg->second;
1742 }
else if (s_state ==
"ERROR") {
1743 auto err_msg = serverMap.find(
"errormessage");
1744 if (err_msg != serverMap.end())
1745 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second <<
" : " << err_msg->second;
1747 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second;
1751 edm::LogWarning(
"EvFDaqDirector") <<
"Unknown Server state -:" << server_state->second;
1760 if (ec != boost::asio::error::eof) {
1761 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1775 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
1777 edm::LogWarning(
"EvFDaqDirector") <<
"socket shutdown error -:" << ec;
1802 uint16_t& rawHeaderSize,
1803 int32_t& serverEventsInNewFile,
1804 int64_t& fileSizeFromMetadata,
1806 bool requireHeader) {
1814 int stopFileLS = -1;
1817 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
1818 if (stopFileCheck == 0)
1824 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
1828 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 1842 timeval ts_lockbegin;
1843 gettimeofday(&ts_lockbegin,
nullptr);
1846 uint32_t serverLS, closedServerLS;
1847 unsigned int serverHttpStatus;
1854 int maxLS = stopFileLS < 0 ? -1 :
std::max(stopFileLS, (
int)currentLumiSection);
1855 bool rawHeader =
false;
1857 serverHttpStatus, serverError, serverLS, closedServerLS, nextFileJson, nextFileRaw, rawHeader, maxLS);
1867 if (currentLumiSection == 0) {
1873 if (closedServerLS >= currentLumiSection) {
1875 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1880 bool fileFound =
true;
1885 nextFileRaw, rawFd, rawHeaderSize, fileSizeFromMetadata, fileFound, serverLS,
false, requireHeader);
1887 serverEventsInNewFile =
grabNextJsonFile(nextFileJson, nextFileRaw, fileSizeFromMetadata, fileFound);
1890 if (serverEventsInNewFile < 0 && rawFd != -1) {
1911 if (currentLumiSection == 0) {
1921 if (closedServerLS >= currentLumiSection) {
1924 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1932 else if (fileStatus ==
newFile) {
1935 }
else if (fileStatus ==
noFile) {
1939 edm::LogWarning(
"EvFDaqDirector") <<
"Server reported LS " << serverLS
1940 <<
" which is smaller than currently open LS " <<
ls <<
". Ignoring response";
1952 if (!std::filesystem::is_directory(openPath)) {
1953 LogDebug(
"EvFDaqDirector") <<
"<open> FU dir not found. Creating... -:" << openPath.string();
1954 std::filesystem::create_directories(openPath);
1959 std::ifstream ij(
file);
1963 if (!
reader.parse(ij, deserializeRoot)) {
1964 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" <<
file;
1968 int ret = deserializeRoot.
get(
"lastLS",
"").
asInt();
1976 unsigned int lscount = 1;
1978 std::stringstream
ss;
1979 ss << fileprefix << std::setfill(
'0') << std::setw(4) << lscount <<
"_EoLS.jsn";
1997 std::vector<std::string>
destinations = tsPset.getParameter<std::vector<std::string>>(
"destinations");
1999 destinationsVal.append(
dest);
2000 (*transferSystemJson_)[
"destinations"] = destinationsVal;
2003 std::vector<std::string> modes = tsPset.getParameter<std::vector<std::string>>(
"transferModes");
2004 for (
auto&
mode : modes)
2006 (*transferSystemJson_)[
"transferModes"] = modesVal;
2008 for (
auto psKeyItr = tsPset.psetTable().begin(); psKeyItr != tsPset.psetTable().end(); ++psKeyItr) {
2009 if (psKeyItr->first !=
"destinations" && psKeyItr->first !=
"transferModes") {
2012 for (
auto&
mode : modes) {
2014 if (!streamDef.
existsAs<std::vector<std::string>>(
mode,
true))
2016 <<
" Missing transfer system specification for -:" << psKeyItr->first <<
" (transferMode " <<
mode 2018 std::vector<std::string> streamDestinations = streamDef.
getParameter<std::vector<std::string>>(
mode);
2022 if (streamDestinations.empty())
2024 <<
" Missing transter system destination(s) for -: " << psKeyItr->first <<
", mode:" <<
mode;
2026 for (
auto& sdest : streamDestinations) {
2027 bool sDestValid =
false;
2028 sDestsValue.append(sdest);
2035 <<
" Invalid transter system destination specified for -: " << psKeyItr->first <<
", mode:" <<
mode 2036 <<
", dest:" << sdest;
2038 streamVal[
mode] = sDestsValue;
2040 (*transferSystemJson_)[psKeyItr->first] = streamVal;
2045 throw cms::Exception(
"EvFDaqDirector") <<
"transferSystem PSet not found";
2052 streamRequestName =
stream;
2054 std::stringstream
msg;
2055 msg <<
"Transfer system mode definitions missing for -: " <<
stream;
2066 <<
"Selected mode string is not provided as DaqDirector parameter." 2067 <<
"Switch on requireTSPSet parameter to enforce this requirement. Setting mode to empty string.";
2071 throw cms::Exception(
"EvFDaqDirector") <<
"Selected mode string is not provided as DaqDirector parameter.";
2075 std::stringstream
msg;
2090 ret += (*it).asString();
2105 tbb::concurrent_hash_map<std::string, std::string>::accessor ac;
2107 ac->second = streamType;
2114 tbb::concurrent_hash_map<std::string, std::string>::const_accessor search_ac;
2116 return search_ac->second;
2118 edm::LogInfo(
"EvFDaqDirector") <<
" No merging type specified for stream " <<
stream <<
". Using default value";
2120 tbb::concurrent_hash_map<std::string, std::string>::accessor ac;
2122 ac->second = defaultName;
2129 int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
2130 close(proc_flag_fd);
2133 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_
const_iterator end() const
std::vector< std::string > bu_base_dirs_all_
LuminosityBlockNumber_t luminosityBlock() const
T getParameter(std::string const &) 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_
const_iterator begin() const
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::shared_ptr< Json::Value > transferSystemJson_
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_
ParameterSet const & getParameterSet(std::string const &) const
Value get(UInt index, const Value &defaultValue) const
std::string getEoLSFilePathOnFU(const unsigned int ls) const
Value & append(const Value &value)
Append value to array at the end.
std::string to_string(const V &value)
void removeFile(std::string)
bool lumisectionDiscarded(unsigned int ls)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
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 getStreamDestinations(std::string const &stream) const
std::string getOpenProtocolBufferHistogramFilePath(const unsigned int ls, std::string const &stream) const
unsigned long previousFileSize_
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
std::string mergeTypePset_
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 getStreamMergeType(std::string const &stream, MergeType defaultType)
tbb::concurrent_hash_map< std::string, std::string > mergeTypeMap_
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 selectedTransferMode_
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 preBeginJob(edm::PathsAndConsumesOfModulesBase const &, edm::ProcessContext const &)
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 checkMergeTypePSet(edm::ProcessContext const &pc)
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_
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
std::string rootHistogramFileNameWithInstance(const unsigned int run, const unsigned int ls, std::string const &stream, std::string const &instance)
ParameterSet const & getParameterSet(ParameterSetID const &id)
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.
static const std::vector< std::string > MergeTypeNames_
unsigned int getLumisectionToStart() const
int grabNextJsonFile(std::string const &jsonSourcePath, std::string const &rawSourcePath, int64_t &fileSizeFromJson, bool &fileFound)
void checkTransferSystemPSet(edm::ProcessContext const &pc)
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
Iterator for object and array value.
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)
ParameterSetID const & parameterSetID() const
std::string bu_run_open_dir_
array value (ordered list)