CMS 3D CMS Logo

SonicClientBase.cc
Go to the documentation of this file.
4 
6  const std::string& debugName,
7  const std::string& clientName)
8  : allowedTries_(params.getUntrackedParameter<unsigned>("allowedTries", 0)),
9  debugName_(debugName),
10  clientName_(clientName),
11  fullDebugName_(debugName_) {
12  if (!clientName_.empty())
13  fullDebugName_ += ":" + clientName_;
14 
15  std::string modeName(params.getParameter<std::string>("mode"));
16  if (modeName == "Sync")
18  else if (modeName == "Async")
20  else if (modeName == "PseudoAsync")
22  else
23  throw cms::Exception("Configuration") << "Unknown mode for SonicClient: " << modeName;
24 }
25 
27  if (dispatcher_ and mode_ == mode)
28  return;
29  mode_ = mode;
30 
31  //get correct dispatcher for mode
33  dispatcher_ = std::make_unique<SonicDispatcher>(this);
34  else if (mode_ == SonicMode::PseudoAsync)
35  dispatcher_ = std::make_unique<SonicDispatcherPseudoAsync>(this);
36 }
37 
39  start();
40  holder_ = std::move(holder);
41 }
42 
44 
45 void SonicClientBase::finish(bool success, std::exception_ptr eptr) {
46  //retries are only allowed if no exception was raised
47  if (!success and !eptr) {
48  ++tries_;
49  //if max retries has not been exceeded, call evaluate again
50  if (tries_ < allowedTries_) {
51  evaluate();
52  //avoid calling doneWaiting() twice
53  return;
54  }
55  //prepare an exception if exceeded
56  else {
57  cms::Exception ex("SonicCallFailed");
58  ex << "call failed after max " << tries_ << " tries";
59  eptr = make_exception_ptr(ex);
60  }
61  }
62  if (holder_) {
63  holder_->doneWaiting(eptr);
64  holder_.reset();
65  } else if (eptr)
66  std::rethrow_exception(eptr);
67 
68  //reset client data now (usually done at end of produce())
69  if (eptr)
70  reset();
71 }
72 
74  //restrict allowed values
75  desc.ifValue(edm::ParameterDescription<std::string>("mode", "PseudoAsync", true),
76  edm::allowedValues<std::string>("Sync", "Async", "PseudoAsync"));
77  if (allowRetry)
78  desc.addUntracked<unsigned>("allowedTries", 0);
79 }
allowedValues.h
SonicClientBase::fillBasePSetDescription
static void fillBasePSetDescription(edm::ParameterSetDescription &desc, bool allowRetry=true)
Definition: SonicClientBase.cc:73
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
SonicMode
SonicMode
Definition: SonicClientBase.h:16
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
SonicClientBase::finish
void finish(bool success, std::exception_ptr eptr=std::exception_ptr{})
Definition: SonicClientBase.cc:45
SonicClientBase::tries_
unsigned tries_
Definition: SonicClientBase.h:56
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:114
SonicClientBase::SonicClientBase
SonicClientBase(const edm::ParameterSet &params, const std::string &debugName, const std::string &clientName)
Definition: SonicClientBase.cc:5
SonicClientBase::evaluate
virtual void evaluate()=0
SonicClientBase::reset
virtual void reset()
Definition: SonicClientBase.h:37
SonicMode::PseudoAsync
SonicMode::Sync
SonicClientBase::mode_
SonicMode mode_
Definition: SonicClientBase.h:54
edm::ParameterSet
Definition: ParameterSet.h:47
SonicMode::Async
SonicClientBase::fullDebugName_
std::string fullDebugName_
Definition: SonicClientBase.h:60
SonicClientBase.h
SonicClientBase::allowedTries_
unsigned allowedTries_
Definition: SonicClientBase.h:56
SonicClientBase::dispatcher_
std::unique_ptr< SonicDispatcher > dispatcher_
Definition: SonicClientBase.h:55
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
Exception
Definition: hltDiff.cc:245
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
SonicClientBase::start
void start()
Definition: SonicClientBase.cc:43
Exception.h
cms::Exception
Definition: Exception.h:70
SonicClientBase::mode
SonicMode mode() const
Definition: SonicClientBase.h:28
SonicClientBase::clientName_
std::string clientName_
Definition: SonicClientBase.h:60
edm::ParameterDescription
Definition: ParameterDescription.h:110
SonicClientBase::holder_
std::optional< edm::WaitingTaskWithArenaHolder > holder_
Definition: SonicClientBase.h:57
SonicClientBase::setMode
void setMode(SonicMode mode)
Definition: SonicClientBase.cc:26