8 #include <boost/algorithm/string.hpp>
9 #include <boost/checked_delete.hpp>
10 #include <boost/type_traits.hpp>
20 #include "ifmap/ifmap_log_types.h"
28 const string &
type,
const string &name)
29 : origin(orig), id_type(
type), id_name(name) {
39 #if (__GNUC_PREREQ(4, 2) > 0)
41 assert(has_destructor);
44 boost::checked_delete(content.release());
53 unique_ptr<DBEntry> entry(
60 string name = metadata;
61 std::replace(name.begin(), name.end(),
'-',
'_');
62 name =
"__ifmap__." + name +
".0";
71 if ((node == NULL) || node->
IsDeleted()) {
91 static_cast<const IFMapNode *
>(key.release()));
101 const string &id_name) {
108 const string &id_name,
116 const string &metadata) {
119 assert(table != NULL);
121 return (link ? (link->
IsDeleted() ? NULL : link) : NULL);
125 const string &metadata,
126 uint64_t sequence_number,
130 assert(table != NULL);
131 IFMAP_DEBUG(IFMapLinkOperation,
"Creating", metadata);
132 return table->
AddLink(first, second, metadata, sequence_number, origin);
145 assert(table != NULL);
155 if (first->
IsLess(*second)) {
156 oss << first->
name() <<
"," << second->
name();
158 oss << second->
name() <<
"," << first->
name();
189 if (
object == NULL) {
191 object->set_origin(origin);
199 uint64_t sequence_number) {
209 object->set_sequence_number(sequence_number);
216 uint64_t sequence_number) {
219 object->set_sequence_number(sequence_number);
230 assert(data != NULL);
239 IFMAP_TRACE(IFMapTblNotFoundTrace,
"Cant find table",
246 IFMAP_TRACE(IFMapTblNotFoundTrace,
"Cant find table",
253 bool lchanged =
false;
257 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
276 if (identifier == NULL) {
281 if (identifier->
empty()) {
282 first->
Remove(identifier);
292 bool rchanged =
false;
295 if (second == NULL) {
296 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
305 bool mchanged =
false;
307 if (mtable != NULL) {
312 if (midnode == NULL) {
313 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
347 if (
object == NULL) {
410 node != NULL; node = next) {
412 if (node->IsDeleted()) {
423 const std::string &vm_name,
424 bool subscribe,
bool has_vms) {
435 uint64_t sequence_number = 0;
438 std::string metadata = std::string(
"virtual-router-virtual-machine");
442 glink =
LinkNodeAdd(vr_node, vm_node, metadata, sequence_number, origin);
451 const std::string &vm_name) {
452 bool changed =
false;
458 if (vr_node == NULL) {
466 assert(vm_table != NULL);
469 assert(vm_node != NULL);
479 std::string metadata = std::string(
"virtual-router-virtual-machine");
486 const std::string &vm_name,
492 assert(vr_node != NULL);
497 assert(vm_table != NULL);
500 assert(vm_node != NULL);
void set_last_change_at_to_now()
const DBGraph * graph() const
bool HasAdjacencies(DBGraph *graph) const
Edge Link(DBGraphVertex *lhs, DBGraphVertex *rhs, DBGraphEdge *link)
void RemoveNode(DBGraphVertex *entry)
void AddNode(DBGraphVertex *entry)
bool HasListeners() const
const std::string & name() const
void Delete(DBEntryBase *)
virtual void Change(DBEntry *entry)
virtual void Add(DBEntry *entry)
virtual DBEntry * GetNext(const DBEntryBase *entry)
virtual DBEntry * GetFirst()
DBEntry * Find(const DBEntry *entry)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
DBTableBase * FindTable(const std::string &name)
virtual void ClearProperty(const std::string &attr_key)=0
virtual bool empty() const
virtual bool SetProperty(const std::string &attr_key, AutogenProperty *data)=0
void TransferPropertyToOldProperty()
virtual bool SetData(const AutogenProperty *data)=0
IFMapLink * FindLink(const std::string &metadata, IFMapNode *left, IFMapNode *right)
IFMapLink * AddLink(IFMapNode *left, IFMapNode *right, const std::string &metadata, uint64_t sequence_number, const IFMapOrigin &origin)
void DeleteLink(IFMapLink *link, const IFMapOrigin &origin)
virtual std::string ToString() const
void UpdateProperties(const IFMapOrigin &in_origin, uint64_t sequence_number)
void AddOriginInfo(const IFMapOrigin &in_origin, uint64_t seq_num)
void Remove(IFMapObject *obj)
const std::string & name() const
virtual bool IsLess(const DBEntry &db_entry) const
IFMapObject * GetObject()
void Insert(IFMapObject *obj)
IFMapObject * Find(IFMapOrigin origin)
virtual std::string ToString() const
uint64_t sequence_number()
void IFMapProcVmSubscribe(const std::string &vr_name, const std::string &vm_name)
IFMapLinkAttr * LocateLinkAttr(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
static std::string LinkAttrKey(IFMapNode *first, IFMapNode *second)
static IFMapNode * TableEntryLookup(IFMapServerTable *table, const std::string &id_name)
void LinkNodeUpdate(IFMapLink *link, uint64_t sequence_number, const IFMapOrigin &origin)
void IFMapVmSubscribe(const std::string &vr_name, const std::string &vm_name, bool subscribe, bool has_vms)
IFMapNode * EntryLocate(RequestKey *key, bool *changep)
static void RemoveObjectAndDeleteNode(IFMapNode *node, const IFMapOrigin &origin)
IFMapLink * LinkNodeAdd(IFMapNode *first, IFMapNode *second, const std::string &metadata, uint64_t sequence_number, const IFMapOrigin &origin)
IFMapServerTable(DB *db, const std::string &name, DBGraph *graph)
static IFMapNode * TableEntryLocate(IFMapServerTable *table, const std::string &id_name, bool *changep)
void LinkNodeDelete(IFMapLink *link, const IFMapOrigin &origin)
IFMapNode * EntryLookup(RequestKey *key)
void IFMapRemoveVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
void IFMapAddVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
IFMapLink * FindLinkNode(IFMapNode *first, IFMapNode *second, const std::string &metadata)
void Notify(IFMapNode *node)
bool DeleteIfEmpty(IFMapNode *node)
IFMapIdentifier * LocateIdentifier(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
virtual void Input(DBTablePartition *partition, DBClient *client, DBRequest *req)
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *key) const
void DeleteNode(IFMapNode *node)
void IFMapProcVmUnsubscribe(const std::string &vr_name, const std::string &vm_name, bool has_vms)
IFMapObject * LocateObject(IFMapNode *node, IFMapOrigin origin)
virtual IFMapObject * AllocObject()=0
#define IFMAP_DEBUG(obj,...)
#define IFMAP_TRACE(obj,...)
#define IFMAP_WARN(obj,...)
static IFMapServerTable * TableFind(DB *db, const string &metadata)
std::unique_ptr< DBRequestKey > key
std::unique_ptr< DBRequestData > data
std::unique_ptr< AutogenProperty > content