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