CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Attributes

stor::RegistrationInfoBase Class Reference

#include <RegistrationInfoBase.h>

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

List of all members.

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 edm::ParameterSet &pset, const std::string &remoteHost, const EventServingParams &eventServingParams, const bool useEventServingParams)
 RegistrationInfoBase (const std::string &consumerName, const std::string &remoteHost, const int &queueSize, const enquing_policy::PolicyTag &queuePolicy, const utils::Duration_t &secondsToStale)
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 
)
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, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), stor::enquing_policy::Max, reco_skim_cfg_mod::maxEventRequestRate, evf::utils::policy, seconds(), and stor::utils::secondsToDuration().

    :
  remoteHost_(remoteHost),
  consumerId_(0),
  lastConsumerContact_(utils::getCurrentTime())
  {
    try
    {
      consumerName_ = pset.getUntrackedParameter<std::string>("consumerName");
    }
    catch( edm::Exception& e )
    {
      consumerName_ = pset.getUntrackedParameter<std::string>("DQMconsumerName", "Unknown");
    }

    try
    {
      sourceURL_ = pset.getParameter<std::string>("sourceURL");
    }
    catch( edm::Exception& e )
    {
      sourceURL_ = pset.getUntrackedParameter<std::string>("sourceURL", "Unknown");
    }

    const double maxEventRequestRate = pset.getUntrackedParameter<double>("maxEventRequestRate", 0);
    if ( maxEventRequestRate > 0 )
      minEventRequestInterval_ = utils::secondsToDuration(1 / maxEventRequestRate);
    else
      minEventRequestInterval_ = boost::posix_time::not_a_date_time;

    maxConnectTries_ = pset.getUntrackedParameter<int>("maxConnectTries", 300);

    connectTrySleepTime_ = pset.getUntrackedParameter<int>("connectTrySleepTime", 10);

    retryInterval_ = pset.getUntrackedParameter<int>("retryInterval", 5);

    queueSize_ = pset.getUntrackedParameter<int>("queueSize",
      useEventServingParams ? eventServingParams.consumerQueueSize_ : 0);

    const std::string policy =
      pset.getUntrackedParameter<std::string>("queuePolicy",
        useEventServingParams ? eventServingParams.consumerQueuePolicy_ : "Default");
    if ( policy == "DiscardNew" )
    {
      queuePolicy_ = enquing_policy::DiscardNew;
    }
    else if ( policy == "DiscardOld" )
    {
      queuePolicy_ = enquing_policy::DiscardOld;
    }
    else if ( policy == "Default" )
    {
      queuePolicy_ = enquing_policy::Max;
    }
    else
    {
      XCEPT_RAISE( stor::exception::ConsumerRegistration,
        "Unknown enqueuing policy: " + policy );
    }

    secondsToStale_ = utils::secondsToDuration(
      pset.getUntrackedParameter<double>("consumerTimeOut", 0)
    );
    if ( useEventServingParams && secondsToStale_ < boost::posix_time::seconds(1) )
      secondsToStale_ = eventServingParams.activeConsumerTimeout_;
  }
virtual stor::RegistrationInfoBase::~RegistrationInfoBase ( ) [inline, virtual]

The virtual destructor allows polymorphic containment-by-reference.

Definition at line 58 of file RegistrationInfoBase.h.

{};

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

const ConsumerID& stor::RegistrationInfoBase::consumerId ( ) const [inline]

Definition at line 96 of file RegistrationInfoBase.h.

References consumerId_.

Referenced by stor::operator<<().

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

Definition at line 93 of file RegistrationInfoBase.h.

References consumerName_.

Referenced by stor::operator<<().

{ return consumerName_; }
virtual void stor::RegistrationInfoBase::do_appendToPSet ( edm::ParameterSet ) const [protected, pure virtual]
virtual void stor::RegistrationInfoBase::do_eventType ( std::ostream &  ) const [protected, pure virtual]
virtual void stor::RegistrationInfoBase::do_registerMe ( EventDistributor ) [protected, pure 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().

  {
    do_eventType(os);
  }
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_, MultipleCompare::pset, queuePolicy_, queueSize_, retryInterval_, secondsToStale(), secondsToStale_, and sourceURL_.

  {
    edm::ParameterSet pset;

    if ( consumerName_ != "Unknown" )
      pset.addUntrackedParameter<std::string>("consumerName", consumerName_);

    if ( sourceURL_  != "Unknown" )
      pset.addParameter<std::string>("sourceURL", sourceURL_);

    if ( maxConnectTries_ != 300 )
      pset.addUntrackedParameter<int>("maxConnectTries", maxConnectTries_);
    
    if ( connectTrySleepTime_ != 10 )
      pset.addUntrackedParameter<int>("connectTrySleepTime", connectTrySleepTime_);

    if ( retryInterval_ != 5 )
      pset.addUntrackedParameter<int>("retryInterval", retryInterval_);
    
    if ( queueSize_ > 0 )
      pset.addUntrackedParameter<int>("queueSize", queueSize_);
    
    if ( ! minEventRequestInterval_.is_not_a_date_time() )
    {
      const double rate = 1 / utils::durationToSeconds(minEventRequestInterval_);
      pset.addUntrackedParameter<double>("maxEventRequestRate", rate);
    }

    const double secondsToStale = utils::durationToSeconds(secondsToStale_);
    if ( secondsToStale > 0 )
      pset.addUntrackedParameter<double>("consumerTimeOut", secondsToStale);

    if ( queuePolicy_ == enquing_policy::DiscardNew )
      pset.addUntrackedParameter<std::string>("queuePolicy", "DiscardNew");
    if ( queuePolicy_ == enquing_policy::DiscardOld )
      pset.addUntrackedParameter<std::string>("queuePolicy", "DiscardOld");

    do_appendToPSet(pset);

    return pset;
  }
bool stor::RegistrationInfoBase::isStale ( const utils::TimePoint_t now) const [inline]

Definition at line 163 of file RegistrationInfoBase.h.

References lastConsumerContact_, and secondsToStale().

  {
    return ( now > lastConsumerContact_ + secondsToStale() );
  }
bool stor::RegistrationInfoBase::isValid ( void  ) const [inline]

Definition at line 90 of file RegistrationInfoBase.h.

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

{ return consumerId_.isValid(); }
double stor::RegistrationInfoBase::lastContactSecondsAgo ( const utils::TimePoint_t now) const [inline]
const int& stor::RegistrationInfoBase::maxConnectTries ( ) const [inline]

Definition at line 98 of file RegistrationInfoBase.h.

References maxConnectTries_.

{ return maxConnectTries_; }
const utils::Duration_t& stor::RegistrationInfoBase::minEventRequestInterval ( ) const [inline]

Definition at line 101 of file RegistrationInfoBase.h.

References minEventRequestInterval_.

bool stor::RegistrationInfoBase::operator!= ( const RegistrationInfoBase other) const [virtual]

Definition at line 161 of file RegistrationInfoBase.cc.

  {
    return ! ( *this == other );
  }
bool stor::RegistrationInfoBase::operator< ( const RegistrationInfoBase other) const [virtual]

Definition at line 143 of file RegistrationInfoBase.cc.

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

  {
    if ( queueSize() != other.queueSize() )
      return ( queueSize() < other.queueSize() );
    if ( queuePolicy() != other.queuePolicy() )
      return ( queuePolicy() < other.queuePolicy() );
    return ( secondsToStale() < other.secondsToStale() );
  }
bool stor::RegistrationInfoBase::operator== ( const RegistrationInfoBase other) const [virtual]

Definition at line 152 of file RegistrationInfoBase.cc.

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

  {
    return (
      queueSize() == other.queueSize() &&
      queuePolicy() == other.queuePolicy() &&
      secondsToStale() == other.secondsToStale()
    );
  }
const QueueID& stor::RegistrationInfoBase::queueId ( ) const [inline]

Definition at line 91 of file RegistrationInfoBase.h.

References queueId_.

Referenced by stor::operator<<().

{ 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::EventConsumerRegistrationInfo::do_eventType(), and stor::DQMEventConsumerRegistrationInfo::do_eventType().

  {
    os << "Queue type: " << queuePolicy_ <<
      ", size " << queueSize_ << 
      ", timeout " << secondsToStale_.total_seconds() << "s";
  }
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==().

{ return 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==().

{ return queueSize_; }
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().

  {
    do_registerMe(dist);
  }
const std::string& stor::RegistrationInfoBase::remoteHost ( ) const [inline]

Definition at line 94 of file RegistrationInfoBase.h.

References remoteHost_.

Referenced by stor::operator<<().

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

Definition at line 100 of file RegistrationInfoBase.h.

References retryInterval_.

{ return 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==().

{ return secondsToStale_; }
void stor::RegistrationInfoBase::setConsumerId ( const ConsumerID id) [inline]

Definition at line 109 of file RegistrationInfoBase.h.

References consumerId_.

{ consumerId_ = id; }
void stor::RegistrationInfoBase::setMinEventRequestInterval ( const utils::Duration_t interval) [inline]
void stor::RegistrationInfoBase::setQueueId ( const QueueID id) [inline]

Definition at line 107 of file RegistrationInfoBase.h.

References queueId_.

{ queueId_ = id; }
void stor::RegistrationInfoBase::setSourceURL ( const std::string &  url) [inline]

Definition at line 108 of file RegistrationInfoBase.h.

References sourceURL_.

{ sourceURL_ = url; }
const std::string& stor::RegistrationInfoBase::sourceURL ( ) const [inline]

Member Data Documentation

Definition at line 133 of file RegistrationInfoBase.h.

Referenced by connectTrySleepTime(), and getPSet().

Definition at line 137 of file RegistrationInfoBase.h.

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

Definition at line 127 of file RegistrationInfoBase.h.

Referenced by consumerName(), and getPSet().

Definition at line 138 of file RegistrationInfoBase.h.

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

Definition at line 132 of file RegistrationInfoBase.h.

Referenced by getPSet(), and maxConnectTries().

Definition at line 136 of file RegistrationInfoBase.h.

Referenced by queueId(), and setQueueId().

Definition at line 130 of file RegistrationInfoBase.h.

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

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().

Definition at line 134 of file RegistrationInfoBase.h.

Referenced by getPSet(), and retryInterval().

Definition at line 131 of file RegistrationInfoBase.h.

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

Definition at line 128 of file RegistrationInfoBase.h.

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