git ls-files -z |xargs -0 perl -pi -e 's/RedisWriter/IcingaDB/g'

This commit is contained in:
Alexander Aleksandrovič Klimov 2019-10-29 17:32:29 +01:00 committed by Michael Friedrich
parent c7e9997294
commit f51454af65
9 changed files with 129 additions and 129 deletions

View File

@ -7,7 +7,7 @@
library "redis" library "redis"
object RedisWriter "redis" { object IcingaDB "redis" {
//host = "127.0.0.1" //host = "127.0.0.1"
//port = 6379 //port = 6379
//password = "xxx" //password = "xxx"

View File

@ -249,7 +249,7 @@ std::set<UserGroup::Ptr> CompatUtility::GetCheckableNotificationUserGroups(const
return usergroups; return usergroups;
} }
/* Used in DB IDO, StatusDataWriter, Livestatus, CompatLogger, GelfWriter, RedisWriter. */ /* Used in DB IDO, StatusDataWriter, Livestatus, CompatLogger, GelfWriter, IcingaDB. */
String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr) String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
{ {
if (!cr) if (!cr)
@ -264,7 +264,7 @@ String CompatUtility::GetCheckResultOutput(const CheckResult::Ptr& cr)
return raw_output.SubStr(0, line_end); return raw_output.SubStr(0, line_end);
} }
/* Used in DB IDO, StatusDataWriter and Livestatus, RedisWriter. */ /* Used in DB IDO, StatusDataWriter and Livestatus, IcingaDB. */
String CompatUtility::GetCheckResultLongOutput(const CheckResult::Ptr& cr) String CompatUtility::GetCheckResultLongOutput(const CheckResult::Ptr& cr)
{ {
if (!cr) if (!cr)

View File

@ -88,7 +88,7 @@ void LogQuery(RedisConnection::Query& query, Log& msg)
void RedisConnection::FireAndForgetQuery(RedisConnection::Query query) void RedisConnection::FireAndForgetQuery(RedisConnection::Query query)
{ {
{ {
Log msg (LogNotice, "RedisWriter", "Firing and forgetting query:"); Log msg (LogNotice, "IcingaDB", "Firing and forgetting query:");
LogQuery(query, msg); LogQuery(query, msg);
} }
@ -103,7 +103,7 @@ void RedisConnection::FireAndForgetQuery(RedisConnection::Query query)
void RedisConnection::FireAndForgetQueries(RedisConnection::Queries queries) void RedisConnection::FireAndForgetQueries(RedisConnection::Queries queries)
{ {
for (auto& query : queries) { for (auto& query : queries) {
Log msg (LogNotice, "RedisWriter", "Firing and forgetting query:"); Log msg (LogNotice, "IcingaDB", "Firing and forgetting query:");
LogQuery(query, msg); LogQuery(query, msg);
} }
@ -118,7 +118,7 @@ void RedisConnection::FireAndForgetQueries(RedisConnection::Queries queries)
RedisConnection::Reply RedisConnection::GetResultOfQuery(RedisConnection::Query query) RedisConnection::Reply RedisConnection::GetResultOfQuery(RedisConnection::Query query)
{ {
{ {
Log msg (LogNotice, "RedisWriter", "Executing query:"); Log msg (LogNotice, "IcingaDB", "Executing query:");
LogQuery(query, msg); LogQuery(query, msg);
} }
@ -139,7 +139,7 @@ RedisConnection::Reply RedisConnection::GetResultOfQuery(RedisConnection::Query
RedisConnection::Replies RedisConnection::GetResultsOfQueries(RedisConnection::Queries queries) RedisConnection::Replies RedisConnection::GetResultsOfQueries(RedisConnection::Queries queries)
{ {
for (auto& query : queries) { for (auto& query : queries) {
Log msg (LogNotice, "RedisWriter", "Executing query:"); Log msg (LogNotice, "IcingaDB", "Executing query:");
LogQuery(query, msg); LogQuery(query, msg);
} }
@ -161,7 +161,7 @@ void RedisConnection::Connect(asio::yield_context& yc)
{ {
Defer notConnecting ([this]() { m_Connecting.store(m_Connected.load()); }); Defer notConnecting ([this]() { m_Connecting.store(m_Connected.load()); });
Log(LogInformation, "RedisWriter", "Trying to connect to Redis server (async)"); Log(LogInformation, "IcingaDB", "Trying to connect to Redis server (async)");
try { try {
if (m_Path.IsEmpty()) { if (m_Path.IsEmpty()) {
@ -176,11 +176,11 @@ void RedisConnection::Connect(asio::yield_context& yc)
m_Connected.store(true); m_Connected.store(true);
Log(LogInformation, "RedisWriter", "Connected to Redis server"); Log(LogInformation, "IcingaDB", "Connected to Redis server");
} catch (const boost::coroutines::detail::forced_unwind&) { } catch (const boost::coroutines::detail::forced_unwind&) {
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log(LogCritical, "RedisWriter") Log(LogCritical, "IcingaDB")
<< "Cannot connect to " << m_Host << ":" << m_Port << ": " << ex.what(); << "Cannot connect to " << m_Host << ":" << m_Port << ": " << ex.what();
} }
} }
@ -203,11 +203,11 @@ void RedisConnection::ReadLoop(asio::yield_context& yc)
} catch (const boost::coroutines::detail::forced_unwind&) { } catch (const boost::coroutines::detail::forced_unwind&) {
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log(LogCritical, "RedisWriter") Log(LogCritical, "IcingaDB")
<< "Error during receiving the response to a query which has been fired and forgotten: " << ex.what(); << "Error during receiving the response to a query which has been fired and forgotten: " << ex.what();
continue; continue;
} catch (...) { } catch (...) {
Log(LogCritical, "RedisWriter") Log(LogCritical, "IcingaDB")
<< "Error during receiving the response to a query which has been fired and forgotten"; << "Error during receiving the response to a query which has been fired and forgotten";
continue; continue;
} }
@ -276,12 +276,12 @@ void RedisConnection::WriteLoop(asio::yield_context& yc)
} catch (const boost::coroutines::detail::forced_unwind&) { } catch (const boost::coroutines::detail::forced_unwind&) {
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log msg (LogCritical, "RedisWriter", "Error during sending query"); Log msg (LogCritical, "IcingaDB", "Error during sending query");
LogQuery(item, msg); LogQuery(item, msg);
msg << " which has been fired and forgotten: " << ex.what(); msg << " which has been fired and forgotten: " << ex.what();
continue; continue;
} catch (...) { } catch (...) {
Log msg (LogCritical, "RedisWriter", "Error during sending query"); Log msg (LogCritical, "IcingaDB", "Error during sending query");
LogQuery(item, msg); LogQuery(item, msg);
msg << " which has been fired and forgotten"; msg << " which has been fired and forgotten";
continue; continue;
@ -308,12 +308,12 @@ void RedisConnection::WriteLoop(asio::yield_context& yc)
} catch (const boost::coroutines::detail::forced_unwind&) { } catch (const boost::coroutines::detail::forced_unwind&) {
throw; throw;
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log msg (LogCritical, "RedisWriter", "Error during sending query"); Log msg (LogCritical, "IcingaDB", "Error during sending query");
LogQuery(item[i], msg); LogQuery(item[i], msg);
msg << " which has been fired and forgotten: " << ex.what(); msg << " which has been fired and forgotten: " << ex.what();
continue; continue;
} catch (...) { } catch (...) {
Log msg (LogCritical, "RedisWriter", "Error during sending query"); Log msg (LogCritical, "IcingaDB", "Error during sending query");
LogQuery(item[i], msg); LogQuery(item[i], msg);
msg << " which has been fired and forgotten"; msg << " which has been fired and forgotten";
continue; continue;

View File

@ -65,49 +65,49 @@ return id
)EOF"; )EOF";
INITIALIZE_ONCE(&RedisWriter::ConfigStaticInitialize); INITIALIZE_ONCE(&IcingaDB::ConfigStaticInitialize);
void RedisWriter::ConfigStaticInitialize() void IcingaDB::ConfigStaticInitialize()
{ {
/* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */ /* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */
Checkable::OnStateChange.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type, const MessageOrigin::Ptr&) { Checkable::OnStateChange.connect([](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type, const MessageOrigin::Ptr&) {
RedisWriter::StateChangeHandler(checkable, cr, type); IcingaDB::StateChangeHandler(checkable, cr, type);
}); });
/* triggered when acknowledged host/service goes back to ok and when the acknowledgement gets deleted */ /* triggered when acknowledged host/service goes back to ok and when the acknowledgement gets deleted */
Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const MessageOrigin::Ptr&) { Checkable::OnAcknowledgementCleared.connect([](const Checkable::Ptr& checkable, const MessageOrigin::Ptr&) {
RedisWriter::StateChangeHandler(checkable); IcingaDB::StateChangeHandler(checkable);
}); });
/* triggered on create, update and delete objects */ /* triggered on create, update and delete objects */
ConfigObject::OnActiveChanged.connect([](const ConfigObject::Ptr& object, const Value&) { ConfigObject::OnActiveChanged.connect([](const ConfigObject::Ptr& object, const Value&) {
RedisWriter::VersionChangedHandler(object); IcingaDB::VersionChangedHandler(object);
}); });
ConfigObject::OnVersionChanged.connect([](const ConfigObject::Ptr& object, const Value&) { ConfigObject::OnVersionChanged.connect([](const ConfigObject::Ptr& object, const Value&) {
RedisWriter::VersionChangedHandler(object); IcingaDB::VersionChangedHandler(object);
}); });
/* fixed/flexible downtime add */ /* fixed/flexible downtime add */
Downtime::OnDowntimeAdded.connect(&RedisWriter::DowntimeAddedHandler); Downtime::OnDowntimeAdded.connect(&IcingaDB::DowntimeAddedHandler);
/* fixed downtime start */ /* fixed downtime start */
Downtime::OnDowntimeStarted.connect(&RedisWriter::DowntimeStartedHandler); Downtime::OnDowntimeStarted.connect(&IcingaDB::DowntimeStartedHandler);
/* flexible downtime start */ /* flexible downtime start */
Downtime::OnDowntimeTriggered.connect(&RedisWriter::DowntimeStartedHandler); Downtime::OnDowntimeTriggered.connect(&IcingaDB::DowntimeStartedHandler);
/* fixed/flexible downtime end or remove */ /* fixed/flexible downtime end or remove */
Downtime::OnDowntimeRemoved.connect(&RedisWriter::DowntimeRemovedHandler); Downtime::OnDowntimeRemoved.connect(&IcingaDB::DowntimeRemovedHandler);
Checkable::OnNotificationSentToAllUsers.connect([]( Checkable::OnNotificationSentToAllUsers.connect([](
const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
const NotificationType& type, const CheckResult::Ptr& cr, const String& author, const String& text, const NotificationType& type, const CheckResult::Ptr& cr, const String& author, const String& text,
const MessageOrigin::Ptr& const MessageOrigin::Ptr&
) { ) {
RedisWriter::NotificationSentToAllUsersHandler(notification, checkable, users, type, cr, author, text); IcingaDB::NotificationSentToAllUsersHandler(notification, checkable, users, type, cr, author, text);
}); });
Comment::OnCommentAdded.connect(&RedisWriter::CommentAddedHandler); Comment::OnCommentAdded.connect(&IcingaDB::CommentAddedHandler);
Comment::OnCommentRemoved.connect(&RedisWriter::CommentRemovedHandler); Comment::OnCommentRemoved.connect(&IcingaDB::CommentRemovedHandler);
Checkable::OnFlappingChanged.connect(&RedisWriter::FlappingChangedHandler); Checkable::OnFlappingChanged.connect(&IcingaDB::FlappingChangedHandler);
} }
static std::pair<String, String> SplitOutput(String output) static std::pair<String, String> SplitOutput(String output)
@ -123,13 +123,13 @@ static std::pair<String, String> SplitOutput(String output)
return {std::move(output), std::move(longOutput)}; return {std::move(output), std::move(longOutput)};
} }
void RedisWriter::UpdateAllConfigObjects() void IcingaDB::UpdateAllConfigObjects()
{ {
double startTime = Utility::GetTime(); double startTime = Utility::GetTime();
// Use a Workqueue to pack objects in parallel // Use a Workqueue to pack objects in parallel
WorkQueue upq(25000, Configuration::Concurrency); WorkQueue upq(25000, Configuration::Concurrency);
upq.SetName("RedisWriter:ConfigDump"); upq.SetName("IcingaDB:ConfigDump");
typedef std::pair<ConfigType *, String> TypePair; typedef std::pair<ConfigType *, String> TypePair;
std::vector<TypePair> types; std::vector<TypePair> types;
@ -162,7 +162,7 @@ void RedisWriter::UpdateAllConfigObjects()
auto objectChunks (ChunkObjects(type.first->GetObjects(), 500)); auto objectChunks (ChunkObjects(type.first->GetObjects(), 500));
WorkQueue upqObjectType(25000, Configuration::Concurrency); WorkQueue upqObjectType(25000, Configuration::Concurrency);
upqObjectType.SetName("RedisWriter:ConfigDump:" + lcType); upqObjectType.SetName("IcingaDB:ConfigDump:" + lcType);
upqObjectType.ParallelFor(objectChunks, [this, &type, &lcType](decltype(objectChunks)::const_reference chunk) { upqObjectType.ParallelFor(objectChunks, [this, &type, &lcType](decltype(objectChunks)::const_reference chunk) {
std::map<String, std::vector<String>> hMSets, publishes; std::map<String, std::vector<String>> hMSets, publishes;
@ -250,7 +250,7 @@ void RedisWriter::UpdateAllConfigObjects()
m_Rcon->FireAndForgetQueries(std::move(transaction)); m_Rcon->FireAndForgetQueries(std::move(transaction));
} }
Log(LogNotice, "RedisWriter") Log(LogNotice, "IcingaDB")
<< "Dumped " << bulkCounter << " objects of type " << type.second; << "Dumped " << bulkCounter << " objects of type " << type.second;
}); });
@ -276,7 +276,7 @@ void RedisWriter::UpdateAllConfigObjects()
boost::rethrow_exception(exc); boost::rethrow_exception(exc);
} }
} catch(const std::exception& e) { } catch(const std::exception& e) {
Log(LogCritical, "RedisWriter") Log(LogCritical, "IcingaDB")
<< "Exception during ConfigDump: " << e.what(); << "Exception during ConfigDump: " << e.what();
} }
} }
@ -284,11 +284,11 @@ void RedisWriter::UpdateAllConfigObjects()
m_Rcon->FireAndForgetQuery({"XADD", "icinga:dump", "*", "type", "*", "state", "done"}); m_Rcon->FireAndForgetQuery({"XADD", "icinga:dump", "*", "type", "*", "state", "done"});
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "Initial config/status dump finished in " << Utility::GetTime() - startTime << " seconds."; << "Initial config/status dump finished in " << Utility::GetTime() - startTime << " seconds.";
} }
std::vector<std::vector<intrusive_ptr<ConfigObject>>> RedisWriter::ChunkObjects(std::vector<intrusive_ptr<ConfigObject>> objects, size_t chunkSize) { std::vector<std::vector<intrusive_ptr<ConfigObject>>> IcingaDB::ChunkObjects(std::vector<intrusive_ptr<ConfigObject>> objects, size_t chunkSize) {
std::vector<std::vector<intrusive_ptr<ConfigObject>>> chunks; std::vector<std::vector<intrusive_ptr<ConfigObject>>> chunks;
auto offset (objects.begin()); auto offset (objects.begin());
auto end (objects.end()); auto end (objects.end());
@ -308,7 +308,7 @@ std::vector<std::vector<intrusive_ptr<ConfigObject>>> RedisWriter::ChunkObjects(
return std::move(chunks); return std::move(chunks);
} }
void RedisWriter::DeleteKeys(const std::vector<String>& keys) { void IcingaDB::DeleteKeys(const std::vector<String>& keys) {
std::vector<String> query = {"DEL"}; std::vector<String> query = {"DEL"};
for (auto& key : keys) { for (auto& key : keys) {
query.emplace_back(key); query.emplace_back(key);
@ -317,7 +317,7 @@ void RedisWriter::DeleteKeys(const std::vector<String>& keys) {
m_Rcon->FireAndForgetQuery(std::move(query)); m_Rcon->FireAndForgetQuery(std::move(query));
} }
std::vector<String> RedisWriter::GetTypeObjectKeys(const String& type) std::vector<String> IcingaDB::GetTypeObjectKeys(const String& type)
{ {
std::vector<String> keys = { std::vector<String> keys = {
m_PrefixConfigObject + type, m_PrefixConfigObject + type,
@ -361,7 +361,7 @@ static ConfigObject::Ptr GetObjectByName(const String& name)
return ConfigObject::GetObject<ConfigType>(name); return ConfigObject::GetObject<ConfigType>(name);
} }
void RedisWriter::InsertObjectDependencies(const ConfigObject::Ptr& object, const String typeName, std::map<String, std::vector<String>>& hMSets, void IcingaDB::InsertObjectDependencies(const ConfigObject::Ptr& object, const String typeName, std::map<String, std::vector<String>>& hMSets,
std::map<String, std::vector<String>>& publishes, bool runtimeUpdate) std::map<String, std::vector<String>>& publishes, bool runtimeUpdate)
{ {
String objectKey = GetObjectIdentifier(object); String objectKey = GetObjectIdentifier(object);
@ -780,7 +780,7 @@ void RedisWriter::InsertObjectDependencies(const ConfigObject::Ptr& object, cons
} }
} }
void RedisWriter::UpdateState(const Checkable::Ptr& checkable) void IcingaDB::UpdateState(const Checkable::Ptr& checkable)
{ {
Dictionary::Ptr stateAttrs = SerializeState(checkable); Dictionary::Ptr stateAttrs = SerializeState(checkable);
@ -788,7 +788,7 @@ void RedisWriter::UpdateState(const Checkable::Ptr& checkable)
} }
// Used to update a single object, used for runtime updates // Used to update a single object, used for runtime updates
void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate) void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -836,7 +836,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtime
// Takes object and collects IcingaDB relevant attributes and computes checksums. Returns whether the object is relevant // Takes object and collects IcingaDB relevant attributes and computes checksums. Returns whether the object is relevant
// for IcingaDB. // for IcingaDB.
bool RedisWriter::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& attributes, Dictionary::Ptr& checksums) bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& attributes, Dictionary::Ptr& checksums)
{ {
attributes->Set("name_checksum", CalculateCheckSumString(object->GetName())); attributes->Set("name_checksum", CalculateCheckSumString(object->GetName()));
attributes->Set("environment_id", CalculateCheckSumString(GetEnvironment())); attributes->Set("environment_id", CalculateCheckSumString(GetEnvironment()));
@ -1093,7 +1093,7 @@ bool RedisWriter::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr
* icinga:config:object:downtime) need to be prepended. There is nothing to indicate success or failure. * icinga:config:object:downtime) need to be prepended. There is nothing to indicate success or failure.
*/ */
void void
RedisWriter::CreateConfigUpdate(const ConfigObject::Ptr& object, const String typeName, std::map<String, std::vector<String>>& hMSets, IcingaDB::CreateConfigUpdate(const ConfigObject::Ptr& object, const String typeName, std::map<String, std::vector<String>>& hMSets,
std::map<String, std::vector<String>>& publishes, bool runtimeUpdate) std::map<String, std::vector<String>>& publishes, bool runtimeUpdate)
{ {
/* TODO: This isn't essentially correct as we don't keep track of config objects ourselves. This would avoid duplicated config updates at startup. /* TODO: This isn't essentially correct as we don't keep track of config objects ourselves. This would avoid duplicated config updates at startup.
@ -1128,7 +1128,7 @@ RedisWriter::CreateConfigUpdate(const ConfigObject::Ptr& object, const String ty
} }
} }
void RedisWriter::SendConfigDelete(const ConfigObject::Ptr& object) void IcingaDB::SendConfigDelete(const ConfigObject::Ptr& object)
{ {
String typeName = object->GetReflectionType()->GetName().ToLower(); String typeName = object->GetReflectionType()->GetName().ToLower();
String objectKey = GetObjectIdentifier(object); String objectKey = GetObjectIdentifier(object);
@ -1152,7 +1152,7 @@ unsigned short GetPreviousHardState(const Checkable::Ptr& checkable, const Servi
} }
} }
void RedisWriter::SendStatusUpdate(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type) void IcingaDB::SendStatusUpdate(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1228,7 +1228,7 @@ void RedisWriter::SendStatusUpdate(const ConfigObject::Ptr& object, const CheckR
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendSentNotification( void IcingaDB::SendSentNotification(
const Notification::Ptr& notification, const Checkable::Ptr& checkable, size_t users, const Notification::Ptr& notification, const Checkable::Ptr& checkable, size_t users,
NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text
) )
@ -1276,7 +1276,7 @@ void RedisWriter::SendSentNotification(
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendAddedDowntime(const Downtime::Ptr& downtime) void IcingaDB::SendAddedDowntime(const Downtime::Ptr& downtime)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1343,7 +1343,7 @@ void RedisWriter::SendAddedDowntime(const Downtime::Ptr& downtime)
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendStartedDowntime(const Downtime::Ptr& downtime) void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1412,7 +1412,7 @@ void RedisWriter::SendStartedDowntime(const Downtime::Ptr& downtime)
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendRemovedDowntime(const Downtime::Ptr& downtime) void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1480,7 +1480,7 @@ void RedisWriter::SendRemovedDowntime(const Downtime::Ptr& downtime)
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendAddedComment(const Comment::Ptr& comment) void IcingaDB::SendAddedComment(const Comment::Ptr& comment)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1524,7 +1524,7 @@ void RedisWriter::SendAddedComment(const Comment::Ptr& comment)
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendRemovedComment(const Comment::Ptr& comment) void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1569,7 +1569,7 @@ void RedisWriter::SendRemovedComment(const Comment::Ptr& comment)
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
void RedisWriter::SendFlappingChanged(const Checkable::Ptr& checkable, const Value& value) void IcingaDB::SendFlappingChanged(const Checkable::Ptr& checkable, const Value& value)
{ {
if (!m_Rcon || !m_Rcon->IsConnected()) if (!m_Rcon || !m_Rcon->IsConnected())
return; return;
@ -1611,7 +1611,7 @@ void RedisWriter::SendFlappingChanged(const Checkable::Ptr& checkable, const Val
m_Rcon->FireAndForgetQuery(std::move(xAdd)); m_Rcon->FireAndForgetQuery(std::move(xAdd));
} }
Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable) Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable)
{ {
Dictionary::Ptr attrs = new Dictionary(); Dictionary::Ptr attrs = new Dictionary();
@ -1709,7 +1709,7 @@ Dictionary::Ptr RedisWriter::SerializeState(const Checkable::Ptr& checkable)
} }
std::vector<String> std::vector<String>
RedisWriter::UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType, IcingaDB::UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType,
const String& typeNameOverride) const String& typeNameOverride)
{ {
Type::Ptr type = object->GetReflectionType(); Type::Ptr type = object->GetReflectionType();
@ -1751,73 +1751,73 @@ RedisWriter::UpdateObjectAttrs(const ConfigObject::Ptr& object, int fieldType,
//m_Rcon->FireAndForgetQuery({"HSET", keyPrefix + typeName, GetObjectIdentifier(object), JsonEncode(attrs)}); //m_Rcon->FireAndForgetQuery({"HSET", keyPrefix + typeName, GetObjectIdentifier(object), JsonEncode(attrs)});
} }
void RedisWriter::StateChangeHandler(const ConfigObject::Ptr& object) void IcingaDB::StateChangeHandler(const ConfigObject::Ptr& object)
{ {
auto checkable (dynamic_pointer_cast<Checkable>(object)); auto checkable (dynamic_pointer_cast<Checkable>(object));
if (checkable) { if (checkable) {
RedisWriter::StateChangeHandler(object, checkable->GetLastCheckResult(), checkable->GetStateType()); IcingaDB::StateChangeHandler(object, checkable->GetLastCheckResult(), checkable->GetStateType());
} }
} }
void RedisWriter::StateChangeHandler(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type) void IcingaDB::StateChangeHandler(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type)
{ {
for (const RedisWriter::Ptr& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (const IcingaDB::Ptr& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, object, cr, type]() { rw->SendStatusUpdate(object, cr, type); }); rw->m_WorkQueue.Enqueue([rw, object, cr, type]() { rw->SendStatusUpdate(object, cr, type); });
} }
} }
void RedisWriter::VersionChangedHandler(const ConfigObject::Ptr& object) void IcingaDB::VersionChangedHandler(const ConfigObject::Ptr& object)
{ {
Type::Ptr type = object->GetReflectionType(); Type::Ptr type = object->GetReflectionType();
if (object->IsActive()) { if (object->IsActive()) {
// Create or update the object config // Create or update the object config
for (const RedisWriter::Ptr& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (const IcingaDB::Ptr& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
if (rw) if (rw)
rw->m_WorkQueue.Enqueue([rw, object]() { rw->SendConfigUpdate(object, true); }); rw->m_WorkQueue.Enqueue([rw, object]() { rw->SendConfigUpdate(object, true); });
} }
} else if (!object->IsActive() && } else if (!object->IsActive() &&
object->GetExtension("ConfigObjectDeleted")) { // same as in apilistener-configsync.cpp object->GetExtension("ConfigObjectDeleted")) { // same as in apilistener-configsync.cpp
// Delete object config // Delete object config
for (const RedisWriter::Ptr& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (const IcingaDB::Ptr& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
if (rw) if (rw)
rw->m_WorkQueue.Enqueue([rw, object]() { rw->SendConfigDelete(object); }); rw->m_WorkQueue.Enqueue([rw, object]() { rw->SendConfigDelete(object); });
} }
} }
} }
void RedisWriter::DowntimeAddedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeAddedHandler(const Downtime::Ptr& downtime)
{ {
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendAddedDowntime(downtime); }); rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendAddedDowntime(downtime); });
} }
} }
void RedisWriter::DowntimeStartedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime)
{ {
StateChangeHandler(downtime->GetCheckable()); StateChangeHandler(downtime->GetCheckable());
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendStartedDowntime(downtime); }); rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendStartedDowntime(downtime); });
} }
} }
void RedisWriter::DowntimeRemovedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeRemovedHandler(const Downtime::Ptr& downtime)
{ {
StateChangeHandler(downtime->GetCheckable()); StateChangeHandler(downtime->GetCheckable());
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendRemovedDowntime(downtime); }); rw->m_WorkQueue.Enqueue([rw, downtime]() { rw->SendRemovedDowntime(downtime); });
} }
} }
void RedisWriter::NotificationSentToAllUsersHandler( void IcingaDB::NotificationSentToAllUsersHandler(
const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, const Notification::Ptr& notification, const Checkable::Ptr& checkable, const std::set<User::Ptr>& users,
NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text NotificationType type, const CheckResult::Ptr& cr, const String& author, const String& text
) )
{ {
auto rws (ConfigType::GetObjectsByType<RedisWriter>()); auto rws (ConfigType::GetObjectsByType<IcingaDB>());
if (!rws.empty()) { if (!rws.empty()) {
auto usersAmount (users.size()); auto usersAmount (users.size());
@ -1831,23 +1831,23 @@ void RedisWriter::NotificationSentToAllUsersHandler(
} }
} }
void RedisWriter::CommentAddedHandler(const Comment::Ptr& comment) void IcingaDB::CommentAddedHandler(const Comment::Ptr& comment)
{ {
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, comment]() { rw->SendAddedComment(comment); }); rw->m_WorkQueue.Enqueue([rw, comment]() { rw->SendAddedComment(comment); });
} }
} }
void RedisWriter::CommentRemovedHandler(const Comment::Ptr& comment) void IcingaDB::CommentRemovedHandler(const Comment::Ptr& comment)
{ {
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, comment]() { rw->SendRemovedComment(comment); }); rw->m_WorkQueue.Enqueue([rw, comment]() { rw->SendRemovedComment(comment); });
} }
} }
void RedisWriter::FlappingChangedHandler(const Checkable::Ptr& checkable, const Value& value) void IcingaDB::FlappingChangedHandler(const Checkable::Ptr& checkable, const Value& value)
{ {
for (auto& rw : ConfigType::GetObjectsByType<RedisWriter>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->m_WorkQueue.Enqueue([rw, checkable, value]() { rw->SendFlappingChanged(checkable, value); }); rw->m_WorkQueue.Enqueue([rw, checkable, value]() { rw->SendFlappingChanged(checkable, value); });
} }
} }

View File

@ -26,7 +26,7 @@
using namespace icinga; using namespace icinga;
Dictionary::Ptr RedisWriter::GetStats() Dictionary::Ptr IcingaDB::GetStats()
{ {
Dictionary::Ptr stats = new Dictionary(); Dictionary::Ptr stats = new Dictionary();

View File

@ -41,7 +41,7 @@
using namespace icinga; using namespace icinga;
String RedisWriter::FormatCheckSumBinary(const String& str) String IcingaDB::FormatCheckSumBinary(const String& str)
{ {
char output[20*2+1]; char output[20*2+1];
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
@ -50,7 +50,7 @@ String RedisWriter::FormatCheckSumBinary(const String& str)
return output; return output;
} }
String RedisWriter::FormatCommandLine(const Value& commandLine) String IcingaDB::FormatCommandLine(const Value& commandLine)
{ {
String result; String result;
if (commandLine.IsObjectType<Array>()) { if (commandLine.IsObjectType<Array>()) {
@ -77,12 +77,12 @@ String RedisWriter::FormatCommandLine(const Value& commandLine)
return result; return result;
} }
String RedisWriter::GetEnvironment() String IcingaDB::GetEnvironment()
{ {
return ConfigType::GetObjectsByType<IcingaApplication>()[0]->GetEnvironment(); return ConfigType::GetObjectsByType<IcingaApplication>()[0]->GetEnvironment();
} }
String RedisWriter::GetObjectIdentifier(const ConfigObject::Ptr& object) String IcingaDB::GetObjectIdentifier(const ConfigObject::Ptr& object)
{ {
Type::Ptr type = object->GetReflectionType(); Type::Ptr type = object->GetReflectionType();
@ -92,12 +92,12 @@ String RedisWriter::GetObjectIdentifier(const ConfigObject::Ptr& object)
return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetName()})); return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetName()}));
} }
String RedisWriter::CalculateCheckSumString(const String& str) String IcingaDB::CalculateCheckSumString(const String& str)
{ {
return SHA1(str); return SHA1(str);
} }
String RedisWriter::CalculateCheckSumArray(const Array::Ptr& arr) String IcingaDB::CalculateCheckSumArray(const Array::Ptr& arr)
{ {
/* Ensure that checksums happen in a defined order. */ /* Ensure that checksums happen in a defined order. */
Array::Ptr tmpArr = arr->ShallowClone(); Array::Ptr tmpArr = arr->ShallowClone();
@ -107,7 +107,7 @@ String RedisWriter::CalculateCheckSumArray(const Array::Ptr& arr)
return SHA1(PackObject(tmpArr)); return SHA1(PackObject(tmpArr));
} }
String RedisWriter::CalculateCheckSumProperties(const ConfigObject::Ptr& object, const std::set<String>& propertiesBlacklist) String IcingaDB::CalculateCheckSumProperties(const ConfigObject::Ptr& object, const std::set<String>& propertiesBlacklist)
{ {
//TODO: consider precision of 6 for double values; use specific config fields for hashing? //TODO: consider precision of 6 for double values; use specific config fields for hashing?
return HashValue(object, propertiesBlacklist); return HashValue(object, propertiesBlacklist);
@ -115,12 +115,12 @@ String RedisWriter::CalculateCheckSumProperties(const ConfigObject::Ptr& object,
static const std::set<String> metadataWhitelist ({"package", "source_location", "templates"}); static const std::set<String> metadataWhitelist ({"package", "source_location", "templates"});
String RedisWriter::CalculateCheckSumMetadata(const ConfigObject::Ptr& object) String IcingaDB::CalculateCheckSumMetadata(const ConfigObject::Ptr& object)
{ {
return HashValue(object, metadataWhitelist, true); return HashValue(object, metadataWhitelist, true);
} }
String RedisWriter::CalculateCheckSumVars(const CustomVarObject::Ptr& object) String IcingaDB::CalculateCheckSumVars(const CustomVarObject::Ptr& object)
{ {
Dictionary::Ptr vars = object->GetVars(); Dictionary::Ptr vars = object->GetVars();
@ -169,7 +169,7 @@ String RedisWriter::CalculateCheckSumVars(const CustomVarObject::Ptr& object)
* *
* @return JSON-like data structure for Redis * @return JSON-like data structure for Redis
*/ */
Dictionary::Ptr RedisWriter::SerializeVars(const CustomVarObject::Ptr& object) Dictionary::Ptr IcingaDB::SerializeVars(const CustomVarObject::Ptr& object)
{ {
Dictionary::Ptr vars = object->GetVars(); Dictionary::Ptr vars = object->GetVars();
@ -199,12 +199,12 @@ Dictionary::Ptr RedisWriter::SerializeVars(const CustomVarObject::Ptr& object)
static const std::set<String> propertiesBlacklistEmpty; static const std::set<String> propertiesBlacklistEmpty;
String RedisWriter::HashValue(const Value& value) String IcingaDB::HashValue(const Value& value)
{ {
return HashValue(value, propertiesBlacklistEmpty); return HashValue(value, propertiesBlacklistEmpty);
} }
String RedisWriter::HashValue(const Value& value, const std::set<String>& propertiesBlacklist, bool propertiesWhitelist) String IcingaDB::HashValue(const Value& value, const std::set<String>& propertiesBlacklist, bool propertiesWhitelist)
{ {
Value temp; Value temp;
bool mutabl; bool mutabl;
@ -252,11 +252,11 @@ String RedisWriter::HashValue(const Value& value, const std::set<String>& proper
return SHA1(PackObject(temp)); return SHA1(PackObject(temp));
} }
String RedisWriter::GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj) String IcingaDB::GetLowerCaseTypeNameDB(const ConfigObject::Ptr& obj)
{ {
return obj->GetReflectionType()->GetName().ToLower(); return obj->GetReflectionType()->GetName().ToLower();
} }
long long RedisWriter::TimestampToMilliseconds(double timestamp) { long long IcingaDB::TimestampToMilliseconds(double timestamp) {
return static_cast<long long>(timestamp * 1000); return static_cast<long long>(timestamp * 1000);
} }

View File

@ -35,14 +35,14 @@ using namespace icinga;
//TODO Make configurable and figure out a sane default //TODO Make configurable and figure out a sane default
#define MAX_EVENTS_DEFAULT 5000 #define MAX_EVENTS_DEFAULT 5000
REGISTER_TYPE(RedisWriter); REGISTER_TYPE(IcingaDB);
RedisWriter::RedisWriter() IcingaDB::IcingaDB()
: m_Rcon(nullptr) : m_Rcon(nullptr)
{ {
m_Rcon = nullptr; m_Rcon = nullptr;
m_WorkQueue.SetName("RedisWriter"); m_WorkQueue.SetName("IcingaDB");
m_PrefixConfigObject = "icinga:config:"; m_PrefixConfigObject = "icinga:config:";
m_PrefixConfigCheckSum = "icinga:checksum:"; m_PrefixConfigCheckSum = "icinga:checksum:";
@ -52,11 +52,11 @@ RedisWriter::RedisWriter()
/** /**
* Starts the component. * Starts the component.
*/ */
void RedisWriter::Start(bool runtimeCreated) void IcingaDB::Start(bool runtimeCreated)
{ {
ObjectImpl<RedisWriter>::Start(runtimeCreated); ObjectImpl<IcingaDB>::Start(runtimeCreated);
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "'" << GetName() << "' started."; << "'" << GetName() << "' started.";
m_ConfigDumpInProgress = false; m_ConfigDumpInProgress = false;
@ -83,27 +83,27 @@ void RedisWriter::Start(bool runtimeCreated)
m_StatsTimer->OnTimerExpired.connect([this](const Timer * const&) { PublishStatsTimerHandler(); }); m_StatsTimer->OnTimerExpired.connect([this](const Timer * const&) { PublishStatsTimerHandler(); });
m_StatsTimer->Start(); m_StatsTimer->Start();
m_WorkQueue.SetName("RedisWriter"); m_WorkQueue.SetName("IcingaDB");
boost::thread thread(&RedisWriter::HandleEvents, this); boost::thread thread(&IcingaDB::HandleEvents, this);
thread.detach(); thread.detach();
} }
void RedisWriter::ExceptionHandler(boost::exception_ptr exp) void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
{ {
Log(LogCritical, "RedisWriter", "Exception during redis query. Verify that Redis is operational."); Log(LogCritical, "IcingaDB", "Exception during redis query. Verify that Redis is operational.");
Log(LogDebug, "RedisWriter") Log(LogDebug, "IcingaDB")
<< "Exception during redis operation: " << DiagnosticInformation(exp); << "Exception during redis operation: " << DiagnosticInformation(exp);
} }
void RedisWriter::ReconnectTimerHandler() void IcingaDB::ReconnectTimerHandler()
{ {
m_WorkQueue.Enqueue([this]() { TryToReconnect(); }); m_WorkQueue.Enqueue([this]() { TryToReconnect(); });
} }
void RedisWriter::TryToReconnect() void IcingaDB::TryToReconnect()
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
@ -131,16 +131,16 @@ void RedisWriter::TryToReconnect()
m_ConfigDumpInProgress = false; m_ConfigDumpInProgress = false;
} }
void RedisWriter::UpdateSubscriptionsTimerHandler() void IcingaDB::UpdateSubscriptionsTimerHandler()
{ {
m_WorkQueue.Enqueue([this]() { UpdateSubscriptions(); }); m_WorkQueue.Enqueue([this]() { UpdateSubscriptions(); });
} }
void RedisWriter::UpdateSubscriptions() void IcingaDB::UpdateSubscriptions()
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
Log(LogInformation, "RedisWriter", "Updating Redis subscriptions"); Log(LogInformation, "IcingaDB", "Updating Redis subscriptions");
/* TODO: /* TODO:
* Silently return in this case. Usually the RedisConnection checks for connectivity and logs in failure case. * Silently return in this case. Usually the RedisConnection checks for connectivity and logs in failure case.
@ -168,8 +168,8 @@ void RedisWriter::UpdateSubscriptions()
RedisSubscriptionInfo rsi; RedisSubscriptionInfo rsi;
if (!RedisWriter::GetSubscriptionTypes(key, rsi)) { if (!IcingaDB::GetSubscriptionTypes(key, rsi)) {
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "Subscription \"" << key << "\" has no types listed."; << "Subscription \"" << key << "\" has no types listed.";
} else { } else {
m_Subscriptions[key.SubStr(keyPrefix.GetLength())] = rsi; m_Subscriptions[key.SubStr(keyPrefix.GetLength())] = rsi;
@ -177,11 +177,11 @@ void RedisWriter::UpdateSubscriptions()
} }
} while (cursor != "0"); } while (cursor != "0");
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "Current Redis event subscriptions: " << m_Subscriptions.size(); << "Current Redis event subscriptions: " << m_Subscriptions.size();
} }
bool RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi) bool IcingaDB::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
{ {
try { try {
Array::Ptr redisReply = m_Rcon->GetResultOfQuery({ "SMEMBERS", key }); Array::Ptr redisReply = m_Rcon->GetResultOfQuery({ "SMEMBERS", key });
@ -197,11 +197,11 @@ bool RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
} }
} }
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "Subscriber Info - Key: " << key << " Value: " << Value(Array::FromSet(rsi.EventTypes)); << "Subscriber Info - Key: " << key << " Value: " << Value(Array::FromSet(rsi.EventTypes));
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log(LogWarning, "RedisWriter") Log(LogWarning, "IcingaDB")
<< "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex); << "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex);
return false; return false;
@ -210,12 +210,12 @@ bool RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi)
return true; return true;
} }
void RedisWriter::PublishStatsTimerHandler(void) void IcingaDB::PublishStatsTimerHandler(void)
{ {
m_WorkQueue.Enqueue([this]() { PublishStats(); }); m_WorkQueue.Enqueue([this]() { PublishStats(); });
} }
void RedisWriter::PublishStats() void IcingaDB::PublishStats()
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
@ -229,7 +229,7 @@ void RedisWriter::PublishStats()
m_Rcon->FireAndForgetQuery({ "PUBLISH", "icinga:stats", jsonStats }); m_Rcon->FireAndForgetQuery({ "PUBLISH", "icinga:stats", jsonStats });
} }
void RedisWriter::HandleEvents() void IcingaDB::HandleEvents()
{ {
String queueName = Utility::NewUniqueID(); String queueName = Utility::NewUniqueID();
EventQueue::Ptr queue = new EventQueue(queueName); EventQueue::Ptr queue = new EventQueue(queueName);
@ -265,7 +265,7 @@ void RedisWriter::HandleEvents()
EventQueue::UnregisterIfUnused(queueName, queue); EventQueue::UnregisterIfUnused(queueName, queue);
} }
void RedisWriter::HandleEvent(const Dictionary::Ptr& event) void IcingaDB::HandleEvent(const Dictionary::Ptr& event)
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
@ -284,7 +284,7 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
if (maxExists != 0) { if (maxExists != 0) {
String redisReply = m_Rcon->GetResultOfQuery({ "GET", "icinga:subscription:" + name + ":limit"}); String redisReply = m_Rcon->GetResultOfQuery({ "GET", "icinga:subscription:" + name + ":limit"});
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "Got limit " << redisReply << " for " << name; << "Got limit " << redisReply << " for " << name;
maxEvents = Convert::ToLong(redisReply); maxEvents = Convert::ToLong(redisReply);
@ -298,7 +298,7 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
} }
} }
void RedisWriter::SendEvent(const Dictionary::Ptr& event) void IcingaDB::SendEvent(const Dictionary::Ptr& event)
{ {
AssertOnWorkQueue(); AssertOnWorkQueue();
@ -347,7 +347,7 @@ void RedisWriter::SendEvent(const Dictionary::Ptr& event)
String body = JsonEncode(event); String body = JsonEncode(event);
// Log(LogInformation, "RedisWriter") // Log(LogInformation, "IcingaDB")
// << "Sending event \"" << body << "\""; // << "Sending event \"" << body << "\"";
m_Rcon->FireAndForgetQueries({ m_Rcon->FireAndForgetQueries({
@ -355,15 +355,15 @@ void RedisWriter::SendEvent(const Dictionary::Ptr& event)
{ "PUBLISH", "icinga:event:" + event->Get("type"), body }}); { "PUBLISH", "icinga:event:" + event->Get("type"), body }});
} }
void RedisWriter::Stop(bool runtimeRemoved) void IcingaDB::Stop(bool runtimeRemoved)
{ {
Log(LogInformation, "RedisWriter") Log(LogInformation, "IcingaDB")
<< "'" << GetName() << "' stopped."; << "'" << GetName() << "' stopped.";
ObjectImpl<RedisWriter>::Stop(runtimeRemoved); ObjectImpl<IcingaDB>::Stop(runtimeRemoved);
} }
void RedisWriter::AssertOnWorkQueue() void IcingaDB::AssertOnWorkQueue()
{ {
ASSERT(m_WorkQueue.IsWorkerThread()); ASSERT(m_WorkQueue.IsWorkerThread());
} }

View File

@ -42,13 +42,13 @@ struct RedisSubscriptionInfo
/** /**
* @ingroup redis * @ingroup redis
*/ */
class RedisWriter : public ObjectImpl<RedisWriter> class IcingaDB : public ObjectImpl<IcingaDB>
{ {
public: public:
DECLARE_OBJECT(RedisWriter); DECLARE_OBJECT(IcingaDB);
DECLARE_OBJECTNAME(RedisWriter); DECLARE_OBJECTNAME(IcingaDB);
RedisWriter(); IcingaDB();
static void ConfigStaticInitialize(); static void ConfigStaticInitialize();

View File

@ -24,7 +24,7 @@ library redis;
namespace icinga namespace icinga
{ {
class RedisWriter : ConfigObject class IcingaDB : ConfigObject
{ {
[config] String host { [config] String host {
default {{{ return "127.0.0.1"; }}} default {{{ return "127.0.0.1"; }}}