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)
 
void addToUnscheduledWorkers (ParameterSet &pset, ProductRegistry &preg, PreallocationConfiguration const *prealloc, std::shared_ptr< ProcessConfiguration > processConfiguration, std::string label, 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, std::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 (std::shared_ptr< ActivityRegistry > actReg, ExceptionToActionTable const &actions)
 
 WorkerManager (std::shared_ptr< ModuleRegistry > modReg, std::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_
 
std::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 ( std::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:84
actions
Definition: Schedule.cc:370
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:82
areg
Definition: Schedule.cc:370
std::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:86
WorkerRegistry workerReg_
Definition: WorkerManager.h:81
edm::WorkerManager::WorkerManager ( std::shared_ptr< ModuleRegistry modReg,
std::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:84
actions
Definition: Schedule.cc:370
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:82
areg
Definition: Schedule.cc:370
std::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:86
WorkerRegistry workerReg_
Definition: WorkerManager.h:81

Member Function Documentation

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

Definition at line 67 of file WorkerManager.h.

References actionTable_.

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

67 {return *actionTable_;}
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:82
void edm::WorkerManager::addToAllWorkers ( Worker w)

Definition at line 127 of file WorkerManager.cc.

References allWorkers_, and edm::search_all().

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

127  {
128  if(!search_all(allWorkers_, w)) {
129  allWorkers_.push_back(w);
130  }
131  }
const double w
Definition: UKUtility.cc:23
AllWorkers allWorkers_
Definition: WorkerManager.h:84
bool search_all(ForwardSequence const &s, Datum const &d)
Definition: Algorithms.h:46
void edm::WorkerManager::addToUnscheduledWorkers ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::shared_ptr< ProcessConfiguration processConfiguration,
std::string  label,
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().

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

Definition at line 63 of file WorkerManager.h.

References allWorkers_.

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

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

Definition at line 93 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().

93  {
94  auto const runLookup = iRegistry.productLookup(InRun);
95  auto const lumiLookup = iRegistry.productLookup(InLumi);
96  auto const eventLookup = iRegistry.productLookup(InEvent);
97  for(auto& worker : allWorkers_) {
98  worker->updateLookup(InRun,*runLookup);
99  worker->updateLookup(InLumi,*lumiLookup);
100  worker->updateLookup(InEvent,*eventLookup);
101  }
102 
103  for_all(allWorkers_, std::bind(&Worker::beginJob, std::placeholders::_1));
105  }
AllWorkers allWorkers_
Definition: WorkerManager.h:84
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void loadMissingDictionaries()
void beginJob()
Definition: Worker.cc:104
void edm::WorkerManager::beginStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 108 of file WorkerManager.cc.

References allWorkers_.

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

108  {
109  for(auto& worker: allWorkers_) {
110  worker->beginStream(iID, streamContext);
111  }
112  }
AllWorkers allWorkers_
Definition: WorkerManager.h:84
void edm::WorkerManager::endJob ( void  )

Definition at line 73 of file WorkerManager.cc.

References allWorkers_.

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

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

Definition at line 79 of file WorkerManager.cc.

References edm::ExceptionCollector::addException(), allWorkers_, and edm::convertException::wrap().

79  {
80  for(auto& worker : allWorkers_) {
81  try {
83  worker->endJob();
84  });
85  }
86  catch (cms::Exception const& ex) {
87  collector.addException(ex);
88  }
89  }
90  }
AllWorkers allWorkers_
Definition: WorkerManager.h:84
auto wrap(F iFunc) -> decltype(iFunc())
void edm::WorkerManager::endStream ( StreamID  iID,
StreamContext streamContext 
)

Definition at line 115 of file WorkerManager.cc.

References allWorkers_.

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

115  {
116  for(auto& worker: allWorkers_) {
117  worker->endStream(iID, streamContext);
118  }
119  }
AllWorkers allWorkers_
Definition: WorkerManager.h:84
Worker * edm::WorkerManager::getWorker ( ParameterSet pset,
ProductRegistry preg,
PreallocationConfiguration const *  prealloc,
std::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:370
ExceptionToActionTable const * actionTable_
Definition: WorkerManager.h:82
WorkerRegistry workerReg_
Definition: WorkerManager.h:81
Worker * getWorker(WorkerParams const &p, std::string const &moduleLabel)
Retrieve the particular instance of the worker.
preg
Definition: Schedule.cc:370
prealloc
Definition: Schedule.cc:370
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 91 of file WorkerManager.h.

References alignCSCRings::action, actionTable_, edm::addContextAndPrintException(), cms::Exception::category(), cms::Exception::context(), alignCSCRings::e, edm::exception_actions::FailPath, edm::ExceptionToActionTable::find(), edm::exception_actions::IgnoreCompletely, edm::printCmsExceptionWarning(), resetAll(), edm::exception_actions::Rethrow, setupOnDemandSystem(), edm::exception_actions::SkipEvent, unscheduled_, and edm::convertException::wrap().

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().

96  {
97  this->resetAll();
98 
99  try {
100  convertException::wrap([&]() {
101  try {
102  if (T::isEvent_) {
103  setupOnDemandSystem(dynamic_cast<EventPrincipal&>(ep), es);
104  } else {
105  //make sure the unscheduled items see this run or lumi rtansition
106  unscheduled_->runNow<T,U>(ep, es,streamID, topContext, context);
107  }
108  }
109  catch(cms::Exception& e) {
111  assert (action != exception_actions::IgnoreCompletely);
112  assert (action != exception_actions::FailPath);
113  if (action == exception_actions::SkipEvent) {
114  printCmsExceptionWarning("SkipEvent", e);
115  } else {
116  throw;
117  }
118  }
119  });
120  }
121  catch(cms::Exception& ex) {
122  if (ex.context().empty()) {
123  addContextAndPrintException("Calling function WorkerManager::processOneOccurrence", ex, cleaningUpAfterException);
124  } else {
125  addContextAndPrintException("", ex, cleaningUpAfterException);
126  }
127  throw;
128  }
129  }
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:82
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)
std::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:86
auto wrap(F iFunc) -> decltype(iFunc())
long double T
void setupOnDemandSystem(EventPrincipal &principal, EventSetup const &es)
void edm::WorkerManager::resetAll ( )
private

Definition at line 122 of file WorkerManager.cc.

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

Referenced by processOneOccurrence().

122  {
123  for_all(allWorkers_, std::bind(&Worker::reset, std::placeholders::_1));
124  }
AllWorkers allWorkers_
Definition: WorkerManager.h:84
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void reset()
Definition: Worker.h:91
void edm::WorkerManager::setOnDemandProducts ( ProductRegistry pregistry,
std::set< std::string > const &  unscheduledLabels 
) const

Definition at line 63 of file WorkerManager.cc.

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

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

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

Definition at line 134 of file WorkerManager.cc.

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

Referenced by processOneOccurrence().

134  {
135  // NOTE: who owns the productdescrption? Just copied by value
136  unscheduled_->setEventSetup(es);
137  ep.setUnscheduledHandler(unscheduled_);
138  }
std::shared_ptr< UnscheduledCallProducer > unscheduled_
Definition: WorkerManager.h:86

Member Data Documentation

ExceptionToActionTable const* edm::WorkerManager::actionTable_
private

Definition at line 82 of file WorkerManager.h.

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

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

Definition at line 81 of file WorkerManager.h.

Referenced by getWorker().