| 209 | } |
| 210 | |
| 211 | void IcingaDB::UpdateAllConfigObjects() |
| 212 | { |
| 213 | // This function performs an initial dump of all configuration objects into Redis, thus there are no |
| 214 | // previously enqueued queries on m_RconWorker that we need to wait for. So, no Sync() call is necessary here. |
| 215 | m_RconWorker->FireAndForgetQuery({"XADD", "icinga:schema", "MAXLEN", "1", "*", "version", "6"}, {}, true); |
| 216 | |
| 217 | Log(LogInformation, "IcingaDB") << "Starting initial config/status dump"; |
| 218 | double startTime = Utility::GetTime(); |
| 219 | |
| 220 | SetOngoingDumpStart(startTime); |
| 221 | |
| 222 | Defer resetOngoingDumpStart ([this]() { |
| 223 | SetOngoingDumpStart(0); |
| 224 | }); |
| 225 | |
| 226 | // Use a Workqueue to pack objects in parallel |
| 227 | WorkQueue upq(25000, Configuration::Concurrency, LogNotice); |
| 228 | upq.SetName("IcingaDB:ConfigDump"); |
| 229 | |
| 230 | // Add a new type=* state=wip entry to the stream and remove all previous entries (MAXLEN 1). |
| 231 | m_RconWorker->FireAndForgetQuery({"XADD", "icinga:dump", "MAXLEN", "1", "*", "key", "*", "state", "wip"}); |
| 232 | |
| 233 | const std::vector<RedisConnection::QueryArg> globalKeys = { |
| 234 | CONFIG_REDIS_KEY_PREFIX "customvar", |
| 235 | CONFIG_REDIS_KEY_PREFIX "action:url", |
| 236 | CONFIG_REDIS_KEY_PREFIX "notes:url", |
| 237 | CONFIG_REDIS_KEY_PREFIX "icon:image", |
| 238 | |
| 239 | // These keys aren't tied to a specific Checkable type but apply to both "Host" and "Service" types, |
| 240 | // and as such we've to make sure to clear them before we actually start dumping the actual objects. |
| 241 | // This allows us to wait on both types to be dumped before we send a config dump done signal for those keys. |
| 242 | CONFIG_REDIS_KEY_PREFIX "dependency:node", |
| 243 | CONFIG_REDIS_KEY_PREFIX "dependency:edge", |
| 244 | CONFIG_REDIS_KEY_PREFIX "dependency:edge:state", |
| 245 | CONFIG_REDIS_KEY_PREFIX "redundancygroup", |
| 246 | CONFIG_REDIS_KEY_PREFIX "redundancygroup:state", |
| 247 | }; |
| 248 | DeleteKeys(m_RconWorker, globalKeys); |
| 249 | DeleteKeys(m_RconWorker, {"icinga:nextupdate:host", "icinga:nextupdate:service"}); |
| 250 | m_RconWorker->Sync(); |
| 251 | |
| 252 | Defer resetDumpedGlobals ([this]() { |
| 253 | m_DumpedGlobals.CustomVar.Reset(); |
| 254 | m_DumpedGlobals.ActionUrl.Reset(); |
| 255 | m_DumpedGlobals.NotesUrl.Reset(); |
| 256 | m_DumpedGlobals.IconImage.Reset(); |
| 257 | m_DumpedGlobals.DependencyGroup.Reset(); |
| 258 | }); |
| 259 | |
| 260 | upq.ParallelFor(l_SyncableTypes, false, [this](const SyncableTypeInfo& info) { |
| 261 | // No structured binding is allowed here till C++20 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85889). |
| 262 | Type::Ptr type; |
| 263 | QueryArgPair redisKeyPair; |
| 264 | std::tie(type, redisKeyPair) = info; |
| 265 | ConfigType *ctype = dynamic_cast<ConfigType *>(type.get()); |
| 266 | if (!ctype) |
| 267 | return; |
| 268 |
nothing calls this directly
no test coverage detected