7 #include <boost/algorithm/string.hpp>
8 #include <boost/checked_delete.hpp>
9 #include <boost/type_traits.hpp>
19 #include "ifmap/ifmap_log_types.h"
27 const string &
type,
const string &name)
28 : origin(orig), id_type(type), id_name(name) {
38 #if (__GNUC_PREREQ(4, 2) > 0)
40 assert(has_destructor);
43 boost::checked_delete(content.release());
52 unique_ptr<DBEntry> entry(
53 new IFMapNode(const_cast<IFMapServerTable *>(
this)));
59 string name = metadata;
60 std::replace(name.begin(), name.end(),
'-',
'_');
61 name =
"__ifmap__." + name +
".0";
70 if ((node == NULL) || node->
IsDeleted()) {
90 static_cast<const IFMapNode *
>(key.release()));
100 const string &id_name) {
107 const string &id_name,
115 const string &metadata) {
118 assert(table != NULL);
120 return (link ? (link->
IsDeleted() ? NULL : link) : NULL);
124 const string &metadata,
125 uint64_t sequence_number,
129 assert(table != NULL);
130 IFMAP_DEBUG(IFMapLinkOperation,
"Creating", metadata);
131 return table->
AddLink(first, second, metadata, sequence_number, origin);
144 assert(table != NULL);
154 if (first->
IsLess(*second)) {
155 oss << first->
name() <<
"," << second->
name();
157 oss << second->
name() <<
"," << first->
name();
168 partition->Delete(node);
188 if (
object == NULL) {
190 object->set_origin(origin);
198 uint64_t sequence_number) {
208 object->set_sequence_number(sequence_number);
215 uint64_t sequence_number) {
218 object->set_sequence_number(sequence_number);
229 assert(data != NULL);
238 IFMAP_TRACE(IFMapTblNotFoundTrace,
"Cant find table",
245 IFMAP_TRACE(IFMapTblNotFoundTrace,
"Cant find table",
252 bool lchanged =
false;
256 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
275 if (identifier == NULL) {
280 if (identifier->
empty()) {
281 first->
Remove(identifier);
291 bool rchanged =
false;
294 if (second == NULL) {
295 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
304 bool mchanged =
false;
306 if (mtable != NULL) {
311 if (midnode == NULL) {
312 IFMAP_WARN(IFMapIdentifierNotFound,
"Cant find identifier",
346 if (
object == NULL) {
409 node != NULL; node = next) {
411 if (node->IsDeleted()) {
422 const std::string &vm_name,
423 bool subscribe,
bool has_vms) {
434 uint64_t sequence_number = 0;
437 std::string metadata = std::string(
"virtual-router-virtual-machine");
441 glink =
LinkNodeAdd(vr_node, vm_node, metadata, sequence_number, origin);
450 const std::string &vm_name) {
451 bool changed =
false;
457 if (vr_node == NULL) {
465 assert(vm_table != NULL);
468 assert(vm_node != NULL);
478 std::string metadata = std::string(
"virtual-router-virtual-machine");
485 const std::string &vm_name,
491 assert(vr_node != NULL);
496 assert(vm_table != NULL);
499 assert(vm_node != NULL);
IFMapLink * FindLinkNode(IFMapNode *first, IFMapNode *second, const std::string &metadata)
void Notify(IFMapNode *node)
const DBGraph * graph() const
static void RemoveObjectAndDeleteNode(IFMapNode *node, const IFMapOrigin &origin)
static IFMapServerTable * TableFind(DB *db, const string &metadata)
IFMapLinkAttr * LocateLinkAttr(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
void UpdateProperties(const IFMapOrigin &in_origin, uint64_t sequence_number)
IFMapObject * LocateObject(IFMapNode *node, IFMapOrigin origin)
virtual IFMapObject * AllocObject()=0
virtual std::string ToString() const
void set_last_change_at_to_now()
void Remove(IFMapObject *obj)
virtual bool empty() const
virtual DBEntry * GetNext(const DBEntryBase *entry)
IFMapNode * EntryLocate(RequestKey *key, bool *changep)
std::unique_ptr< DBRequestData > data
std::unique_ptr< AutogenProperty > content
void DeleteLink(IFMapLink *link, const IFMapOrigin &origin)
void Delete(DBEntryBase *)
bool HasAdjacencies(DBGraph *graph) const
IFMapLink * FindLink(const std::string &metadata, IFMapNode *left, IFMapNode *right)
static IFMapNode * TableEntryLookup(IFMapServerTable *table, const std::string &id_name)
virtual void Change(DBEntry *entry)
#define IFMAP_DEBUG(obj,...)
IFMapLink * AddLink(IFMapNode *left, IFMapNode *right, const std::string &metadata, uint64_t sequence_number, const IFMapOrigin &origin)
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)
void AddNode(DBGraphVertex *entry)
uint64_t sequence_number()
IFMapIdentifier * LocateIdentifier(IFMapNode *node, IFMapOrigin origin, uint64_t sequence_number)
void IFMapRemoveVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
std::unique_ptr< DBRequestKey > key
void Insert(IFMapObject *obj)
void RemoveNode(DBGraphVertex *entry)
IFMapObject * Find(IFMapOrigin origin)
virtual bool SetData(const AutogenProperty *data)=0
const std::string & name() const
const std::string & name() const
Edge Link(DBGraphVertex *lhs, DBGraphVertex *rhs, DBGraphEdge *link)
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
IFMapObject * GetObject()
void IFMapProcVmUnsubscribe(const std::string &vr_name, const std::string &vm_name, bool has_vms)
#define IFMAP_WARN(obj,...)
void DeleteNode(IFMapNode *node)
static IFMapNode * TableEntryLocate(IFMapServerTable *table, const std::string &id_name, bool *changep)
virtual bool IsLess(const DBEntry &db_entry) const
bool HasListeners() const
DBEntry * Find(const DBEntry *entry)
virtual bool SetProperty(const std::string &attr_key, AutogenProperty *data)=0
void IFMapAddVrVmLink(IFMapNode *vr_node, IFMapNode *vm_node)
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *key) const
virtual DBEntry * GetFirst()
virtual std::string ToString() const
virtual void Add(DBEntry *entry)
#define IFMAP_TRACE(obj,...)
IFMapNode * EntryLookup(RequestKey *key)
void TransferPropertyToOldProperty()
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)
DBTableBase * FindTable(const std::string &name)
virtual void ClearProperty(const std::string &attr_key)=0
void AddOriginInfo(const IFMapOrigin &in_origin, uint64_t seq_num)