mirror of https://github.com/Icinga/icinga2.git
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.
|
||||
|
||||
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
|
||||
|
|
|
@ -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) "*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -21,3 +21,4 @@ add_subdirectory(icinga)
|
|||
add_subdirectory(db_ido)
|
||||
add_subdirectory(methods)
|
||||
add_subdirectory(hello)
|
||||
add_subdirectory(remote)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "db_ido/dbobject.h"
|
||||
#include "base/dynamicobject.h"
|
||||
#include "cluster/endpoint.h"
|
||||
#include "remote/endpoint.h"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -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. *
|
||||
******************************************************************************/
|
||||
|
||||
#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;
|
||||
}
|
|
@ -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>
|
|
@ -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"
|
|
@ -29,7 +29,7 @@ namespace icinga
|
|||
/**
|
||||
* A JSON-RPC connection.
|
||||
*
|
||||
* @ingroup cluster
|
||||
* @ingroup remote
|
||||
*/
|
||||
class JsonRpc
|
||||
{
|
|
@ -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…
Reference in New Issue