Fixed remote replication of non-config attributes.

This commit is contained in:
Gunnar Beutner 2012-08-04 10:23:18 +02:00
parent d4c6824056
commit b9ee3b26eb
6 changed files with 29 additions and 38 deletions

View File

@ -468,16 +468,16 @@ void DynamicObject::RegisterClass(const String& type, DynamicObject::Factory fac
GetClasses()[type] = factory;
}
DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& properties)
DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::Ptr& serializedUpdate)
{
DynamicObject::ClassMap::iterator ct;
ct = GetClasses().find(type);
DynamicObject::Ptr obj;
if (ct != GetClasses().end()) {
obj = ct->second(properties);
obj = ct->second(serializedUpdate);
} else {
obj = boost::make_shared<DynamicObject>(properties);
obj = boost::make_shared<DynamicObject>(serializedUpdate);
Logger::Write(LogCritical, "base", "Creating generic DynamicObject for type '" + type + "'");
}
@ -494,6 +494,9 @@ DynamicObject::Ptr DynamicObject::Create(const String& type, const Dictionary::P
m_PersistentUpdates.erase(st);
}
/* apply the object's non-config attributes */
obj->ApplyUpdate(serializedUpdate, Attribute_All & ~Attribute_Config);
return obj;
}

View File

@ -118,7 +118,7 @@ public:
static void RestoreObjects(const String& filename);
static void RegisterClass(const String& type, Factory factory);
static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& properties);
static DynamicObject::Ptr Create(const String& type, const Dictionary::Ptr& serializedUpdate);
static double GetCurrentTx(void);
static void BeginTx(void);

View File

@ -26,8 +26,6 @@ using namespace icinga;
*/
void CIBSyncComponent::Start(void)
{
m_SyncingConfig = false;
m_Endpoint = boost::make_shared<VirtualEndpoint>();
/* config objects */
@ -148,10 +146,6 @@ void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
void CIBSyncComponent::LocalObjectRegisteredHandler(const DynamicObject::Ptr& object)
{
/* don't send messages when we're currently processing a remote update */
if (m_SyncingConfig)
return;
if (!ShouldReplicateObject(object))
return;
@ -161,10 +155,6 @@ void CIBSyncComponent::LocalObjectRegisteredHandler(const DynamicObject::Ptr& ob
void CIBSyncComponent::LocalObjectUnregisteredHandler(const DynamicObject::Ptr& object)
{
/* don't send messages when we're currently processing a remote update */
if (m_SyncingConfig)
return;
if (!ShouldReplicateObject(object))
return;
@ -259,14 +249,7 @@ void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
return;
if (!object->IsLocal()) {
try {
m_SyncingConfig = true;
object->Unregister();
m_SyncingConfig = false;
} catch (...) {
m_SyncingConfig = false;
throw;
}
object->Unregister();
}
}

View File

@ -34,7 +34,6 @@ public:
private:
VirtualEndpoint::Ptr m_Endpoint;
bool m_SyncingConfig;
static void ServiceStateChangeRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);

View File

@ -14,7 +14,8 @@ MBaAFNVJHVPJNwqEcG51lpqZJWVPaysFMA0GCSqGSIb3DQEBBQUAA4GBAIhhjKWw
5JKirNidgG9PuD8x47VsRTkESLlq/pS7KjkE1nWCG9JpR5oVSzx2WXomiaAZ4q2C
WS1z4HD9HF4NbhY+xVBi0Fj/kotuXCCweRo5EVp7Q4fabm1maJemFwMTHGhBLu7a
v4dquYyOk9Dhkwcjajyn+KWceCoUTdI3LB2t
-----END CERTIFICATE----------BEGIN PRIVATE KEY-----
-----END CERTIFICATE-----
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKznFbotQFqI2z7i
v+1nvbsCAS2ji3wcUESN/pOj8843bWl0+Io0/w0mr0OVOMBji2IdMrksqkvPEF/w
7Kgxi150lbPJk9+24qDDsNl4p6mjUOsSuL8otBWMUnsCOmDpGIu9d+TRGklIHfNo

View File

@ -1,25 +1,30 @@
local object application "icinga" {
ca = "ca.crt",
cert = "icinga-c2.pem"
local object Application "icinga" {
cert = "icinga-c2.pem",
ca = "ca.crt",
pidpath = "icinga-checker1.pid",
macros = {
plugindir = "/usr/local/icinga/libexec"
}
}
local object component "checker" {
local object Component "checker" {
}
local object component "discovery" {
broker = 0
local object Component "discovery" {
broker = 0
}
/* trusted upstream endpoint */
local object endpoint "icinga-c1" {
node = "192.168.5.46",
service = 7777,
local object Endpoint "icinga-c1" {
node = "192.168.5.46",
service = 7777,
roles = { "all" }
roles = { "all" }
}
local object role "all" {
publications = { "*" },
subscriptions = { "*" }
local object Role "all" {
publications = { "*" },
subscriptions = { "*" }
}