Add downtime handlers to state sync

This commit is contained in:
Noah Hilverling 2018-11-30 09:28:20 +01:00 committed by Michael Friedrich
parent af05a354fa
commit 2202bde56c
2 changed files with 15 additions and 0 deletions

View File

@ -57,6 +57,13 @@ void RedisWriter::ConfigStaticInitialize()
/* triggered on create, update and delete objects */
ConfigObject::OnActiveChanged.connect(std::bind(&RedisWriter::VersionChangedHandler, _1));
ConfigObject::OnVersionChanged.connect(std::bind(&RedisWriter::VersionChangedHandler, _1));
/* fixed downtime start */
Downtime::OnDowntimeStarted.connect(std::bind(&RedisWriter::DowntimeChangedHandler, _1));
/* flexible downtime start */
Downtime::OnDowntimeTriggered.connect(std::bind(&RedisWriter::DowntimeChangedHandler, _1));
/* fixed/flexible downtime end */
Downtime::OnDowntimeRemoved.connect(std::bind(&RedisWriter::DowntimeChangedHandler, _1));
}
void RedisWriter::UpdateAllConfigObjects()
@ -771,3 +778,9 @@ void RedisWriter::VersionChangedHandler(const ConfigObject::Ptr& object)
}
}
}
void RedisWriter::DowntimeChangedHandler(const Downtime::Ptr& downtime)
{
Log(LogCritical, "Downtime", "Downtime sync got triggered");
StateChangeHandler(downtime->GetCheckable());
}

View File

@ -27,6 +27,7 @@
#include "base/workqueue.hpp"
#include "redis/redisconnection.hpp"
#include "icinga/checkable.hpp"
#include "icinga/downtime.hpp"
#include <hiredis/hiredis.h>
namespace icinga
@ -101,6 +102,7 @@ private:
static void StateChangeHandler(const ConfigObject::Ptr &object);
static void VersionChangedHandler(const ConfigObject::Ptr& object);
static void DowntimeChangedHandler(const Downtime::Ptr& downtime);
void AssertOnWorkQueue();