mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-26 11:08:51 +02:00
ApiListener#ReplayLog(): replay messages from SQLite
This commit is contained in:
parent
345e323481
commit
7a48bb856b
@ -1565,16 +1565,50 @@ void ApiListener::ReplayLog(const JsonRpcConnection::Ptr& client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (last_sync) {
|
if (last_sync) {
|
||||||
{
|
|
||||||
ObjectLock olock2(endpoint);
|
|
||||||
endpoint->SetSyncing(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenLogFile();
|
OpenLogFile();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log(LogNotice, "ApiListener")
|
||||||
|
<< "Replaying log.";
|
||||||
|
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
for (auto& message : endpoint->GetReplayLog()) {
|
||||||
|
try {
|
||||||
|
client->SendRawMessage(message.second);
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "ApiListener")
|
||||||
|
<< "Error while replaying log for endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex, false);
|
||||||
|
|
||||||
|
Log(LogDebug, "ApiListener")
|
||||||
|
<< "Error while replaying log for endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
++count;
|
||||||
|
|
||||||
|
if (message.first > logpos_ts + 10) {
|
||||||
|
logpos_ts = message.first;
|
||||||
|
|
||||||
|
client->SendMessage(new Dictionary({
|
||||||
|
{ "jsonrpc", "2.0" },
|
||||||
|
{ "method", "log::SetLogPosition" },
|
||||||
|
{ "params", new Dictionary({
|
||||||
|
{ "log_position", logpos_ts }
|
||||||
|
}) }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Log(count > 0u ? LogInformation : LogNotice, "ApiListener")
|
||||||
|
<< "Replayed " << count << " messages.";
|
||||||
|
|
||||||
|
ObjectLock olock2(endpoint);
|
||||||
|
endpoint->SetSyncing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApiListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
void ApiListener::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user