76 std::atomic<std::uint_least64_t>
m_runs;
88 using namespace edm::service;
119 if (pset.
exists(
"updateIntervalSeconds"))
123 if (pset.
exists(
"EMAInterval"))
186 std::vector<edm::LuminosityBlockRange> toProcess = pset.
getUntrackedParameter<std::vector<LuminosityBlockRange> >(
"lumisToProcess", std::vector<LuminosityBlockRange>());
189 for (
auto const &range : toProcess)
191 if (range.startRun() != range.endRun()) {
break;}
193 lumiCount += (range.endLumi()-range.startLumi());
196 unsigned int eventsPerLumi = pset.
getUntrackedParameter<
unsigned int>(
"numberEventsInLuminosityBlock", 0);
197 if ((lumiCount == 0) && (maxEvents > 0) && (eventsPerLumi > 0))
199 lumiCount =
static_cast<unsigned int>(std::ceil(static_cast<float>(maxEvents) / static_cast<float>(eventsPerLumi)));
203 std::stringstream ss_max_files; ss_max_files << fileNames.size();
208 if (maxLumis < 0) {maxLumis = lumiCount;}
209 if (maxLumis > static_cast<int>(lumiCount))
211 maxLumis = lumiCount;
216 std::stringstream ss_max_events; ss_max_events <<
maxEvents;
221 std::stringstream ss_max_lumis; ss_max_lumis << maxLumis;
242 return getenv(
"_CONDOR_CHIRP_CONFIG") &&
updateChirp(
"Elapsed",
"0");
276 std::cout <<
"At post, CPU service is NOT available.\n";
331 if (sinceLastUpdate > 0)
349 for (
const auto & storage : stats)
355 if (storage.first ==
token.value()) {
continue;}
356 for (
const auto &
counter : storage.second)
360 readOps +=
counter.second.successes;
362 readBytes +=
counter.second.amount;
363 readTimeTotal +=
counter.second.timeTotal;
367 readVOps +=
counter.second.successes;
368 readSegs +=
counter.second.vector_count;
369 readBytes +=
counter.second.amount;
370 readTimeTotal +=
counter.second.timeTotal;
374 writeBytes +=
counter.second.amount;
375 writeTimeTotal +=
counter.second.timeTotal;
383 updateChirp(
"ReadTimeMsecs", readTimeTotal/(1000*1000));
385 updateChirp(
"WriteTimeMsecs", writeTimeTotal/(1000*1000));
389 template<
typename T>
bool
392 std::stringstream
ss; ss <<
value;
400 std::stringstream
ss; ss <<
"ChirpCMSSW" <<
m_tag << key_suffix;
404 std::cout <<
"condor_chirp set_job_attr_delayed " << key <<
" " << value << std::endl;
407 posix_spawn_file_actions_t file_actions;
408 int devnull_fd = open(
"/dev/null", O_RDWR);
409 if (devnull_fd == -1) {
return false;}
410 posix_spawn_file_actions_init(&file_actions);
411 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 1);
412 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 2);
414 const std::string set_job_attr =
"set_job_attr_delayed";
415 std::vector<const char *>
argv;
416 argv.push_back(chirp_name.c_str());
417 argv.push_back(set_job_attr.c_str());
418 argv.push_back(key.c_str());
419 argv.push_back(value.c_str());
420 argv.push_back(
NULL);
421 int status = posix_spawnp(&pid,
"condor_chirp", &file_actions,
NULL, const_cast<char* const*>(&argv[0]), environ);
423 posix_spawn_file_actions_destroy(&file_actions);
428 while ((waitpid(pid, &status, 0) == -1) && errno == -EINTR) {}
437 desc.
setComment(
"Service to update HTCondor with the current CMSSW status.");
439 ->setComment(
"Interval, in seconds, for HTCondor updates");
441 ->setComment(
"Enable debugging of this service");
443 ->setComment(
"Interval, in seconds, to calculate event rate over (using EMA)");
445 ->setComment(
"Identifier tag for this process (a value of 'Foo' results in ClassAd attributes of the form 'ChirpCMSSWFoo*')");
446 descriptions.
add(
"CondorStatusService", desc);
std::atomic< time_t > m_lastUpdate
static float m_defaultEmaInterval
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)
CondorStatusService & operator=(const CondorStatusService &)=delete
std::atomic< std::uint_least64_t > m_runs
void watchPostGlobalEndLumi(PostGlobalEndLumi::slot_type const &iSlot)
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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
virtual double getTotalCPU() const =0
bool updateChirp(const std::string &key_suffix, const T &value)
static std::atomic< unsigned int > counter
std::vector< EventRange > & sortAndRemoveOverlaps(std::vector< EventRange > &eventRange)
std::atomic_flag m_shouldUpdate
ParameterDescriptionBase * addOptionalUntracked(U const &iLabel, T const &value)
volatile std::atomic< bool > shutdown_flag false
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)