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

Method ForwardHistoryEntries

lib/icingadb/icingadb-objects.cpp:2562–2632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2560}
2561
2562void IcingaDB::ForwardHistoryEntries()
2563{
2564 using clock = std::chrono::steady_clock;
2565
2566 const std::chrono::seconds logInterval (10);
2567 auto nextLog (clock::now() + logInterval);
2568
2569 auto logPeriodically ([this, logInterval, &nextLog]() {
2570 if (clock::now() > nextLog) {
2571 nextLog += logInterval;
2572
2573 auto size (m_HistoryBulker.Size());
2574
2575 Log(size > m_HistoryBulker.GetBulkSize() ? LogInformation : LogNotice, "IcingaDB")
2576 << "Pending history queries: " << size;
2577 }
2578 });
2579
2580 for (;;) {
2581 logPeriodically();
2582
2583 auto haystack (m_HistoryBulker.ConsumeMany());
2584
2585 if (haystack.empty()) {
2586 if (!GetActive()) {
2587 break;
2588 }
2589
2590 continue;
2591 }
2592
2593 uintmax_t attempts = 0;
2594
2595 auto logFailure ([&haystack, &attempts](const char* err = nullptr) {
2596 Log msg (LogNotice, "IcingaDB");
2597
2598 msg << "history: " << haystack.size() << " queries failed temporarily (attempt #" << ++attempts << ")";
2599
2600 if (err) {
2601 msg << ": " << err;
2602 }
2603 });
2604
2605 for (;;) {
2606 logPeriodically();
2607
2608 if (m_Rcon && m_Rcon->IsConnected()) {
2609 try {
2610 m_Rcon->GetResultsOfQueries(haystack, {0, 0, haystack.size()});
2611 break;
2612 } catch (const std::exception& ex) {
2613 logFailure(ex.what());
2614 } catch (...) {
2615 logFailure();
2616 }
2617 } else {
2618 logFailure("not connected to Redis");
2619 }

Callers

nothing calls this directly

Calls 9

LogClass · 0.85
GetBulkSizeMethod · 0.80
ConsumeManyMethod · 0.80
IsConnectedMethod · 0.80
GetResultsOfQueriesMethod · 0.80
SizeMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected