OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ovsdb_client_connection_state.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_CONNECTION_STATE_H_
6 #define SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_CONNECTION_STATE_H_
7 
8 #include <boost/intrusive_ptr.hpp>
9 #include <tbb/atomic.h>
10 #include <base/connection_info.h>
11 #include <db/db.h>
12 #include <db/db_entry.h>
13 #include <db/db_table.h>
14 #include <db/db_table_partition.h>
15 
16 #include <cmn/agent.h>
17 #include <oper/physical_device.h>
18 #include <uve/agent_uve_base.h>
19 
20 #include "ovsdb_client_idl.h"
21 
22 namespace OVSDB {
23 class HaStaleDevVnTable;
25 typedef boost::intrusive_ptr<ConnectionStateEntry> ConnectionStateEntryPtr;
26 
27 // Table to maintain Connection State for Physical Switches/Devices
29 public:
30  typedef std::map<std::string, ConnectionStateEntry *> EntryMap;
31  ConnectionStateTable(Agent *agent, OvsPeerManager *manager);
32  virtual ~ConnectionStateTable();
33 
34  // Adding first IDL to ConnectionState Entry marks session Up
35  void AddIdlToConnectionState(const std::string &device_name,
36  OvsdbClientIdl *idl);
37 
38  // Deleting last IDL from ConnectionState Entry marks session Down
39  void DelIdlToConnectionState(const std::string &device_name,
40  OvsdbClientIdl *idl);
41 
42  ConnectionStateEntry *Find(const std::string &device_name);
43 
44 private:
46 
48 
49  // API to update connection info state
50  void UpdateConnectionInfo(ConnectionStateEntry *entry, bool deleted);
51  void NotifyUve(ConnectionStateEntry *entry, bool deleted);
52 
59 };
60 
61 // Connection State Entry represent a physical router, reports connection
62 // state Up as long as config and idl for Physical Switch exists
63 class ConnectionStateEntry : public DBState {
64 public:
65  typedef std::set<OvsdbClientIdl *> IdlList;
67  const std::string &device_name,
68  const boost::uuids::uuid &u);
69  virtual ~ConnectionStateEntry();
70 
71  bool IsConnectionActive();
72 
75  }
76 
77 private:
78  friend class ConnectionStateTable;
81 
83  std::string device_name_;
87  // Ha Stale Dev VN table for the device, which listens to physical
88  // device VN table for the give device, and re-exports the ha stale
89  // L2 route with lower preference
90  // it is created as soon as we have config for physical device to
91  // provide re-export functionality on both Active and Backup ToR
92  // Agent
94  tbb::atomic<int> refcount_;
96 };
97 
98 };
99 
100 #endif //SRC_VNSW_AGENT_OVS_TOR_AGENT_OVSDB_CLIENT_CONNECTION_STATE_H_
101 
void PhysicalDeviceNotify(DBTablePartBase *part, DBEntryBase *e)
ConnectionStateTable(Agent *agent, OvsPeerManager *manager)
void AddIdlToConnectionState(const std::string &device_name, OvsdbClientIdl *idl)
friend void intrusive_ptr_add_ref(ConnectionStateEntry *p)
DISALLOW_COPY_AND_ASSIGN(ConnectionStateEntry)
friend void intrusive_ptr_release(ConnectionStateEntry *p)
int ListenerId
Definition: db_table.h:62
boost::uuids::uuid uuid
friend void intrusive_ptr_release(ConnectionStateEntry *p)
void DelIdlToConnectionState(const std::string &device_name, OvsdbClientIdl *idl)
HaStaleDevVnTable * ha_stale_dev_vn_table() const
Definition: agent.h:358
boost::intrusive_ptr< ConnectionStateEntry > ConnectionStateEntryPtr
ConnectionStateEntry(ConnectionStateTable *table, const std::string &device_name, const boost::uuids::uuid &u)
std::set< OvsdbClientIdl * > IdlList
void UpdateConnectionInfo(ConnectionStateEntry *entry, bool deleted)
ConnectionStateEntry * Find(const std::string &device_name)
void NotifyUve(ConnectionStateEntry *entry, bool deleted)
DISALLOW_COPY_AND_ASSIGN(ConnectionStateTable)
std::map< std::string, ConnectionStateEntry * > EntryMap