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

Method SendConfigUpdateHeavy

lib/db_ido/dbobject.cpp:112–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110}
111
112void DbObject::SendConfigUpdateHeavy(const Dictionary::Ptr& configFields)
113{
114 /* update custom var config and status */
115 SendVarsConfigUpdateHeavy();
116
117 /* config attributes */
118 if (!configFields)
119 return;
120
121 ASSERT(configFields->Contains("config_hash"));
122
123 Value configHash = configFields->Get("config_hash");
124 // Since all the child tables are relying on the inserted parent ID, we first need to insert/update the
125 // configuration fields of the current object without the actual config_hash value. Having the config hash
126 // set only after all relation queries eliminates some rare race conditions where e.g. host group members
127 // are not written to the database because Icinga 2 / the DBMS was unexpectedly stopped/reloaded shortly
128 // after the config_hash column was updated.
129 configFields->Set("config_hash", Empty);
130
131 ConfigObject::Ptr object = GetObject();
132
133 DbQuery query;
134 query.Table = GetType()->GetTable() + "s";
135 query.Type = DbQueryInsert | DbQueryUpdate;
136 query.Category = DbCatConfig;
137 query.Fields = configFields;
138 query.Fields->Set(GetType()->GetIDColumn(), object);
139 query.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
140 query.Fields->Set("config_type", 1);
141 query.WhereCriteria = new Dictionary({
142 { GetType()->GetIDColumn(), object }
143 });
144 query.Object = this;
145 query.ConfigUpdate = true;
146 OnQuery(query);
147
148 m_LastConfigUpdate = Utility::GetTime();
149
150 // Trigger config heavy udpates of the child classes.
151 OnConfigUpdateHeavy();
152
153 // Now update the config hash attribute of the current object.
154 DbQuery configHashQuery;
155 configHashQuery.Table = GetType()->GetTable() + "s";
156 configHashQuery.Type = DbQueryUpdate;
157 configHashQuery.Category = DbCatConfig;
158 configHashQuery.Fields = new Dictionary({{"config_hash", configHash}});
159 configHashQuery.Object = this;
160 configHashQuery.ConfigUpdate = true;
161 configHashQuery.WhereCriteria = new Dictionary({{GetType()->GetIDColumn(), object}});
162 OnQuery(configHashQuery);
163
164 // Lastly, update some common configs that do not affect the config_hash column.
165 OnConfigUpdateLight();
166}
167
168void DbObject::SendConfigUpdateLight()
169{

Callers 2

VersionChangedHandlerMethod · 0.80
UpdateObjectMethod · 0.80

Calls 5

GetTableMethod · 0.80
GetIDColumnMethod · 0.80
ContainsMethod · 0.45
GetMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected