fix mq config and log control

This commit is contained in:
lnk
2026-04-17 16:35:35 +08:00
parent cf94a99cad
commit 54c97ad103
4 changed files with 412 additions and 22 deletions

View File

@@ -358,6 +358,14 @@ std::string WEB_EVENT = "";
std::string WEB_FILEUPLOAD = "";
std::string WEB_FILEDOWNLOAD = "";
// 日志限流配置
int G_LOG_RATE_RESET_SEC = 3600; // 1小时重置
int G_LOG_RATE_LIMIT_SEC = 60; // 进入限流后60秒1条
int G_LOG_RATE_KEEP_ALL_MS = 60000; // 间隔 >= 60000ms全部保留
int G_LOG_RATE_KEEP_BURST_MS = 1000; // 间隔 >= 1000ms按二级策略
int G_LOG_RATE_KEEP_BURST_COUNT = 60; // 二级保留前60条
int G_LOG_RATE_KEEP_HIGHFREQ_COUNT = 10; // 高频保留前10条
//lnk20250115添加台账锁
extern pthread_mutex_t mtx;
@@ -781,6 +789,29 @@ void init_config() {
std::cout << "Read G_TEST_NUM:" << G_TEST_NUM << std::endl;
std::cout << "Read G_TEST_TYPE:" << G_TEST_TYPE << std::endl;
// 日志限流配置
G_LOG_RATE_RESET_SEC = settings.value("LogRate/ResetSec", 3600).toInt();
G_LOG_RATE_LIMIT_SEC = settings.value("LogRate/LimitSec", 60).toInt();
G_LOG_RATE_KEEP_ALL_MS = settings.value("LogRate/KeepAllMs", 60000).toInt();
G_LOG_RATE_KEEP_BURST_MS = settings.value("LogRate/KeepBurstMs", 1000).toInt();
G_LOG_RATE_KEEP_BURST_COUNT = settings.value("LogRate/KeepBurstCount", 60).toInt();
G_LOG_RATE_KEEP_HIGHFREQ_COUNT = settings.value("LogRate/KeepHighFreqCount", 10).toInt();
std::cout << "Read G_LOG_RATE_RESET_SEC:" << G_LOG_RATE_RESET_SEC << std::endl;
std::cout << "Read G_LOG_RATE_LIMIT_SEC:" << G_LOG_RATE_LIMIT_SEC << std::endl;
std::cout << "Read G_LOG_RATE_KEEP_ALL_MS:" << G_LOG_RATE_KEEP_ALL_MS << std::endl;
std::cout << "Read G_LOG_RATE_KEEP_BURST_MS:" << G_LOG_RATE_KEEP_BURST_MS << std::endl;
std::cout << "Read G_LOG_RATE_KEEP_BURST_COUNT:" << G_LOG_RATE_KEEP_BURST_COUNT << std::endl;
std::cout << "Read G_LOG_RATE_KEEP_HIGHFREQ_COUNT:" << G_LOG_RATE_KEEP_HIGHFREQ_COUNT << std::endl;
if (G_LOG_RATE_RESET_SEC <= 0) G_LOG_RATE_RESET_SEC = 3600;
if (G_LOG_RATE_LIMIT_SEC <= 0) G_LOG_RATE_LIMIT_SEC = 60;
if (G_LOG_RATE_KEEP_ALL_MS <= 0) G_LOG_RATE_KEEP_ALL_MS = 60000;
if (G_LOG_RATE_KEEP_BURST_MS <= 0) G_LOG_RATE_KEEP_BURST_MS = 1000;
if (G_LOG_RATE_KEEP_BURST_COUNT < 0) G_LOG_RATE_KEEP_BURST_COUNT = 60;
if (G_LOG_RATE_KEEP_HIGHFREQ_COUNT < 0) G_LOG_RATE_KEEP_HIGHFREQ_COUNT = 10;
//20241212lnk添加多前置
if (g_front_seg_index != 0 && g_front_seg_num != 0) {
MULTIPLE_NODE_FLAG = 1;
@@ -6542,6 +6573,9 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
// 循环发送 300 条消息
if(type == 0){
std::cout << " use ledger send msg " << std::endl;
pthread_mutex_lock(&mtx);
for (int i = 0; (total_messages > 0 && g_node_id == 100) && i < g_node->n_clients; ++i) {//台账模拟不限制进程号
ied = (ied_t*)g_node->clients[i];
@@ -6611,6 +6645,13 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
}
}
}
std::cout << "Finished sending " << g_node->n_clients << " messages." << std::endl;
pthread_mutex_unlock(&mtx);
}
else{
std::cout << " use monitor + number send msg " << std::endl;
@@ -6663,9 +6704,10 @@ void rocketmq_test_300(int mpnum,int front_index,int type) {
apr_sleep(apr_time_from_msec(60000/total_messages)); // 添加毫秒延时
}*/
}
}
std::cout << "Finished sending " << total_messages << " messages." << std::endl;
std::cout << "Finished sending " << total_messages << " messages." << std::endl;
}
}
}