78 std::atomic<std::uint_least64_t>
m_runs;
121 if (pset.
exists(
"updateIntervalSeconds"))
125 if (pset.
exists(
"EMAInterval"))
188 std::vector<edm::LuminosityBlockRange> toProcess = pset.
getUntrackedParameter<std::vector<LuminosityBlockRange> >(
"lumisToProcess", std::vector<LuminosityBlockRange>());
191 for (
auto const &range : toProcess)
193 if (range.startRun() != range.endRun()) {
break;}
195 lumiCount += (range.endLumi()-range.startLumi());
198 unsigned int eventsPerLumi = pset.
getUntrackedParameter<
unsigned int>(
"numberEventsInLuminosityBlock", 0);
199 if ((lumiCount == 0) && (maxEvents > 0) && (eventsPerLumi > 0))
201 lumiCount =
static_cast<unsigned int>(std::ceil(static_cast<float>(maxEvents) / static_cast<float>(eventsPerLumi)));
205 std::stringstream ss_max_files; ss_max_files << fileNames.size();
210 if (maxLumis < 0) {maxLumis = lumiCount;}
211 if (maxLumis > static_cast<int>(lumiCount))
213 maxLumis = lumiCount;
218 std::stringstream ss_max_events; ss_max_events <<
maxEvents;
223 std::stringstream ss_max_lumis; ss_max_lumis << maxLumis;
244 return getenv(
"_CONDOR_CHIRP_CONFIG") &&
updateChirp(
"Elapsed",
"0");
278 std::cout <<
"At post, CPU service is NOT available.\n";
333 if (sinceLastUpdate > 0)
346 site.erase(std::remove_if(site.begin(), site.end(),
347 [](
char x){
return !isalnum(x) && (x !=
'_');}),
349 auto & iostats = iter.second;
350 updateChirp(
"IOSite_" + site +
"_ReadBytes", iostats.bytesRead);
352 std::chrono::duration_cast<std::chrono::milliseconds>(iostats.transferTime).count());
366 for (
const auto & storage : stats)
372 if (storage.first == token.value()) {
continue;}
373 for (
const auto &
counter : storage.second)
377 readOps +=
counter.second.successes;
379 readBytes +=
counter.second.amount;
380 readTimeTotal +=
counter.second.timeTotal;
384 readVOps +=
counter.second.successes;
385 readSegs +=
counter.second.vector_count;
386 readBytes +=
counter.second.amount;
387 readTimeTotal +=
counter.second.timeTotal;
391 writeBytes +=
counter.second.amount;
392 writeTimeTotal +=
counter.second.timeTotal;
400 updateChirp(
"ReadTimeMsecs", readTimeTotal/(1000*1000));
402 updateChirp(
"WriteTimeMsecs", writeTimeTotal/(1000*1000));
406 template<
typename T>
bool 409 std::stringstream ss; ss <<
value;
420 value_copy.erase(remove_if(value_copy.begin(), value_copy.end(), [](
const char &
c) {
return !isascii(
c) || (
c ==
'"') || (
c ==
'\\');}), value_copy.end());
428 std::stringstream ss; ss <<
"ChirpCMSSW" <<
m_tag << key_suffix;
432 std::cout <<
"condor_chirp set_job_attr_delayed " << key <<
" " << value << std::endl;
435 posix_spawn_file_actions_t file_actions;
436 int devnull_fd = open(
"/dev/null", O_RDWR);
437 if (devnull_fd == -1) {
return false;}
438 posix_spawn_file_actions_init(&file_actions);
439 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 1);
440 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 2);
442 const std::string set_job_attr =
"set_job_attr_delayed";
443 std::vector<const char *>
argv;
444 argv.push_back(chirp_name.c_str());
445 argv.push_back(set_job_attr.c_str());
446 argv.push_back(key.c_str());
447 argv.push_back(value.c_str());
448 argv.push_back(
nullptr);
449 int status = posix_spawnp(&pid,
"condor_chirp", &file_actions,
nullptr, const_cast<char* const*>(&argv[0]), environ);
451 posix_spawn_file_actions_destroy(&file_actions);
456 while ((waitpid(pid, &status, 0) == -1) && errno == -EINTR) {}
465 desc.
setComment(
"Service to update HTCondor with the current CMSSW status.");
467 ->setComment(
"Interval, in seconds, for HTCondor updates");
469 ->setComment(
"Enable debugging of this service");
471 ->setComment(
"Interval, in seconds, to calculate event rate over (using EMA)");
473 ->setComment(
"Identifier tag for this process (a value of 'Foo' results in ClassAd attributes of the form 'ChirpCMSSWFoo*')");
474 descriptions.
add(
"CondorStatusService", desc);
std::atomic< time_t > m_lastUpdate
static float m_defaultEmaInterval
bool updateChirpImpl(std::string const &key, std::string const &value)
T getUntrackedParameter(std::string const &, T const &) const
CondorStatusService(ParameterSet const &pset, edm::ActivityRegistry &ar)
void preSourceConstruction(ModuleDescription const &md, int maxEvents, int maxLumis, int maxSecondsUntilRampdown)
#define DEFINE_FWK_SERVICE_MAKER(concrete, maker)
void runPost(GlobalContext const &)
void watchPostEndJob(PostEndJob::slot_type const &iSlot)
void beginPre(PathsAndConsumesOfModulesBase const &, ProcessContext const &processContext)
virtual bool cpuInfo(std::string &models, double &avgSpeed)=0
CPU information - the models present and average speed.
void updateImpl(time_t secsSinceLastUpdate)
std::atomic< std::uint_least64_t > m_events
edm::serviceregistry::AllArgsMaker< edm::service::CondorStatusService > CondorStatusServiceMaker
ParameterSet const & getParameterSet(ParameterSetID const &id)
void watchPostEvent(PostEvent::slot_type const &iSlot)
static LuminosityBlockNumber_t maxLuminosityBlockNumber()
static const StorageStats & summary(void)
void lumiPost(GlobalContext const &)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
ParameterSet getUntrackedParameterSet(std::string const &name, ParameterSet const &defaultValue) const
std::atomic< std::uint_least64_t > m_lumis
std::vector< std::pair< std::string, CondorIOStats > > condorUpdate()
ParameterSetID const & parameterSetID() const
void setComment(std::string const &value)
void watchPostCloseFile(PostCloseFile::slot_type const &iSlot)
static StorageClassToken tokenForStorageClassName(std::string const &iName)
bool updateChirpQuoted(const std::string &key_suffix, const std::string &value)
CondorStatusService & operator=(const CondorStatusService &)=delete
std::atomic< std::uint_least64_t > m_runs
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
virtual double getTotalCPU() const =0
std::uint_least64_t m_lastEventCount
void eventPost(StreamContext const &iContext)
unsigned long long uint64_t
ParameterSet const & getParameterSet(std::string const &) const
void watchPostGlobalEndRun(PostGlobalEndRun::slot_type const &iSlot)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void watchPreBeginJob(PreBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
static unsigned int m_defaultUpdateInterval
edm::ParameterSetID m_processParameterSetID
bool updateChirp(const std::string &key_suffix, const T &value)
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
std::atomic_flag m_shouldUpdate
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
static void fillDescriptions(ConfigurationDescriptions &descriptions)
void watchPostBeginJob(PostBeginJob::slot_type const &iSlot)
convenience function for attaching to signal
std::atomic< std::uint_least64_t > m_files
void filePost(std::string const &, bool)