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;
844 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
846 nextFile = nextFileJson;
855 nextFile = nextFileRaw;
861 if (
stat(BUEoLSFile.c_str(), &
buf) == 0) {
863 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
865 nextFile = nextFileJson;
870 nextFile = nextFileRaw;
875 if (indexFilesInLS < 0)
880 if ((
int)
index < indexFilesInLS) {
883 <<
"Potential miss of index file in LS -: " <<
ls <<
". Missing " << nextFile <<
" because " 884 << indexFilesInLS - 1 <<
" is the highest index expected. Will not update fu.lock file";
885 setExceptionState =
true;
894 if (maxLS >= 0 &&
ls > (
unsigned int)maxLS)
899 if (
stat(nextFileJson.c_str(), &
buf) == 0) {
902 nextFile = nextFileJson;
907 nextFile = nextFileRaw;
919 edm::LogError(
"EvFDaqDirector") <<
"Error creating fu read/write lock stream " << strerror(errno);
921 edm::LogInfo(
"EvFDaqDirector") <<
"Initializing FU LOCK FILE";
930 open(
fulockfile_.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
937 <<
" create:" <<
create <<
" error:" << strerror(errno);
943 edm::LogError(
"EvFDaqDirector") <<
"problem with opening fuwritelock file stream -: " << strerror(errno);
974 if (checkIfExists ==
false ||
stat(fuBoLS.c_str(), &
buf) != 0) {
975 int bol_fd = open(fuBoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
981 const uint32_t currentLumiSection,
984 if (currentLumiSection > 0) {
991 open(fuEoLS.c_str(), O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
997 }
else if (doCreateBoLS) {
1004 uint16_t& rawHeaderSize,
1005 uint16_t& rawDataType,
1006 uint32_t& lsFromHeader,
1007 int32_t& eventsFromHeader,
1008 int64_t& fileSizeFromHeader,
1014 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1017 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1029 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1031 <<
"parseFRDFileHeader - failed to open input file -: " << rawSourcePath <<
" : " << strerror(errno);
1032 if (errno == ENOENT)
1048 if (frd_version == 0) {
1050 if (requireHeader) {
1051 edm::LogError(
"EvFDaqDirector") <<
"no header or invalid version string found in:" << rawSourcePath;
1056 lseek(
infile, 0, SEEK_SET);
1059 eventsFromHeader = -1;
1060 fileSizeFromHeader = -1;
1062 }
else if (frd_version == 1) {
1069 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1070 <<
" v:" << frd_version;
1077 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1078 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1081 }
else if (frd_version == 2) {
1088 edm::LogError(
"EvFDaqDirector") <<
"inconsistent header size: " << rawSourcePath <<
" size: " << headerSizeRaw
1089 <<
" v:" << frd_version;
1096 eventsFromHeader = (int32_t)fhContent->
eventCount_;
1097 fileSizeFromHeader = (int64_t)fhContent->
fileSize_;
1113 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unable to read " <<
path <<
" : " << strerror(errno);
1118 if ((
size_t)sz_read < buf_sz) {
1119 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - file smaller than header: " <<
path;
1129 if ((
infile = ::open(rawSourcePath.c_str(), O_RDONLY)) < 0) {
1130 edm::LogWarning(
"EvFDaqDirector") <<
"rawFileHasHeader - failed to open input file -: " << rawSourcePath <<
" : " 1141 if (frd_version == 1) {
1148 }
else if (frd_version == 2) {
1156 edm::LogError(
"EvFDaqDirector") <<
"rawFileHasHeader - unknown version: " << frd_version;
1165 uint16_t& rawHeaderSize,
1166 int64_t& fileSizeFromHeader,
1170 bool requireHeader) {
1175 size_t pos = 0, n_tokens = 0;
1176 while (n_tokens++ < 3 && (
pos = jsonStem.find(
'_',
pos + 1)) != std::string::npos) {
1180 std::ostringstream fileNameWithPID;
1182 fileNameWithPID << reducedJsonStem <<
"_pid" << std::setfill(
'0') << std::setw(5) <<
pid_ <<
".jsn";
1186 LogDebug(
"EvFDaqDirector") <<
"RAW parse -: " << rawSourcePath <<
" and JSON create " << jsonDestPath;
1190 int32_t nbEventsWrittenRaw;
1191 int64_t fileSizeFromRaw;
1192 uint16_t rawDataType;
1210 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1211 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1212 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1213 if (errno == EEXIST) {
1214 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - destination file already exists -: " << jsonDestPath
1218 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file -: " << jsonDestPath <<
" : " 1220 struct stat out_stat;
1221 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1223 <<
"grabNextJsonFromRaw - output file possibly got created with error, deleting and retry -: " 1225 if (unlink(jsonDestPath.c_str()) == -1) {
1227 <<
"grabNextJsonFromRaw - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1230 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1231 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to open output file (on retry) -: " 1232 << jsonDestPath <<
" : " << strerror(errno);
1237 std::stringstream
ss;
1238 ss <<
"{\"data\":[" << nbEventsWrittenRaw <<
"," << fileSizeFromRaw <<
",\"" << rawSourcePath <<
"\"]}";
1242 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - failed to write to output file file -: " << jsonDestPath
1243 <<
" : " << strerror(errno);
1247 if (serverLS && serverLS != lsFromRaw)
1248 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFromRaw - mismatch in expected (server) LS " << serverLS
1249 <<
" and raw file header LS " << lsFromRaw;
1251 fileSizeFromHeader = fileSizeFromRaw;
1252 return nbEventsWrittenRaw;
1257 int64_t& fileSizeFromJson,
1262 std::ostringstream fileNameWithPID;
1263 fileNameWithPID <<
std::filesystem::path(rawSourcePath).stem().string() <<
"_pid" << std::setfill(
'0')
1264 << std::setw(5) <<
pid_ <<
".jsn";
1269 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1273 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1274 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file -: " << jsonSourcePath <<
" : " 1276 if ((
infile = ::open(jsonSourcePath.c_str(), O_RDONLY)) < 0) {
1277 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open input file (on retry) -: " 1278 << jsonSourcePath <<
" : " << strerror(errno);
1279 if (errno == ENOENT)
1285 int oflag = O_CREAT | O_WRONLY | O_TRUNC | O_EXCL;
1286 int omode = S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH;
1287 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1288 if (errno == EEXIST) {
1289 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - destination file already exists -: " << jsonDestPath
1294 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file -: " << jsonDestPath <<
" : " 1296 struct stat out_stat;
1297 if (
stat(jsonDestPath.c_str(), &out_stat) == 0) {
1299 <<
"grabNextJsonFile - output file possibly got created with error, deleting and retry -: " << jsonDestPath;
1300 if (unlink(jsonDestPath.c_str()) == -1) {
1302 <<
"grabNextJsonFile - failed to remove -: " << jsonDestPath <<
" : " << strerror(errno);
1305 if ((
outfile = ::open(jsonDestPath.c_str(), oflag, omode)) < 0) {
1306 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to open output file (on retry) -: " 1307 << jsonDestPath <<
" : " << strerror(errno);
1313 const std::size_t buf_sz = 512;
1314 std::size_t tot_written = 0;
1315 std::unique_ptr<char[]>
buf(
new char[buf_sz]);
1317 ssize_t sz, sz_read = 1, sz_write;
1318 while (sz_read > 0 && (sz_read = ::
read(
infile,
buf.get(), buf_sz)) > 0) {
1321 assert(sz_read - sz_write > 0);
1322 if ((sz = ::
write(
outfile,
buf.get() + sz_write, sz_read - sz_write)) < 0) {
1329 }
while (sz_write < sz_read);
1334 if (tot_written > 0) {
1336 if (unlink(jsonSourcePath.c_str()) == -1) {
1337 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to remove -: " << jsonSourcePath <<
" : " 1342 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - failed to copy json file or file was empty -: " 1351 std::stringstream
ss;
1354 if (tot_written <= buf_sz) {
1359 std::ifstream ij(jsonDestPath);
1361 }
catch (std::filesystem::filesystem_error
const& ex) {
1362 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - FILESYSTEM ERROR CAUGHT -: " << ex.what();
1368 if (tot_written <= buf_sz)
1370 edm::LogError(
"EvFDaqDirector") <<
"Failed to deserialize JSON file -: " << jsonDestPath <<
"\nERROR:\n" 1371 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1378 dp.deserialize(deserializeRoot);
1382 if (
i <
dp.getData().size()) {
1389 if (!
dp.getData().empty())
1393 <<
"grabNextJsonFile - " 1394 <<
" error reading number of events from BU JSON; No input value. data -: " <<
data;
1400 fileSizeFromJson = -1;
1403 if (
i <
dp.getData().size()) {
1406 fileSizeFromJson = std::stol(dataSize);
1409 edm::LogWarning(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of Bytes from BU JSON. " 1410 <<
"Input value is -: " << dataSize;
1416 return std::stoi(
data);
1417 }
catch (
const std::out_of_range&
e) {
1418 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - error parsing number of events from BU JSON. " 1419 <<
"Input value is -: " <<
data;
1420 }
catch (
const std::invalid_argument&
e) {
1421 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - argument error parsing events from BU JSON. " 1422 <<
"Input value is -: " <<
data;
1423 }
catch (std::runtime_error
const&
e) {
1425 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - std::runtime_error exception -: " <<
e.what();
1429 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED! -: " <<
e.what();
1432 edm::LogError(
"EvFDaqDirector") <<
"grabNextJsonFile - SOME OTHER EXCEPTION OCCURED!";
1445 std::ostringstream fileNameWithPID;
1446 fileNameWithPID << jsonSourcePath.stem().string() <<
"_pid" << std::setfill(
'0') << std::setw(5) << getpid()
1448 jsonDestPath /= fileNameWithPID.str();
1450 LogDebug(
"EvFDaqDirector") <<
"JSON rename -: " << jsonSourcePath <<
" to " << jsonDestPath;
1453 }
catch (std::filesystem::filesystem_error
const& ex) {
1455 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1465 }
catch (std::filesystem::filesystem_error
const& ex) {
1467 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1470 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile std::exception CAUGHT -: " << ex.what();
1473 std::ifstream ij(jsonDestPath);
1477 std::stringstream
ss;
1479 if (!
reader.parse(
ss.str(), deserializeRoot)) {
1480 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile Failed to deserialize JSON file -: " << jsonDestPath
1482 <<
reader.getFormatedErrorMessages() <<
"CONTENT:\n" 1484 throw std::runtime_error(
"Cannot deserialize input JSON file");
1490 dp.deserialize(deserializeRoot);
1494 if (
i <
dp.getData().size()) {
1500 if (!
dp.getData().empty())
1504 <<
" error reading number of events from BU JSON -: No input value " <<
data;
1506 return std::stoi(
data);
1507 }
catch (std::filesystem::filesystem_error
const& ex) {
1510 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile BOOST FILESYSTEM ERROR CAUGHT -: " << ex.what();
1511 }
catch (std::runtime_error
const&
e) {
1514 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile runtime Exception -: " <<
e.what();
1515 }
catch (
const std::out_of_range&) {
1516 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile error parsing number of events from BU JSON. " 1517 <<
"Input value is -: " <<
data;
1518 }
catch (
const std::invalid_argument&) {
1519 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile argument error parsing events from BU JSON. " 1520 <<
"Input value is -: " <<
data;
1524 edm::LogError(
"EvFDaqDirector") <<
"grabNextFile SOME OTHER EXCEPTION OCCURED!!!! -: " <<
e.what();
1533 uint32_t& closedServerLS,
1539 serverError =
false;
1541 boost::system::error_code ec;
1549 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1555 boost::asio::streambuf request;
1556 std::ostream request_stream(&request);
1559 std::stringstream spath;
1560 spath <<
path <<
"&stopls=" << maxLS;
1564 request_stream <<
"GET " <<
path <<
" HTTP/1.1\r\n";
1566 request_stream <<
"Accept: */*\r\n";
1567 request_stream <<
"Connection: keep-alive\r\n\r\n";
1572 edm::LogInfo(
"EvFDaqDirector") <<
"reconnecting socket on received connection_reset";
1576 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::connect error -:" << ec;
1582 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::write error -:" << ec;
1587 boost::asio::streambuf response;
1588 boost::asio::read_until(*
socket_, response,
"\r\n", ec);
1590 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1595 std::istream response_stream(&response);
1598 response_stream >> http_version;
1600 response_stream >> serverHttpStatus;
1603 std::getline(response_stream, status_message);
1604 if (!response_stream || http_version.substr(0, 5) !=
"HTTP/") {
1609 if (serverHttpStatus != 200) {
1610 edm::LogWarning(
"EvFDaqDirector") <<
"Response returned with status code " << serverHttpStatus;
1617 while (std::getline(response_stream,
header) &&
header !=
"\r") {
1621 std::map<std::string, std::string> serverMap;
1622 while (std::getline(response_stream, fileInfo) && fileInfo !=
"\r") {
1623 auto pos = fileInfo.find(
'=');
1624 if (
pos == std::string::npos)
1626 auto stitle = fileInfo.substr(0,
pos);
1627 auto svalue = fileInfo.substr(
pos + 1);
1628 serverMap[stitle] = svalue;
1632 auto server_version = serverMap.find(
"version");
1633 assert(server_version != serverMap.end());
1635 auto server_run = serverMap.find(
"runnumber");
1636 assert(server_run != serverMap.end());
1639 auto server_state = serverMap.find(
"state");
1640 assert(server_state != serverMap.end());
1642 auto server_eols = serverMap.find(
"lasteols");
1643 assert(server_eols != serverMap.end());
1645 auto server_ls = serverMap.find(
"lumisection");
1647 int version_maj = 1;
1648 int version_min = 0;
1649 int version_rev = 0;
1651 auto* s_ptr = server_version->second.c_str();
1652 if (!server_version->second.empty() && server_version->second[0] ==
'"')
1654 auto res = sscanf(s_ptr,
"%d.%d.%d", &version_maj, &version_min, &version_rev);
1656 res = sscanf(s_ptr,
"%d.%d", &version_maj, &version_min);
1658 res = sscanf(s_ptr,
"%d", &version_maj);
1661 edm::LogWarning(
"EvFDaqDirector") <<
"Can not parse server version " << server_version->second;
1668 if (server_ls != serverMap.end())
1671 serverLS = closedServerLS + 1;
1674 if (s_state ==
"STARTING")
1676 auto server_file = serverMap.find(
"file");
1677 assert(server_file == serverMap.end());
1679 edm::LogInfo(
"EvFDaqDirector") <<
"Got STARTING notification with last EOLS " << closedServerLS;
1680 }
else if (s_state ==
"READY") {
1681 auto server_file = serverMap.find(
"file");
1682 if (server_file == serverMap.end()) {
1684 if (serverLS <= closedServerLS)
1685 serverLS = closedServerLS + 1;
1688 <<
"Got READY notification with last EOLS " << closedServerLS <<
" and no new file";
1692 auto server_fileprefix = serverMap.find(
"fileprefix");
1694 if (server_fileprefix != serverMap.end()) {
1695 auto pssize = server_fileprefix->second.size();
1696 if (pssize > 1 && server_fileprefix->second[0] ==
'"' && server_fileprefix->second[pssize - 1] ==
'"')
1697 fileprefix = server_fileprefix->second.substr(1, pssize - 2);
1699 fileprefix = server_fileprefix->second;
1703 auto ssize = server_file->second.size();
1704 if (ssize > 1 && server_file->second[0] ==
'"' && server_file->second[ssize - 1] ==
'"')
1705 filestem = server_file->second.substr(1, ssize - 2);
1707 filestem = server_file->second;
1708 assert(!filestem.empty());
1709 if (version_maj > 1) {
1710 nextFileRaw =
bu_run_dir_ +
"/" + fileprefix + filestem +
".raw";
1711 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1715 nextFileRaw =
bu_run_dir_ +
"/" + filestem +
".raw";
1716 filestem =
bu_run_dir_ +
"/" + fileprefix + filestem;
1717 nextFileJson = filestem +
".jsn";
1721 edm::LogInfo(
"EvFDaqDirector") <<
"Got READY notification with last EOLS " << closedServerLS <<
" new LS " 1722 << serverLS <<
" file:" << filestem;
1724 }
else if (s_state ==
"EOLS") {
1725 serverLS = closedServerLS + 1;
1726 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOLS notification with last EOLS " << closedServerLS;
1728 }
else if (s_state ==
"EOR") {
1730 edm::LogInfo(
"EvFDaqDirector") <<
"Got EOR notification with last EOLS " << closedServerLS;
1732 }
else if (s_state ==
"NORUN") {
1733 auto err_msg = serverMap.find(
"errormessage");
1734 if (err_msg != serverMap.end())
1735 edm::LogWarning(
"EvFDaqDirector") <<
"Server NORUN -:" << server_state->second <<
" : " << err_msg->second;
1740 }
else if (s_state ==
"ERROR") {
1741 auto err_msg = serverMap.find(
"errormessage");
1742 if (err_msg != serverMap.end())
1743 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second <<
" : " << err_msg->second;
1745 edm::LogWarning(
"EvFDaqDirector") <<
"Server error -:" << server_state->second;
1749 edm::LogWarning(
"EvFDaqDirector") <<
"Unknown Server state -:" << server_state->second;
1758 if (ec != boost::asio::error::eof) {
1759 edm::LogWarning(
"EvFDaqDirector") <<
"boost::asio::read_until error -:" << ec;
1773 socket_->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec);
1775 edm::LogWarning(
"EvFDaqDirector") <<
"socket shutdown error -:" << ec;
1800 uint16_t& rawHeaderSize,
1801 int32_t& serverEventsInNewFile,
1802 int64_t& fileSizeFromMetadata,
1804 bool requireHeader) {
1812 int stopFileLS = -1;
1815 if (stopFileCheck == 0 || stopFilePidCheck == 0) {
1816 if (stopFileCheck == 0)
1822 if (stopFileLS >= 0 && (
int)
ls >= stopFileLS)
1826 edm::LogWarning(
"EvFDaqDirector") <<
"Detected stop request from hltd. Ending run for this process after LS -: " 1840 timeval ts_lockbegin;
1841 gettimeofday(&ts_lockbegin,
nullptr);
1844 uint32_t serverLS, closedServerLS;
1845 unsigned int serverHttpStatus;
1852 int maxLS = stopFileLS < 0 ? -1 :
std::max(stopFileLS, (
int)currentLumiSection);
1853 bool rawHeader =
false;
1855 serverHttpStatus, serverError, serverLS, closedServerLS, nextFileJson, nextFileRaw, rawHeader, maxLS);
1865 if (currentLumiSection == 0) {
1871 if (closedServerLS >= currentLumiSection) {
1873 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1878 bool fileFound =
true;
1883 nextFileRaw, rawFd, rawHeaderSize, fileSizeFromMetadata, fileFound, serverLS,
false, requireHeader);
1885 serverEventsInNewFile =
grabNextJsonFile(nextFileJson, nextFileRaw, fileSizeFromMetadata, fileFound);
1888 if (serverEventsInNewFile < 0 && rawFd != -1) {
1909 if (currentLumiSection == 0) {
1919 if (closedServerLS >= currentLumiSection) {
1922 for (uint32_t
i =
std::max(currentLumiSection, 1
U);
i <= closedServerLS;
i++)
1930 else if (fileStatus ==
newFile) {
1933 }
else if (fileStatus ==
noFile) {
1937 edm::LogWarning(
"EvFDaqDirector") <<
"Server reported LS " << serverLS
1938 <<
" which is smaller than currently open LS " <<
ls <<
". Ignoring response";
1950 if (!std::filesystem::is_directory(openPath)) {
1951 LogDebug(
"EvFDaqDirector") <<
"<open> FU dir not found. Creating... -:" << openPath.string();
1952 std::filesystem::create_directories(openPath);
1957 std::ifstream ij(
file);
1961 if (!
reader.parse(ij, deserializeRoot)) {
1962 edm::LogError(
"EvFDaqDirector") <<
"Cannot deserialize input JSON file -:" <<
file;
1966 int ret = deserializeRoot.
get(
"lastLS",
"").
asInt();
1974 unsigned int lscount = 1;
1976 std::stringstream
ss;
1977 ss << fileprefix << std::setfill(
'0') << std::setw(4) << lscount <<
"_EoLS.jsn";
1995 std::vector<std::string>
destinations = tsPset.getParameter<std::vector<std::string>>(
"destinations");
1997 destinationsVal.append(
dest);
1998 (*transferSystemJson_)[
"destinations"] = destinationsVal;
2001 std::vector<std::string> modes = tsPset.getParameter<std::vector<std::string>>(
"transferModes");
2002 for (
auto&
mode : modes)
2004 (*transferSystemJson_)[
"transferModes"] = modesVal;
2006 for (
auto psKeyItr = tsPset.psetTable().begin(); psKeyItr != tsPset.psetTable().end(); ++psKeyItr) {
2007 if (psKeyItr->first !=
"destinations" && psKeyItr->first !=
"transferModes") {
2010 for (
auto&
mode : modes) {
2012 if (!streamDef.
existsAs<std::vector<std::string>>(
mode,
true))
2014 <<
" Missing transfer system specification for -:" << psKeyItr->first <<
" (transferMode " <<
mode 2016 std::vector<std::string> streamDestinations = streamDef.
getParameter<std::vector<std::string>>(
mode);
2020 if (streamDestinations.empty())
2022 <<
" Missing transter system destination(s) for -: " << psKeyItr->first <<
", mode:" <<
mode;
2024 for (
auto& sdest : streamDestinations) {
2025 bool sDestValid =
false;
2026 sDestsValue.append(sdest);
2033 <<
" Invalid transter system destination specified for -: " << psKeyItr->first <<
", mode:" <<
mode 2034 <<
", dest:" << sdest;
2036 streamVal[
mode] = sDestsValue;
2038 (*transferSystemJson_)[psKeyItr->first] = streamVal;
2043 throw cms::Exception(
"EvFDaqDirector") <<
"transferSystem PSet not found";
2050 streamRequestName =
stream;
2052 std::stringstream
msg;
2053 msg <<
"Transfer system mode definitions missing for -: " <<
stream;
2064 <<
"Selected mode string is not provided as DaqDirector parameter." 2065 <<
"Switch on requireTSPSet parameter to enforce this requirement. Setting mode to empty string.";
2069 throw cms::Exception(
"EvFDaqDirector") <<
"Selected mode string is not provided as DaqDirector parameter.";
2073 std::stringstream
msg;
2088 ret += (*it).asString();
2103 tbb::concurrent_hash_map<std::string, std::string>::accessor ac;
2105 ac->second = streamType;
2112 tbb::concurrent_hash_map<std::string, std::string>::const_accessor search_ac;
2114 return search_ac->second;
2116 edm::LogInfo(
"EvFDaqDirector") <<
" No merging type specified for stream " <<
stream <<
". Using default value";
2118 tbb::concurrent_hash_map<std::string, std::string>::accessor ac;
2120 ac->second = defaultName;
2127 int proc_flag_fd = open(proc_flag.c_str(), O_RDWR | O_CREAT, S_IRWXU | S_IWGRP | S_IRGRP | S_IWOTH | S_IROTH);
2128 close(proc_flag_fd);
2131 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.
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_
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
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)