Private record core definitions. More...
#include "TextBuffer.h"
#include "Tokenizer.h"
#include "ink_defs.h"
#include "ink_string.h"
#include "P_RecFile.h"
#include "P_RecUtils.h"
#include "P_RecMessage.h"
#include "P_RecCore.h"
Go to the source code of this file.
Defines | |
#define | REC_REGISTER_STAT_XXX(A, B) |
#define | REC_REGISTER_CONFIG_XXX(A, B) |
#define | TMP_FILENAME_EXT_STR ".tmp" |
#define | TMP_FILENAME_EXT_LEN (sizeof(TMP_FILENAME_EXT_STR) - 1) |
Functions | |
static int | send_reset_message (RecRecord *record) |
static int | send_set_message (RecRecord *record) |
int | send_register_message (RecRecord *record) |
int | send_push_message () |
int | send_pull_message (RecMessageT msg_type) |
int | recv_message_cb (RecMessage *msg, RecMessageT msg_type, void *) |
int | _RecRegisterStatInt (RecT rec_type, const char *name, RecInt data_default, RecPersistT persist_type) |
int | _RecRegisterStatFloat (RecT rec_type, const char *name, RecFloat data_default, RecPersistT persist_type) |
int | _RecRegisterStatString (RecT rec_type, const char *name, RecString data_default, RecPersistT persist_type) |
int | _RecRegisterStatCounter (RecT rec_type, const char *name, RecCounter data_default, RecPersistT persist_type) |
int | RecRegisterConfigInt (RecT rec_type, const char *name, RecInt data_default, RecUpdateT update_type, RecCheckT check_type, const char *check_regex, RecAccessT access_type) |
int | RecRegisterConfigFloat (RecT rec_type, const char *name, RecFloat data_default, RecUpdateT update_type, RecCheckT check_type, const char *check_regex, RecAccessT access_type) |
int | RecRegisterConfigString (RecT rec_type, const char *name, const char *data_default_tmp, RecUpdateT update_type, RecCheckT check_type, const char *check_regex, RecAccessT access_type) |
int | RecRegisterConfigCounter (RecT rec_type, const char *name, RecCounter data_default, RecUpdateT update_type, RecCheckT check_type, const char *check_regex, RecAccessT access_type) |
int | RecSetRecord (RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *data_raw, bool lock, bool inc_version) |
int | RecSetRecordConvert (const char *name, const RecString rec_string, bool lock, bool inc_version) |
int | RecSetRecordInt (const char *name, RecInt rec_int, bool lock, bool inc_version) |
int | RecSetRecordFloat (const char *name, RecFloat rec_float, bool lock, bool inc_version) |
int | RecSetRecordString (const char *name, const RecString rec_string, bool lock, bool inc_version) |
int | RecSetRecordCounter (const char *name, RecCounter rec_counter, bool lock, bool inc_version) |
int | RecReadStatsFile () |
int | RecSyncStatsFile () |
static void | RecConsumeConfigEntry (RecT rec_type, RecDataT data_type, const char *name, const char *value, bool inc_version) |
int | RecReadConfigFile (bool inc_version) |
int | RecSyncConfigToTB (textBuffer *tb, bool *inc_version) |
int | RecExecConfigUpdateCbs (unsigned int update_required_type) |
int | RecResetStatRecord (const char *name) |
int | RecResetStatRecord (RecT type, bool all) |
int | RecSetSyncRequired (char *name, bool lock) |
int | RecWriteConfigFile (textBuffer *tb) |
Variables | |
RecModeT | g_mode_type = RECM_NULL |
Private record core definitions.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file P_RecCore.cc.
#define REC_REGISTER_CONFIG_XXX | ( | A, | ||
B | ||||
) |
RecRecord *r; \ RecData my_data_default; \ my_data_default.A = data_default; \ if ((r = RecRegisterConfig(rec_type, name, B, my_data_default, \ update_type, check_type, \ check_regex, access_type)) != NULL) { \ if (i_am_the_record_owner(r->rec_type)) { \ r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ } else { \ send_register_message(r); \ } \ return REC_ERR_OKAY; \ } else { \ return REC_ERR_FAIL; \ }
Definition at line 322 of file P_RecCore.cc.
Referenced by RecRegisterConfigCounter(), RecRegisterConfigFloat(), RecRegisterConfigInt(), and RecRegisterConfigString().
#define REC_REGISTER_STAT_XXX | ( | A, | ||
B | ||||
) |
ink_assert((rec_type == RECT_NODE) || \ (rec_type == RECT_CLUSTER) || \ (rec_type == RECT_PROCESS) || \ (rec_type == RECT_LOCAL) || \ (rec_type == RECT_PLUGIN)); \ RecRecord *r; \ RecData my_data_default; \ my_data_default.A = data_default; \ if ((r = RecRegisterStat(rec_type, name, B, my_data_default, \ persist_type)) != NULL) { \ if (i_am_the_record_owner(r->rec_type)) { \ r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ } else { \ send_register_message(r); \ } \ return REC_ERR_OKAY; \ } else { \ return REC_ERR_FAIL; \ }
Definition at line 273 of file P_RecCore.cc.
Referenced by _RecRegisterStatCounter(), _RecRegisterStatFloat(), _RecRegisterStatInt(), and _RecRegisterStatString().
#define TMP_FILENAME_EXT_LEN (sizeof(TMP_FILENAME_EXT_STR) - 1) |
#define TMP_FILENAME_EXT_STR ".tmp" |
Referenced by RecWriteConfigFile().
int _RecRegisterStatCounter | ( | RecT | rec_type, | |
const char * | name, | |||
RecCounter | data_default, | |||
RecPersistT | persist_type | |||
) |
Definition at line 313 of file P_RecCore.cc.
References REC_REGISTER_STAT_XXX, and RECD_COUNTER.
int _RecRegisterStatFloat | ( | RecT | rec_type, | |
const char * | name, | |||
RecFloat | data_default, | |||
RecPersistT | persist_type | |||
) |
Definition at line 301 of file P_RecCore.cc.
References REC_REGISTER_STAT_XXX, and RECD_FLOAT.
int _RecRegisterStatInt | ( | RecT | rec_type, | |
const char * | name, | |||
RecInt | data_default, | |||
RecPersistT | persist_type | |||
) |
Definition at line 295 of file P_RecCore.cc.
References REC_REGISTER_STAT_XXX, and RECD_INT.
int _RecRegisterStatString | ( | RecT | rec_type, | |
const char * | name, | |||
RecString | data_default, | |||
RecPersistT | persist_type | |||
) |
Definition at line 307 of file P_RecCore.cc.
References REC_REGISTER_STAT_XXX, and RECD_STRING.
static void RecConsumeConfigEntry | ( | RecT | rec_type, | |
RecDataT | data_type, | |||
const char * | name, | |||
const char * | value, | |||
bool | inc_version | |||
) | [static] |
Definition at line 629 of file P_RecCore.cc.
References RecDataClear(), RecDataSetFromString(), and RecSetRecord().
Referenced by RecReadConfigFile().
int RecExecConfigUpdateCbs | ( | unsigned int | update_required_type | ) |
Definition at line 802 of file P_RecCore.cc.
References RecRecord::config_meta, RecRecord::data, RecRecord::data_type, g_num_records, g_records, RecRecord::lock, RecRecord::name, RecConfigCbList_t::next, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, REC_TYPE_IS_CONFIG, RecConfigCbList_t::update_cb, RecConfigMeta::update_cb_list, RecConfigCbList_t::update_cookie, and RecConfigMeta::update_required.
Referenced by config_update_thr(), and config_update_cont::exec_callbacks().
int RecReadConfigFile | ( | bool | inc_version | ) |
Definition at line 643 of file P_RecCore.cc.
References DL_Note, g_rec_config_fpath, g_records_rwlock, ink_rwlock_unlock(), ink_rwlock_wrlock(), RecConfigFileParse(), RecConsumeConfigEntry(), and RecDebug().
Referenced by RecCoreInit().
int RecReadStatsFile | ( | ) |
Definition at line 531 of file P_RecCore.cc.
References ats_free(), RecRecord::data, RecStatMeta::data_raw, RecRecord::data_type, DL_Debug, DL_Warning, g_records_rwlock, ink_rwlock_unlock(), ink_rwlock_wrlock(), RecRecord::name, REC_ERR_FAIL, REC_ERR_OKAY, RecRecord::rec_type, REC_TYPE_IS_STAT, RecConfigReadPersistentStatsPath(), RecDebug(), RecGetRecordPersistenceType(), RecLog(), RecMessageReadFromDisk(), RecMessageUnmarshalFirst(), RecMessageUnmarshalNext(), RECP_NON_PERSISTENT, RecSetRecord(), and RecRecord::stat_meta.
Referenced by RecCoreInit().
int RecRegisterConfigCounter | ( | RecT | rec_type, | |
const char * | name, | |||
RecCounter | data_default, | |||
RecUpdateT | update_type, | |||
RecCheckT | check_type, | |||
const char * | check_regex, | |||
RecAccessT | access_type | |||
) |
Definition at line 369 of file P_RecCore.cc.
References ink_assert, REC_REGISTER_CONFIG_XXX, RECD_COUNTER, RECT_CONFIG, and RECT_LOCAL.
int RecRegisterConfigFloat | ( | RecT | rec_type, | |
const char * | name, | |||
RecFloat | data_default, | |||
RecUpdateT | update_type, | |||
RecCheckT | check_type, | |||
const char * | check_regex, | |||
RecAccessT | access_type | |||
) |
Definition at line 349 of file P_RecCore.cc.
References ink_assert, REC_REGISTER_CONFIG_XXX, RECD_FLOAT, RECT_CONFIG, and RECT_LOCAL.
int RecRegisterConfigInt | ( | RecT | rec_type, | |
const char * | name, | |||
RecInt | data_default, | |||
RecUpdateT | update_type, | |||
RecCheckT | check_type, | |||
const char * | check_regex, | |||
RecAccessT | access_type | |||
) |
Definition at line 340 of file P_RecCore.cc.
References ink_assert, REC_REGISTER_CONFIG_XXX, RECD_INT, RECT_CONFIG, and RECT_LOCAL.
Referenced by DiagsConfig::RegisterDiagConfig(), and TSMgmtIntCreate().
int RecRegisterConfigString | ( | RecT | rec_type, | |
const char * | name, | |||
const char * | data_default_tmp, | |||
RecUpdateT | update_type, | |||
RecCheckT | check_type, | |||
const char * | check_regex, | |||
RecAccessT | access_type | |||
) |
Definition at line 359 of file P_RecCore.cc.
References ink_assert, REC_REGISTER_CONFIG_XXX, RECD_STRING, RECT_CONFIG, and RECT_LOCAL.
Referenced by DiagsConfig::RegisterDiagConfig(), and TSMgmtStringCreate().
int RecResetStatRecord | ( | const char * | name | ) |
Definition at line 841 of file P_RecCore.cc.
References RecRecord::data, RecRecord::data_type, g_records_ht, i_am_the_record_owner(), ink_hash_table_lookup(), RecRecord::name, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, RecDataSet(), RecRecordFree(), RecRecordInit(), and send_reset_message().
Referenced by recv_message_cb().
int RecResetStatRecord | ( | RecT | type, | |
bool | all | |||
) |
Definition at line 877 of file P_RecCore.cc.
References RecRecord::data, RecRecord::data_default, RecRecord::data_type, DL_Note, g_num_records, g_records, i_am_the_record_owner(), RecRecord::lock, RecRecord::name, RecStatMeta::persist_type, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, REC_TYPE_IS_STAT, RECD_STRING, RecDataSet(), RecDebug(), RECP_NON_PERSISTENT, RecRecordFree(), RecRecordInit(), send_reset_message(), RecRecord::stat_meta, and RecRecord::version.
int RecSetRecord | ( | RecT | rec_type, | |
const char * | name, | |||
RecDataT | data_type, | |||
RecData * | data, | |||
RecRawStat * | data_raw, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 382 of file P_RecCore.cc.
References RecRecord::data, RecStatMeta::data_raw, RecRecord::data_type, g_records_ht, g_records_rwlock, i_am_the_record_owner(), ink_assert, ink_atoi64(), ink_hash_table_insert(), ink_hash_table_lookup(), ink_rwlock_unlock(), ink_rwlock_wrlock(), RecRecord::name, rec_mutex_acquire(), rec_mutex_release(), RecData::rec_string, RecRecord::rec_type, REC_TYPE_IS_CONFIG, REC_TYPE_IS_STAT, RecAlloc(), RECD_COUNTER, RECD_FLOAT, RECD_INT, RECD_NULL, RECD_STRING, RecDataSet(), RecRecordFree(), RecRecordInit(), RECT_NULL, send_set_message(), and RecRecord::stat_meta.
Referenced by RecConsumeConfigEntry(), RecReadStatsFile(), RecSetRecordConvert(), RecSetRecordCounter(), RecSetRecordFloat(), RecSetRecordInt(), RecSetRecordString(), and recv_message_cb().
int RecSetRecordConvert | ( | const char * | name, | |
const RecString | rec_string, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 487 of file P_RecCore.cc.
References RecData::rec_string, RECD_NULL, RecSetRecord(), and RECT_NULL.
int RecSetRecordCounter | ( | const char * | name, | |
RecCounter | rec_counter, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 519 of file P_RecCore.cc.
References RecData::rec_counter, RECD_COUNTER, RecSetRecord(), and RECT_NULL.
int RecSetRecordFloat | ( | const char * | name, | |
RecFloat | rec_float, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 503 of file P_RecCore.cc.
References RecData::rec_float, RECD_FLOAT, RecSetRecord(), and RECT_NULL.
int RecSetRecordInt | ( | const char * | name, | |
RecInt | rec_int, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 495 of file P_RecCore.cc.
References RecData::rec_int, RECD_INT, RecSetRecord(), and RECT_NULL.
Referenced by CB_After_Cache_Init().
int RecSetRecordString | ( | const char * | name, | |
const RecString | rec_string, | |||
bool | lock, | |||
bool | inc_version | |||
) |
Definition at line 511 of file P_RecCore.cc.
References RecData::rec_string, RECD_STRING, RecSetRecord(), and RECT_NULL.
int RecSetSyncRequired | ( | char * | name, | |
bool | lock | |||
) |
Definition at line 917 of file P_RecCore.cc.
References g_records_ht, g_records_rwlock, i_am_the_record_owner(), ink_hash_table_lookup(), ink_rwlock_unlock(), ink_rwlock_wrlock(), rec_mutex_acquire(), rec_mutex_release(), and REC_TYPE_IS_CONFIG.
int RecSyncConfigToTB | ( | textBuffer * | tb, | |
bool * | inc_version | |||
) |
Definition at line 664 of file P_RecCore.cc.
References ats_malloc(), ats_strdup, textBuffer::copyFrom(), llqrec_s::data, enqueue(), RecConfigFileEntry::entry, RecConfigFileEntry::entry_type, g_mode_type, g_num_records, g_rec_config_contents_ht, g_rec_config_contents_llq, g_rec_config_lock, g_records, g_records_ht, g_records_rwlock, llq_s::head, ink_assert, ink_hash_table_insert(), ink_hash_table_isbound(), ink_hash_table_lookup(), ink_mutex_acquire(), ink_mutex_release(), ink_rwlock_rdlock(), ink_rwlock_unlock(), RecRecord::lock, RecRecord::name, llqrec_s::next, REC_DISK_SYNC_REQUIRED, REC_INC_CONFIG_VERSION, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, REC_TYPE_IS_CONFIG, RECD_COUNTER, RECD_FLOAT, RECD_INT, RECD_STRING, RECE_COMMENT, RECM_NULL, RECM_SERVER, RECM_STAND_ALONE, RECT_CLUSTER, RECT_CONFIG, RECT_LOCAL, RECT_NODE, RECT_PROCESS, textBuffer::reUse(), and RecRecord::sync_required.
Referenced by sync_cont::sync(), and sync_thr().
int RecSyncStatsFile | ( | ) |
Definition at line 588 of file P_RecCore.cc.
References DL_Note, g_mode_type, g_num_records, g_records, ink_assert, RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, RecStatMeta::persist_type, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, REC_TYPE_IS_STAT, RecConfigReadPersistentStatsPath(), RecDebug(), RECG_NULL, RECM_NULL, RECM_SERVER, RECM_STAND_ALONE, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), RecMessageWriteToDisk(), RECP_PERSISTENT, and RecRecord::stat_meta.
Referenced by sync_cont::sync(), and sync_thr().
int recv_message_cb | ( | RecMessage * | msg, | |
RecMessageT | msg_type, | |||
void * | ||||
) |
Definition at line 187 of file P_RecCore.cc.
References RecConfigMeta::access_type, RecConfigMeta::check_expr, RecConfigMeta::check_type, RecRecord::config_meta, RecRecord::data, RecRecord::data_default, RecStatMeta::data_raw, RecRecord::data_type, DL_Note, ink_assert, RecRecord::name, RecMessageHdr::o_end, RecMessageHdr::o_start, RecStatMeta::persist_type, REC_ERR_FAIL, RecRecord::rec_type, REC_TYPE_IS_CONFIG, REC_TYPE_IS_STAT, RecDebug(), RecForceInsert(), RECG_PULL_ACK, RECG_PULL_REQ, RECG_PUSH, RECG_REGISTER, RECG_RESET, RECG_SET, RecMessageUnmarshalFirst(), RecMessageUnmarshalNext(), RecRegisterConfig(), RecRegisterStat(), RecResetStatRecord(), RecSetRecord(), send_pull_message(), RecRecord::stat_meta, and RecConfigMeta::update_type.
Referenced by RecLocalInitMessage(), and recv_message_cb__process().
int RecWriteConfigFile | ( | textBuffer * | tb | ) |
Definition at line 965 of file P_RecCore.cc.
References ats_free(), ats_malloc(), textBuffer::bufPtr(), DL_Note, DL_Warning, g_rec_config_fpath, REC_ERR_OKAY, REC_HANDLE_INVALID, RecDebug(), RecFileClose(), RecFileOpenW(), RecFileSync(), RecFileWrite(), RecLog(), textBuffer::spaceUsed(), and TMP_FILENAME_EXT_STR.
Referenced by sync_cont::sync(), and sync_thr().
int send_pull_message | ( | RecMessageT | msg_type | ) |
Definition at line 136 of file P_RecCore.cc.
References DL_Note, g_num_records, g_records, i_am_the_record_owner(), RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, RecStatMeta::persist_type, rec_mutex_acquire(), rec_mutex_release(), RecRecord::rec_type, REC_TYPE_IS_STAT, RecDebug(), RECG_PULL_ACK, RECG_PULL_REQ, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), RecMessageSend(), RecRecord::registered, RecRecord::stat_meta, and RecRecord::sync_required.
Referenced by RecProcessInitMessage(), and recv_message_cb().
int send_push_message | ( | ) |
Definition at line 101 of file P_RecCore.cc.
References DL_Note, g_num_records, g_records, i_am_the_record_owner(), RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, rec_mutex_acquire(), rec_mutex_release(), REC_PEER_SYNC_REQUIRED, RecRecord::rec_type, RecDebug(), RECG_PUSH, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), RecMessageSend(), and RecRecord::sync_required.
Referenced by sync_cont::sync(), and sync_thr().
int send_register_message | ( | RecRecord * | record | ) |
Definition at line 81 of file P_RecCore.cc.
References DL_Note, RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, rec_mutex_acquire(), rec_mutex_release(), RecDebug(), RECG_REGISTER, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), and RecMessageSend().
Referenced by _RecRegisterRawStat().
static int send_reset_message | ( | RecRecord * | record | ) | [static] |
Definition at line 41 of file P_RecCore.cc.
References DL_Note, RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, rec_mutex_acquire(), rec_mutex_release(), RecDebug(), RECG_RESET, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), and RecMessageSend().
Referenced by RecResetStatRecord().
static int send_set_message | ( | RecRecord * | record | ) | [static] |
Definition at line 61 of file P_RecCore.cc.
References DL_Note, RecRecord::lock, RecMessageHdr::o_start, RecMessageHdr::o_write, rec_mutex_acquire(), rec_mutex_release(), RecDebug(), RECG_SET, RecMessageAlloc(), RecMessageFree(), RecMessageMarshal_Realloc(), and RecMessageSend().
Referenced by RecSetRecord().
RecModeT g_mode_type = RECM_NULL |
Definition at line 34 of file P_RecCore.cc.
Referenced by i_am_the_record_owner(), RecLocalInit(), RecMessageInit(), RecMessageSend(), RecProcessInit(), RecSyncConfigToTB(), and RecSyncStatsFile().