为了便于单元测试,支持设置垃圾回收时间,默认10秒。
This commit is contained in:
@@ -158,7 +158,8 @@ enum MAAT_INIT_OPT
|
|||||||
//This option also disables background update.
|
//This option also disables background update.
|
||||||
MAAT_OPT_ENABLE_UPDATE, //VALUE is interger, SIZE=sizeof(int). 1: Enabled, 0:Disabled. DEFAULT: Backgroud update is enabled. Runtime setting is allowed.
|
MAAT_OPT_ENABLE_UPDATE, //VALUE is interger, SIZE=sizeof(int). 1: Enabled, 0:Disabled. DEFAULT: Backgroud update is enabled. Runtime setting is allowed.
|
||||||
MAAT_OPT_ACCEPT_TAGS, //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Format is a JSON, e.g.{"tags":[{"tag":"location","value":"Beijing/ChaoYang/Huayan/22A"},{"tag":"isp","value":"telecom"}]}
|
MAAT_OPT_ACCEPT_TAGS, //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Format is a JSON, e.g.{"tags":[{"tag":"location","value":"Beijing/ChaoYang/Huayan/22A"},{"tag":"isp","value":"telecom"}]}
|
||||||
MAAT_OPT_FOREIGN_CONT_DIR //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Specifies a local diretory to store foreign content. Default: []table_info_path]_files
|
MAAT_OPT_FOREIGN_CONT_DIR, //VALUE is a const char*, MUST end with '\0', SIZE= strlen(string+'\0')+1. Specifies a local diretory to store foreign content. Default: []table_info_path]_files
|
||||||
|
MAAT_OPT_GARBAGE_COLLECTION_TIMEOUT_MS //VALUE is interger, SIZE=sizeof(int). DEFAULT:10,000 milliseconds.
|
||||||
};
|
};
|
||||||
//return -1 if failed, return 0 on success;
|
//return -1 if failed, return 0 on success;
|
||||||
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size);
|
int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const void* value,int size);
|
||||||
|
|||||||
@@ -547,8 +547,9 @@ Maat_feather_t Maat_feather(int max_thread_num,const char* table_info_path,void*
|
|||||||
feather->logger=logger;
|
feather->logger=logger;
|
||||||
feather->scan_thread_num=max_thread_num;
|
feather->scan_thread_num=max_thread_num;
|
||||||
|
|
||||||
feather->effect_interval_ms=60*1000;
|
feather->rule_effect_interval_ms=60*1000;
|
||||||
feather->scan_interval_ms=1*1000;
|
feather->rule_update_checking_interval_ms=1*1000;
|
||||||
|
feather->garbage_collection_timeout_ms=10*1000;
|
||||||
feather->rule_scan_type=0;
|
feather->rule_scan_type=0;
|
||||||
feather->thread_call_cnt=alignment_int64_array_alloc(max_thread_num);
|
feather->thread_call_cnt=alignment_int64_array_alloc(max_thread_num);
|
||||||
feather->outer_mid_cnt=alignment_int64_array_alloc(max_thread_num);
|
feather->outer_mid_cnt=alignment_int64_array_alloc(max_thread_num);
|
||||||
@@ -621,7 +622,7 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_feather->effect_interval_ms=intval;
|
_feather->rule_effect_interval_ms=intval;
|
||||||
break;
|
break;
|
||||||
case MAAT_OPT_SCANDIR_INTERVAL_MS:
|
case MAAT_OPT_SCANDIR_INTERVAL_MS:
|
||||||
intval=*(const int*)value;
|
intval=*(const int*)value;
|
||||||
@@ -629,8 +630,17 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo
|
|||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_feather->scan_interval_ms=intval;
|
_feather->rule_update_checking_interval_ms=intval;
|
||||||
break;
|
break;
|
||||||
|
case MAAT_OPT_GARBAGE_COLLECTION_TIMEOUT_MS:
|
||||||
|
intval=*(const int*)value;
|
||||||
|
if(size!=sizeof(int)||intval<0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
_feather->garbage_collection_timeout_ms=intval;
|
||||||
|
break;
|
||||||
|
|
||||||
case MAAT_OPT_FULL_CFG_DIR:
|
case MAAT_OPT_FULL_CFG_DIR:
|
||||||
assert(_feather->input_mode==SOURCE_NONE);
|
assert(_feather->input_mode==SOURCE_NONE);
|
||||||
if(size>(int)sizeof(_feather->iris_ctx.full_dir))
|
if(size>(int)sizeof(_feather->iris_ctx.full_dir))
|
||||||
@@ -846,8 +856,9 @@ void maat_read_full_config(_Maat_feather_t* _feather)
|
|||||||
int Maat_initiate_feather(Maat_feather_t feather)
|
int Maat_initiate_feather(Maat_feather_t feather)
|
||||||
{
|
{
|
||||||
_Maat_feather_t* _feather=(_Maat_feather_t*)feather;
|
_Maat_feather_t* _feather=(_Maat_feather_t*)feather;
|
||||||
_feather->garbage_bin=Maat_garbage_bin_new(_feather->effect_interval_ms/1000+10);
|
|
||||||
system_cmd_mkdir(_feather->foreign_cont_dir);
|
system_cmd_mkdir(_feather->foreign_cont_dir);
|
||||||
|
_feather->garbage_bin=Maat_garbage_bin_new(_feather->rule_effect_interval_ms/1000+_feather->garbage_collection_timeout_ms/1000);
|
||||||
|
|
||||||
if(_feather->DEFERRED_LOAD_ON==0)
|
if(_feather->DEFERRED_LOAD_ON==0)
|
||||||
{
|
{
|
||||||
maat_read_full_config(_feather);
|
maat_read_full_config(_feather);
|
||||||
|
|||||||
@@ -2477,7 +2477,7 @@ void maat_finish_cb(void* u_para)
|
|||||||
feather->scanner->version=feather->maat_version;
|
feather->scanner->version=feather->maat_version;
|
||||||
expr_wait_q_cnt=MESA_lqueue_get_count(feather->scanner->region_update_q);
|
expr_wait_q_cnt=MESA_lqueue_get_count(feather->scanner->region_update_q);
|
||||||
feather->postpone_q_size=expr_wait_q_cnt+feather->scanner->gie_update_q_size+feather->scanner->xx_plugin_update_q_size;
|
feather->postpone_q_size=expr_wait_q_cnt+feather->scanner->gie_update_q_size+feather->scanner->xx_plugin_update_q_size;
|
||||||
if(time(NULL)-feather->scanner->last_update_time>=feather->effect_interval_ms/1000)
|
if(time(NULL)-feather->scanner->last_update_time>=feather->rule_effect_interval_ms/1000)
|
||||||
{
|
{
|
||||||
do_scanner_update(feather->scanner,
|
do_scanner_update(feather->scanner,
|
||||||
feather->scan_thread_num,
|
feather->scan_thread_num,
|
||||||
@@ -2603,7 +2603,7 @@ void *thread_rule_monitor(void *arg)
|
|||||||
pthread_mutex_unlock(&(feather->background_update_mutex));
|
pthread_mutex_unlock(&(feather->background_update_mutex));
|
||||||
while(feather->still_working)
|
while(feather->still_working)
|
||||||
{
|
{
|
||||||
usleep(feather->scan_interval_ms*1000);
|
usleep(feather->rule_update_checking_interval_ms*1000);
|
||||||
scan_dir_cnt++;
|
scan_dir_cnt++;
|
||||||
if(0==pthread_mutex_trylock(&(feather->background_update_mutex)))
|
if(0==pthread_mutex_trylock(&(feather->background_update_mutex)))
|
||||||
{
|
{
|
||||||
@@ -2704,7 +2704,7 @@ void *thread_rule_monitor(void *arg)
|
|||||||
expr_wait_q_cnt=MESA_lqueue_get_count(feather->scanner->region_update_q);
|
expr_wait_q_cnt=MESA_lqueue_get_count(feather->scanner->region_update_q);
|
||||||
feather->postpone_q_size=expr_wait_q_cnt+feather->scanner->gie_update_q_size;
|
feather->postpone_q_size=expr_wait_q_cnt+feather->scanner->gie_update_q_size;
|
||||||
total_wait_rule_cnt=feather->postpone_q_size+feather->scanner->to_update_compile_cnt+feather->scanner->to_update_group_cnt;
|
total_wait_rule_cnt=feather->postpone_q_size+feather->scanner->to_update_compile_cnt+feather->scanner->to_update_group_cnt;
|
||||||
if(total_wait_rule_cnt>0&&time(NULL)-feather->scanner->last_update_time>=feather->effect_interval_ms/1000)
|
if(total_wait_rule_cnt>0&&time(NULL)-feather->scanner->last_update_time>=feather->rule_effect_interval_ms/1000)
|
||||||
{
|
{
|
||||||
do_scanner_update(feather->scanner,
|
do_scanner_update(feather->scanner,
|
||||||
feather->scan_thread_num,
|
feather->scan_thread_num,
|
||||||
|
|||||||
@@ -290,8 +290,9 @@ struct _Maat_feather_t
|
|||||||
struct source_redis_ctx mr_ctx;
|
struct source_redis_ctx mr_ctx;
|
||||||
};
|
};
|
||||||
int still_working;
|
int still_working;
|
||||||
int scan_interval_ms;
|
int rule_update_checking_interval_ms;
|
||||||
int effect_interval_ms;
|
int rule_effect_interval_ms;
|
||||||
|
int garbage_collection_timeout_ms;
|
||||||
int cumulative_update_off;
|
int cumulative_update_off;
|
||||||
int stat_on;
|
int stat_on;
|
||||||
int perf_on;
|
int perf_on;
|
||||||
|
|||||||
Reference in New Issue
Block a user