MCPcopy Create free account
hub / github.com/Icinga/icinga2 / UpdateAllConfigObjects

Method UpdateAllConfigObjects

lib/icingadb/icingadb-objects.cpp:211–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void 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

Callers

nothing calls this directly

Calls 15

LogClass · 0.85
FireAndForgetQueryMethod · 0.80
SyncMethod · 0.80
ResetMethod · 0.80
ParallelForMethod · 0.80
ToLowerMethod · 0.80
GetResultOfQueryMethod · 0.80
findMethod · 0.80
IsActiveMethod · 0.80
HasExceptionsMethod · 0.80
GetExceptionsMethod · 0.80
emplaceMethod · 0.80

Tested by

no test coverage detected