CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
stor::RegistrationInfoBase Class Referenceabstract

#include <RegistrationInfoBase.h>

Inheritance diagram for stor::RegistrationInfoBase:
stor::DQMEventConsumerRegistrationInfo stor::EventConsumerRegistrationInfo

Public Member Functions

const int & connectTrySleepTime () const
 
void consumerContact ()
 
const ConsumerIDconsumerId () const
 
const std::string & consumerName () const
 
void eventType (std::ostream &) const
 
edm::ParameterSet getPSet () const
 
bool isStale (const utils::TimePoint_t &) const
 
bool isValid () const
 
double lastContactSecondsAgo (const utils::TimePoint_t &) const
 
const int & maxConnectTries () const
 
const utils::Duration_tminEventRequestInterval () const
 
virtual bool operator!= (const RegistrationInfoBase &) const
 
virtual bool operator< (const RegistrationInfoBase &) const
 
virtual bool operator== (const RegistrationInfoBase &) const
 
const QueueIDqueueId () const
 
void queueInfo (std::ostream &) const
 
const enquing_policy::PolicyTagqueuePolicy () const
 
const int & queueSize () const
 
void registerMe (EventDistributor *dist)
 
 RegistrationInfoBase (const std::string &consumerName, const std::string &remoteHost, const int &queueSize, const enquing_policy::PolicyTag &queuePolicy, const utils::Duration_t &secondsToStale)
 
 RegistrationInfoBase (const edm::ParameterSet &pset, const std::string &remoteHost, const EventServingParams &eventServingParams, const bool useEventServingParams)
 
const std::string & remoteHost () const
 
const int & retryInterval () const
 
const utils::Duration_tsecondsToStale () const
 
void setConsumerId (const ConsumerID &id)
 
void setMinEventRequestInterval (const utils::Duration_t &interval)
 
void setQueueId (const QueueID &id)
 
void setSourceURL (const std::string &url)
 
const std::string & sourceURL () const
 
virtual ~RegistrationInfoBase ()
 

Protected Member Functions

virtual void do_appendToPSet (edm::ParameterSet &) const =0
 
virtual void do_eventType (std::ostream &) const =0
 
virtual void do_registerMe (EventDistributor *)=0
 

Private Attributes

int connectTrySleepTime_
 
ConsumerID consumerId_
 
std::string consumerName_
 
utils::TimePoint_t lastConsumerContact_
 
int maxConnectTries_
 
utils::Duration_t minEventRequestInterval_
 
QueueID queueId_
 
enquing_policy::PolicyTag queuePolicy_
 
int queueSize_
 
const std::string remoteHost_
 
int retryInterval_
 
utils::Duration_t secondsToStale_
 
std::string sourceURL_
 

Detailed Description

Defines the common interface for event and DQM consumer registration info objects.

Author:
mommsen
Revision:
1.7
Date:
2011/03/07 15:31:32

Definition at line 32 of file RegistrationInfoBase.h.

Constructor & Destructor Documentation

stor::RegistrationInfoBase::RegistrationInfoBase ( const std::string &  consumerName,
const std::string &  remoteHost,
const int &  queueSize,
const enquing_policy::PolicyTag queuePolicy,
const utils::Duration_t secondsToStale 
)

Definition at line 13 of file RegistrationInfoBase.cc.

19  :
25  consumerId_(0),
27  { }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
const std::string & consumerName() const
utils::TimePoint_t lastConsumerContact_
const int & queueSize() const
const std::string & remoteHost() const
const enquing_policy::PolicyTag & queuePolicy() const
enquing_policy::PolicyTag queuePolicy_
const utils::Duration_t & secondsToStale() const
stor::RegistrationInfoBase::RegistrationInfoBase ( const edm::ParameterSet pset,
const std::string &  remoteHost,
const EventServingParams eventServingParams,
const bool  useEventServingParams 
)

Definition at line 30 of file RegistrationInfoBase.cc.

References stor::EventServingParams::activeConsumerTimeout_, stor::EventServingParams::consumerQueuePolicy_, stor::EventServingParams::consumerQueueSize_, stor::enquing_policy::DiscardNew, stor::enquing_policy::DiscardOld, alignCSCRings::e, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), stor::enquing_policy::Max, reco_skim_cfg_mod::maxEventRequestRate, evf::utils::policy, seconds(), and stor::utils::secondsToDuration().

35  :
37  consumerId_(0),
39  {
40  try
41  {
42  consumerName_ = pset.getUntrackedParameter<std::string>("consumerName");
43  }
44  catch( edm::Exception& e )
45  {
46  consumerName_ = pset.getUntrackedParameter<std::string>("DQMconsumerName", "Unknown");
47  }
48 
49  try
50  {
51  sourceURL_ = pset.getParameter<std::string>("sourceURL");
52  }
53  catch( edm::Exception& e )
54  {
55  sourceURL_ = pset.getUntrackedParameter<std::string>("sourceURL", "Unknown");
56  }
57 
58  const double maxEventRequestRate = pset.getUntrackedParameter<double>("maxEventRequestRate", 0);
59  if ( maxEventRequestRate > 0 )
60  minEventRequestInterval_ = utils::secondsToDuration(1 / maxEventRequestRate);
61  else
62  minEventRequestInterval_ = boost::posix_time::not_a_date_time;
63 
64  maxConnectTries_ = pset.getUntrackedParameter<int>("maxConnectTries", 300);
65 
66  connectTrySleepTime_ = pset.getUntrackedParameter<int>("connectTrySleepTime", 10);
67 
68  retryInterval_ = pset.getUntrackedParameter<int>("retryInterval", 5);
69 
70  queueSize_ = pset.getUntrackedParameter<int>("queueSize",
71  useEventServingParams ? eventServingParams.consumerQueueSize_ : 0);
72 
73  const std::string policy =
74  pset.getUntrackedParameter<std::string>("queuePolicy",
75  useEventServingParams ? eventServingParams.consumerQueuePolicy_ : "Default");
76  if ( policy == "DiscardNew" )
77  {
79  }
80  else if ( policy == "DiscardOld" )
81  {
83  }
84  else if ( policy == "Default" )
85  {
87  }
88  else
89  {
90  XCEPT_RAISE( stor::exception::ConsumerRegistration,
91  "Unknown enqueuing policy: " + policy );
92  }
93 
95  pset.getUntrackedParameter<double>("consumerTimeOut", 0)
96  );
97  if ( useEventServingParams && secondsToStale_ < boost::posix_time::seconds(1) )
98  secondsToStale_ = eventServingParams.activeConsumerTimeout_;
99  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
double seconds()
Duration_t secondsToDuration(double const &seconds)
Definition: Utils.h:140
utils::Duration_t minEventRequestInterval_
utils::TimePoint_t lastConsumerContact_
const std::string & remoteHost() const
enquing_policy::PolicyTag queuePolicy_
virtual stor::RegistrationInfoBase::~RegistrationInfoBase ( )
inlinevirtual

The virtual destructor allows polymorphic containment-by-reference.

Definition at line 58 of file RegistrationInfoBase.h.

58 {};

Member Function Documentation

const int& stor::RegistrationInfoBase::connectTrySleepTime ( ) const
inline

Definition at line 99 of file RegistrationInfoBase.h.

References connectTrySleepTime_.

void stor::RegistrationInfoBase::consumerContact ( )
inline

Mark time when consumer last contacted us

Definition at line 145 of file RegistrationInfoBase.h.

References stor::utils::getCurrentTime(), and lastConsumerContact_.

146  {
148  }
TimePoint_t getCurrentTime()
Definition: Utils.h:158
utils::TimePoint_t lastConsumerContact_
const ConsumerID& stor::RegistrationInfoBase::consumerId ( ) const
inline

Definition at line 96 of file RegistrationInfoBase.h.

References consumerId_.

Referenced by stor::operator<<().

96 { return consumerId_; }
const std::string& stor::RegistrationInfoBase::consumerName ( ) const
inline

Definition at line 93 of file RegistrationInfoBase.h.

References consumerName_.

Referenced by stor::operator<<().

93 { return consumerName_; }
virtual void stor::RegistrationInfoBase::do_appendToPSet ( edm::ParameterSet ) const
protectedpure virtual
virtual void stor::RegistrationInfoBase::do_eventType ( std::ostream &  ) const
protectedpure virtual
virtual void stor::RegistrationInfoBase::do_registerMe ( EventDistributor )
protectedpure virtual
void stor::RegistrationInfoBase::eventType ( std::ostream &  os) const
inline

Returns a formatted string which contains the information about the event type.

Definition at line 157 of file RegistrationInfoBase.h.

References do_eventType().

158  {
159  do_eventType(os);
160  }
virtual void do_eventType(std::ostream &) const =0
edm::ParameterSet stor::RegistrationInfoBase::getPSet ( ) const

Return the ParameterSet containing the consumer registration infos

Definition at line 101 of file RegistrationInfoBase.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), connectTrySleepTime_, consumerName_, stor::enquing_policy::DiscardNew, stor::enquing_policy::DiscardOld, do_appendToPSet(), stor::utils::durationToSeconds(), maxConnectTries_, minEventRequestInterval_, queuePolicy_, queueSize_, scaleCards::rate, retryInterval_, secondsToStale(), secondsToStale_, and sourceURL_.

102  {
103  edm::ParameterSet pset;
104 
105  if ( consumerName_ != "Unknown" )
106  pset.addUntrackedParameter<std::string>("consumerName", consumerName_);
107 
108  if ( sourceURL_ != "Unknown" )
109  pset.addParameter<std::string>("sourceURL", sourceURL_);
110 
111  if ( maxConnectTries_ != 300 )
112  pset.addUntrackedParameter<int>("maxConnectTries", maxConnectTries_);
113 
114  if ( connectTrySleepTime_ != 10 )
115  pset.addUntrackedParameter<int>("connectTrySleepTime", connectTrySleepTime_);
116 
117  if ( retryInterval_ != 5 )
118  pset.addUntrackedParameter<int>("retryInterval", retryInterval_);
119 
120  if ( queueSize_ > 0 )
121  pset.addUntrackedParameter<int>("queueSize", queueSize_);
122 
123  if ( ! minEventRequestInterval_.is_not_a_date_time() )
124  {
126  pset.addUntrackedParameter<double>("maxEventRequestRate", rate);
127  }
128 
130  if ( secondsToStale > 0 )
131  pset.addUntrackedParameter<double>("consumerTimeOut", secondsToStale);
132 
134  pset.addUntrackedParameter<std::string>("queuePolicy", "DiscardNew");
136  pset.addUntrackedParameter<std::string>("queuePolicy", "DiscardOld");
137 
138  do_appendToPSet(pset);
139 
140  return pset;
141  }
utils::Duration_t minEventRequestInterval_
virtual void do_appendToPSet(edm::ParameterSet &) const =0
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:145
list rate
Definition: scaleCards.py:77
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:209
enquing_policy::PolicyTag queuePolicy_
const utils::Duration_t & secondsToStale() const
double durationToSeconds(Duration_t const &)
Definition: Utils.h:147
bool stor::RegistrationInfoBase::isStale ( const utils::TimePoint_t now) const
inline

Definition at line 163 of file RegistrationInfoBase.h.

References lastConsumerContact_, and secondsToStale().

164  {
165  return ( now > lastConsumerContact_ + secondsToStale() );
166  }
utils::TimePoint_t lastConsumerContact_
const utils::Duration_t & secondsToStale() const
bool stor::RegistrationInfoBase::isValid ( void  ) const
inline

Definition at line 90 of file RegistrationInfoBase.h.

References consumerId_, and stor::ConsumerID::isValid().

90 { return consumerId_.isValid(); }
bool isValid() const
Definition: ConsumerID.h:34
double stor::RegistrationInfoBase::lastContactSecondsAgo ( const utils::TimePoint_t now) const
inline

Definition at line 169 of file RegistrationInfoBase.h.

References stor::utils::durationToSeconds(), and lastConsumerContact_.

170  {
172  }
utils::TimePoint_t lastConsumerContact_
double durationToSeconds(Duration_t const &)
Definition: Utils.h:147
const int& stor::RegistrationInfoBase::maxConnectTries ( ) const
inline

Definition at line 98 of file RegistrationInfoBase.h.

References maxConnectTries_.

const utils::Duration_t& stor::RegistrationInfoBase::minEventRequestInterval ( ) const
inline

Definition at line 101 of file RegistrationInfoBase.h.

References minEventRequestInterval_.

101 { return minEventRequestInterval_; }
utils::Duration_t minEventRequestInterval_
bool stor::RegistrationInfoBase::operator!= ( const RegistrationInfoBase other) const
virtual

Definition at line 161 of file RegistrationInfoBase.cc.

162  {
163  return ! ( *this == other );
164  }
bool stor::RegistrationInfoBase::operator< ( const RegistrationInfoBase other) const
virtual

Definition at line 143 of file RegistrationInfoBase.cc.

References queuePolicy(), queueSize(), and secondsToStale().

Referenced by stor::DQMEventConsumerRegistrationInfo::operator<(), and stor::EventConsumerRegistrationInfo::operator<().

144  {
145  if ( queueSize() != other.queueSize() )
146  return ( queueSize() < other.queueSize() );
147  if ( queuePolicy() != other.queuePolicy() )
148  return ( queuePolicy() < other.queuePolicy() );
149  return ( secondsToStale() < other.secondsToStale() );
150  }
const int & queueSize() const
const enquing_policy::PolicyTag & queuePolicy() const
const utils::Duration_t & secondsToStale() const
bool stor::RegistrationInfoBase::operator== ( const RegistrationInfoBase other) const
virtual

Definition at line 152 of file RegistrationInfoBase.cc.

References queuePolicy(), queueSize(), and secondsToStale().

Referenced by stor::DQMEventConsumerRegistrationInfo::operator==(), and stor::EventConsumerRegistrationInfo::operator==().

153  {
154  return (
155  queueSize() == other.queueSize() &&
156  queuePolicy() == other.queuePolicy() &&
157  secondsToStale() == other.secondsToStale()
158  );
159  }
const int & queueSize() const
const enquing_policy::PolicyTag & queuePolicy() const
const utils::Duration_t & secondsToStale() const
const QueueID& stor::RegistrationInfoBase::queueId ( ) const
inline

Definition at line 91 of file RegistrationInfoBase.h.

References queueId_.

Referenced by stor::operator<<().

91 { return queueId_; }
void stor::RegistrationInfoBase::queueInfo ( std::ostream &  os) const

Print queue information into ostream

Definition at line 166 of file RegistrationInfoBase.cc.

References queuePolicy_, queueSize_, and secondsToStale_.

Referenced by stor::DQMEventConsumerRegistrationInfo::do_eventType(), and stor::EventConsumerRegistrationInfo::do_eventType().

167  {
168  os << "Queue type: " << queuePolicy_ <<
169  ", size " << queueSize_ <<
170  ", timeout " << secondsToStale_.total_seconds() << "s";
171  }
enquing_policy::PolicyTag queuePolicy_
const enquing_policy::PolicyTag& stor::RegistrationInfoBase::queuePolicy ( ) const
inline

Definition at line 92 of file RegistrationInfoBase.h.

References queuePolicy_.

Referenced by operator<(), stor::operator<<(), and operator==().

92 { return queuePolicy_; }
enquing_policy::PolicyTag queuePolicy_
const int& stor::RegistrationInfoBase::queueSize ( ) const
inline

Definition at line 97 of file RegistrationInfoBase.h.

References queueSize_.

Referenced by operator<(), stor::operator<<(), and operator==().

void stor::RegistrationInfoBase::registerMe ( EventDistributor dist)
inline

Register the consumer represented by this registration with the specified EventDistributor.

Definition at line 151 of file RegistrationInfoBase.h.

References do_registerMe().

152  {
153  do_registerMe(dist);
154  }
virtual void do_registerMe(EventDistributor *)=0
const std::string& stor::RegistrationInfoBase::remoteHost ( ) const
inline

Definition at line 94 of file RegistrationInfoBase.h.

References remoteHost_.

Referenced by stor::operator<<().

94 { return remoteHost_; }
const int& stor::RegistrationInfoBase::retryInterval ( ) const
inline

Definition at line 100 of file RegistrationInfoBase.h.

References retryInterval_.

const utils::Duration_t& stor::RegistrationInfoBase::secondsToStale ( ) const
inline

Definition at line 102 of file RegistrationInfoBase.h.

References secondsToStale_.

Referenced by getPSet(), isStale(), operator<(), stor::operator<<(), and operator==().

102 { return secondsToStale_; }
void stor::RegistrationInfoBase::setConsumerId ( const ConsumerID id)
inline
void stor::RegistrationInfoBase::setMinEventRequestInterval ( const utils::Duration_t interval)
inline
void stor::RegistrationInfoBase::setQueueId ( const QueueID id)
inline
void stor::RegistrationInfoBase::setSourceURL ( const std::string &  url)
inline
const std::string& stor::RegistrationInfoBase::sourceURL ( ) const
inline

Member Data Documentation

int stor::RegistrationInfoBase::connectTrySleepTime_
private

Definition at line 133 of file RegistrationInfoBase.h.

Referenced by connectTrySleepTime(), and getPSet().

ConsumerID stor::RegistrationInfoBase::consumerId_
private

Definition at line 137 of file RegistrationInfoBase.h.

Referenced by consumerId(), isValid(), and setConsumerId().

std::string stor::RegistrationInfoBase::consumerName_
private

Definition at line 127 of file RegistrationInfoBase.h.

Referenced by consumerName(), and getPSet().

utils::TimePoint_t stor::RegistrationInfoBase::lastConsumerContact_
private

Definition at line 138 of file RegistrationInfoBase.h.

Referenced by consumerContact(), isStale(), and lastContactSecondsAgo().

int stor::RegistrationInfoBase::maxConnectTries_
private

Definition at line 132 of file RegistrationInfoBase.h.

Referenced by getPSet(), and maxConnectTries().

utils::Duration_t stor::RegistrationInfoBase::minEventRequestInterval_
private
QueueID stor::RegistrationInfoBase::queueId_
private

Definition at line 136 of file RegistrationInfoBase.h.

Referenced by queueId(), and setQueueId().

enquing_policy::PolicyTag stor::RegistrationInfoBase::queuePolicy_
private

Definition at line 130 of file RegistrationInfoBase.h.

Referenced by getPSet(), queueInfo(), and queuePolicy().

int stor::RegistrationInfoBase::queueSize_
private

Definition at line 129 of file RegistrationInfoBase.h.

Referenced by getPSet(), queueInfo(), and queueSize().

const std::string stor::RegistrationInfoBase::remoteHost_
private

Definition at line 126 of file RegistrationInfoBase.h.

Referenced by remoteHost().

int stor::RegistrationInfoBase::retryInterval_
private

Definition at line 134 of file RegistrationInfoBase.h.

Referenced by getPSet(), and retryInterval().

utils::Duration_t stor::RegistrationInfoBase::secondsToStale_
private

Definition at line 131 of file RegistrationInfoBase.h.

Referenced by getPSet(), queueInfo(), and secondsToStale().

std::string stor::RegistrationInfoBase::sourceURL_
private

Definition at line 128 of file RegistrationInfoBase.h.

Referenced by getPSet(), setSourceURL(), and sourceURL().