mirror of https://github.com/Icinga/icinga2.git
parent
93834623a0
commit
91e1e9d93e
|
@ -48,7 +48,7 @@ REGISTER_STATSFUNCTION(ApiListener, &ApiListener::StatsFunc);
|
||||||
REGISTER_APIFUNCTION(Hello, icinga, &ApiListener::HelloAPIHandler);
|
REGISTER_APIFUNCTION(Hello, icinga, &ApiListener::HelloAPIHandler);
|
||||||
|
|
||||||
ApiListener::ApiListener(void)
|
ApiListener::ApiListener(void)
|
||||||
: m_LogMessageCount(0)
|
: m_SyncQueue(0, 4), m_LogMessageCount(0)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
void ApiListener::OnConfigLoaded(void)
|
void ApiListener::OnConfigLoaded(void)
|
||||||
|
@ -373,7 +373,22 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
|
||||||
if (endpoint) {
|
if (endpoint) {
|
||||||
endpoint->AddClient(aclient);
|
endpoint->AddClient(aclient);
|
||||||
|
|
||||||
if (need_sync) {
|
if (need_sync)
|
||||||
|
m_SyncQueue.Enqueue(boost::bind(&ApiListener::SyncClient, this, aclient, endpoint));
|
||||||
|
} else
|
||||||
|
AddAnonymousClient(aclient);
|
||||||
|
} else {
|
||||||
|
Log(LogNotice, "ApiListener", "New HTTP client");
|
||||||
|
|
||||||
|
HttpServerConnection::Ptr aclient = new HttpServerConnection(identity, verify_ok, tlsStream);
|
||||||
|
aclient->Start();
|
||||||
|
AddHttpClient(aclient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint)
|
||||||
|
{
|
||||||
|
try {
|
||||||
{
|
{
|
||||||
ObjectLock olock(endpoint);
|
ObjectLock olock(endpoint);
|
||||||
|
|
||||||
|
@ -392,15 +407,9 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
|
||||||
<< "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";
|
<< "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";
|
||||||
|
|
||||||
ReplayLog(aclient);
|
ReplayLog(aclient);
|
||||||
}
|
} catch (const std::exception& ex) {
|
||||||
} else
|
Log(LogCritical, "ApiListener")
|
||||||
AddAnonymousClient(aclient);
|
<< "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
|
||||||
} else {
|
|
||||||
Log(LogNotice, "ApiListener", "New HTTP client");
|
|
||||||
|
|
||||||
HttpServerConnection::Ptr aclient = new HttpServerConnection(identity, verify_ok, tlsStream);
|
|
||||||
aclient->Start();
|
|
||||||
AddHttpClient(aclient);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ private:
|
||||||
void ListenerThreadProc(const Socket::Ptr& server);
|
void ListenerThreadProc(const Socket::Ptr& server);
|
||||||
|
|
||||||
WorkQueue m_RelayQueue;
|
WorkQueue m_RelayQueue;
|
||||||
|
WorkQueue m_SyncQueue;
|
||||||
|
|
||||||
boost::mutex m_LogLock;
|
boost::mutex m_LogLock;
|
||||||
Stream::Ptr m_LogFile;
|
Stream::Ptr m_LogFile;
|
||||||
|
@ -143,6 +144,8 @@ private:
|
||||||
void DeleteConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,
|
void DeleteConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,
|
||||||
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
|
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
|
||||||
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
|
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
|
||||||
|
|
||||||
|
void SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,6 @@ void JsonRpcConnection::HeartbeatTimerHandler(void)
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
|
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
|
||||||
BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
|
BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
|
||||||
if (endpoint->GetSyncing()) {
|
|
||||||
Log(LogInformation, "JsonRpcConnection")
|
|
||||||
<< "Not sending heartbeat for endpoint '" << endpoint->GetName() << "' because we're replaying the log for it.";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client->m_NextHeartbeat != 0 && client->m_NextHeartbeat < Utility::GetTime()) {
|
if (client->m_NextHeartbeat != 0 && client->m_NextHeartbeat < Utility::GetTime()) {
|
||||||
Log(LogWarning, "JsonRpcConnection")
|
Log(LogWarning, "JsonRpcConnection")
|
||||||
<< "Client for endpoint '" << endpoint->GetName() << "' has requested "
|
<< "Client for endpoint '" << endpoint->GetName() << "' has requested "
|
||||||
|
|
Loading…
Reference in New Issue