mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 15:14:07 +02:00
GelfWriter: Ensure to join queue and execute queries on Pause/Shutdown/Reload
This commit is contained in:
parent
24c3572b03
commit
68e7027c93
@ -107,12 +107,26 @@ void GelfWriter::Resume()
|
|||||||
Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
|
Checkable::OnStateChange.connect(std::bind(&GelfWriter::StateChangeHandler, this, _1, _2, _3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Pause is equivalent to Stop, but with HA capabilities to resume at runtime. */
|
||||||
void GelfWriter::Pause()
|
void GelfWriter::Pause()
|
||||||
{
|
{
|
||||||
Log(LogInformation, "GelfWriter")
|
m_ReconnectTimer.reset();
|
||||||
<< "'" << GetName() << "' paused.";
|
|
||||||
|
try {
|
||||||
|
ReconnectInternal();
|
||||||
|
} catch (const std::exception&) {
|
||||||
|
Log(LogInformation, "GelfWriter")
|
||||||
|
<< "'" << GetName() << "' paused. Unable to connect, not flushing buffers. Data may be lost on reload.";
|
||||||
|
|
||||||
|
ObjectImpl<GelfWriter>::Pause();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_WorkQueue.Join();
|
m_WorkQueue.Join();
|
||||||
|
DisconnectInternal();
|
||||||
|
|
||||||
|
Log(LogInformation, "GraphiteWriter")
|
||||||
|
<< "'" << GetName() << "' paused.";
|
||||||
|
|
||||||
ObjectImpl<GelfWriter>::Pause();
|
ObjectImpl<GelfWriter>::Pause();
|
||||||
}
|
}
|
||||||
@ -145,6 +159,11 @@ void GelfWriter::Reconnect()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReconnectInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GelfWriter::ReconnectInternal()
|
||||||
|
{
|
||||||
double startTime = Utility::GetTime();
|
double startTime = Utility::GetTime();
|
||||||
|
|
||||||
CONTEXT("Reconnecting to Graylog Gelf '" + GetName() + "'");
|
CONTEXT("Reconnecting to Graylog Gelf '" + GetName() + "'");
|
||||||
@ -184,6 +203,11 @@ void GelfWriter::Disconnect()
|
|||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
|
||||||
|
DisconnectInternal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GelfWriter::DisconnectInternal()
|
||||||
|
{
|
||||||
if (!GetConnected())
|
if (!GetConnected())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -72,7 +72,9 @@ private:
|
|||||||
void ReconnectTimerHandler();
|
void ReconnectTimerHandler();
|
||||||
|
|
||||||
void Disconnect();
|
void Disconnect();
|
||||||
|
void DisconnectInternal();
|
||||||
void Reconnect();
|
void Reconnect();
|
||||||
|
void ReconnectInternal();
|
||||||
|
|
||||||
void AssertOnWorkQueue();
|
void AssertOnWorkQueue();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user