CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends
SonicClientBase Class Referenceabstract

#include <SonicClientBase.h>

Inheritance diagram for SonicClientBase:
SonicClient< InputT, OutputT > SonicClient< TritonInputMap, TritonOutputMap > TritonClient

Public Member Functions

const std::string & clientName () const
 
const std::string & debugName () const
 
virtual void dispatch ()
 
virtual void dispatch (edm::WaitingTaskWithArenaHolder holder)
 
SonicMode mode () const
 
virtual void reset ()
 
void setDebugName (const std::string &debugName)
 
 SonicClientBase (const edm::ParameterSet &params)
 
virtual ~SonicClientBase ()=default
 

Static Public Member Functions

static void fillBasePSetDescription (edm::ParameterSetDescription &desc, bool allowRetry=true)
 

Protected Member Functions

virtual void evaluate ()=0
 
void finish (bool success, std::exception_ptr eptr=std::exception_ptr{})
 
void start ()
 
void start (edm::WaitingTaskWithArenaHolder holder)
 

Protected Attributes

unsigned allowedTries_
 
std::string clientName_
 
std::string debugName_
 
std::unique_ptr< SonicDispatcherdispatcher_
 
std::string fullDebugName_
 
std::optional< edm::WaitingTaskWithArenaHolderholder_
 
SonicMode mode_
 
std::chrono::time_point< std::chrono::high_resolution_clock > t0_
 
unsigned tries_
 

Friends

class SonicDispatcher
 
class SonicDispatcherPseudoAsync
 

Detailed Description

Definition at line 19 of file SonicClientBase.h.

Constructor & Destructor Documentation

◆ SonicClientBase()

SonicClientBase::SonicClientBase ( const edm::ParameterSet params)

Definition at line 5 of file SonicClientBase.cc.

6  : allowedTries_(params.getUntrackedParameter<unsigned>("allowedTries", 0)) {
7  std::string modeName(params.getParameter<std::string>("mode"));
8  if (modeName == "Sync")
10  else if (modeName == "Async")
12  else if (modeName == "PseudoAsync")
14  else
15  throw cms::Exception("Configuration") << "Unknown mode for SonicClient: " << modeName;
16 
17  //get correct dispatcher for mode
19  dispatcher_ = std::make_unique<SonicDispatcher>(this);
20  else if (mode_ == SonicMode::PseudoAsync)
21  dispatcher_ = std::make_unique<SonicDispatcherPseudoAsync>(this);
22 }

References Async, dispatcher_, Exception, mode_, or, CalibrationSummaryClient_cfi::params, PseudoAsync, AlCaHLTBitMon_QueryRunRegistry::string, and Sync.

◆ ~SonicClientBase()

virtual SonicClientBase::~SonicClientBase ( )
virtualdefault

Member Function Documentation

◆ clientName()

const std::string& SonicClientBase::clientName ( ) const
inline

Definition at line 29 of file SonicClientBase.h.

29 { return clientName_; }

References clientName_.

◆ debugName()

const std::string& SonicClientBase::debugName ( ) const
inline

Definition at line 28 of file SonicClientBase.h.

28 { return debugName_; }

References debugName_.

Referenced by setDebugName().

◆ dispatch() [1/2]

virtual void SonicClientBase::dispatch ( )
inlinevirtual

Definition at line 36 of file SonicClientBase.h.

36 { dispatcher_->dispatch(); }

References dispatcher_.

◆ dispatch() [2/2]

virtual void SonicClientBase::dispatch ( edm::WaitingTaskWithArenaHolder  holder)
inlinevirtual

Definition at line 33 of file SonicClientBase.h.

33 { dispatcher_->dispatch(std::move(holder)); }

References dispatcher_, and eostools::move().

◆ evaluate()

virtual void SonicClientBase::evaluate ( )
protectedpure virtual

◆ fillBasePSetDescription()

void SonicClientBase::fillBasePSetDescription ( edm::ParameterSetDescription desc,
bool  allowRetry = true 
)
static

Definition at line 71 of file SonicClientBase.cc.

71  {
72  //restrict allowed values
73  desc.ifValue(edm::ParameterDescription<std::string>("mode", "PseudoAsync", true),
74  edm::allowedValues<std::string>("Sync", "Async", "PseudoAsync"));
75  if (allowRetry)
76  desc.addUntracked<unsigned>("allowedTries", 0);
77 }

References submitPVResolutionJobs::desc.

Referenced by TritonClient::fillPSetDescription().

◆ finish()

void SonicClientBase::finish ( bool  success,
std::exception_ptr  eptr = std::exception_ptr{} 
)
protected

Definition at line 42 of file SonicClientBase.cc.

42  {
43  //retries are only allowed if no exception was raised
44  if (!success and !eptr) {
45  ++tries_;
46  //if max retries has not been exceeded, call evaluate again
47  if (tries_ < allowedTries_) {
48  evaluate();
49  //avoid calling doneWaiting() twice
50  return;
51  }
52  //prepare an exception if exceeded
53  else {
54  cms::Exception ex("SonicCallFailed");
55  ex << "call failed after max " << tries_ << " tries";
56  eptr = make_exception_ptr(ex);
57  }
58  }
59  if (!debugName_.empty()) {
61  edm::LogInfo(fullDebugName_) << "Client time: "
62  << std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0_).count();
63  }
64  if (holder_) {
65  holder_->doneWaiting(eptr);
66  holder_.reset();
67  } else if (eptr)
68  std::rethrow_exception(eptr);
69 }

References allowedTries_, debugName_, evaluate(), fullDebugName_, holder_, submitPVValidationJobs::now, summarizeEdmComparisonLogfiles::success, t0_, RandomServiceHelper::t1, and tries_.

Referenced by progressbar.ProgressBar::__next__(), and TritonClient::evaluate().

◆ mode()

SonicMode SonicClientBase::mode ( void  ) const
inline

Definition at line 30 of file SonicClientBase.h.

30 { return mode_; }

References mode_.

◆ reset()

virtual void SonicClientBase::reset ( void  )
inlinevirtual

Reimplemented in TritonClient.

Definition at line 39 of file SonicClientBase.h.

39 {}

◆ setDebugName()

void SonicClientBase::setDebugName ( const std::string &  debugName)

Definition at line 24 of file SonicClientBase.cc.

24  {
27  if (!clientName_.empty())
28  fullDebugName_ += ":" + clientName_;
29 }

References clientName_, debugName(), debugName_, and fullDebugName_.

◆ start() [1/2]

void SonicClientBase::start ( )
protected

Definition at line 36 of file SonicClientBase.cc.

36  {
37  tries_ = 0;
38  if (!debugName_.empty())
40 }

References debugName_, submitPVValidationJobs::now, t0_, and tries_.

Referenced by progressbar.ProgressBar::__next__(), and start().

◆ start() [2/2]

void SonicClientBase::start ( edm::WaitingTaskWithArenaHolder  holder)
protected

Definition at line 31 of file SonicClientBase.cc.

31  {
32  start();
33  holder_ = std::move(holder);
34 }

References holder_, eostools::move(), and start().

Referenced by progressbar.ProgressBar::__next__(), SonicDispatcher::dispatch(), and SonicDispatcherPseudoAsync::dispatch().

Friends And Related Function Documentation

◆ SonicDispatcher

friend class SonicDispatcher
friend

Definition at line 63 of file SonicClientBase.h.

◆ SonicDispatcherPseudoAsync

friend class SonicDispatcherPseudoAsync
friend

Definition at line 64 of file SonicClientBase.h.

Member Data Documentation

◆ allowedTries_

unsigned SonicClientBase::allowedTries_
protected

Definition at line 56 of file SonicClientBase.h.

Referenced by finish().

◆ clientName_

std::string SonicClientBase::clientName_
protected

Definition at line 60 of file SonicClientBase.h.

Referenced by clientName(), setDebugName(), and TritonClient::TritonClient().

◆ debugName_

std::string SonicClientBase::debugName_
protected

◆ dispatcher_

std::unique_ptr<SonicDispatcher> SonicClientBase::dispatcher_
protected

Definition at line 55 of file SonicClientBase.h.

Referenced by dispatch(), and SonicClientBase().

◆ fullDebugName_

std::string SonicClientBase::fullDebugName_
protected

◆ holder_

std::optional<edm::WaitingTaskWithArenaHolder> SonicClientBase::holder_
protected

Definition at line 57 of file SonicClientBase.h.

Referenced by finish(), and start().

◆ mode_

SonicMode SonicClientBase::mode_
protected

Definition at line 54 of file SonicClientBase.h.

Referenced by TritonClient::evaluate(), mode(), and SonicClientBase().

◆ t0_

std::chrono::time_point<std::chrono::high_resolution_clock> SonicClientBase::t0_
protected

Definition at line 61 of file SonicClientBase.h.

Referenced by finish(), and start().

◆ tries_

unsigned SonicClientBase::tries_
protected

Definition at line 56 of file SonicClientBase.h.

Referenced by finish(), and start().

submitPVValidationJobs.now
now
Definition: submitPVValidationJobs.py:639
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
SonicClientBase::debugName
const std::string & debugName() const
Definition: SonicClientBase.h:28
SonicClientBase::tries_
unsigned tries_
Definition: SonicClientBase.h:56
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
summarizeEdmComparisonLogfiles.success
success
Definition: summarizeEdmComparisonLogfiles.py:115
SonicClientBase::evaluate
virtual void evaluate()=0
SonicMode::PseudoAsync
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SonicMode::Sync
SonicClientBase::mode_
SonicMode mode_
Definition: SonicClientBase.h:54
SonicMode::Async
SonicClientBase::fullDebugName_
std::string fullDebugName_
Definition: SonicClientBase.h:60
SonicClientBase::debugName_
std::string debugName_
Definition: SonicClientBase.h:60
SonicClientBase::allowedTries_
unsigned allowedTries_
Definition: SonicClientBase.h:56
SonicClientBase::dispatcher_
std::unique_ptr< SonicDispatcher > dispatcher_
Definition: SonicClientBase.h:55
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
SonicClientBase::t0_
std::chrono::time_point< std::chrono::high_resolution_clock > t0_
Definition: SonicClientBase.h:61
Exception
Definition: hltDiff.cc:246
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:36
cms::Exception
Definition: Exception.h:70
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