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 (edm::WaitingTaskWithArenaHolder holder)
 
virtual void dispatch ()
 
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 (edm::WaitingTaskWithArenaHolder holder)
 
void start ()
 

Protected Attributes

unsigned allowedTries_
 
std::string clientName_
 
std::string debugName_
 
std::unique_ptr< SonicDispatcherdispatcher_
 
std::string fullDebugName_
 
std::optional< edm::WaitingTaskWithArenaHolderholder_
 
SonicMode mode_
 
unsigned tries_
 
bool verbose_
 

Friends

class SonicDispatcher
 
class SonicDispatcherPseudoAsync
 

Detailed Description

Definition at line 18 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.

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

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 }
const std::string & debugName() const
const std::string & clientName() const
void setMode(SonicMode mode)
std::string debugName_
std::string clientName_
std::string fullDebugName_
unsigned allowedTries_

◆ ~SonicClientBase()

virtual SonicClientBase::~SonicClientBase ( )
virtualdefault

Member Function Documentation

◆ clientName()

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

Definition at line 27 of file SonicClientBase.h.

References clientName_.

27 { return clientName_; }
std::string clientName_

◆ debugName()

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

Definition at line 26 of file SonicClientBase.h.

References debugName_.

26 { return debugName_; }
std::string debugName_

◆ dispatch() [1/2]

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

Definition at line 31 of file SonicClientBase.h.

References dispatcher_, and eostools::move().

31 { dispatcher_->dispatch(std::move(holder)); }
std::unique_ptr< SonicDispatcher > dispatcher_
def move(src, dest)
Definition: eostools.py:511

◆ dispatch() [2/2]

virtual void SonicClientBase::dispatch ( )
inlinevirtual

Definition at line 34 of file SonicClientBase.h.

References dispatcher_.

34 { dispatcher_->dispatch(); }
std::unique_ptr< SonicDispatcher > dispatcher_

◆ evaluate()

virtual void SonicClientBase::evaluate ( )
protectedpure virtual

◆ fillBasePSetDescription()

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

Definition at line 73 of file SonicClientBase.cc.

References submitPVResolutionJobs::desc.

Referenced by TritonClient::fillPSetDescription().

73  {
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  desc.addUntracked<bool>("verbose", false);
80 }

◆ finish()

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

Definition at line 45 of file SonicClientBase.cc.

References allowedTries_, evaluate(), holder_, reset(), summarizeEdmComparisonLogfiles::success, and tries_.

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

45  {
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 }
virtual void evaluate()=0
std::optional< edm::WaitingTaskWithArenaHolder > holder_
unsigned allowedTries_
virtual void reset()

◆ mode()

SonicMode SonicClientBase::mode ( void  ) const
inline

Definition at line 28 of file SonicClientBase.h.

References mode_.

Referenced by setMode().

28 { return mode_; }

◆ reset()

virtual void SonicClientBase::reset ( void  )
inlinevirtual

Reimplemented in TritonClient.

Definition at line 37 of file SonicClientBase.h.

Referenced by finish().

37 {}

◆ setMode()

void SonicClientBase::setMode ( SonicMode  mode)
protected

Definition at line 26 of file SonicClientBase.cc.

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

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

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 }
SonicMode mode() const
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
std::unique_ptr< SonicDispatcher > dispatcher_

◆ start() [1/2]

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

Definition at line 38 of file SonicClientBase.cc.

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

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

38  {
39  start();
40  holder_ = std::move(holder);
41 }
std::optional< edm::WaitingTaskWithArenaHolder > holder_
def move(src, dest)
Definition: eostools.py:511

◆ start() [2/2]

void SonicClientBase::start ( )
protected

Definition at line 43 of file SonicClientBase.cc.

References tries_.

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

43 { tries_ = 0; }

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 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

Definition at line 61 of file SonicClientBase.h.

Referenced by debugName(), and TritonClient::reportServerSideStats().

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

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

◆ tries_

unsigned SonicClientBase::tries_
protected

Definition at line 57 of file SonicClientBase.h.

Referenced by finish(), and start().

◆ verbose_

bool SonicClientBase::verbose_
protected

Definition at line 55 of file SonicClientBase.h.