mirror of https://github.com/Icinga/icinga2.git
Ignore remote object updates when local object is newer.
This commit is contained in:
parent
512f46907e
commit
a7be3a40c9
|
@ -99,12 +99,28 @@ string ConfigObject::GetSource(void) const
|
||||||
return value;
|
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)
|
void ConfigObject::Commit(void)
|
||||||
{
|
{
|
||||||
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
|
ConfigObject::Ptr dobj = GetObject(GetType(), GetName());
|
||||||
ConfigObject::Ptr self = GetSelf();
|
ConfigObject::Ptr self = GetSelf();
|
||||||
assert(!dobj || dobj == self);
|
assert(!dobj || dobj == self);
|
||||||
m_Container->CheckObject(self);
|
m_Container->CheckObject(self);
|
||||||
|
|
||||||
|
time_t now;
|
||||||
|
time(&now);
|
||||||
|
SetCommitTimestamp(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigObject::Unregister(void)
|
void ConfigObject::Unregister(void)
|
||||||
|
|
|
@ -82,6 +82,8 @@ public:
|
||||||
void SetSource(const string& value);
|
void SetSource(const string& value);
|
||||||
string GetSource(void) const;
|
string GetSource(void) const;
|
||||||
|
|
||||||
|
time_t GetCommitTimestamp(void) const;
|
||||||
|
|
||||||
void Commit(void);
|
void Commit(void);
|
||||||
void Unregister(void);
|
void Unregister(void);
|
||||||
|
|
||||||
|
@ -101,6 +103,8 @@ private:
|
||||||
Dictionary::Ptr m_Properties;
|
Dictionary::Ptr m_Properties;
|
||||||
Dictionary::Ptr m_Tags;
|
Dictionary::Ptr m_Tags;
|
||||||
|
|
||||||
|
void SetCommitTimestamp(time_t ts);
|
||||||
|
|
||||||
static bool TypeAndNameGetter(const ConfigObject::Ptr& object, pair<string, string> *key);
|
static bool TypeAndNameGetter(const ConfigObject::Ptr& object, pair<string, string> *key);
|
||||||
static bool TypePredicate(const ConfigObject::Ptr& object, string type);
|
static bool TypePredicate(const ConfigObject::Ptr& object, string type);
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,10 @@ void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} 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());
|
object->SetProperties(properties.GetDictionary());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue