OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ifmap_server_table.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #ifndef ctrlplane_ifmap_server_table_h
6 #define ctrlplane_ifmap_server_table_h
7 
8 #include "db/db_graph_base.h"
9 #include "ifmap/autogen.h"
10 #include "ifmap/ifmap_table.h"
11 #include "ifmap/ifmap_origin.h"
12 
13 class DBGraph;
14 class IFMapNode;
15 class IFMapLink;
16 class IFMapObject;
17 class IFMapIdentifier;
18 class IFMapLinkAttr;
19 
20 class IFMapServerTable : public IFMapTable {
21 public:
23  RequestData();
24  RequestData(IFMapOrigin::Origin orig, const std::string &type,
25  const std::string &name);
26  ~RequestData();
28  std::string id_type;
29  std::string id_name;
30  std::string metadata;
31  std::unique_ptr<AutogenProperty> content;
32  };
33 
34  IFMapServerTable(DB *db, const std::string &name, DBGraph *graph);
35 
36  // Allocate an IFMapNode.
37  virtual std::unique_ptr<DBEntry> AllocEntry(const DBRequestKey *key) const;
38 
39  // Process a DB add/change/delete request. Requests consist of 1 or 2
40  // identifiers plus associated metadata.
41  virtual void Input(DBTablePartition *partition, DBClient *client,
42  DBRequest *req);
43 
44  // Remove all nodes.
45  virtual void Clear();
46 
47  // When a property or link has been removed, delete the entry if no longer
48  // necessary.
49  bool DeleteIfEmpty(IFMapNode *node);
50  void Notify(IFMapNode *node);
51 
52  static std::string LinkAttrKey(IFMapNode *first, IFMapNode *second);
53 
54  void IFMapVmSubscribe(const std::string &vr_name,
55  const std::string &vm_name, bool subscribe, bool has_vms);
56  void IFMapAddVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node);
57  void IFMapRemoveVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node);
58  static void RemoveObjectAndDeleteNode(IFMapNode *node,
59  const IFMapOrigin &origin);
60 
61 private:
62  IFMapNode *EntryLocate(RequestKey *key, bool *changep);
64 
67  uint64_t sequence_number);
69  uint64_t sequence_number);
70 
71  void DeleteNode(IFMapNode *node);
72 
74  const std::string &id_name);
76  const std::string &id_name,
77  bool *changep);
78 
79  IFMapLink *LinkNodeAdd(IFMapNode *first, IFMapNode *second,
80  const std::string &metadata, uint64_t sequence_number,
81  const IFMapOrigin &origin);
82  IFMapLink *FindLinkNode(IFMapNode *first, IFMapNode *second, const std::string &metadata);
83 
84  void LinkNodeDelete(IFMapLink *link, const IFMapOrigin &origin);
85  void LinkNodeUpdate(IFMapLink *link, uint64_t sequence_number,
86  const IFMapOrigin &origin);
87  void IFMapProcVmSubscribe(const std::string &vr_name,
88  const std::string &vm_name);
89  void IFMapProcVmUnsubscribe(const std::string &vr_name,
90  const std::string &vm_name, bool has_vms);
91 };
92 
93 #endif
IFMapLink * FindLinkNode(IFMapNode *first, IFMapNode *second, const std::string &metadata)
void Notify(IFMapNode *node)
const DBGraph * graph() const
virtual void Clear()
static void RemoveObjectAndDeleteNode(IFMapNode *node, const IFMapOrigin &origin)
IFMapLinkAttr * LocateLinkAttr(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
IFMapObject * LocateObject(IFMapNode *node, IFMapOrigin origin)
IFMapNode * EntryLocate(RequestKey *key, bool *changep)
std::unique_ptr< AutogenProperty > content
static IFMapNode * TableEntryLookup(IFMapServerTable *table, const std::string &id_name)
Definition: db.h:24
void IFMapProcVmSubscribe(const std::string &vr_name, const std::string &vm_name)
IFMapServerTable(DB *db, const std::string &name, DBGraph *graph)
IFMapLink * LinkNodeAdd(IFMapNode *first, IFMapNode *second, const std::string &metadata, uint64_t sequence_number, const IFMapOrigin &origin)
void IFMapVmSubscribe(const std::string &vr_name, const std::string &vm_name, bool subscribe, bool has_vms)
uint8_t type
Definition: load_balance.h:109
IFMapIdentifier * LocateIdentifier(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
void IFMapRemoveVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
const std::string & name() const
Definition: db_table.h:110
void IFMapProcVmUnsubscribe(const std::string &vr_name, const std::string &vm_name, bool has_vms)
void DeleteNode(IFMapNode *node)
static IFMapNode * TableEntryLocate(IFMapServerTable *table, const std::string &id_name, bool *changep)
void IFMapAddVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *key) const
IFMapNode * EntryLookup(RequestKey *key)
void LinkNodeDelete(IFMapLink *link, const IFMapOrigin &origin)
virtual void Input(DBTablePartition *partition, DBClient *client, DBRequest *req)
static std::string LinkAttrKey(IFMapNode *first, IFMapNode *second)
bool DeleteIfEmpty(IFMapNode *node)
void LinkNodeUpdate(IFMapLink *link, uint64_t sequence_number, const IFMapOrigin &origin)