68 std::atomic<std::uint_least64_t>
m_runs;
79 using namespace edm::service;
107 if (pset.
exists(
"updateIntervalSeconds"))
111 if (pset.
exists(
"EMAInterval"))
170 std::vector<edm::LuminosityBlockRange> toProcess = pset.
getUntrackedParameter<std::vector<LuminosityBlockRange> >(
"lumisToProcess", std::vector<LuminosityBlockRange>());
173 for (
auto const &range : toProcess)
175 if (range.startRun() != range.endRun()) {
break;}
177 lumiCount += (range.endLumi()-range.startLumi());
180 unsigned int eventsPerLumi = pset.
getUntrackedParameter<
unsigned int>(
"numberEventsInLuminosityBlock", 0);
181 if ((lumiCount == 0) && (maxEvents > 0) && (eventsPerLumi > 0))
183 lumiCount =
static_cast<unsigned int>(std::ceil(static_cast<float>(maxEvents) / static_cast<float>(eventsPerLumi)));
187 std::stringstream ss_max_files; ss_max_files << fileNames.size();
188 updateChirp(
"ChirpCMSSWMaxFiles", ss_max_files.str());
192 if (maxLumis < 0) {maxLumis = lumiCount;}
193 if (maxLumis > static_cast<int>(lumiCount))
195 maxLumis = lumiCount;
200 std::stringstream ss_max_events; ss_max_events <<
maxEvents;
201 updateChirp(
"ChirpCMSSWMaxEvents", ss_max_events.str());
205 std::stringstream ss_max_lumis; ss_max_lumis << maxLumis;
206 updateChirp(
"ChirpCMSSWMaxLumis", ss_max_lumis.str());
226 return getenv(
"_CONDOR_CHIRP_CONFIG") &&
updateChirp(
"ChirpCMSSWElapsed",
"0");
284 std::stringstream ss_now; ss_now <<
now;
289 std::stringstream ss_events; ss_events <<
m_events;
293 std::stringstream ss_lumis; ss_lumis <<
m_lumis;
296 std::stringstream ss_runs; ss_runs <<
m_runs;
299 std::stringstream ss_files; ss_files <<
m_files;
303 if (sinceLastUpdate > 0)
305 std::stringstream ss_elapsed; ss_elapsed << jobTime;
306 updateChirp(
"ChirpCMSSWElapsed", ss_elapsed.str());
309 std::stringstream ss_rate; ss_rate <<
m_rate;
320 std::cout <<
"condor_chirp set_job_attr_delayed " << key <<
" " << value << std::endl;
323 posix_spawn_file_actions_t file_actions;
324 int devnull_fd = open(
"/dev/null", O_RDWR);
325 if (devnull_fd == -1) {
return false;}
326 posix_spawn_file_actions_init(&file_actions);
327 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 1);
328 posix_spawn_file_actions_adddup2(&file_actions, devnull_fd, 2);
330 const std::string set_job_attr =
"set_job_attr_delayed";
331 std::vector<const char *>
argv;
332 argv.push_back(chirp_name.c_str());
333 argv.push_back(set_job_attr.c_str());
334 argv.push_back(key.c_str());
335 argv.push_back(value.c_str());
336 argv.push_back(
NULL);
337 int status = posix_spawnp(&pid,
"condor_chirp", &file_actions,
NULL, const_cast<char* const*>(&argv[0]), environ);
339 posix_spawn_file_actions_destroy(&file_actions);
344 while ((waitpid(pid, &status, 0) == -1) && errno == -EINTR) {}
353 desc.
setComment(
"Service to update HTCondor with the current CMSSW status.");
355 ->setComment(
"Interval, in seconds, for HTCondor updates");
357 ->setComment(
"Enable debugging of this service");
359 ->setComment(
"Interval, in seconds, to calculate event rate over (using EMA)");
360 descriptions.
add(
"CondorStatusService", desc);
std::atomic< time_t > m_lastUpdate
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)
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()
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)
bool updateChirp(std::string const &key, std::string const &value)
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
static float m_defaultEmaInterval
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
edm::ParameterSetID m_processParameterSetID
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 unsigned int m_defaultUpdateInterval
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)