]> granicus.if.org Git - icinga2/commitdiff
Moved configrpc code into the cibsync module.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 13:08:15 +0000 (15:08 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 2 Jul 2012 13:08:15 +0000 (15:08 +0200)
components/Makefile.am
components/cibsync/cibsynccomponent.cpp
components/cibsync/cibsynccomponent.h
components/configrpc/Makefile.am [deleted file]
components/configrpc/configrpc.vcxproj [deleted file]
components/configrpc/configrpccomponent.cpp [deleted file]
components/configrpc/configrpccomponent.h [deleted file]
components/configrpc/i2-configrpc.h [deleted file]
configure.ac

index d8211bb52c05ddbe92f77de6b26049d279469783..b54490e97c585533be39e381fcc732a3fccfa40b 100644 (file)
@@ -6,7 +6,6 @@ SUBDIRS = \
        cibsync \
        compat \
        configfile \
-       configrpc \
        delegation \
        demo \
        discovery
index a616fd3602b02490def24e1f8db6b191e27bfa80..501764d76b4e20484babbb3f76d10a7e6a5f6552 100644 (file)
@@ -36,9 +36,33 @@ string CIBSyncComponent::GetName(void) const
  */
 void CIBSyncComponent::Start(void)
 {
+       m_SyncingConfig = false;
+
        m_Endpoint = boost::make_shared<VirtualEndpoint>();
+
+       /* config objects */
+       m_Endpoint->RegisterTopicHandler("config::FetchObjects",
+           boost::bind(&CIBSyncComponent::FetchObjectsHandler, this, _2));
+
+       ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&CIBSyncComponent::LocalObjectCommittedHandler, this, _2));
+       ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&CIBSyncComponent::LocalObjectCommittedHandler, this, _2));
+       ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&CIBSyncComponent::LocalObjectRemovedHandler, this, _2));
+
+       m_Endpoint->RegisterPublication("config::ObjectCommitted");
+       m_Endpoint->RegisterPublication("config::ObjectRemoved");
+
+       EndpointManager::GetInstance()->OnNewEndpoint.connect(boost::bind(&CIBSyncComponent::NewEndpointHandler, this, _2));
+
+       m_Endpoint->RegisterPublication("config::FetchObjects");
+       m_Endpoint->RegisterTopicHandler("config::ObjectCommitted",
+           boost::bind(&CIBSyncComponent::RemoteObjectCommittedHandler, this, _2, _3));
+       m_Endpoint->RegisterTopicHandler("config::ObjectRemoved",
+           boost::bind(&CIBSyncComponent::RemoteObjectRemovedHandler, this, _3));
+
+       /* service status */
        m_Endpoint->RegisterTopicHandler("delegation::ServiceStatus",
            boost::bind(&CIBSyncComponent::ServiceStatusRequestHandler, _2, _3));
+
        EndpointManager::GetInstance()->RegisterEndpoint(m_Endpoint);
 }
 
@@ -102,4 +126,173 @@ void CIBSyncComponent::ServiceStatusRequestHandler(const Endpoint::Ptr& sender,
        CIB::UpdateTaskStatistics(now, 1);
 }
 
+void CIBSyncComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
+{
+       /* no need to sync the config with local endpoints */
+       if (endpoint->IsLocal())
+               return;
+
+       endpoint->OnSessionEstablished.connect(boost::bind(&CIBSyncComponent::SessionEstablishedHandler, this, _1));
+}
+
+void CIBSyncComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoint)
+{
+       RequestMessage request;
+       request.SetMethod("config::FetchObjects");
+
+       EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, endpoint, request);
+}
+
+RequestMessage CIBSyncComponent::MakeObjectMessage(const ConfigObject::Ptr& object, string method, bool includeProperties)
+{
+       RequestMessage msg;
+       msg.SetMethod(method);
+
+       MessagePart params;
+       msg.SetParams(params);
+
+       params.SetProperty("name", object->GetName());
+       params.SetProperty("type", object->GetType());
+
+       if (includeProperties)
+               params.SetProperty("properties", object->GetProperties());
+
+       return msg;
+}
+
+bool CIBSyncComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
+{
+       return (!object->IsLocal());
+}
+
+void CIBSyncComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
+{
+       ConfigObject::Set::Ptr allObjects = ConfigObject::GetAllObjects();
+
+       for (ConfigObject::Set::Iterator ci = allObjects->Begin(); ci != allObjects->End(); ci++) {
+               ConfigObject::Ptr object = *ci;
+
+               if (!ShouldReplicateObject(object))
+                       continue;
+
+               RequestMessage request = MakeObjectMessage(object, "config::ObjectCommitted", true);
+
+               EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, sender, request);
+       }
+}
+
+void CIBSyncComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& object)
+{
+       /* don't send messages when we're currently processing a remote update */
+       if (m_SyncingConfig)
+               return;
+
+       if (!ShouldReplicateObject(object))
+               return;
+
+       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
+           MakeObjectMessage(object, "config::ObjectCommitted", true));
+}
+
+void CIBSyncComponent::LocalObjectRemovedHandler(const ConfigObject::Ptr& object)
+{
+       /* don't send messages when we're currently processing a remote update */
+       if (m_SyncingConfig)
+               return;
+
+       if (!ShouldReplicateObject(object))
+               return;
+
+       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
+           MakeObjectMessage(object, "config::ObjectRemoved", false));
+}
+
+void CIBSyncComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
+{
+       MessagePart params;
+       if (!request.GetParams(&params))
+               return;
+
+       string name;
+       if (!params.GetProperty("name", &name))
+               return;
+
+       string type;
+       if (!params.GetProperty("type", &type))
+               return;
+
+       MessagePart properties;
+       if (!params.GetProperty("properties", &properties))
+               return;
+
+       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
+
+       if (!object) {
+               object = boost::make_shared<ConfigObject>(properties.GetDictionary());
+
+               if (object->GetSource() == EndpointManager::GetInstance()->GetIdentity()) {
+                       /* the peer sent us an object that was originally created by us - 
+                        * however if was deleted locally so we have to tell the peer to destroy
+                        * its copy of the object. */
+                       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
+                           MakeObjectMessage(object, "config::ObjectRemoved", false));
+
+                       return;
+               }
+       } else {
+               /* TODO: compare transaction timestamps and reject the update if our local object is newer */
+
+               object->SetProperties(properties.GetDictionary());
+       }
+
+       if (object->IsLocal())
+               throw invalid_argument("Replicated remote object is marked as local.");
+
+       if (object->GetSource().empty())
+               object->SetSource(sender->GetIdentity());
+
+       try {
+               /* TODO: only ignore updates for _this_ object rather than all objects
+                * this might be relevant if the commit handler for this object
+                * creates other objects. */
+               m_SyncingConfig = true;
+               object->Commit();
+               m_SyncingConfig = false;
+       } catch (const std::exception& ex) {
+               m_SyncingConfig = false;
+               throw;
+       }
+}
+
+void CIBSyncComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
+{
+       MessagePart params;
+       if (!request.GetParams(&params))
+               return;
+
+       string name;
+       if (!params.GetProperty("name", &name))
+               return;
+
+       string type;
+       if (!params.GetProperty("type", &type))
+               return;
+
+       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
+
+       if (!object)
+               return;
+
+       if (!object->IsLocal()) {
+               try {
+                       m_SyncingConfig = true;
+                       object->Unregister();
+                       m_SyncingConfig = false;
+               } catch (const std::exception& ex) {
+                       m_SyncingConfig = false;
+                       throw;
+               }
+       }
+}
+
 EXPORT_COMPONENT(cibsync, CIBSyncComponent);
index dc71fe6e2ddebb86477d5725854d07b8c24ff759..95dae5828583c0383ab6d0783c9bc651e58ab4b0 100644 (file)
@@ -37,6 +37,24 @@ private:
        VirtualEndpoint::Ptr m_Endpoint;
 
        static void ServiceStatusRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+
+       bool m_SyncingConfig;
+
+       void NewEndpointHandler(const Endpoint::Ptr& endpoint);
+       void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
+
+       void LocalObjectCommittedHandler(const ConfigObject::Ptr& object);
+       void LocalObjectRemovedHandler(const ConfigObject::Ptr& object);
+
+       void FetchObjectsHandler(const Endpoint::Ptr& sender);
+       void RemoteObjectCommittedHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
+       void RemoteObjectRemovedHandler(const RequestMessage& request);
+
+       static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
+           string method, bool includeProperties);
+
+       static bool ShouldReplicateObject(const ConfigObject::Ptr& object);
+
 };
 
 }
diff --git a/components/configrpc/Makefile.am b/components/configrpc/Makefile.am
deleted file mode 100644 (file)
index 054c8eb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-pkglib_LTLIBRARIES = \
-       configrpc.la
-
-configrpc_la_SOURCES = \
-       configrpccomponent.cpp \
-       configrpccomponent.h \
-       i2-configrpc.h
-
-configrpc_la_CPPFLAGS = \
-       $(BOOST_CPPFLAGS) \
-       -I${top_srcdir}/base \
-       -I${top_srcdir}/jsonrpc \
-       -I${top_srcdir}/icinga
-
-configrpc_la_LDFLAGS = \
-       $(BOOST_LDFLAGS) \
-       -module \
-       -no-undefined \
-       @RELEASE_INFO@ \
-       @VERSION_INFO@
-
-configrpc_la_LIBADD = \
-       ${top_builddir}/base/libbase.la \
-       ${top_builddir}/jsonrpc/libjsonrpc.la \
-       ${top_builddir}/icinga/libicinga.la
diff --git a/components/configrpc/configrpc.vcxproj b/components/configrpc/configrpc.vcxproj
deleted file mode 100644 (file)
index eae5056..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="configrpccomponent.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="configrpccomponent.h" />
-    <ClInclude Include="i2-configrpc.h" />
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{697C6D7E-3109-484C-A7AF-384D28711610}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>icinga</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-    <IncludePath>$(SolutionDir)\base;$(SolutionDir)\jsonrpc;$(SolutionDir)\icinga;$(SolutionDir)\dyn;$(IncludePath)</IncludePath>
-    <LibraryPath>$(OutDir);$(LibraryPath)</LibraryPath>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;CONFIGCOMPONENT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <WarningLevel>Level3</WarningLevel>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <MinimalRebuild>false</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>
-      </PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;CONFIGCOMPONENT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
-      <WarningLevel>Level3</WarningLevel>
-      <MultiProcessorCompilation>true</MultiProcessorCompilation>
-      <MinimalRebuild>false</MinimalRebuild>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>base.lib;jsonrpc.lib;icinga.lib;cJSON.lib;%(AdditionalDependencies)</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>
\ No newline at end of file
diff --git a/components/configrpc/configrpccomponent.cpp b/components/configrpc/configrpccomponent.cpp
deleted file mode 100644 (file)
index 931281c..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#include "i2-configrpc.h"
-
-using namespace icinga;
-
-string ConfigRpcComponent::GetName(void) const
-{
-       return "configcomponent";
-}
-
-void ConfigRpcComponent::Start(void)
-{
-       m_Syncing = false;
-
-       EndpointManager::Ptr endpointManager = EndpointManager::GetInstance();
-
-       m_Endpoint = boost::make_shared<VirtualEndpoint>();
-
-       m_Endpoint->RegisterTopicHandler("config::FetchObjects",
-           boost::bind(&ConfigRpcComponent::FetchObjectsHandler, this, _2));
-
-       ConfigObject::GetAllObjects()->OnObjectAdded.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
-       ConfigObject::GetAllObjects()->OnObjectCommitted.connect(boost::bind(&ConfigRpcComponent::LocalObjectCommittedHandler, this, _2));
-       ConfigObject::GetAllObjects()->OnObjectRemoved.connect(boost::bind(&ConfigRpcComponent::LocalObjectRemovedHandler, this, _2));
-
-       m_Endpoint->RegisterPublication("config::ObjectCommitted");
-       m_Endpoint->RegisterPublication("config::ObjectRemoved");
-
-       endpointManager->OnNewEndpoint.connect(boost::bind(&ConfigRpcComponent::NewEndpointHandler, this, _2));
-
-       m_Endpoint->RegisterPublication("config::FetchObjects");
-       m_Endpoint->RegisterTopicHandler("config::ObjectCommitted",
-           boost::bind(&ConfigRpcComponent::RemoteObjectCommittedHandler, this, _2, _3));
-       m_Endpoint->RegisterTopicHandler("config::ObjectRemoved",
-           boost::bind(&ConfigRpcComponent::RemoteObjectRemovedHandler, this, _3));
-
-       endpointManager->RegisterEndpoint(m_Endpoint);
-}
-
-void ConfigRpcComponent::Stop(void)
-{
-       EndpointManager::Ptr mgr = EndpointManager::GetInstance();
-
-       if (mgr)
-               mgr->UnregisterEndpoint(m_Endpoint);
-}
-
-void ConfigRpcComponent::NewEndpointHandler(const Endpoint::Ptr& endpoint)
-{
-       /* no need to sync the config with local endpoints */
-       if (endpoint->IsLocal())
-               return;
-
-       endpoint->OnSessionEstablished.connect(boost::bind(&ConfigRpcComponent::SessionEstablishedHandler, this, _1));
-}
-
-void ConfigRpcComponent::SessionEstablishedHandler(const Endpoint::Ptr& endpoint)
-{
-       RequestMessage request;
-       request.SetMethod("config::FetchObjects");
-
-       EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, endpoint, request);
-}
-
-RequestMessage ConfigRpcComponent::MakeObjectMessage(const ConfigObject::Ptr& object, string method, bool includeProperties)
-{
-       RequestMessage msg;
-       msg.SetMethod(method);
-
-       MessagePart params;
-       msg.SetParams(params);
-
-       params.SetProperty("name", object->GetName());
-       params.SetProperty("type", object->GetType());
-
-       if (includeProperties)
-               params.SetProperty("properties", object->GetProperties());
-
-       return msg;
-}
-
-bool ConfigRpcComponent::ShouldReplicateObject(const ConfigObject::Ptr& object)
-{
-       return (!object->IsLocal());
-}
-
-void ConfigRpcComponent::FetchObjectsHandler(const Endpoint::Ptr& sender)
-{
-       ConfigObject::Set::Ptr allObjects = ConfigObject::GetAllObjects();
-
-       for (ConfigObject::Set::Iterator ci = allObjects->Begin(); ci != allObjects->End(); ci++) {
-               ConfigObject::Ptr object = *ci;
-
-               if (!ShouldReplicateObject(object))
-                       continue;
-
-               RequestMessage request = MakeObjectMessage(object, "config::ObjectCommitted", true);
-
-               EndpointManager::GetInstance()->SendUnicastMessage(m_Endpoint, sender, request);
-       }
-}
-
-void ConfigRpcComponent::LocalObjectCommittedHandler(const ConfigObject::Ptr& object)
-{
-       /* don't send messages when we're currently processing a remote update */
-       if (m_Syncing)
-               return;
-
-       if (!ShouldReplicateObject(object))
-               return;
-
-       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
-           MakeObjectMessage(object, "config::ObjectCommitted", true));
-}
-
-void ConfigRpcComponent::LocalObjectRemovedHandler(const ConfigObject::Ptr& object)
-{
-       /* don't send messages when we're currently processing a remote update */
-       if (m_Syncing)
-               return;
-
-       if (!ShouldReplicateObject(object))
-               return;
-
-       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
-           MakeObjectMessage(object, "config::ObjectRemoved", false));
-}
-
-void ConfigRpcComponent::RemoteObjectCommittedHandler(const Endpoint::Ptr& sender, const RequestMessage& request)
-{
-       MessagePart params;
-       if (!request.GetParams(&params))
-               return;
-
-       string name;
-       if (!params.GetProperty("name", &name))
-               return;
-
-       string type;
-       if (!params.GetProperty("type", &type))
-               return;
-
-       MessagePart properties;
-       if (!params.GetProperty("properties", &properties))
-               return;
-
-       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
-
-       if (!object) {
-               object = boost::make_shared<ConfigObject>(properties.GetDictionary());
-
-               if (object->GetSource() == EndpointManager::GetInstance()->GetIdentity()) {
-                       /* the peer sent us an object that was originally created by us - 
-                        * however if was deleted locally so we have to tell the peer to destroy
-                        * its copy of the object. */
-                       EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint,
-                           MakeObjectMessage(object, "config::ObjectRemoved", false));
-
-                       return;
-               }
-       } else {
-               /* TODO: compare transaction timestamps and reject the update if our local object is newer */
-
-               object->SetProperties(properties.GetDictionary());
-       }
-
-       if (object->IsLocal())
-               throw invalid_argument("Replicated remote object is marked as local.");
-
-       if (object->GetSource().empty())
-               object->SetSource(sender->GetIdentity());
-
-       try {
-               /* TODO: only ignore updates for _this_ object rather than all objects
-                * this might be relevant if the commit handler for this object
-                * creates other objects. */
-               m_Syncing = true;
-               object->Commit();
-               m_Syncing = false;
-       } catch (const std::exception& ex) {
-               m_Syncing = false;
-               throw;
-       }
-}
-
-void ConfigRpcComponent::RemoteObjectRemovedHandler(const RequestMessage& request)
-{
-       MessagePart params;
-       if (!request.GetParams(&params))
-               return;
-
-       string name;
-       if (!params.GetProperty("name", &name))
-               return;
-
-       string type;
-       if (!params.GetProperty("type", &type))
-               return;
-
-       ConfigObject::Ptr object = ConfigObject::GetObject(type, name);
-
-       if (!object)
-               return;
-
-       if (!object->IsLocal()) {
-               try {
-                       m_Syncing = true;
-                       object->Unregister();
-                       m_Syncing = false;
-               } catch (const std::exception& ex) {
-                       m_Syncing = false;
-                       throw;
-               }
-       }
-}
-
-EXPORT_COMPONENT(configrpc, ConfigRpcComponent);
diff --git a/components/configrpc/configrpccomponent.h b/components/configrpc/configrpccomponent.h
deleted file mode 100644 (file)
index 5e9bc07..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef CONFIGRPCCOMPONENT_H
-#define CONFIGRPCCOMPONENT_H
-
-namespace icinga
-{
-
-/**
- * @ingroup configrpc
- */
-class ConfigRpcComponent : public Component
-{
-public:
-       virtual string GetName(void) const;
-       virtual void Start(void);
-       virtual void Stop(void);
-
-private:
-       VirtualEndpoint::Ptr m_Endpoint;
-       bool m_Syncing;
-
-       void NewEndpointHandler(const Endpoint::Ptr& endpoint);
-       void SessionEstablishedHandler(const Endpoint::Ptr& endpoint);
-
-       void LocalObjectCommittedHandler(const ConfigObject::Ptr& object);
-       void LocalObjectRemovedHandler(const ConfigObject::Ptr& object);
-
-       void FetchObjectsHandler(const Endpoint::Ptr& sender);
-       void RemoteObjectCommittedHandler(const Endpoint::Ptr& sender, const RequestMessage& request);
-       void RemoteObjectRemovedHandler(const RequestMessage& request);
-
-       static RequestMessage MakeObjectMessage(const ConfigObject::Ptr& object,
-           string method, bool includeProperties);
-
-       static bool ShouldReplicateObject(const ConfigObject::Ptr& object);
-};
-
-}
-
-#endif /* CONFIGRPCCOMPONENT_H */
diff --git a/components/configrpc/i2-configrpc.h b/components/configrpc/i2-configrpc.h
deleted file mode 100644 (file)
index fee0b75..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
-
-#ifndef I2CONFIGRPC_H
-#define I2CONFIGRPC_H
-
-/**
- * @defgroup configrpc ConfigRpc component
- *
- * The ConfigRpc component replicates configuration objects to other peers.
- */
-
-#include <i2-base.h>
-#include <i2-jsonrpc.h>
-#include <i2-icinga.h>
-
-#include "configrpccomponent.h"
-
-#endif /* I2CONFIGRPC_H */
index 27c47bb5aee73dcbc077ff5c284e5def12abd587..1678990d79a66457f722807a98b14617a74b8e5b 100644 (file)
@@ -72,7 +72,6 @@ components/checker/Makefile
 components/cibsync/Makefile
 components/compat/Makefile
 components/configfile/Makefile
-components/configrpc/Makefile
 components/delegation/Makefile
 components/demo/Makefile
 components/discovery/Makefile