return value;
}
+void ConfigObject::SetCommitTimestamp(time_t ts)
+{
+ GetProperties()->SetProperty("__tx", ts);
+}
+
+time_t ConfigObject::GetCommitTimestamp(void) const
+{
+ long value = false;
+ GetProperties()->GetProperty("__tx", &value);
+ return value;
+}
+
void ConfigObject::Commit(void)
{
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
ConfigObject::Ptr self = GetSelf();
assert(!dobj || dobj == self);
m_Container->CheckObject(self);
+
+ time_t now;
+ time(&now);
+ SetCommitTimestamp(now);
}
void ConfigObject::Unregister(void)
void SetSource(const string& value);
string GetSource(void) const;
+ time_t GetCommitTimestamp(void) const;
+
void Commit(void);
void Unregister(void);
Dictionary::Ptr m_Properties;
Dictionary::Ptr m_Tags;
+ void SetCommitTimestamp(time_t ts);
+
static bool TypeAndNameGetter(const ConfigObject::Ptr& object, pair<string, string> *key);
static bool TypePredicate(const ConfigObject::Ptr& object, string type);
return;
}
} else {
- /* TODO: compare transaction timestamps and reject the update if our local object is newer */
+ ConfigObject::Ptr remoteObject = boost::make_shared<ConfigObject>(properties.GetDictionary());
+
+ if (object->GetCommitTimestamp() >= remoteObject->GetCommitTimestamp())
+ return;
object->SetProperties(properties.GetDictionary());
}