@@ -254,17 +254,17 @@ void IcingaDB::UpdateAllConfigObjects()
254
254
String configObject = m_PrefixConfigObject + lcType;
255
255
256
256
// Skimmed away attributes and checksums HMSETs' keys and values by Redis key.
257
- std::map<String, std::vector<std::vector<String>> > ourContentRaw {{configCheckSum, {}}, {configObject, {}}};
257
+ std::map<String, RedisConnection::Queries > ourContentRaw {{configCheckSum, {}}, {configObject, {}}};
258
258
std::mutex ourContentMutex;
259
259
260
260
upqObjectType.ParallelFor (objectChunks, [&](decltype (objectChunks)::const_reference chunk) {
261
- std::map<String, std::vector<String> > hMSets;
261
+ std::map<String, RedisConnection::Query > hMSets;
262
262
// Two values are appended per object: Object ID (Hash encoded) and Object State (IcingaDB::SerializeState() -> JSON encoded)
263
- std::vector<String> states = {" HMSET" , m_PrefixConfigObject + lcType + " :state" };
263
+ RedisConnection::Query states = {" HMSET" , m_PrefixConfigObject + lcType + " :state" };
264
264
// Two values are appended per object: Object ID (Hash encoded) and State Checksum ({ "checksum": checksum } -> JSON encoded)
265
- std::vector<String> statesChksms = {" HMSET" , m_PrefixConfigCheckSum + lcType + " :state" };
266
- std::vector<std::vector<String> > transaction = {{" MULTI" }};
267
- std::vector<String> hostZAdds = {" ZADD" , " icinga:nextupdate:host" }, serviceZAdds = {" ZADD" , " icinga:nextupdate:service" };
265
+ RedisConnection::Query statesChksms = {" HMSET" , m_PrefixConfigCheckSum + lcType + " :state" };
266
+ RedisConnection::Queries transaction = {{" MULTI" }};
267
+ RedisConnection::Query hostZAdds = {" ZADD" , " icinga:nextupdate:host" }, serviceZAdds = {" ZADD" , " icinga:nextupdate:service" };
268
268
269
269
auto skimObjects ([&]() {
270
270
std::lock_guard<std::mutex> l (ourContentMutex);
@@ -346,7 +346,7 @@ void IcingaDB::UpdateAllConfigObjects()
346
346
zAdds->emplace_back (GetObjectIdentifier (checkable));
347
347
348
348
if (zAdds->size () >= 102u ) {
349
- std::vector<String> header (zAdds->begin (), zAdds->begin () + 2u );
349
+ RedisConnection::Query header (zAdds->begin (), zAdds->begin () + 2u );
350
350
351
351
rcon->FireAndForgetQuery (std::move (*zAdds), Prio::CheckResult);
352
352
@@ -417,7 +417,7 @@ void IcingaDB::UpdateAllConfigObjects()
417
417
418
418
auto & ourCheckSums (ourContent[configCheckSum]);
419
419
auto & ourObjects (ourContent[configObject]);
420
- std::vector<String> setChecksum, setObject, delChecksum, delObject;
420
+ RedisConnection::Query setChecksum, setObject, delChecksum, delObject;
421
421
422
422
auto redisCurrent (redisCheckSums.begin ());
423
423
auto redisEnd (redisCheckSums.end ());
@@ -430,12 +430,12 @@ void IcingaDB::UpdateAllConfigObjects()
430
430
setChecksum.insert (setChecksum.begin (), {" HMSET" , configCheckSum});
431
431
setObject.insert (setObject.begin (), {" HMSET" , configObject});
432
432
433
- std::vector<std::vector<String>> transaction;
433
+ RedisConnection::Queries transaction;
434
434
435
- transaction.emplace_back (std::vector<String> {" MULTI" });
435
+ transaction.emplace_back (RedisConnection::Query {" MULTI" });
436
436
transaction.emplace_back (std::move (setChecksum));
437
437
transaction.emplace_back (std::move (setObject));
438
- transaction.emplace_back (std::vector<String> {" EXEC" });
438
+ transaction.emplace_back (RedisConnection::Query {" EXEC" });
439
439
440
440
setChecksum.clear ();
441
441
setObject.clear ();
@@ -449,12 +449,12 @@ void IcingaDB::UpdateAllConfigObjects()
449
449
delChecksum.insert (delChecksum.begin (), {" HDEL" , configCheckSum});
450
450
delObject.insert (delObject.begin (), {" HDEL" , configObject});
451
451
452
- std::vector<std::vector<String>> transaction;
452
+ RedisConnection::Queries transaction;
453
453
454
- transaction.emplace_back (std::vector<String> {" MULTI" });
454
+ transaction.emplace_back (RedisConnection::Query {" MULTI" });
455
455
transaction.emplace_back (std::move (delChecksum));
456
456
transaction.emplace_back (std::move (delObject));
457
- transaction.emplace_back (std::vector<String> {" EXEC" });
457
+ transaction.emplace_back (RedisConnection::Query {" EXEC" });
458
458
459
459
delChecksum.clear ();
460
460
delObject.clear ();
@@ -582,7 +582,7 @@ std::vector<std::vector<intrusive_ptr<ConfigObject>>> IcingaDB::ChunkObjects(std
582
582
}
583
583
584
584
void IcingaDB::DeleteKeys (const RedisConnection::Ptr & conn, const std::vector<String>& keys, RedisConnection::QueryPriority priority) {
585
- std::vector<String> query = {" DEL" };
585
+ RedisConnection::Query query = {" DEL" };
586
586
for (auto & key : keys) {
587
587
query.emplace_back (key);
588
588
}
@@ -654,7 +654,7 @@ static ConfigObject::Ptr GetObjectByName(const String& name)
654
654
return ConfigObject::GetObject<ConfigType>(name);
655
655
}
656
656
657
- void IcingaDB::InsertObjectDependencies (const ConfigObject::Ptr & object, const String typeName, std::map<String, std::vector<String> >& hMSets,
657
+ void IcingaDB::InsertObjectDependencies (const ConfigObject::Ptr & object, const String typeName, std::map<String, RedisConnection::Query >& hMSets,
658
658
std::vector<Dictionary::Ptr >& runtimeUpdates, bool runtimeUpdate)
659
659
{
660
660
String objectKey = GetObjectIdentifier (object);
@@ -1161,7 +1161,7 @@ void IcingaDB::UpdateState(const Checkable::Ptr& checkable, StateUpdate mode)
1161
1161
if (mode & StateUpdate::RuntimeOnly) {
1162
1162
ObjectLock olock (stateAttrs);
1163
1163
1164
- std::vector<String> streamadd ({
1164
+ RedisConnection::Query streamadd ({
1165
1165
" XADD" , " icinga:runtime:state" , " MAXLEN" , " ~" , " 1000000" , " *" ,
1166
1166
" runtime_type" , " upsert" ,
1167
1167
" redis_key" , redisStateKey,
@@ -1185,7 +1185,7 @@ void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpd
1185
1185
1186
1186
String typeName = GetLowerCaseTypeNameDB (object);
1187
1187
1188
- std::map<String, std::vector<String> > hMSets;
1188
+ std::map<String, RedisConnection::Query > hMSets;
1189
1189
std::vector<Dictionary::Ptr > runtimeUpdates;
1190
1190
1191
1191
CreateConfigUpdate (object, typeName, hMSets, runtimeUpdates, runtimeUpdate);
@@ -1194,7 +1194,7 @@ void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpd
1194
1194
UpdateState (checkable, runtimeUpdate ? StateUpdate::Full : StateUpdate::Volatile);
1195
1195
}
1196
1196
1197
- std::vector<std::vector<String> > transaction = {{" MULTI" }};
1197
+ RedisConnection::Queries transaction = {{" MULTI" }};
1198
1198
1199
1199
for (auto & kv : hMSets) {
1200
1200
if (!kv.second .empty ()) {
@@ -1204,7 +1204,7 @@ void IcingaDB::SendConfigUpdate(const ConfigObject::Ptr& object, bool runtimeUpd
1204
1204
}
1205
1205
1206
1206
for (auto & objectAttributes : runtimeUpdates) {
1207
- std::vector<String> xAdd ({" XADD" , " icinga:runtime" , " MAXLEN" , " ~" , " 1000000" , " *" });
1207
+ RedisConnection::Query xAdd ({" XADD" , " icinga:runtime" , " MAXLEN" , " ~" , " 1000000" , " *" });
1208
1208
ObjectLock olock (objectAttributes);
1209
1209
1210
1210
for (const Dictionary::Pair& kv : objectAttributes) {
@@ -1547,7 +1547,7 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a
1547
1547
* icinga:config:object:downtime) need to be prepended. There is nothing to indicate success or failure.
1548
1548
*/
1549
1549
void
1550
- IcingaDB::CreateConfigUpdate (const ConfigObject::Ptr & object, const String typeName, std::map<String, std::vector<String> >& hMSets,
1550
+ IcingaDB::CreateConfigUpdate (const ConfigObject::Ptr & object, const String typeName, std::map<String, RedisConnection::Query >& hMSets,
1551
1551
std::vector<Dictionary::Ptr >& runtimeUpdates, bool runtimeUpdate)
1552
1552
{
1553
1553
/* TODO: This isn't essentially correct as we don't keep track of config objects ourselves. This would avoid duplicated config updates at startup.
@@ -1710,7 +1710,7 @@ void IcingaDB::SendStateChange(const ConfigObject::Ptr& object, const CheckResul
1710
1710
Array::Ptr rawId = new Array ({m_EnvironmentId, object->GetName ()});
1711
1711
rawId->Add (eventTs);
1712
1712
1713
- std::vector<String> xAdd ({
1713
+ RedisConnection::Query xAdd ({
1714
1714
" XADD" , " icinga:history:stream:state" , " *" ,
1715
1715
" id" , HashValue (rawId),
1716
1716
" environment_id" , m_EnvironmentId,
@@ -1794,7 +1794,7 @@ void IcingaDB::SendSentNotification(
1794
1794
1795
1795
auto notificationHistoryId (HashValue (rawId));
1796
1796
1797
- std::vector<String> xAdd ({
1797
+ RedisConnection::Query xAdd ({
1798
1798
" XADD" , " icinga:history:stream:notification" , " *" ,
1799
1799
" id" , notificationHistoryId,
1800
1800
" environment_id" , m_EnvironmentId,
@@ -1858,7 +1858,7 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
1858
1858
/* Update checkable state as in_downtime may have changed. */
1859
1859
UpdateState (checkable, StateUpdate::Full);
1860
1860
1861
- std::vector<String> xAdd ({
1861
+ RedisConnection::Query xAdd ({
1862
1862
" XADD" , " icinga:history:stream:downtime" , " *" ,
1863
1863
" downtime_id" , GetObjectIdentifier (downtime),
1864
1864
" environment_id" , m_EnvironmentId,
@@ -1948,7 +1948,7 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
1948
1948
/* Update checkable state as in_downtime may have changed. */
1949
1949
UpdateState (checkable, StateUpdate::Full);
1950
1950
1951
- std::vector<String> xAdd ({
1951
+ RedisConnection::Query xAdd ({
1952
1952
" XADD" , " icinga:history:stream:downtime" , " *" ,
1953
1953
" downtime_id" , GetObjectIdentifier (downtime),
1954
1954
" environment_id" , m_EnvironmentId,
@@ -2030,7 +2030,7 @@ void IcingaDB::SendAddedComment(const Comment::Ptr& comment)
2030
2030
Service::Ptr service;
2031
2031
tie (host, service) = GetHostService (checkable);
2032
2032
2033
- std::vector<String> xAdd ({
2033
+ RedisConnection::Query xAdd ({
2034
2034
" XADD" , " icinga:history:stream:comment" , " *" ,
2035
2035
" comment_id" , GetObjectIdentifier (comment),
2036
2036
" environment_id" , m_EnvironmentId,
@@ -2102,7 +2102,7 @@ void IcingaDB::SendRemovedComment(const Comment::Ptr& comment)
2102
2102
Service::Ptr service;
2103
2103
tie (host, service) = GetHostService (checkable);
2104
2104
2105
- std::vector<String> xAdd ({
2105
+ RedisConnection::Query xAdd ({
2106
2106
" XADD" , " icinga:history:stream:comment" , " *" ,
2107
2107
" comment_id" , GetObjectIdentifier (comment),
2108
2108
" environment_id" , m_EnvironmentId,
@@ -2165,7 +2165,7 @@ void IcingaDB::SendFlappingChange(const Checkable::Ptr& checkable, double change
2165
2165
Service::Ptr service;
2166
2166
tie (host, service) = GetHostService (checkable);
2167
2167
2168
- std::vector<String> xAdd ({
2168
+ RedisConnection::Query xAdd ({
2169
2169
" XADD" , " icinga:history:stream:flapping" , " *" ,
2170
2170
" environment_id" , m_EnvironmentId,
2171
2171
" host_id" , GetObjectIdentifier (host),
@@ -2260,7 +2260,7 @@ void IcingaDB::SendAcknowledgementSet(const Checkable::Ptr& checkable, const Str
2260
2260
/* Update checkable state as is_acknowledged may have changed. */
2261
2261
UpdateState (checkable, StateUpdate::Full);
2262
2262
2263
- std::vector<String> xAdd ({
2263
+ RedisConnection::Query xAdd ({
2264
2264
" XADD" , " icinga:history:stream:acknowledgement" , " *" ,
2265
2265
" environment_id" , m_EnvironmentId,
2266
2266
" host_id" , GetObjectIdentifier (host),
@@ -2318,7 +2318,7 @@ void IcingaDB::SendAcknowledgementCleared(const Checkable::Ptr& checkable, const
2318
2318
/* Update checkable state as is_acknowledged may have changed. */
2319
2319
UpdateState (checkable, StateUpdate::Full);
2320
2320
2321
- std::vector<String> xAdd ({
2321
+ RedisConnection::Query xAdd ({
2322
2322
" XADD" , " icinga:history:stream:acknowledgement" , " *" ,
2323
2323
" environment_id" , m_EnvironmentId,
2324
2324
" host_id" , GetObjectIdentifier (host),
@@ -2959,7 +2959,7 @@ void IcingaDB::DeleteRelationship(const String& id, const String& redisKeyWithou
2959
2959
2960
2960
String redisKey = m_PrefixConfigObject + redisKeyWithoutPrefix;
2961
2961
2962
- std::vector<std::vector<String>> queries;
2962
+ RedisConnection::Queries queries;
2963
2963
2964
2964
if (hasChecksum) {
2965
2965
queries.push_back ({" HDEL" , m_PrefixConfigCheckSum + redisKeyWithoutPrefix, id});
0 commit comments