mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
Use RedisConnection::Quer* type aliases instead of (the equivalent std::vector)
This expresses what kind of vector it is and allows to easily change those types in the future.
This commit is contained in:
parent
9abf482708
commit
7958048a72
@ -271,12 +271,12 @@ void IcingaDB::UpdateAllConfigObjects()
|
|||||||
String configObject = m_PrefixConfigObject + lcType;
|
String configObject = m_PrefixConfigObject + lcType;
|
||||||
|
|
||||||
// Skimmed away attributes and checksums HMSETs' keys and values by Redis key.
|
// Skimmed away attributes and checksums HMSETs' keys and values by Redis key.
|
||||||
std::map<String, std::vector<std::vector<String>>> ourContentRaw {{configCheckSum, {}}, {configObject, {}}};
|
std::map<String, RedisConnection::Queries> ourContentRaw {{configCheckSum, {}}, {configObject, {}}};
|
||||||
std::mutex ourContentMutex;
|
std::mutex ourContentMutex;
|
||||||
|
|
||||||
upqObjectType.ParallelFor(objectChunks, [&](decltype(objectChunks)::const_reference chunk) {
|
upqObjectType.ParallelFor(objectChunks, [&](decltype(objectChunks)::const_reference chunk) {
|
||||||
std::map<String, std::vector<String>> hMSets;
|
std::map<String, RedisConnection::Query> hMSets;
|
||||||
std::vector<String> hostZAdds = {"ZADD", "icinga:nextupdate:host"}, serviceZAdds = {"ZADD", "icinga:nextupdate:service"};
|
RedisConnection::Query hostZAdds = {"ZADD", "icinga:nextupdate:host"}, serviceZAdds = {"ZADD", "icinga:nextupdate:service"};
|
||||||
|
|
||||||
auto skimObjects ([&]() {
|
auto skimObjects ([&]() {
|
||||||
std::lock_guard<std::mutex> l (ourContentMutex);
|
std::lock_guard<std::mutex> l (ourContentMutex);
|
||||||
@ -342,7 +342,7 @@ void IcingaDB::UpdateAllConfigObjects()
|
|||||||
zAdds->emplace_back(GetObjectIdentifier(checkable));
|
zAdds->emplace_back(GetObjectIdentifier(checkable));
|
||||||
|
|
||||||
if (zAdds->size() >= 102u) {
|
if (zAdds->size() >= 102u) {
|
||||||
std::vector<String> header (zAdds->begin(), zAdds->begin() + 2u);
|
RedisConnection::Query header (zAdds->begin(), zAdds->begin() + 2u);
|
||||||
|
|
||||||
rcon->FireAndForgetQuery(std::move(*zAdds), Prio::CheckResult);
|
rcon->FireAndForgetQuery(std::move(*zAdds), Prio::CheckResult);
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ void IcingaDB::UpdateAllConfigObjects()
|
|||||||
|
|
||||||
auto& ourCheckSums (ourContent[configCheckSum]);
|
auto& ourCheckSums (ourContent[configCheckSum]);
|
||||||
auto& ourObjects (ourContent[configObject]);
|
auto& ourObjects (ourContent[configObject]);
|
||||||
std::vector<String> setChecksum, setObject, delChecksum, delObject;
|
RedisConnection::Query setChecksum, setObject, delChecksum, delObject;
|
||||||
|
|
||||||
auto redisCurrent (redisCheckSums.begin());
|
auto redisCurrent (redisCheckSums.begin());
|
||||||
auto redisEnd (redisCheckSums.end());
|
auto redisEnd (redisCheckSums.end());
|
||||||
@ -411,12 +411,12 @@ void IcingaDB::UpdateAllConfigObjects()
|
|||||||
setChecksum.insert(setChecksum.begin(), {"HMSET", configCheckSum});
|
setChecksum.insert(setChecksum.begin(), {"HMSET", configCheckSum});
|
||||||
setObject.insert(setObject.begin(), {"HMSET", configObject});
|
setObject.insert(setObject.begin(), {"HMSET", configObject});
|
||||||
|
|
||||||
std::vector<std::vector<String>> transaction;
|
RedisConnection::Queries transaction;
|
||||||
|
|
||||||
transaction.emplace_back(std::vector<String>{"MULTI"});
|
transaction.emplace_back(RedisConnection::Query{"MULTI"});
|
||||||
transaction.emplace_back(std::move(setChecksum));
|
transaction.emplace_back(std::move(setChecksum));
|
||||||
transaction.emplace_back(std::move(setObject));
|
transaction.emplace_back(std::move(setObject));
|
||||||
transaction.emplace_back(std::vector<String>{"EXEC"});
|
transaction.emplace_back(RedisConnection::Query{"EXEC"});
|
||||||
|
|
||||||
setChecksum.clear();
|
setChecksum.clear();
|
||||||
setObject.clear();
|
setObject.clear();
|
||||||
@ -430,12 +430,12 @@ void IcingaDB::UpdateAllConfigObjects()
|
|||||||
delChecksum.insert(delChecksum.begin(), {"HDEL", configCheckSum});
|
delChecksum.insert(delChecksum.begin(), {"HDEL", configCheckSum});
|
||||||
delObject.insert(delObject.begin(), {"HDEL", configObject});
|
delObject.insert(delObject.begin(), {"HDEL", configObject});
|
||||||
|
|
||||||
std::vector<std::vector<String>> transaction;
|
RedisConnection::Queries transaction;
|
||||||
|
|
||||||
transaction.emplace_back(std::vector<String>{"MULTI"});
|
transaction.emplace_back(RedisConnection::Query{"MULTI"});
|
||||||
transaction.emplace_back(std::move(delChecksum));
|
transaction.emplace_back(std::move(delChecksum));
|
||||||
transaction.emplace_back(std::move(delObject));
|
transaction.emplace_back(std::move(delObject));
|
||||||
transaction.emplace_back(std::vector<String>{"EXEC"});
|
transaction.emplace_back(RedisConnection::Query{"EXEC"});
|
||||||
|
|
||||||
delChecksum.clear();
|
delChecksum.clear();
|
||||||
delObject.clear();
|
delObject.clear();
|
||||||
@ -563,7 +563,7 @@ std::vector<std::vector<intrusive_ptr<ConfigObject>>> IcingaDB::ChunkObjects(std
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IcingaDB::DeleteKeys(const RedisConnection::Ptr& conn, const std::vector<String>& keys, RedisConnection::QueryPriority priority) {
|
void IcingaDB::DeleteKeys(const RedisConnection::Ptr& conn, const std::vector<String>& keys, RedisConnection::QueryPriority priority) {
|
||||||
std::vector<String> query = {"DEL"};
|
RedisConnection::Query query = {"DEL"};
|
||||||
for (auto& key : keys) {
|
for (auto& key : keys) {
|
||||||
query.emplace_back(key);
|
query.emplace_back(key);
|
||||||
}
|
}
|
||||||
@ -635,7 +635,7 @@ static ConfigObject::Ptr GetObjectByName(const String& name)
|
|||||||
return ConfigObject::GetObject<ConfigType>(name);
|
return ConfigObject::GetObject<ConfigType>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IcingaDB::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, RedisConnection::Query>& hMSets,
|
||||||
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate)
|
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate)
|
||||||
{
|
{
|
||||||
String objectKey = GetObjectIdentifier(object);
|
String objectKey = GetObjectIdentifier(object);
|
||||||
@ -1333,7 +1333,7 @@ void IcingaDB::UpdateState(const Checkable::Ptr& checkable, StateUpdate mode)
|
|||||||
if (mode & StateUpdate::RuntimeOnly) {
|
if (mode & StateUpdate::RuntimeOnly) {
|
||||||
ObjectLock olock(stateAttrs);
|
ObjectLock olock(stateAttrs);
|
||||||
|
|
||||||
std::vector<String> streamadd({
|
RedisConnection::Query streamadd({
|
||||||
"XADD", "icinga:runtime:state", "MAXLEN", "~", "1000000", "*",
|
"XADD", "icinga:runtime:state", "MAXLEN", "~", "1000000", "*",
|
||||||
"runtime_type", "upsert",
|
"runtime_type", "upsert",
|
||||||
"redis_key", redisStateKey,
|
"redis_key", redisStateKey,
|
||||||
@ -1466,7 +1466,7 @@ void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpd
|
|||||||
|
|
||||||
String typeName = GetLowerCaseTypeNameDB(object);
|
String typeName = GetLowerCaseTypeNameDB(object);
|
||||||
|
|
||||||
std::map<String, std::vector<String>> hMSets;
|
std::map<String, RedisConnection::Query> hMSets;
|
||||||
std::vector<Dictionary::Ptr> runtimeUpdates;
|
std::vector<Dictionary::Ptr> runtimeUpdates;
|
||||||
|
|
||||||
CreateConfigUpdate(object, typeName, hMSets, runtimeUpdates, runtimeUpdate);
|
CreateConfigUpdate(object, typeName, hMSets, runtimeUpdates, runtimeUpdate);
|
||||||
@ -1806,7 +1806,7 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a
|
|||||||
* 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
|
||||||
IcingaDB::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, RedisConnection::Query>& hMSets,
|
||||||
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate)
|
std::vector<Dictionary::Ptr>& runtimeUpdates, 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.
|
||||||
@ -1969,7 +1969,7 @@ void IcingaDB::SendStateChange(const ConfigObject::Ptr& object, const CheckResul
|
|||||||
Array::Ptr rawId = new Array({m_EnvironmentId, object->GetName()});
|
Array::Ptr rawId = new Array({m_EnvironmentId, object->GetName()});
|
||||||
rawId->Add(eventTs);
|
rawId->Add(eventTs);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:state", "*",
|
"XADD", "icinga:history:stream:state", "*",
|
||||||
"id", HashValue(rawId),
|
"id", HashValue(rawId),
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2053,7 +2053,7 @@ void IcingaDB::SendSentNotification(
|
|||||||
|
|
||||||
auto notificationHistoryId (HashValue(rawId));
|
auto notificationHistoryId (HashValue(rawId));
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:notification", "*",
|
"XADD", "icinga:history:stream:notification", "*",
|
||||||
"id", notificationHistoryId,
|
"id", notificationHistoryId,
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2117,7 +2117,7 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
|
|||||||
/* Update checkable state as in_downtime may have changed. */
|
/* Update checkable state as in_downtime may have changed. */
|
||||||
UpdateState(checkable, StateUpdate::Full);
|
UpdateState(checkable, StateUpdate::Full);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:downtime", "*",
|
"XADD", "icinga:history:stream:downtime", "*",
|
||||||
"downtime_id", GetObjectIdentifier(downtime),
|
"downtime_id", GetObjectIdentifier(downtime),
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2207,7 +2207,7 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
|
|||||||
/* Update checkable state as in_downtime may have changed. */
|
/* Update checkable state as in_downtime may have changed. */
|
||||||
UpdateState(checkable, StateUpdate::Full);
|
UpdateState(checkable, StateUpdate::Full);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:downtime", "*",
|
"XADD", "icinga:history:stream:downtime", "*",
|
||||||
"downtime_id", GetObjectIdentifier(downtime),
|
"downtime_id", GetObjectIdentifier(downtime),
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2289,7 +2289,7 @@ void IcingaDB::SendAddedComment(const Comment::Ptr& comment)
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:comment", "*",
|
"XADD", "icinga:history:stream:comment", "*",
|
||||||
"comment_id", GetObjectIdentifier(comment),
|
"comment_id", GetObjectIdentifier(comment),
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2361,7 +2361,7 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:comment", "*",
|
"XADD", "icinga:history:stream:comment", "*",
|
||||||
"comment_id", GetObjectIdentifier(comment),
|
"comment_id", GetObjectIdentifier(comment),
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
@ -2424,7 +2424,7 @@ void IcingaDB::SendFlappingChange(const Checkable::Ptr& checkable, double change
|
|||||||
Service::Ptr service;
|
Service::Ptr service;
|
||||||
tie(host, service) = GetHostService(checkable);
|
tie(host, service) = GetHostService(checkable);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:flapping", "*",
|
"XADD", "icinga:history:stream:flapping", "*",
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
"host_id", GetObjectIdentifier(host),
|
"host_id", GetObjectIdentifier(host),
|
||||||
@ -2519,7 +2519,7 @@ void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const Str
|
|||||||
/* Update checkable state as is_acknowledged may have changed. */
|
/* Update checkable state as is_acknowledged may have changed. */
|
||||||
UpdateState(checkable, StateUpdate::Full);
|
UpdateState(checkable, StateUpdate::Full);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:acknowledgement", "*",
|
"XADD", "icinga:history:stream:acknowledgement", "*",
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
"host_id", GetObjectIdentifier(host),
|
"host_id", GetObjectIdentifier(host),
|
||||||
@ -2577,7 +2577,7 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
|
|||||||
/* Update checkable state as is_acknowledged may have changed. */
|
/* Update checkable state as is_acknowledged may have changed. */
|
||||||
UpdateState(checkable, StateUpdate::Full);
|
UpdateState(checkable, StateUpdate::Full);
|
||||||
|
|
||||||
std::vector<String> xAdd ({
|
RedisConnection::Query xAdd ({
|
||||||
"XADD", "icinga:history:stream:acknowledgement", "*",
|
"XADD", "icinga:history:stream:acknowledgement", "*",
|
||||||
"environment_id", m_EnvironmentId,
|
"environment_id", m_EnvironmentId,
|
||||||
"host_id", GetObjectIdentifier(host),
|
"host_id", GetObjectIdentifier(host),
|
||||||
@ -3327,7 +3327,7 @@ void IcingaDB::DeleteRelationship(const String& id, const String& redisKeyWithou
|
|||||||
|
|
||||||
String redisKey = m_PrefixConfigObject + redisKeyWithoutPrefix;
|
String redisKey = m_PrefixConfigObject + redisKeyWithoutPrefix;
|
||||||
|
|
||||||
std::vector<std::vector<String>> queries;
|
RedisConnection::Queries queries;
|
||||||
|
|
||||||
if (hasChecksum) {
|
if (hasChecksum) {
|
||||||
queries.push_back({"HDEL", m_PrefixConfigCheckSum + redisKeyWithoutPrefix, id});
|
queries.push_back({"HDEL", m_PrefixConfigCheckSum + redisKeyWithoutPrefix, id});
|
||||||
|
@ -175,7 +175,7 @@ void IcingaDB::PublishStats()
|
|||||||
status->Set("timestamp", TimestampToMilliseconds(Utility::GetTime()));
|
status->Set("timestamp", TimestampToMilliseconds(Utility::GetTime()));
|
||||||
status->Set("icingadb_environment", m_EnvironmentId);
|
status->Set("icingadb_environment", m_EnvironmentId);
|
||||||
|
|
||||||
std::vector<String> query {"XADD", "icinga:stats", "MAXLEN", "1", "*"};
|
RedisConnection::Query query {"XADD", "icinga:stats", "MAXLEN", "1", "*"};
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock statusLock (status);
|
ObjectLock statusLock (status);
|
||||||
|
@ -112,13 +112,13 @@ private:
|
|||||||
std::vector<String> GetTypeDumpSignalKeys(const Type::Ptr& type);
|
std::vector<String> GetTypeDumpSignalKeys(const Type::Ptr& type);
|
||||||
void InsertCheckableDependencies(const Checkable::Ptr& checkable, std::map<String, RedisConnection::Query>& hMSets,
|
void InsertCheckableDependencies(const Checkable::Ptr& checkable, std::map<String, RedisConnection::Query>& hMSets,
|
||||||
std::vector<Dictionary::Ptr>* runtimeUpdates, const DependencyGroup::Ptr& onlyDependencyGroup = nullptr);
|
std::vector<Dictionary::Ptr>* runtimeUpdates, const DependencyGroup::Ptr& onlyDependencyGroup = nullptr);
|
||||||
void InsertObjectDependencies(const ConfigObject::Ptr& object, const String typeName, std::map<String, std::vector<String>>& hMSets,
|
void InsertObjectDependencies(const ConfigObject::Ptr& object, const String typeName, std::map<String, RedisConnection::Query>& hMSets,
|
||||||
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate);
|
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate);
|
||||||
void UpdateDependenciesState(const Checkable::Ptr& checkable, const DependencyGroup::Ptr& onlyDependencyGroup = nullptr,
|
void UpdateDependenciesState(const Checkable::Ptr& checkable, const DependencyGroup::Ptr& onlyDependencyGroup = nullptr,
|
||||||
std::set<DependencyGroup*>* seenGroups = nullptr) const;
|
std::set<DependencyGroup*>* seenGroups = nullptr) const;
|
||||||
void UpdateState(const Checkable::Ptr& checkable, StateUpdate mode);
|
void UpdateState(const Checkable::Ptr& checkable, StateUpdate mode);
|
||||||
void SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate);
|
void SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpdate);
|
||||||
void CreateConfigUpdate(const ConfigObject::Ptr& object, const String type, std::map<String, std::vector<String>>& hMSets,
|
void CreateConfigUpdate(const ConfigObject::Ptr& object, const String type, std::map<String, RedisConnection::Query>& hMSets,
|
||||||
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate);
|
std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate);
|
||||||
void SendConfigDelete(const ConfigObject::Ptr& object);
|
void SendConfigDelete(const ConfigObject::Ptr& object);
|
||||||
void SendStateChange(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type);
|
void SendStateChange(const ConfigObject::Ptr& object, const CheckResult::Ptr& cr, StateType type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user