]> granicus.if.org Git - icinga2/commitdiff
Move cluster endpoint/jsonrpc functionality into libremote.
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 7 Mar 2014 16:40:10 +0000 (17:40 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Thu, 20 Mar 2014 17:03:47 +0000 (18:03 +0100)
Refs #5690
Refs #5636

15 files changed:
components/cluster/CMakeLists.txt
components/cluster/cluster-type.conf
components/cluster/clusterchecktask.cpp
components/cluster/clusterlistener.cpp
components/cluster/clusterlistener.h
lib/CMakeLists.txt
lib/db_ido/dbobject.cpp
lib/db_ido/endpointdbobject.h
lib/remote/CMakeLists.txt [new file with mode: 0644]
lib/remote/endpoint.cpp [moved from components/cluster/endpoint.cpp with 87% similarity]
lib/remote/endpoint.h [moved from components/cluster/endpoint.h with 98% similarity]
lib/remote/endpoint.ti [moved from components/cluster/endpoint.ti with 100% similarity]
lib/remote/jsonrpc.cpp [moved from components/cluster/jsonrpc.cpp with 98% similarity]
lib/remote/jsonrpc.h [moved from components/cluster/jsonrpc.h with 98% similarity]
lib/remote/remote-type.conf [new file with mode: 0644]

index 883d50aac6de79ecadc6069301ad6643720fc1f3..387873957559a9fe38a2d577b62b3c5b288a0c04 100644 (file)
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
 mkclass_target(clusterlistener.ti clusterlistener.th)
-mkclass_target(endpoint.ti endpoint.th)
 
 mkembedconfig_target(cluster-type.conf cluster-type.cpp)
 
 add_library(cluster SHARED
   clusterchecktask.cpp clusterlistener.cpp clusterlistener.th
-  endpoint.cpp endpoint.th jsonrpc.cpp cluster-type.cpp
+  cluster-type.cpp
 )
 
-target_link_libraries(cluster ${Boost_LIBRARIES} base config icinga)
+target_link_libraries(cluster ${Boost_LIBRARIES} base config icinga remote)
 
 set_target_properties (
   cluster PROPERTIES
index 127927c71a38725e7aa2de5f965b671fb29bafc9..71497cb2c5b73d7c0056b242ef12aa6d9f5e180b 100644 (file)
@@ -36,27 +36,3 @@ type ClusterListener {
                %attribute name(Endpoint) "*"
        }
 }
-
-type Endpoint {
-       %require "host",
-       %attribute string "host",
-
-       %require "port",
-       %attribute string "port",
-
-       %attribute array "config_files" {
-               %attribute string "*"
-       },
-
-       %attribute array "config_files_recursive" {
-               %attribute string "*",
-               %attribute dictionary "*" {
-                       %attribute string "path",
-                       %attribute string "pattern"
-               }
-       },
-
-       %attribute array "accept_config" {
-               %attribute name(Endpoint) "*"
-       }
-}
index 0404cc00f8893ca384db9ebcaf43c771d0a1c508..2d0dc65bb4a29874374487128878fa92c249b23f 100644 (file)
@@ -18,8 +18,8 @@
  ******************************************************************************/
 
 #include "cluster/clusterchecktask.h"
-#include "cluster/endpoint.h"
 #include "cluster/clusterlistener.h"
+#include "remote/endpoint.h"
 #include "icinga/cib.h"
 #include "icinga/service.h"
 #include "icinga/icingaapplication.h"
index bcb707e3b4c203d956a76b7da903529ae8ed4628..f3d771c292505ffa2c92cae429fbaeba5588c86a 100644 (file)
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "cluster/clusterlistener.h"
-#include "cluster/endpoint.h"
+#include "remote/endpoint.h"
 #include "icinga/cib.h"
 #include "icinga/domain.h"
 #include "icinga/icingaapplication.h"
index e1d5eb34174a1b2314ef32dcb5c34a510f1faaa1..1691e7290fcc1b0ea9fd895c85f6096a819ae667 100644 (file)
@@ -31,7 +31,7 @@
 #include "base/stdiostream.h"
 #include "base/workqueue.h"
 #include "icinga/service.h"
-#include "cluster/endpoint.h"
+#include "remote/endpoint.h"
 
 namespace icinga
 {
index 2945e539a62997b73a9fadae8de6491b84d9935c..9a70c2377e3c706942f82b468c5ba50536205673 100644 (file)
@@ -21,3 +21,4 @@ add_subdirectory(icinga)
 add_subdirectory(db_ido)
 add_subdirectory(methods)
 add_subdirectory(hello)
+add_subdirectory(remote)
index f20f731a3301490726094c334fe7698ca11fd747..ab6280d180e18a19cb5410df250023b5a7cf2124 100644 (file)
@@ -21,7 +21,7 @@
 #include "db_ido/dbtype.h"
 #include "db_ido/dbvalue.h"
 #include "icinga/service.h"
-#include "cluster/endpoint.h"
+#include "remote/endpoint.h"
 #include "base/dynamictype.h"
 #include "base/objectlock.h"
 #include "base/utility.h"
index a15a820a67fee646ba1a24a06a45a913e43bf8e9..3ada7dd43bd9e2e547ec090244f7df3e74e3a03d 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "db_ido/dbobject.h"
 #include "base/dynamicobject.h"
-#include "cluster/endpoint.h"
+#include "remote/endpoint.h"
 
 namespace icinga
 {
diff --git a/lib/remote/CMakeLists.txt b/lib/remote/CMakeLists.txt
new file mode 100644 (file)
index 0000000..d681ce9
--- /dev/null
@@ -0,0 +1,41 @@
+# Icinga 2
+# Copyright (C) 2012-present 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.
+
+mkclass_target(endpoint.ti endpoint.th)
+
+mkembedconfig_target(remote-type.conf remote-type.cpp)
+
+add_library(remote SHARED
+  endpoint.cpp endpoint.th jsonrpc.cpp remote-type.cpp
+)
+
+target_link_libraries(remote ${Boost_LIBRARIES} base config)
+
+set_target_properties (
+  icinga PROPERTIES
+  INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
+  DEFINE_SYMBOL I2_ICINGA_BUILD
+  FOLDER Lib
+)
+
+install(
+  TARGETS remote
+  RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
+)
+
+
similarity index 87%
rename from components/cluster/endpoint.cpp
rename to lib/remote/endpoint.cpp
index ba8bd378c8ef320600d5da4750dd9766c68f76b2..ca8ee4a8a7171d2c4ad88dddb141f0f9d0553eae 100644 (file)
@@ -17,8 +17,8 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include "cluster/endpoint.h"
-#include "cluster/jsonrpc.h"
+#include "remote/endpoint.h"
+#include "remote/jsonrpc.h"
 #include "base/application.h"
 #include "base/dynamictype.h"
 #include "base/objectlock.h"
@@ -62,10 +62,10 @@ void Endpoint::SetClient(const Stream::Ptr& client)
                thread.detach();
 
                OnConnected(GetSelf());
-               Log(LogWarning, "cluster", "Endpoint connected: " + GetName());
+               Log(LogWarning, "remote", "Endpoint connected: " + GetName());
        } else {
                OnDisconnected(GetSelf());
-               Log(LogWarning, "cluster", "Endpoint disconnected: " + GetName());
+               Log(LogWarning, "remote", "Endpoint disconnected: " + GetName());
        }
 }
 
@@ -81,12 +81,12 @@ void Endpoint::SendMessage(const Dictionary::Ptr& message)
        } catch (const std::exception& ex) {
                std::ostringstream msgbuf;
                msgbuf << "Error while sending JSON-RPC message for endpoint '" << GetName() << "': " << DiagnosticInformation(ex);
-               Log(LogWarning, "cluster", msgbuf.str());
+               Log(LogWarning, "remote", msgbuf.str());
 
                m_Client.reset();
 
                OnDisconnected(GetSelf());
-               Log(LogWarning, "cluster", "Endpoint disconnected: " + GetName());
+               Log(LogWarning, "remote", "Endpoint disconnected: " + GetName());
        }
 }
 
@@ -100,12 +100,12 @@ void Endpoint::MessageThreadProc(const Stream::Ptr& stream)
                try {
                        message = JsonRpc::ReadMessage(stream);
                } catch (const std::exception& ex) {
-                       Log(LogWarning, "cluster", "Error while reading JSON-RPC message for endpoint '" + GetName() + "': " + DiagnosticInformation(ex));
+                       Log(LogWarning, "remote", "Error while reading JSON-RPC message for endpoint '" + GetName() + "': " + DiagnosticInformation(ex));
 
                        m_Client.reset();
 
                        OnDisconnected(GetSelf());
-                       Log(LogWarning, "cluster", "Endpoint disconnected: " + GetName());
+                       Log(LogWarning, "remote", "Endpoint disconnected: " + GetName());
 
                        return;
                }
similarity index 98%
rename from components/cluster/endpoint.h
rename to lib/remote/endpoint.h
index 97f369a5e5d97226dd93e74355be8f2a6070faad..2206cb9276238516a2e78b8cabd818f92d7f80c5 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef ENDPOINT_H
 #define ENDPOINT_H
 
-#include "cluster/endpoint.th"
+#include "remote/endpoint.th"
 #include "base/stream.h"
 #include "base/array.h"
 #include <boost/signals2.hpp>
similarity index 98%
rename from components/cluster/jsonrpc.cpp
rename to lib/remote/jsonrpc.cpp
index 2eabf2df8b12472c6613abdba0ef9c996e3825d7..1a3788ea5e7574ae09146a92cb49c612c54445c9 100644 (file)
@@ -17,7 +17,7 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
-#include "cluster/jsonrpc.h"
+#include "remote/jsonrpc.h"
 #include "base/netstring.h"
 #include "base/objectlock.h"
 #include "base/logger_fwd.h"
similarity index 98%
rename from components/cluster/jsonrpc.h
rename to lib/remote/jsonrpc.h
index 61bd974b272cd128a32800eef74ef002c57a00ac..6a44e4005773412bf00955cd8953675007461f3f 100644 (file)
@@ -29,7 +29,7 @@ namespace icinga
 /**
  * A JSON-RPC connection.
  *
- * @ingroup cluster
+ * @ingroup remote
  */
 class JsonRpc
 {
diff --git a/lib/remote/remote-type.conf b/lib/remote/remote-type.conf
new file mode 100644 (file)
index 0000000..3753029
--- /dev/null
@@ -0,0 +1,42 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012-present 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.             *
+ ******************************************************************************/
+
+type Endpoint {
+       %require "host",
+       %attribute string "host",
+
+       %require "port",
+       %attribute string "port",
+
+       %attribute array "config_files" {
+               %attribute string "*"
+       },
+
+       %attribute array "config_files_recursive" {
+               %attribute string "*",
+               %attribute dictionary "*" {
+                       %attribute string "path",
+                       %attribute string "pattern"
+               }
+       },
+
+       %attribute array "accept_config" {
+               %attribute name(Endpoint) "*"
+       }
+}