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

Method CommitItems

lib/config/configitem.cpp:598–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems, bool silent)
599{
600 if (!silent)
601 Log(LogInformation, "ConfigItem", "Committing config item(s).");
602
603 if (!CommitNewItems(context, upq, newItems)) {
604 upq.ReportExceptions("config");
605
606 for (const ConfigItem::Ptr& item : newItems) {
607 item->Unregister();
608 }
609
610 return false;
611 }
612
613 ApplyRule::CheckMatches(silent);
614
615 if (!silent) {
616 /* log stats for external parsers */
617 typedef std::map<Type::Ptr, int> ItemCountMap;
618 ItemCountMap itemCounts;
619 for (const ConfigItem::Ptr& item : newItems) {
620 if (!item->m_Object)
621 continue;
622
623 itemCounts[item->m_Object->GetReflectionType()]++;
624 }
625
626 for (const ItemCountMap::value_type& kv : itemCounts) {
627 Log(LogInformation, "ConfigItem")
628 << "Instantiated " << kv.second << " " << (kv.second != 1 ? kv.first->GetPluralName() : kv.first->GetName()) << ".";
629 }
630 }
631
632 return true;
633}
634
635/**
636 * ActivateItems activates new config items.

Callers

nothing calls this directly

Calls 6

LogClass · 0.85
ReportExceptionsMethod · 0.80
UnregisterMethod · 0.45
GetReflectionTypeMethod · 0.45
GetPluralNameMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected