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