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