MCPcopy Create free account
hub / github.com/apache/trafficserver / RecCoreInit

Function RecCoreInit

src/records/RecCore.cc:197–258  ·  view source on GitHub ↗

------------------------------------------------------------------------- RecCoreInit -------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

195// RecCoreInit
196//-------------------------------------------------------------------------
197int
198RecCoreInit(Diags *_diags)
199{
200 if (g_initialized) {
201 return REC_ERR_OKAY;
202 }
203
204 // set our diags
205 RecSetDiags(_diags);
206
207 // Initialize config file parsing data structures.
208 RecConfigFileInit();
209
210 g_num_records = 0;
211
212 // initialize record array for our internal stats (this can be reallocated later)
213 g_records = static_cast<RecRecord *>(ats_malloc(max_records_entries * sizeof(RecRecord)));
214
215 // initialize record rwlock
216 ink_rwlock_init(&g_records_rwlock);
217
218 // read stats
219 RecReadStatsFile();
220
221 // read configs
222 bool file_exists = true;
223
224 ink_mutex_init(&g_rec_config_lock);
225
226 g_rec_config_fpath = ats_stringdup(RecConfigReadConfigPath(nullptr, ts::filename::RECORDS));
227
228 // Make sure there is no legacy file, if so we drop a BIG WARNING and fail.
229 // This is to avoid issues with someone ignoring that we now use records.yaml
230 swoc::file::path old_config{RecConfigReadConfigPath(nullptr, "records.config")};
231 if (swoc::file::is_readable(old_config)) {
232 RecLog(DL_Fatal,
233 "**** Found a legacy config file (%s). Please remove it and migrate to the new YAML format before continuing. ****",
234 old_config.c_str());
235 }
236
237 if (RecFileExists(g_rec_config_fpath) == REC_ERR_FAIL) {
238 RecLog(DL_Warning, "Could not find '%s', system will run with defaults\n", ts::filename::RECORDS);
239 file_exists = false;
240 }
241
242 if (file_exists) {
243 auto err = RecReadYamlConfigFile();
244 RecLog(DL_Note, "records parsing completed.");
245 if (!err.empty()) {
246 std::string text;
247 RecLog(DL_Warning, "%s",
248 swoc::bwprint(text, "We have found the following issues when reading the records node:\n {}", err).c_str());
249 }
250 } else {
251 RecLog(DL_Note, "%s does not exist.", g_rec_config_fpath);
252 }
253
254 RecLog(DL_Note, "%s finished loading", std::string{g_rec_config_fpath}.c_str());

Callers 1

RecProcessInitFunction · 0.85

Calls 13

RecSetDiagsFunction · 0.85
RecConfigFileInitFunction · 0.85
ats_mallocFunction · 0.85
ink_rwlock_initFunction · 0.85
RecReadStatsFileFunction · 0.85
ink_mutex_initFunction · 0.85
ats_stringdupFunction · 0.85
RecConfigReadConfigPathFunction · 0.85
is_readableFunction · 0.85
RecFileExistsFunction · 0.85
RecReadYamlConfigFileFunction · 0.85
c_strMethod · 0.45

Tested by

no test coverage detected