CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::WorkerManager Class Reference

#include <WorkerManager.h>

Public Types

typedef std::vector< Worker * > AllWorkers
 

Public Member Functions

ExceptionToActionTable const & actionTable () const
 
void addToAllWorkers (Worker *w, bool useStopwatch)
 
void addToUnscheduledWorkers (ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, boost::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, bool useStopwatch, std::set< std::string > &unscheduledLabels, std::vector< std::string > &shouldBeUsedLabels)
 
AllWorkers const & allWorkers () const
 
void beginJob (ProductRegistry const &iRegistry)
 
void beginStream (StreamID iID, StreamContext &streamContext)
 
void endJob ()
 
void endJob (ExceptionCollector &collector)
 
void endStream (StreamID iID, StreamContext &streamContext)
 
WorkergetWorker (ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, boost::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
 
template<typename T , typename U >
void processOneOccurrence (typename T::MyPrincipal &principal, EventSetup const &eventSetup, StreamID streamID, typename T::Context const *topContext, U const *context, bool cleaningUpAfterException=false)
 
void setOnDemandProducts (ProductRegistry &pregistry, std::set< std::string > const &unscheduledLabels) const
 
 WorkerManager (boost::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
 
 WorkerManager (boost::shared_ptr< ModuleRegistry > modReg, boost::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
 

Private Member Functions

void resetAll ()
 
void setupOnDemandSystem (EventPrincipal &principal, EventSetup const &es)
 

Private Attributes

ExceptionToActionTable const * actionTable_
 
AllWorkers allWorkers_
 
boost::shared_ptr
< UnscheduledCallProducer
unscheduled_
 
WorkerRegistry workerReg_
 

Detailed Description

Definition at line 29 of file WorkerManager.h.

Member Typedef Documentation

typedef std::vector<Worker*> edm::WorkerManager::AllWorkers

Definition at line 31 of file WorkerManager.h.

Constructor & Destructor Documentation

edm::WorkerManager::WorkerManager ( boost::shared_ptr< ActivityRegistry actReg,
ExceptionToActionTable const &  actions 
)

Definition at line 15 of file WorkerManager.cc.

15  :
18  allWorkers_(),
19  unscheduled_(new UnscheduledCallProducer) {
20  } // WorkerManager::WorkerManager
AllWorkers allWorkers_
Definition: WorkerManager.h:85
actions
Definition: Schedule.cc:362
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87
areg
Definition: Schedule.cc:362
WorkerRegistry workerReg_
Definition: WorkerManager.h:82
edm::WorkerManager::WorkerManager ( boost::shared_ptr< ModuleRegistry modReg,
boost::shared_ptr< ActivityRegistry actReg,
ExceptionToActionTable const &  actions 
)

Definition at line 22 of file WorkerManager.cc.

24  :
25  workerReg_(areg,modReg),
27  allWorkers_(),
28  unscheduled_(new UnscheduledCallProducer) {
29  } // WorkerManager::WorkerManager
AllWorkers allWorkers_
Definition: WorkerManager.h:85
actions
Definition: Schedule.cc:362
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87
areg
Definition: Schedule.cc:362
WorkerRegistry workerReg_
Definition: WorkerManager.h:82

Member Function Documentation

ExceptionToActionTable const& edm::WorkerManager::actionTable ( ) const
inline

Definition at line 68 of file WorkerManager.h.

References actionTable_.

Referenced by edm::GlobalSchedule::actionTable(), and edm::StreamSchedule::actionTable().

68 {return *actionTable_;}
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
void edm::WorkerManager::addToAllWorkers ( Worker w,
bool  useStopwatch 
)

Definition at line 134 of file WorkerManager.cc.

References allWorkers_, edm::search_all(), and edm::Worker::useStopwatch().

Referenced by edm::GlobalSchedule::addToAllWorkers(), edm::StreamSchedule::addToAllWorkers(), and addToUnscheduledWorkers().

134  {
135  if(!search_all(allWorkers_, w)) {
136  if(useStopwatch) {
137  w->useStopwatch();
138  }
139  allWorkers_.push_back(w);
140  }
141  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
T w() const
void edm::WorkerManager::addToUnscheduledWorkers ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
boost::shared_ptr< ProcessConfiguration processConfiguration,
std::string  label,
bool  useStopwatch,
std::set< std::string > &  unscheduledLabels,
std::vector< std::string > &  shouldBeUsedLabels 
)

Definition at line 40 of file WorkerManager.cc.

References addToAllWorkers(), edm::ParameterSet::getParameter(), getWorker(), edm::Worker::kFilter, kFilterType(), edm::Worker::kProducer, kProducerType(), edm::Worker::moduleType(), AlCaHLTBitMon_QueryRunRegistry::string, and unscheduled_.

Referenced by edm::SecondaryEventProvider::SecondaryEventProvider(), and edm::StreamSchedule::StreamSchedule().

47  {
48  //Need to
49  // 1) create worker
50  // 2) if it is a WorkerT<EDProducer>, add it to our list
51  auto modType = pset.getParameter<std::string>("@module_edm_type");
52  if(modType == kProducerType || modType == kFilterType) {
53  Worker* newWorker = getWorker(pset, preg, prealloc, processConfiguration, label);
54  assert(newWorker->moduleType() == Worker::kProducer || newWorker->moduleType() == Worker::kFilter);
55  unscheduledLabels.insert(label);
56  unscheduled_->addWorker(newWorker);
57  //add to list so it gets reset each new event
58  addToAllWorkers(newWorker, useStopwatch);
59  } else {
60  shouldBeUsedLabels.push_back(label);
61  }
62  }
static const std::string kFilterType("EDFilter")
processConfiguration
Definition: Schedule.cc:362
Worker * getWorker(ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, boost::shared_ptr< ProcessConfiguration const > processConfiguration, std::string const &label)
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87
static const std::string kProducerType("EDProducer")
void addToAllWorkers(Worker *w, bool useStopwatch)
preg
Definition: Schedule.cc:362
prealloc
Definition: Schedule.cc:362
AllWorkers const& edm::WorkerManager::allWorkers ( ) const
inline

Definition at line 64 of file WorkerManager.h.

References allWorkers_.

Referenced by edm::GlobalSchedule::allWorkers(), and edm::StreamSchedule::allWorkers().

64 {return allWorkers_;}
AllWorkers allWorkers_
Definition: WorkerManager.h:85
void edm::WorkerManager::beginJob ( ProductRegistry const &  iRegistry)

Definition at line 100 of file WorkerManager.cc.

References allWorkers_, edm::Worker::beginJob(), edm::for_all(), edm::InEvent, edm::InLumi, edm::InRun, edm::loadMissingDictionaries(), and edm::ProductRegistry::productLookup().

Referenced by edm::SecondaryEventProvider::beginJob(), and edm::GlobalSchedule::beginJob().

100  {
101  auto const runLookup = iRegistry.productLookup(InRun);
102  auto const lumiLookup = iRegistry.productLookup(InLumi);
103  auto const eventLookup = iRegistry.productLookup(InEvent);
104  for(auto& worker : allWorkers_) {
105  worker->updateLookup(InRun,*runLookup);
106  worker->updateLookup(InLumi,*lumiLookup);
107  worker->updateLookup(InEvent,*eventLookup);
108  }
109 
110  for_all(allWorkers_, boost::bind(&Worker::beginJob, _1));
112  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void loadMissingDictionaries()
void beginJob()
Definition: Worker.cc:111
void edm::WorkerManager::beginStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 115 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::StreamSchedule::beginStream().

115  {
116  for(auto& worker: allWorkers_) {
117  worker->beginStream(iID, streamContext);
118  }
119  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
void edm::WorkerManager::endJob ( void  )

Definition at line 74 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::SecondaryEventProvider::endJob(), and edm::GlobalSchedule::endJob().

74  {
75  for(auto& worker : allWorkers_) {
76  worker->endJob();
77  }
78  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
void edm::WorkerManager::endJob ( ExceptionCollector collector)

Definition at line 80 of file WorkerManager.cc.

References edm::ExceptionCollector::addException(), allWorkers_, edm::convertException::badAllocToEDM(), trackerHits::c, edm::convertException::charPtrToEDM(), alignCSCRings::e, cppFunctionSkipper::exception, alignCSCRings::s, edm::convertException::stdToEDM(), AlCaHLTBitMon_QueryRunRegistry::string, edm::convertException::stringToEDM(), and edm::convertException::unknownToEDM().

80  {
81  for(auto& worker : allWorkers_) {
82  try {
83  try {
84  worker->endJob();
85  }
86  catch (cms::Exception& e) { throw; }
87  catch (std::bad_alloc& bda) { convertException::badAllocToEDM(); }
90  catch (char const* c) { convertException::charPtrToEDM(c); }
91  catch (...) { convertException::unknownToEDM(); }
92  }
93  catch (cms::Exception const& ex) {
94  collector.addException(ex);
95  }
96  }
97  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
void stdToEDM(std::exception const &e)
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
void edm::WorkerManager::endStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 122 of file WorkerManager.cc.

References allWorkers_.

Referenced by edm::StreamSchedule::endStream().

122  {
123  for(auto& worker: allWorkers_) {
124  worker->endStream(iID, streamContext);
125  }
126  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
Worker * edm::WorkerManager::getWorker ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
boost::shared_ptr< ProcessConfiguration const >  processConfiguration,
std::string const &  label 
)

Definition at line 31 of file WorkerManager.cc.

References actionTable_, edm::WorkerRegistry::getWorker(), and workerReg_.

Referenced by addToUnscheduledWorkers(), edm::StreamSchedule::fillWorkers(), and edm::GlobalSchedule::GlobalSchedule().

35  {
36  WorkerParams params(&pset, preg, prealloc, processConfiguration, *actionTable_);
37  return workerReg_.getWorker(params, label);
38  }
processConfiguration
Definition: Schedule.cc:362
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
WorkerRegistry workerReg_
Definition: WorkerManager.h:82
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.
preg
Definition: Schedule.cc:362
prealloc
Definition: Schedule.cc:362
template<typename T , typename U >
void edm::WorkerManager::processOneOccurrence ( typename T::MyPrincipal &  principal,
EventSetup const &  eventSetup,
StreamID  streamID,
typename T::Context const *  topContext,
U const *  context,
bool  cleaningUpAfterException = false 
)

Definition at line 92 of file WorkerManager.h.

References alignCSCRings::action, actionTable_, edm::addContextAndPrintException(), edm::convertException::badAllocToEDM(), trackerHits::c, cms::Exception::category(), edm::convertException::charPtrToEDM(), cms::Exception::context(), alignCSCRings::e, cppFunctionSkipper::exception, edm::exception_actions::FailPath, edm::ExceptionToActionTable::find(), edm::exception_actions::IgnoreCompletely, edm::printCmsExceptionWarning(), resetAll(), edm::exception_actions::Rethrow, alignCSCRings::s, setupOnDemandSystem(), edm::exception_actions::SkipEvent, edm::convertException::stdToEDM(), AlCaHLTBitMon_QueryRunRegistry::string, edm::convertException::stringToEDM(), edm::convertException::unknownToEDM(), and unscheduled_.

Referenced by edm::SecondaryEventProvider::beginLuminosityBlock(), edm::SecondaryEventProvider::beginRun(), edm::SecondaryEventProvider::endLuminosityBlock(), edm::SecondaryEventProvider::endRun(), edm::StreamSchedule::processOneEvent(), edm::GlobalSchedule::processOneGlobal(), edm::StreamSchedule::processOneStream(), and edm::SecondaryEventProvider::setupPileUpEvent().

97  {
98  this->resetAll();
99 
100  try {
101  try {
102  try {
103  if (T::isEvent_) {
104  setupOnDemandSystem(dynamic_cast<EventPrincipal&>(ep), es);
105  } else {
106  //make sure the unscheduled items see this run or lumi rtansition
107  unscheduled_->runNow<T,U>(ep, es,streamID, topContext, context);
108  }
109  }
110  catch(cms::Exception& e) {
112  assert (action != exception_actions::IgnoreCompletely);
113  assert (action != exception_actions::FailPath);
114  if (action == exception_actions::SkipEvent) {
115  printCmsExceptionWarning("SkipEvent", e);
116  } else {
117  throw;
118  }
119  }
120  }
121  catch (cms::Exception& e) { throw; }
122  catch(std::bad_alloc& bda) { convertException::badAllocToEDM(); }
123  catch (std::exception& e) { convertException::stdToEDM(e); }
125  catch(char const* c) { convertException::charPtrToEDM(c); }
126  catch (...) { convertException::unknownToEDM(); }
127  }
128  catch(cms::Exception& ex) {
129  if (ex.context().empty()) {
130  addContextAndPrintException("Calling function WorkerManager::processOneOccurrence", ex, cleaningUpAfterException);
131  } else {
132  addContextAndPrintException("", ex, cleaningUpAfterException);
133  }
134  throw;
135  }
136  }
void addContextAndPrintException(char const *context, cms::Exception &ex, bool disablePrint)
std::string const & category() const
Definition: Exception.cc:183
exception_actions::ActionCodes find(const std::string &category) const
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:83
void stdToEDM(std::exception const &e)
std::list< std::string > const & context() const
Definition: Exception.cc:191
void printCmsExceptionWarning(char const *behavior, cms::Exception const &e, edm::JobReport *jobRep=0, int rc=-1)
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87
void charPtrToEDM(char const *c)
void stringToEDM(std::string &s)
long double T
void setupOnDemandSystem(EventPrincipal &principal, EventSetup const &es)
void edm::WorkerManager::resetAll ( )
private

Definition at line 129 of file WorkerManager.cc.

References allWorkers_, edm::for_all(), and edm::Worker::reset().

Referenced by processOneOccurrence().

129  {
130  for_all(allWorkers_, boost::bind(&Worker::reset, _1));
131  }
AllWorkers allWorkers_
Definition: WorkerManager.h:85
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void reset()
Definition: Worker.h:92
void edm::WorkerManager::setOnDemandProducts ( ProductRegistry pregistry,
std::set< std::string > const &  unscheduledLabels 
) const

Definition at line 64 of file WorkerManager.cc.

References edm::InEvent, parseEventContent::prod, and edm::ProductRegistry::productListUpdator().

Referenced by edm::SecondaryEventProvider::SecondaryEventProvider(), and edm::StreamSchedule::StreamSchedule().

64  {
65  for(auto& prod : pregistry.productListUpdator()) {
66  if(prod.second.produced() &&
67  prod.second.branchType() == InEvent &&
68  unscheduledLabels.end() != unscheduledLabels.find(prod.second.moduleLabel())) {
69  prod.second.setOnDemand(true);
70  }
71  }
72  }
void edm::WorkerManager::setupOnDemandSystem ( EventPrincipal principal,
EventSetup const &  es 
)
private

Definition at line 144 of file WorkerManager.cc.

References edm::EventPrincipal::setUnscheduledHandler(), and unscheduled_.

Referenced by processOneOccurrence().

144  {
145  // NOTE: who owns the productdescrption? Just copied by value
146  unscheduled_->setEventSetup(es);
147  ep.setUnscheduledHandler(unscheduled_);
148  }
boost::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:87

Member Data Documentation

ExceptionToActionTable const* edm::WorkerManager::actionTable_
private

Definition at line 83 of file WorkerManager.h.

Referenced by actionTable(), getWorker(), and processOneOccurrence().

AllWorkers edm::WorkerManager::allWorkers_
private
boost::shared_ptr<UnscheduledCallProducer> edm::WorkerManager::unscheduled_
private
WorkerRegistry edm::WorkerManager::workerReg_
private

Definition at line 82 of file WorkerManager.h.

Referenced by getWorker().