OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
controller_timer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef __VNSW_CONTROLLER_CLEANUP_TIMER_HPP__
6 #define __VNSW_CONTROLLER_CLEANUP_TIMER_HPP__
7 
8 #include <sandesh/sandesh_trace.h>
9 #include <boost/scoped_ptr.hpp>
10 #include <boost/shared_ptr.hpp>
11 
12 class AgentXmppChannel;
13 
14 /*
15  * Controller Timer - abstract class.
16  * Used to manage timers required for removing stale entries for config and
17  * routes received from control nodes and end of config
18  * Functionalities provided are - start, cancel,
19  *
20  */
22  ControllerTimer(Agent *agent, const std::string &timer_name,
23  uint32_t timer_interval);
24  virtual ~ControllerTimer();
25 
26  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
27  virtual bool TimerExpirationDone() {return false;}
28  virtual uint32_t GetTimerInterval() const = 0;
29  virtual uint32_t timer_interval() {
30  return timer_interval_;
31  }
32  virtual void set_timer_interval(uint32_t timer_interval) {
34  }
35 
36  bool Cancel();
37  void Fire();
38  bool TimerExpiredCallback();
39  const std::string& timer_name() const {return timer_name_;}
40  bool running() const;
41 
43  // Timer
45  // Last time when timer was started
47  std::string xmpp_server_;
48  std::string timer_name_;
49  uint32_t timer_interval_;
50 };
51 
52 /*
53  * ConfigCleanupTimer
54  *
55  * Using the sequence number clean all stale configs(All config with lesser
56  * sequence number are deleted)
57  * Timer is started when end of config is determined.
58  * sequence_number_ - picked from agent ifmap xmpp channel.
59  */
61  ConfigCleanupTimer(Agent *agent);
62  virtual ~ConfigCleanupTimer() { }
63 
64  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
65  virtual uint32_t GetTimerInterval() const;
66  virtual bool TimerExpirationDone();
67 
68  uint64_t sequence_number_;
69 };
70 
71 /*
72  * EndOfConfigTimer
73  *
74  * On config channel becoming ready, this timer is started.
75  * Its determined by identifying inactivity(not receiving config) on config channel.
76  * Fallback time - If config is continuously being received or no config is
77  * sent, then there is a fallback for identifying end of config.
78  *
79  * On end of config start end of rib tx timer, walker to notify routes and
80  * config cleanup.
81  */
84  virtual ~EndOfConfigTimer() { }
85 
86  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
87  virtual uint32_t GetTimerInterval() const;
88  virtual bool TimerExpirationDone();
89 
90  uint32_t GetFallbackInterval() const;
91  uint32_t GetInactivityInterval() const;
92  void Reset();
93  void GresEnabled(bool enable);
94 
99  bool fallback_;
102 };
103 
104 /*
105  * EndOfRibTxTimer
106  *
107  * Started on identifying end of config.
108  * End of config starts a walk which will export routes. Each export is time
109  * stamped so that inactivity of route export can be determined. If there is no
110  * export seen for end-of-rib-tx time then end-of-rib-tx is concluded.
111  * Fallback is also present in case route updates never stop for some reason.
112  *
113  * At the end of rib walk EOR is sent to control node.
114  */
116  EndOfRibTxTimer(Agent *agent);
117  virtual ~EndOfRibTxTimer() { }
118 
119  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
120  virtual uint32_t GetTimerInterval() const;
121  virtual bool TimerExpirationDone();
122 
123  uint32_t GetFallbackInterval() const;
124  uint32_t GetInactivityInterval() const;
125  void Reset();
126  void GresEnabled(bool enable);
127 
131  bool fallback_;
133 };
134 
135 /*
136  * EndOfRibRxTimer
137  *
138  * This timer is used as fallback only.
139  * It observes for EOR from control node. In case it is not seen then on
140  * fallback assume that EOR is received. If EOR is received from CN then this
141  * timer is cancelled.
142  * On expiration stale walk to remove stale route paths for this parent peer.
143  */
145  EndOfRibRxTimer(Agent *agent);
146  virtual ~EndOfRibRxTimer() { }
147 
148  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
149  virtual uint32_t GetTimerInterval() const;
150  virtual bool TimerExpirationDone();
151  void Reset();
152  void GresEnabled(bool enable);
153 
157  bool fallback_;
158 };
159 
160 /*
161  * LlgrStaleTimer
162  *
163  * When CN is down and this timer expires then stales will be cleaned.
164  * It is the maximum time for which stale will be retained after CN is not
165  * ready. This timer has no meaning when CN is ready as end-of-rib rx timer is
166  * responsible for flushing out routes.
167  */
169  LlgrStaleTimer(Agent *agent);
170  virtual ~LlgrStaleTimer() { }
171 
172  virtual void Start(AgentXmppChannel *agent_xmpp_channel);
173  virtual uint32_t GetTimerInterval() const;
174  virtual bool TimerExpirationDone();
175  void Reset();
176  void GresEnabled(bool enable);
177 
180 };
181 #endif
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
ConfigCleanupTimer(Agent *agent)
virtual bool TimerExpirationDone()
EndOfRibTxTimer(Agent *agent)
virtual ~LlgrStaleTimer()
bool running() const
uint64_t end_of_rib_tx_time_
ControllerTimer(Agent *agent, const std::string &timer_name, uint32_t timer_interval)
virtual bool TimerExpirationDone()
uint64_t last_route_published_time_
void GresEnabled(bool enable)
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
uint32_t GetInactivityInterval() const
Timer * controller_timer_
virtual uint32_t GetTimerInterval() const =0
AgentIfMapXmppChannel * config_channel_
virtual ~EndOfRibTxTimer()
virtual uint32_t GetTimerInterval() const
virtual void set_timer_interval(uint32_t timer_interval)
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
uint64_t config_inactivity_time_
virtual ~EndOfConfigTimer()
void GresEnabled(bool enable)
virtual uint32_t timer_interval()
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
virtual ~ControllerTimer()
Definition: agent.h:358
uint64_t last_restart_time_
virtual uint32_t GetTimerInterval() const
void GresEnabled(bool enable)
virtual bool TimerExpirationDone()
AgentXmppChannel * agent_xmpp_channel_
uint64_t fallback_interval_
virtual ~ConfigCleanupTimer()
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
uint32_t GetFallbackInterval() const
std::string xmpp_server_
AgentXmppChannel * agent_xmpp_channel_
EndOfRibRxTimer(Agent *agent)
AgentXmppChannel * agent_xmpp_channel_
virtual void Start(AgentXmppChannel *agent_xmpp_channel)
virtual uint32_t GetTimerInterval() const
uint64_t inactivity_detected_time_
uint64_t end_of_config_processed_time_
virtual bool TimerExpirationDone()
virtual uint32_t GetTimerInterval() const
uint32_t GetInactivityInterval() const
EndOfConfigTimer(Agent *agent, AgentIfMapXmppChannel *channel)
std::string timer_name_
uint64_t end_of_rib_rx_time_
uint64_t llgr_stale_time_
const std::string & timer_name() const
uint64_t last_config_receive_time_
uint64_t end_of_rib_rx_fallback_time_
void GresEnabled(bool enable)
virtual bool TimerExpirationDone()
uint32_t timer_interval_
Definition: timer.h:54
uint32_t GetFallbackInterval() const
LlgrStaleTimer(Agent *agent)
virtual uint32_t GetTimerInterval() const
virtual ~EndOfRibRxTimer()
virtual bool TimerExpirationDone()
uint64_t fallback_interval_