OpenSDN source code
vn_uve_table_base.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef vnsw_agent_vn_uve_table_base_h
6 #define vnsw_agent_vn_uve_table_base_h
7 
8 #include <string>
9 #include <set>
10 #include <map>
11 #include <vector>
12 #include <mutex>
13 
14 #include <virtual_network_types.h>
15 #include <oper/vn.h>
16 #include <uve/vn_uve_entry_base.h>
17 
18 //The container class for objects representing VirtualNetwork UVEs
19 //Defines routines for storing and managing (add, delete, change and send)
20 //VirtualNetwork UVEs
22 public:
23  struct VnUveInterfaceState :public DBState {
24  VnUveInterfaceState(const std::string &vm, const std::string &vn)
25  : vm_name_(vm), vn_name_(vn) {
26  }
27  std::string vm_name_;
28  std::string vn_name_;
29  };
30 
31  typedef boost::shared_ptr<VnUveEntryBase> VnUveEntryPtr;
32  typedef std::map<std::string, VnUveEntryPtr> UveVnMap;
33  typedef std::pair<std::string, VnUveEntryPtr> UveVnPair;
34  VnUveTableBase(Agent *agent, uint32_t default_intvl);
35  virtual ~VnUveTableBase();
36 
37  void RegisterDBClients();
38  void Shutdown(void);
39  void SendVnAclRuleCount();
40  bool TimerExpiry();
41 
42 protected:
43  void Delete(const std::string &name);
45  //The following API is made protected for UT.
46  virtual void DispatchVnMsg(const UveVirtualNetworkAgent &uve);
47  virtual void SendVnAceStats(VnUveEntryBase *entry, const VnEntry *vn) {
48  }
49 
52  /* For exclusion between kTaskFlowStatsCollector and kTaskDBExclude */
53  std::mutex uve_vn_map_mutex_;
54 private:
55  VnUveEntryBase* Add(const VnEntry *vn);
56  void Add(const std::string &vn);
57  virtual VnUveEntryPtr Allocate(const VnEntry *vn);
58  virtual VnUveEntryPtr Allocate();
59  void VnNotify(DBTablePartBase *partition, DBEntryBase *e);
60  void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e);
61  void SendDeleteVnMsg(const std::string &vn);
62  void MarkChanged(const VnEntry *vn);
63  void InterfaceDeleteHandler(const std::string &vm, const std::string &vn,
64  const Interface* intf);
65  void InterfaceAddHandler(const VnEntry* vn, const Interface* intf,
66  const std::string &vm_name,
67  VnUveInterfaceState *state);
68  void set_expiry_time(int time);
69  void SendVnMsg(VnUveEntryBase *entry, const VnEntry *vn);
70 
73 
74  // Last visited VmEntry by timer
75  std::string timer_last_visited_;
78 
80 };
81 
82 #endif // vnsw_agent_vn_uve_table_base_h
Definition: agent.h:360
int ListenerId
Definition: db_table.h:62
Definition: timer.h:57
Definition: vn.h:151
DBTableBase::ListenerId vn_listener_id_
virtual void SendVnAceStats(VnUveEntryBase *entry, const VnEntry *vn)
VnUveEntryBase * UveEntryFromVn(const VnEntry *vn)
DISALLOW_COPY_AND_ASSIGN(VnUveTableBase)
std::string timer_last_visited_
std::pair< std::string, VnUveEntryPtr > UveVnPair
void InterfaceNotify(DBTablePartBase *partition, DBEntryBase *e)
void MarkChanged(const VnEntry *vn)
void Delete(const std::string &name)
std::map< std::string, VnUveEntryPtr > UveVnMap
VnUveEntryBase * Add(const VnEntry *vn)
VnUveTableBase(Agent *agent, uint32_t default_intvl)
boost::shared_ptr< VnUveEntryBase > VnUveEntryPtr
void SendDeleteVnMsg(const std::string &vn)
virtual VnUveEntryPtr Allocate()
void VnNotify(DBTablePartBase *partition, DBEntryBase *e)
virtual ~VnUveTableBase()
void InterfaceDeleteHandler(const std::string &vm, const std::string &vn, const Interface *intf)
void SendVnMsg(VnUveEntryBase *entry, const VnEntry *vn)
std::mutex uve_vn_map_mutex_
void Add(const std::string &vn)
virtual void DispatchVnMsg(const UveVirtualNetworkAgent &uve)
void InterfaceAddHandler(const VnEntry *vn, const Interface *intf, const std::string &vm_name, VnUveInterfaceState *state)
void set_expiry_time(int time)
DBTableBase::ListenerId intf_listener_id_
VnUveInterfaceState(const std::string &vm, const std::string &vn)