Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
art::WorkerT< T > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/art/v2_13_00/source/art/Framework/Core/WorkerT.h"

Inheritance diagram for art::WorkerT< T >:
art::Worker

Public Types

using ModuleType = T
 
using WorkerType = WorkerT< T >
 
enum  State {
  Ready, Pass, Fail, Working,
  Exception
}
 

Public Member Functions

 WorkerT (std::unique_ptr< T > &&, ModuleDescription const &, WorkerParams const &)
 
bool modifiesEvent () const override
 
template<typename T >
bool doWork (typename T::MyPrincipal &, CurrentProcessingContext const *cpc)
 
void beginJob ()
 
void endJob ()
 
void respondToOpenInputFile (FileBlock const &fb)
 
void respondToCloseInputFile (FileBlock const &fb)
 
void respondToOpenOutputFiles (FileBlock const &fb)
 
void respondToCloseOutputFiles (FileBlock const &fb)
 
void reset ()
 
ModuleDescription const & description () const
 
ModuleDescription const * descPtr () const
 
void setActivityRegistry (cet::exempt_ptr< ActivityRegistry > areg)
 
void clearCounters ()
 
std::size_t timesRun () const
 
std::size_t timesVisited () const
 
std::size_t timesPassed () const
 
std::size_t timesFailed () const
 
std::size_t timesExcept () const
 
State state () const
 
std::string const & label () const
 

Protected Member Functions

Tmodule ()
 
T const & module () const
 

Private Member Functions

bool implDoProcess (EventPrincipal &ep, CurrentProcessingContext const *cpc, CountingStatistics &) override
 
bool implDoBegin (RunPrincipal &rp, CurrentProcessingContext const *cpc) override
 
bool implDoEnd (RunPrincipal &rp, CurrentProcessingContext const *cpc) override
 
bool implDoBegin (SubRunPrincipal &srp, CurrentProcessingContext const *cpc) override
 
bool implDoEnd (SubRunPrincipal &srp, CurrentProcessingContext const *cpc) override
 
void implBeginJob () override
 
void implEndJob () override
 
void implRespondToOpenInputFile (FileBlock const &fb) override
 
void implRespondToCloseInputFile (FileBlock const &fb) override
 
void implRespondToOpenOutputFiles (FileBlock const &fb) override
 
void implRespondToCloseOutputFiles (FileBlock const &fb) override
 
std::string workerType () const override
 

Private Attributes

std::unique_ptr< Tmodule_
 

Detailed Description

template<typename T>
class art::WorkerT< T >

Definition at line 22 of file WorkerT.h.

Member Typedef Documentation

template<typename T>
using art::WorkerT< T >::ModuleType = T

Definition at line 24 of file WorkerT.h.

template<typename T>
using art::WorkerT< T >::WorkerType = WorkerT<T>

Definition at line 25 of file WorkerT.h.

Member Enumeration Documentation

enum art::Worker::State
inherited
Enumerator
Ready 
Pass 
Fail 
Working 
Exception 

Definition at line 53 of file Worker.h.

Constructor & Destructor Documentation

template<typename T>
art::WorkerT< T >::WorkerT ( std::unique_ptr< T > &&  module,
ModuleDescription const &  md,
WorkerParams const &  wp 
)
inline

Definition at line 73 of file WorkerT.h.

References fetch_tb_beamline_files::md, art::WorkerT< T >::module(), and art::WorkerT< T >::module_.

76  : Worker{md, wp}, module_{std::move(module)}
77  {
78  module_->setModuleDescription(md);
79  module_->registerProducts(wp.reg_, wp.producedProducts_, md);
80  }
T & module()
Definition: WorkerT.h:39
Worker(ModuleDescription const &iMD, WorkerParams const &iWP)
std::unique_ptr< T > module_
Definition: WorkerT.h:69

Member Function Documentation

void art::Worker::beginJob ( )
inherited
void art::Worker::clearCounters ( )
inlineinherited

Definition at line 88 of file Worker.h.

References art::Worker::counts_.

89  {
91  }
CountingStatistics counts_
Definition: Worker.h:157
ExecutionCounts< stats::Visited, stats::Run, stats::Passed, stats::Failed, stats::ExceptionThrown > CountingStatistics
ModuleDescription const* art::Worker::descPtr ( ) const
inlineinherited

Definition at line 79 of file Worker.h.

References art::Worker::md_, and art::Worker::setActivityRegistry().

80  {
81  return &md_;
82  }
ModuleDescription md_
Definition: Worker.h:160
ModuleDescription const& art::Worker::description ( ) const
inlineinherited

Definition at line 74 of file Worker.h.

References art::Worker::md_.

75  {
76  return md_;
77  }
ModuleDescription md_
Definition: Worker.h:160
template<typename T >
bool art::Worker::doWork ( typename T::MyPrincipal &  p,
CurrentProcessingContext const *  cpc 
)
inherited

Definition at line 218 of file Worker.h.

References plot_validation_datamc::action, art::Worker::actions_, art::Worker::actReg_, ana::assert(), art::errors::BadAlloc, art::errors::BadExceptionType, plot_validation_datamc::c, art::Worker::cached_exception_, art::Worker::counts_, e, art::Event, art::Worker::Exception, art::detail::exceptionContext(), art::Worker::Fail, art::actions::FailModule, art::actions::FailPath, art::ActionTable::find(), art::actions::IgnoreCompletely, art::CurrentProcessingContext::isEndPath(), art::Worker::md_, art::errors::OtherArt, art::Worker::Pass, submit_cafana::rc, art::Worker::Ready, art::actions::Rethrow, art::errors::ScheduleExecutionFailure, art::actions::SkipEvent, art::Worker::state_, art::errors::StdException, string, art::errors::Unknown, and art::Worker::Working.

220 {
221  MaybeIncrementCounts<T::level, decltype(counts_)> counts{counts_};
222  counts.template increment<stats::Visited>();
223 
224  switch (state_) {
225  case Ready:
226  break;
227  case Pass:
228  return true;
229  case Fail:
230  return false;
231  case Exception: {
232  // Rethrow the cached exception again. It seems impossible to
233  // get here a second time unless a cet::exception has been
234  // thrown previously.
235  mf::LogWarning("repeat")
236  << "A module has been invoked a second time even though"
237  " it caught an exception during the previous invocation."
238  "\nThis may be an indication of a configuration problem.\n";
239  throw *cached_exception_;
240  }
241  case Working:
242  break; // See below.
243  }
244 
245  bool rc{false};
246  try {
247  if (state_ == Working) {
248  // Not part of the switch statement above because we want the
249  // exception to be caught by our handling mechanism.
251  << "A Module has been invoked while it is still being executed.\n"
252  << "Product dependencies have invoked a module execution cycle.\n";
253  }
254 
255  assert(actReg_.get() != nullptr);
256  state_ = Working;
257 
258  T::preModuleSignal(*actReg_, md_);
259  rc = ImplDoWork<T::processing_action>::invoke(this, p, cpc);
260  T::postModuleSignal(*actReg_, md_);
261 
262  state_ = Pass;
263 
264  if (T::level == Level::Event && !rc)
265  state_ = Fail;
266  }
267  catch (cet::exception& e) {
268 
269  // NOTE: the warning printed as a result of ignoring or failing a
270  // module will only be printed during the full true processing
271  // pass of this module.
272 
273  // Get the action corresponding to this exception. However, if
274  // processing something other than an event (e.g. run, subRun)
275  // always rethrow.
277  actions_.find(e.root_cause()) :
279 
280  // If we are processing an endPath, treat SkipEvent or FailPath as
281  // FailModule, so any subsequent OutputModules are still run.
282  if (cpc && cpc->isEndPath()) {
285  }
286 
287  switch (action) {
289  rc = true;
290  counts.template increment<stats::Passed>();
291  state_ = Pass;
292  mf::LogWarning("IgnoreCompletely") << "Module ignored an exception\n"
293  << e.what();
294  break;
295  }
296  case actions::FailModule: {
297  rc = true;
298  mf::LogWarning("FailModule") << "Module failed due to an exception\n"
299  << e.what();
300  counts.template increment<stats::Failed>();
301  state_ = Fail;
302  break;
303  }
304  default: {
305  // We should not need to include the event/run/module names in
306  // the exception because the error logger will pick this up
307  // automatically. I'm leaving it in until this is verified.
308 
309  // here we simply add a small amount of data to the exception to
310  // add some context, we could have rethrown it as something else
311  // and embedded with this exception as an argument to the
312  // constructor.
313  counts.template increment<stats::ExceptionThrown>();
314  state_ = Exception;
315  e << "cet::exception going through module ";
317  if (auto edmEx = dynamic_cast<art::Exception*>(&e)) {
318  cached_exception_ = std::make_shared<art::Exception>(*edmEx);
319  } else {
320  cached_exception_ = std::make_shared<art::Exception>(
322  }
323  throw;
324  }
325  }
326  }
327  catch (std::bad_alloc const& bda) {
328  counts.template increment<stats::ExceptionThrown>();
329  state_ = Exception;
330  cached_exception_ = std::make_shared<art::Exception>(errors::BadAlloc);
332  << "A std::bad_alloc exception occurred during a call to the module ";
333  detail::exceptionContext(md_, p, *cached_exception_)
334  << "The job has probably exhausted the virtual memory available to the "
335  "process.\n";
336  throw *cached_exception_;
337  }
338  catch (std::exception const& e) {
339  counts.template increment<stats::ExceptionThrown>();
340  state_ = Exception;
341  cached_exception_ = std::make_shared<art::Exception>(errors::StdException);
343  << "A std::exception occurred during a call to the module ";
344  detail::exceptionContext(md_, p, *cached_exception_)
345  << "and cannot be repropagated.\n"
346  << "Previous information:\n"
347  << e.what();
348  throw *cached_exception_;
349  }
350  catch (std::string const& s) {
351  counts.template increment<stats::ExceptionThrown>();
352  state_ = Exception;
353  cached_exception_ =
354  std::make_shared<art::Exception>(errors::BadExceptionType, "std::string");
355  *cached_exception_ << "A std::string thrown as an exception occurred "
356  "during a call to the module ";
357  detail::exceptionContext(md_, p, *cached_exception_)
358  << "and cannot be repropagated.\n"
359  << "Previous information:\n string = " << s;
360  throw *cached_exception_;
361  }
362  catch (char const* c) {
363  counts.template increment<stats::ExceptionThrown>();
364  state_ = Exception;
365  cached_exception_ = std::make_shared<art::Exception>(
366  errors::BadExceptionType, "const char *");
367  *cached_exception_ << "A const char* thrown as an exception occurred "
368  "during a call to the module ";
369  detail::exceptionContext(md_, p, *cached_exception_)
370  << "and cannot be repropagated.\n"
371  << "Previous information:\n const char* = " << c << "\n";
372  throw *cached_exception_;
373  }
374  catch (...) {
375  counts.template increment<stats::ExceptionThrown>();
376  state_ = Exception;
377  cached_exception_ =
378  std::make_shared<art::Exception>(errors::Unknown, "repeated");
379  *cached_exception_
380  << "An unknown occurred during a previous call to the module ";
381  detail::exceptionContext(md_, p, *cached_exception_)
382  << "and cannot be repropagated.\n";
383  throw *cached_exception_;
384  }
385 
386  return rc;
387 }
actions::ActionCodes find(std::string const &category) const
const char * p
Definition: xmltok.h:285
CountingStatistics counts_
Definition: Worker.h:157
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
ActionTable const & actions_
Definition: Worker.h:161
cet::exception & exceptionContext(ModuleDescription const &md, T const &ip, cet::exception &ex)
Definition: Worker.h:208
const XML_Char * s
Definition: expat.h:262
std::shared_ptr< art::Exception > cached_exception_
Definition: Worker.h:162
cet::exempt_ptr< ActivityRegistry > actReg_
Definition: Worker.h:164
ModuleDescription md_
Definition: Worker.h:160
State state_
Definition: Worker.h:158
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
assert(nhit_max >=nhit_nbins)
Float_t e
Definition: plot.C:35
enum BeamMode string
void art::Worker::endJob ( )
inherited
template<typename T >
void art::WorkerT< T >::implBeginJob ( )
overrideprivatevirtual

Implements art::Worker.

Definition at line 130 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

131  {
132  module_->doBeginJob();
133  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
bool art::WorkerT< T >::implDoBegin ( RunPrincipal rp,
CurrentProcessingContext const *  cpc 
)
overrideprivatevirtual

Implements art::Worker.

Definition at line 93 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

94  {
95  return module_->doBeginRun(rp, cpc);
96  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
bool art::WorkerT< T >::implDoBegin ( SubRunPrincipal srp,
CurrentProcessingContext const *  cpc 
)
overrideprivatevirtual

Implements art::Worker.

Definition at line 107 of file WorkerT.h.

References art::WorkerT< T >::module_.

109  {
110  return module_->doBeginSubRun(srp, cpc);
111  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
bool art::WorkerT< T >::implDoEnd ( RunPrincipal rp,
CurrentProcessingContext const *  cpc 
)
overrideprivatevirtual

Implements art::Worker.

Definition at line 100 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

101  {
102  return module_->doEndRun(rp, cpc);
103  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
bool art::WorkerT< T >::implDoEnd ( SubRunPrincipal srp,
CurrentProcessingContext const *  cpc 
)
overrideprivatevirtual

Implements art::Worker.

Definition at line 115 of file WorkerT.h.

References art::WorkerT< T >::module_, and string.

117  {
118  return module_->doEndSubRun(srp, cpc);
119  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
bool art::WorkerT< T >::implDoProcess ( EventPrincipal ep,
CurrentProcessingContext const *  cpc,
CountingStatistics stats 
)
overrideprivatevirtual

Implements art::Worker.

Definition at line 84 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

87  {
88  return module_->doEvent(ep, cpc, stats);
89  }
int stats(TString inputFilePath, Int_t firstRun, Int_t lastRun, Float_t thresh, TString myDet)
Definition: stats.C:13
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
void art::WorkerT< T >::implEndJob ( )
overrideprivatevirtual

Implements art::Worker.

Definition at line 137 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

138  {
139  module_->doEndJob();
140  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
void art::WorkerT< T >::implRespondToCloseInputFile ( FileBlock const &  fb)
overrideprivatevirtual

Implements art::Worker.

Definition at line 151 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

152  {
153  module_->doRespondToCloseInputFile(fb);
154  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
void art::WorkerT< T >::implRespondToCloseOutputFiles ( FileBlock const &  fb)
overrideprivatevirtual

Implements art::Worker.

Definition at line 165 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

166  {
167  module_->doRespondToCloseOutputFiles(fb);
168  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
void art::WorkerT< T >::implRespondToOpenInputFile ( FileBlock const &  fb)
overrideprivatevirtual

Implements art::Worker.

Definition at line 144 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

145  {
146  module_->doRespondToOpenInputFile(fb);
147  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T >
void art::WorkerT< T >::implRespondToOpenOutputFiles ( FileBlock const &  fb)
overrideprivatevirtual

Implements art::Worker.

Definition at line 158 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

159  {
160  module_->doRespondToOpenOutputFiles(fb);
161  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
std::string const& art::Worker::label ( ) const
inlineinherited
template<typename T>
bool art::WorkerT< T >::modifiesEvent ( ) const
inlineoverridevirtual

Implements art::Worker.

Definition at line 32 of file WorkerT.h.

33  {
34  return module_->modifiesEvent();
35  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T>
T& art::WorkerT< T >::module ( )
inlineprotected

Definition at line 39 of file WorkerT.h.

Referenced by art::WorkerT< T >::WorkerT().

40  {
41  return *module_;
42  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
template<typename T>
T const& art::WorkerT< T >::module ( ) const
inlineprotected

Definition at line 44 of file WorkerT.h.

45  {
46  return *module_;
47  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69
void art::Worker::reset ( )
inlineinherited

Definition at line 68 of file Worker.h.

References art::Worker::Ready, and art::Worker::state_.

69  {
70  state_ = Ready;
71  }
State state_
Definition: Worker.h:158
void art::Worker::respondToCloseInputFile ( FileBlock const &  fb)
inherited
void art::Worker::respondToCloseOutputFiles ( FileBlock const &  fb)
inherited
void art::Worker::respondToOpenInputFile ( FileBlock const &  fb)
inherited
void art::Worker::respondToOpenOutputFiles ( FileBlock const &  fb)
inherited
void art::Worker::setActivityRegistry ( cet::exempt_ptr< ActivityRegistry areg)
inherited

The signals are required to live longer than the last call to 'doWork' this was done to improve performance based on profiling

Referenced by art::Worker::descPtr().

State art::Worker::state ( ) const
inlineinherited

Definition at line 119 of file Worker.h.

References art::Worker::modifiesEvent(), art::Worker::state_, and string.

120  {
121  return state_;
122  }
State state_
Definition: Worker.h:158
std::size_t art::Worker::timesExcept ( ) const
inlineinherited

Definition at line 114 of file Worker.h.

References art::Worker::counts_, and art::ExecutionCounts< ARGS >::times().

115  {
116  return counts_.times<stats::ExceptionThrown>();
117  }
CountingStatistics counts_
Definition: Worker.h:157
std::size_t times() const
std::size_t art::Worker::timesFailed ( ) const
inlineinherited

Definition at line 109 of file Worker.h.

References art::Worker::counts_, and art::ExecutionCounts< ARGS >::times().

110  {
111  return counts_.times<stats::Failed>();
112  }
CountingStatistics counts_
Definition: Worker.h:157
std::size_t times() const
std::size_t art::Worker::timesPassed ( ) const
inlineinherited

Definition at line 104 of file Worker.h.

References art::Worker::counts_, and art::ExecutionCounts< ARGS >::times().

105  {
106  return counts_.times<stats::Passed>();
107  }
CountingStatistics counts_
Definition: Worker.h:157
std::size_t times() const
std::size_t art::Worker::timesRun ( ) const
inlineinherited

Definition at line 94 of file Worker.h.

References art::Worker::counts_, and art::ExecutionCounts< ARGS >::times().

95  {
96  return counts_.times<stats::Run>();
97  }
CountingStatistics counts_
Definition: Worker.h:157
std::size_t times() const
std::size_t art::Worker::timesVisited ( ) const
inlineinherited

Definition at line 99 of file Worker.h.

References art::Worker::counts_, and art::ExecutionCounts< ARGS >::times().

100  {
101  return counts_.times<stats::Visited>();
102  }
CountingStatistics counts_
Definition: Worker.h:157
std::size_t times() const
template<typename T >
std::string art::WorkerT< T >::workerType ( ) const
overrideprivatevirtual

Implements art::Worker.

Definition at line 123 of file WorkerT.h.

References art::WorkerT< T >::module_.

Referenced by art::WorkerT< OutputModule >::module().

124  {
125  return module_->workerType();
126  }
std::unique_ptr< T > module_
Definition: WorkerT.h:69

Member Data Documentation

template<typename T>
std::unique_ptr<T> art::WorkerT< T >::module_
private

The documentation for this class was generated from the following file: