OpenSDN source code
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ovsdb_client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_H_
6 #define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_H_
7 
8 class TorAgentParam;
9 class SandeshOvsdbClient;
10 
11 class OvsPeerManager;
12 class KSyncObjectManager;
13 
14 namespace OVSDB {
15 class OvsdbClientSession;
16 class ConnectionStateTable;
17 class OvsdbClient {
18 public:
19  typedef boost::function<void (OvsdbClientSession *)> SessionEventCb;
20 
21  static const uint32_t OVSDBKeepAliveTimer = 10000; // in millisecond
22 
23  // minimum value of keep alive interval
24  static const int OVSDBMinKeepAliveTimer = 2000; // in millisecond
25 
26  static const uint32_t OVSDBHaStaleRouteTimer = 300000; // in millisecond
27 
28  // minimum value of keep alive interval
29  static const int OVSDBMinHaStaleRouteTimer = 60000; // in millisecond
30 
33  virtual ~OvsdbClient();
34  virtual void RegisterClients() = 0;
35  virtual const std::string protocol() = 0;
36  virtual const std::string server() = 0;
37  virtual uint16_t port() = 0;
38  virtual Ip4Address tsn_ip() = 0;
39 
40  // API to find session given ip and port, if port is zero
41  // it should give the next available session for the ip
42  virtual OvsdbClientSession *FindSession(Ip4Address ip, uint16_t port) = 0;
43 
44  // API to get the next session, return first session if
45  // argument provided is NULL
46  virtual OvsdbClientSession *NextSession(OvsdbClientSession *session) = 0;
47  virtual void AddSessionInfo(SandeshOvsdbClient &client) = 0;
48  virtual void shutdown() = 0;
49 
50  // fucntions to be used by UT for event generations
53 
54  void RegisterConnectionTable(Agent *agent);
57  int keepalive_interval() const;
58  int ha_stale_route_interval() const;
59  void Init();
60  static OvsdbClient* Allocate(Agent *agent, TorAgentParam *params,
61  OvsPeerManager *manager);
62 
63 protected:
65 
68 
69 private:
70  boost::scoped_ptr<ConnectionStateTable> connection_table_;
75 };
76 };
77 
78 #endif //SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_OVSDB_CLIENT_H_
int ha_stale_route_interval() const
Definition: ovsdb_client.cc:62
virtual ~OvsdbClient()
Definition: ovsdb_client.cc:25
void RegisterConnectionTable(Agent *agent)
Definition: ovsdb_client.cc:36
virtual Ip4Address tsn_ip()=0
static const int OVSDBMinHaStaleRouteTimer
Definition: ovsdb_client.h:29
static const uint32_t OVSDBKeepAliveTimer
Definition: ovsdb_client.h:21
static const int OVSDBMinKeepAliveTimer
Definition: ovsdb_client.h:24
virtual void AddSessionInfo(SandeshOvsdbClient &client)=0
static OvsdbClient * Allocate(Agent *agent, TorAgentParam *params, OvsPeerManager *manager)
Definition: ovsdb_client.cc:78
virtual void shutdown()=0
OvsdbClient(OvsPeerManager *manager, int keepalive_interval, int ha_stale_route_interval)
Definition: ovsdb_client.cc:18
Definition: agent.h:358
KSyncObjectManager * ksync_obj_manager_
Definition: ovsdb_client.h:71
int keepalive_interval() const
Definition: ovsdb_client.cc:48
boost::scoped_ptr< ConnectionStateTable > connection_table_
Definition: ovsdb_client.h:70
virtual OvsdbClientSession * FindSession(Ip4Address ip, uint16_t port)=0
boost::asio::ip::address_v4 Ip4Address
Definition: address.h:14
virtual const std::string protocol()=0
ConnectionStateTable * connection_table()
Definition: ovsdb_client.cc:40
boost::function< void(OvsdbClientSession *)> SessionEventCb
Definition: ovsdb_client.h:19
virtual uint16_t port()=0
void set_connect_complete_cb(SessionEventCb cb)
Definition: ovsdb_client.cc:28
virtual const std::string server()=0
SessionEventCb connect_complete_cb_
Definition: ovsdb_client.h:66
SessionEventCb pre_connect_complete_cb_
Definition: ovsdb_client.h:67
void set_pre_connect_complete_cb(SessionEventCb cb)
Definition: ovsdb_client.cc:32
OvsPeerManager * peer_manager_
Definition: ovsdb_client.h:64
KSyncObjectManager * ksync_obj_manager()
Definition: ovsdb_client.cc:44
virtual void RegisterClients()=0
static const uint32_t OVSDBHaStaleRouteTimer
Definition: ovsdb_client.h:26
virtual OvsdbClientSession * NextSession(OvsdbClientSession *session)=0
DISALLOW_COPY_AND_ASSIGN(OvsdbClient)