77 std::atomic<std::uint_least64_t>
m_runs;
120 if (pset.
exists(
"updateIntervalSeconds"))
124 if (pset.
exists(
"EMAInterval"))
187 std::vector<edm::LuminosityBlockRange> toProcess = pset.
getUntrackedParameter<std::vector<LuminosityBlockRange> >(
"lumisToProcess", std::vector<LuminosityBlockRange>());
190 for (
auto const &range : toProcess)
192 if (range.startRun() != range.endRun()) {
break;}
194 lumiCount += (range.endLumi()-range.startLumi());
197 unsigned int eventsPerLumi = pset.
getUntrackedParameter<
unsigned int>(
"numberEventsInLuminosityBlock", 0);
198 if ((lumiCount == 0) && (maxEvents > 0) && (eventsPerLumi > 0))
200 lumiCount =
static_cast<unsigned int>(std::ceil(static_cast<float>(maxEvents) / static_cast<float>(eventsPerLumi)));
204 std::stringstream ss_max_files; ss_max_files << fileNames.size();
209 if (maxLumis < 0) {maxLumis = lumiCount;}
210 if (maxLumis > static_cast<int>(lumiCount))
212 maxLumis = lumiCount;
217 std::stringstream ss_max_events; ss_max_events <<
maxEvents;
222 std::stringstream ss_max_lumis; ss_max_lumis << maxLumis;
243 return getenv(
"_CONDOR_CHIRP_CONFIG") &&
updateChirp(
"Elapsed",
"0");
277 std::cout <<
"At post, CPU service is NOT available.\n";
332 if (sinceLastUpdate > 0)
350 for (
const auto & storage : stats)
356 if (storage.first == token.value()) {
continue;}
357 for (
const auto &
counter : storage.second)
361 readOps +=
counter.second.successes;
363 readBytes +=
counter.second.amount;
364 readTimeTotal +=
counter.second.timeTotal;
368 readVOps +=
counter.second.successes;
369 readSegs +=
counter.second.vector_count;
370 readBytes +=
counter.second.amount;
371 readTimeTotal +=
counter.second.timeTotal;
375 writeBytes +=
counter.second.amount;
376 writeTimeTotal +=
counter.second.timeTotal;
384 updateChirp(
"ReadTimeMsecs", readTimeTotal/(1000*1000));
386 updateChirp(
"WriteTimeMsecs", writeTimeTotal/(1000*1000));
390 template<
typename T>
bool 393 std::stringstream ss; ss <<
value;
404 value_copy.erase(remove_if(value_copy.begin(), value_copy.end(), [](
const char &
c) {
return !isascii(
c) || (
c ==
'"') || (
c ==
'\\');}), value_copy.end());
412 std::stringstream ss; ss <<
"ChirpCMSSW" <<
m_tag << key_suffix;
416 std::cout <<
"condor_chirp set_job_attr_delayed " << key <<
" " << value << std::endl;
419 posix_spawn_file_actions_t file_actions;
420 int devnull_fd = open(
"/dev/null", O_RDWR);
421 if (devnull_fd == -1) {
return false;}
422 posix_spawn_file_actions_init(&file_actions);
423 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 1);
424 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 2);
426 const std::string set_job_attr =
"set_job_attr_delayed";
427 std::vector<const char *>
argv;
428 argv.push_back(chirp_name.c_str());
429 argv.push_back(set_job_attr.c_str());
430 argv.push_back(key.c_str());
431 argv.push_back(value.c_str());
432 argv.push_back(
NULL);
433 int status = posix_spawnp(&pid,
"condor_chirp", &file_actions,
NULL, const_cast<char* const*>(&argv[0]), environ);
435 posix_spawn_file_actions_destroy(&file_actions);
440 while ((waitpid(pid, &status, 0) == -1) && errno == -EINTR) {}
449 desc.
setComment(
"Service to update HTCondor with the current CMSSW status.");
451 ->setComment(
"Interval, in seconds, for HTCondor updates");
453 ->setComment(
"Enable debugging of this service");
455 ->setComment(
"Interval, in seconds, to calculate event rate over (using EMA)");
457 ->setComment(
"Identifier tag for this process (a value of 'Foo' results in ClassAd attributes of the form 'ChirpCMSSWFoo*')");
458 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
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)