mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 13:45:04 +02:00
Move cluster endpoint/jsonrpc functionality into libremote.
Refs #5690 Refs #5636
This commit is contained in:
parent
0264e52211
commit
ea973e5c82
@ -16,16 +16,15 @@
|
|||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
mkclass_target(clusterlistener.ti clusterlistener.th)
|
mkclass_target(clusterlistener.ti clusterlistener.th)
|
||||||
mkclass_target(endpoint.ti endpoint.th)
|
|
||||||
|
|
||||||
mkembedconfig_target(cluster-type.conf cluster-type.cpp)
|
mkembedconfig_target(cluster-type.conf cluster-type.cpp)
|
||||||
|
|
||||||
add_library(cluster SHARED
|
add_library(cluster SHARED
|
||||||
clusterchecktask.cpp clusterlistener.cpp clusterlistener.th
|
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 (
|
set_target_properties (
|
||||||
cluster PROPERTIES
|
cluster PROPERTIES
|
||||||
|
@ -36,27 +36,3 @@ type ClusterListener {
|
|||||||
%attribute name(Endpoint) "*"
|
%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) "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "cluster/clusterchecktask.h"
|
#include "cluster/clusterchecktask.h"
|
||||||
#include "cluster/endpoint.h"
|
|
||||||
#include "cluster/clusterlistener.h"
|
#include "cluster/clusterlistener.h"
|
||||||
|
#include "remote/endpoint.h"
|
||||||
#include "icinga/cib.h"
|
#include "icinga/cib.h"
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
#include "icinga/icingaapplication.h"
|
#include "icinga/icingaapplication.h"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "cluster/clusterlistener.h"
|
#include "cluster/clusterlistener.h"
|
||||||
#include "cluster/endpoint.h"
|
#include "remote/endpoint.h"
|
||||||
#include "icinga/cib.h"
|
#include "icinga/cib.h"
|
||||||
#include "icinga/domain.h"
|
#include "icinga/domain.h"
|
||||||
#include "icinga/icingaapplication.h"
|
#include "icinga/icingaapplication.h"
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "base/stdiostream.h"
|
#include "base/stdiostream.h"
|
||||||
#include "base/workqueue.h"
|
#include "base/workqueue.h"
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
#include "cluster/endpoint.h"
|
#include "remote/endpoint.h"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
@ -21,3 +21,4 @@ add_subdirectory(icinga)
|
|||||||
add_subdirectory(db_ido)
|
add_subdirectory(db_ido)
|
||||||
add_subdirectory(methods)
|
add_subdirectory(methods)
|
||||||
add_subdirectory(hello)
|
add_subdirectory(hello)
|
||||||
|
add_subdirectory(remote)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "db_ido/dbtype.h"
|
#include "db_ido/dbtype.h"
|
||||||
#include "db_ido/dbvalue.h"
|
#include "db_ido/dbvalue.h"
|
||||||
#include "icinga/service.h"
|
#include "icinga/service.h"
|
||||||
#include "cluster/endpoint.h"
|
#include "remote/endpoint.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "db_ido/dbobject.h"
|
#include "db_ido/dbobject.h"
|
||||||
#include "base/dynamicobject.h"
|
#include "base/dynamicobject.h"
|
||||||
#include "cluster/endpoint.h"
|
#include "remote/endpoint.h"
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
41
lib/remote/CMakeLists.txt
Normal file
41
lib/remote/CMakeLists.txt
Normal file
@ -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
|
||||||
|
)
|
||||||
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "cluster/endpoint.h"
|
#include "remote/endpoint.h"
|
||||||
#include "cluster/jsonrpc.h"
|
#include "remote/jsonrpc.h"
|
||||||
#include "base/application.h"
|
#include "base/application.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
@ -62,10 +62,10 @@ void Endpoint::SetClient(const Stream::Ptr& client)
|
|||||||
thread.detach();
|
thread.detach();
|
||||||
|
|
||||||
OnConnected(GetSelf());
|
OnConnected(GetSelf());
|
||||||
Log(LogWarning, "cluster", "Endpoint connected: " + GetName());
|
Log(LogWarning, "remote", "Endpoint connected: " + GetName());
|
||||||
} else {
|
} else {
|
||||||
OnDisconnected(GetSelf());
|
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) {
|
} catch (const std::exception& ex) {
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "Error while sending JSON-RPC message for endpoint '" << GetName() << "': " << DiagnosticInformation(ex);
|
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();
|
m_Client.reset();
|
||||||
|
|
||||||
OnDisconnected(GetSelf());
|
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 {
|
try {
|
||||||
message = JsonRpc::ReadMessage(stream);
|
message = JsonRpc::ReadMessage(stream);
|
||||||
} catch (const std::exception& ex) {
|
} 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();
|
m_Client.reset();
|
||||||
|
|
||||||
OnDisconnected(GetSelf());
|
OnDisconnected(GetSelf());
|
||||||
Log(LogWarning, "cluster", "Endpoint disconnected: " + GetName());
|
Log(LogWarning, "remote", "Endpoint disconnected: " + GetName());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef ENDPOINT_H
|
#ifndef ENDPOINT_H
|
||||||
#define ENDPOINT_H
|
#define ENDPOINT_H
|
||||||
|
|
||||||
#include "cluster/endpoint.th"
|
#include "remote/endpoint.th"
|
||||||
#include "base/stream.h"
|
#include "base/stream.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
@ -17,7 +17,7 @@
|
|||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
* 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/netstring.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/logger_fwd.h"
|
#include "base/logger_fwd.h"
|
@ -29,7 +29,7 @@ namespace icinga
|
|||||||
/**
|
/**
|
||||||
* A JSON-RPC connection.
|
* A JSON-RPC connection.
|
||||||
*
|
*
|
||||||
* @ingroup cluster
|
* @ingroup remote
|
||||||
*/
|
*/
|
||||||
class JsonRpc
|
class JsonRpc
|
||||||
{
|
{
|
42
lib/remote/remote-type.conf
Normal file
42
lib/remote/remote-type.conf
Normal file
@ -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) "*"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user