SetField(fid, newValue);
if (updateVersion)
- SetVersion(GetVersion() + 1);
+ SetVersion(Utility::GetTime());
if (updated_original_attributes)
NotifyOriginalAttributes();
original_attributes->Remove(attr);
SetField(fid, newValue);
- /* increment the version. although restoring would mean
- * decrementing the version, but we cannot notify other
- * cluster nodes without increment.
- */
- SetVersion(GetVersion() + 1);
+ SetVersion(Utility::GetTime());
}
bool ConfigObject::IsAttributeModified(const String& attr) const
ObjectLock olock(originalAttributes);
BOOST_FOREACH(const Dictionary::Pair& kv, originalAttributes) {
String key = kv.first;
- // TODO-MA: vars.os
Type::Ptr type = object->GetReflectionType();
[protected] bool state_loaded;
Dictionary::Ptr original_attributes;
[state] int version {
- default {{{ return 1; }}}
+ default {{{ return 0; }}}
};
};
if (objZone.IsEmpty())
continue;
+ /* don't sync objects with an older version time than the endpoint's log position */
+ if (object->GetVersion() < endpoint->GetLocalLogPosition()) {
+ Log(LogDebug, "ApiListener")
+ << "Skipping sync: object '" << object->GetName() << "'"
+ << " is older than local log position of endpoint '"
+ << endpoint->GetName() << "'.";
+ continue;
+ }
+
/* don't sync objects for non-matching parent-child zones */
if (!azone->IsChildOf(lzone) && azone != lzone) {
Log(LogDebug, "ApiListener")
allAttrs->Remove("name");
+ /* update the version for config sync */
+ allAttrs->Set("version", Utility::GetTime());
+
std::ostringstream config;
ConfigWriter::EmitConfigItem(config, type->GetName(), name, false, templates, allAttrs);
ConfigWriter::EmitRaw(config, "\n");