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 ()
 
 SonicClientBase (const edm::ParameterSet &params, const std::string &debugName, const std::string &clientName)
 
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 setMode (SonicMode mode)
 
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,
const std::string &  debugName,
const std::string &  clientName 
)

Definition at line 5 of file SonicClientBase.cc.

8  : allowedTries_(params.getUntrackedParameter<unsigned>("allowedTries", 0)),
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 }

References Async, clientName_, Exception, fullDebugName_, CalibrationSummaryClient_cfi::params, PseudoAsync, setMode(), AlCaHLTBitMon_QueryRunRegistry::string, and Sync.

◆ ~SonicClientBase()

virtual SonicClientBase::~SonicClientBase ( )
virtualdefault

Member Function Documentation

◆ clientName()

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

Definition at line 28 of file SonicClientBase.h.

28 { return clientName_; }

References clientName_.

◆ debugName()

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

Definition at line 27 of file SonicClientBase.h.

27 { return debugName_; }

References debugName_.

◆ dispatch() [1/2]

virtual void SonicClientBase::dispatch ( )
inlinevirtual

Definition at line 35 of file SonicClientBase.h.

35 { dispatcher_->dispatch(); }

References dispatcher_.

◆ dispatch() [2/2]

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

Definition at line 32 of file SonicClientBase.h.

32 { 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 78 of file SonicClientBase.cc.

78  {
79  //restrict allowed values
80  desc.ifValue(edm::ParameterDescription<std::string>("mode", "PseudoAsync", true),
81  edm::allowedValues<std::string>("Sync", "Async", "PseudoAsync"));
82  if (allowRetry)
83  desc.addUntracked<unsigned>("allowedTries", 0);
84 }

References submitPVResolutionJobs::desc.

Referenced by TritonClient::fillPSetDescription().

◆ finish()

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

Definition at line 49 of file SonicClientBase.cc.

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

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 29 of file SonicClientBase.h.

29 { return mode_; }

References mode_.

Referenced by setMode().

◆ reset()

virtual void SonicClientBase::reset ( void  )
inlinevirtual

Reimplemented in TritonClient.

Definition at line 38 of file SonicClientBase.h.

38 {}

◆ setMode()

void SonicClientBase::setMode ( SonicMode  mode)
protected

Definition at line 26 of file SonicClientBase.cc.

26  {
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 }

References Async, dispatcher_, mode(), mode_, or, PseudoAsync, and Sync.

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

◆ start() [1/2]

void SonicClientBase::start ( )
protected

Definition at line 43 of file SonicClientBase.cc.

43  {
44  tries_ = 0;
45  if (!debugName_.empty())
47 }

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 38 of file SonicClientBase.cc.

38  {
39  start();
40  holder_ = std::move(holder);
41 }

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 64 of file SonicClientBase.h.

◆ SonicDispatcherPseudoAsync

friend class SonicDispatcherPseudoAsync
friend

Definition at line 65 of file SonicClientBase.h.

Member Data Documentation

◆ allowedTries_

unsigned SonicClientBase::allowedTries_
protected

Definition at line 57 of file SonicClientBase.h.

Referenced by finish().

◆ clientName_

std::string SonicClientBase::clientName_
protected

Definition at line 61 of file SonicClientBase.h.

Referenced by clientName(), and SonicClientBase().

◆ debugName_

std::string SonicClientBase::debugName_
protected

◆ dispatcher_

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

Definition at line 56 of file SonicClientBase.h.

Referenced by dispatch(), and setMode().

◆ fullDebugName_

std::string SonicClientBase::fullDebugName_
protected

◆ holder_

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

Definition at line 58 of file SonicClientBase.h.

Referenced by finish(), and start().

◆ mode_

SonicMode SonicClientBase::mode_
protected

Definition at line 55 of file SonicClientBase.h.

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

◆ t0_

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

Definition at line 62 of file SonicClientBase.h.

Referenced by finish(), and start().

◆ tries_

unsigned SonicClientBase::tries_
protected

Definition at line 57 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:27
SonicClientBase::tries_
unsigned tries_
Definition: SonicClientBase.h:57
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
SonicClientBase::clientName
const std::string & clientName() const
Definition: SonicClientBase.h:28
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:55
SonicMode::Async
SonicClientBase::fullDebugName_
std::string fullDebugName_
Definition: SonicClientBase.h:61
SonicClientBase::debugName_
std::string debugName_
Definition: SonicClientBase.h:61
SonicClientBase::allowedTries_
unsigned allowedTries_
Definition: SonicClientBase.h:57
SonicClientBase::dispatcher_
std::unique_ptr< SonicDispatcher > dispatcher_
Definition: SonicClientBase.h:56
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:62
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
cms::Exception
Definition: Exception.h:70
SonicClientBase::mode
SonicMode mode() const
Definition: SonicClientBase.h:29
SonicClientBase::clientName_
std::string clientName_
Definition: SonicClientBase.h:61
edm::ParameterDescription
Definition: ParameterDescription.h:110
SonicClientBase::holder_
std::optional< edm::WaitingTaskWithArenaHolder > holder_
Definition: SonicClientBase.h:58
SonicClientBase::setMode
void setMode(SonicMode mode)
Definition: SonicClientBase.cc:26