CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RegistrationInfoBase.h
Go to the documentation of this file.
1 // $Id: RegistrationInfoBase.h,v 1.6.4.1 2011/03/07 11:33:04 mommsen Exp $
3 
4 #ifndef EventFilter_StorageManager_RegistrationInfoBase_h
5 #define EventFilter_StorageManager_RegistrationInfoBase_h
6 
7 #include <string>
8 
9 #include <boost/shared_ptr.hpp>
10 
17 
18 
19 namespace stor {
20 
21  class EventDistributor;
22 
33  {
34 
35  public:
36 
38  (
39  const std::string& consumerName,
40  const std::string& remoteHost,
41  const int& queueSize,
44  );
45 
47  (
48  const edm::ParameterSet& pset,
49  const std::string& remoteHost,
50  const EventServingParams& eventServingParams,
51  const bool useEventServingParams
52  );
53 
58  virtual ~RegistrationInfoBase() {};
59 
63  void consumerContact();
64 
69  void registerMe(EventDistributor* dist);
70 
74  void eventType(std::ostream&) const;
75 
79  edm::ParameterSet getPSet() const;
80 
84  void queueInfo(std::ostream&) const;
85 
86  // Setters:
88 
89  // Accessors
90  bool isValid() const { return consumerId_.isValid(); }
91  const QueueID& queueId() const { return queueId_; }
93  const std::string& consumerName() const { return consumerName_; }
94  const std::string& remoteHost() const { return remoteHost_; }
95  const std::string& sourceURL() const { return sourceURL_; }
96  const ConsumerID& consumerId() const { return consumerId_; }
97  const int& queueSize() const { return queueSize_; }
98  const int& maxConnectTries() const { return maxConnectTries_; }
99  const int& connectTrySleepTime() const { return connectTrySleepTime_; }
100  const int& retryInterval() const { return retryInterval_; }
103  bool isStale(const utils::TimePoint_t&) const;
104  double lastContactSecondsAgo(const utils::TimePoint_t&) const;
105 
106  // Setters
107  void setQueueId(const QueueID& id) { queueId_ = id; }
108  void setSourceURL(const std::string& url) { sourceURL_ = url; }
109  void setConsumerId(const ConsumerID& id) { consumerId_ = id; }
110 
111  // Comparison:
112  virtual bool operator<(const RegistrationInfoBase&) const;
113  virtual bool operator==(const RegistrationInfoBase&) const;
114  virtual bool operator!=(const RegistrationInfoBase&) const;
115 
116 
117  protected:
118 
119  virtual void do_registerMe(EventDistributor*) = 0;
120  virtual void do_eventType(std::ostream&) const = 0;
121  virtual void do_appendToPSet(edm::ParameterSet&) const = 0;
122 
123 
124  private:
125 
126  const std::string remoteHost_;
127  std::string consumerName_;
128  std::string sourceURL_;
139  };
140 
141  typedef boost::shared_ptr<RegistrationInfoBase> RegPtr;
142 
143 
144  inline
146  {
148  }
149 
150  inline
152  {
153  do_registerMe(dist);
154  }
155 
156  inline
157  void RegistrationInfoBase::eventType(std::ostream& os) const
158  {
159  do_eventType(os);
160  }
161 
162  inline
164  {
165  return ( now > lastConsumerContact_ + secondsToStale() );
166  }
167 
168  inline
170  {
172  }
173 
174  std::ostream& operator<<(std::ostream& os,
175  RegistrationInfoBase const& ri);
176 
177 } // namespace stor
178 
179 #endif // EventFilter_StorageManager_RegistrationInfoBase_h
180 
181 
TimePoint_t getCurrentTime()
Definition: Utils.h:158
virtual void do_registerMe(EventDistributor *)=0
const QueueID & queueId() const
boost::shared_ptr< RegistrationInfoBase > RegPtr
const std::string & consumerName() const
const utils::Duration_t & minEventRequestInterval() const
tuple interval
Definition: MergeJob_cfg.py:20
utils::Duration_t minEventRequestInterval_
virtual void do_appendToPSet(edm::ParameterSet &) const =0
virtual bool operator!=(const RegistrationInfoBase &) const
edm::ParameterSet getPSet() const
virtual void do_eventType(std::ostream &) const =0
const std::string & sourceURL() const
void queueInfo(std::ostream &) const
void setSourceURL(const std::string &url)
virtual bool operator==(const RegistrationInfoBase &) const
utils::TimePoint_t lastConsumerContact_
const int & maxConnectTries() const
boost::posix_time::time_duration Duration_t
Definition: Utils.h:41
RegistrationInfoBase(const std::string &consumerName, const std::string &remoteHost, const int &queueSize, const enquing_policy::PolicyTag &queuePolicy, const utils::Duration_t &secondsToStale)
void setMinEventRequestInterval(const utils::Duration_t &interval)
std::ostream & operator<<(std::ostream &os, ConsumerID id)
Definition: ConsumerID.h:69
const int & queueSize() const
void eventType(std::ostream &) const
const int & retryInterval() const
boost::posix_time::ptime TimePoint_t
Definition: Utils.h:35
void registerMe(EventDistributor *dist)
tuple pset
Definition: CrabTask.py:85
void setConsumerId(const ConsumerID &id)
bool isStale(const utils::TimePoint_t &) const
const int & connectTrySleepTime() const
const std::string & remoteHost() const
const enquing_policy::PolicyTag & queuePolicy() const
enquing_policy::PolicyTag queuePolicy_
const utils::Duration_t & secondsToStale() const
double durationToSeconds(Duration_t const &)
Definition: Utils.h:147
virtual bool operator<(const RegistrationInfoBase &) const
void setQueueId(const QueueID &id)
double lastContactSecondsAgo(const utils::TimePoint_t &) const
const ConsumerID & consumerId() const
bool isValid() const
Definition: ConsumerID.h:34