diff --git a/inc/Maat_rule.h b/inc/Maat_rule.h index 71eb650..752fb5e 100644 --- a/inc/Maat_rule.h +++ b/inc/Maat_rule.h @@ -158,8 +158,7 @@ enum MAAT_INIT_OPT //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_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_LINGER //VALUE is interger *, SIZE=sizeof(int). Greater than 0: delete after VALUE seconds; 0: delete foreign content right after the notification callbacks; Less than 0: NEVER delete. Default: 0. + 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 }; //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); diff --git a/src/entry/Maat_api.cpp b/src/entry/Maat_api.cpp index d3ac7e9..c97311e 100644 --- a/src/entry/Maat_api.cpp +++ b/src/entry/Maat_api.cpp @@ -543,7 +543,6 @@ Maat_feather_t Maat_feather(int max_thread_num,const char* table_info_path,void* feather->base_rgn_seq=0; feather->AUTO_NUMBERING_ON=1; feather->backgroud_update_enabled=1; - feather->foreign_cont_linger=0; snprintf(feather->foreign_cont_dir, sizeof(feather->foreign_cont_dir), "%s_files", table_info_path); pthread_mutex_init(&(feather->background_update_mutex),NULL); snprintf(feather->table_info_fn,sizeof(feather->table_info_fn),"%s",table_info_path); @@ -758,9 +757,6 @@ int Maat_set_feather_opt(Maat_feather_t feather,enum MAAT_INIT_OPT type,const vo _feather->foreign_cont_dir[strlen(_feather->foreign_cont_dir)-1]='\0'; } break; - case MAAT_OPT_FOREIGN_CONT_LINGER: - _feather->foreign_cont_linger=*(int*)value; - break; default: return -1; } diff --git a/src/entry/Maat_command.cpp b/src/entry/Maat_command.cpp index 353667b..3496ef8 100644 --- a/src/entry/Maat_command.cpp +++ b/src/entry/Maat_command.cpp @@ -1732,22 +1732,38 @@ void _get_foreign_conts(redisContext *ctx, struct serial_rule_t* rule_list, int for(i=0;iop==MAAT_OP_DEL||p->n_foreign==0) + if(p->n_foreign==0) { continue; } - for(j=0; jn_foreign; j++) + if(p->op==MAAT_OP_DEL) { - if(p->f_keys[j].is_existed==1) + for(j=0; jn_foreign; j++) + { + if(p->f_keys[j].is_existed==1) + { + continue; + } + snprintf(redis_cmd,sizeof(redis_cmd),"GET %s", p->f_keys[j].key); + ret=redisAppendCommand(ctx, redis_cmd); + track[key_num].rule_idx=i; + track[key_num].foreign_idx=j; + key_num++; + assert(ret==REDIS_OK); } - snprintf(redis_cmd,sizeof(redis_cmd),"GET %s", p->f_keys[j].key); - ret=redisAppendCommand(ctx, redis_cmd); - track[key_num].rule_idx=i; - track[key_num].foreign_idx=j; - key_num++; - assert(ret==REDIS_OK); } } for(i=0;iforeign_cont_linger==0) - { - ret=system_cmd_rm(rule_list[i].f_keys[j].filename); - if(ret==-1) - { - MESA_handle_runtime_log(logger,RLOG_LV_INFO,maat_module, - "Foreign content file %s remove failed.", - rule_list[i].f_keys[j].filename); - } - } - else if(feather->foreign_cont_linger>0) - { - garbage_bagging_with_timeout(GARBAGE_FOREIGN_FILE, rule_list[i].f_keys[j].filename, feather->foreign_cont_linger, feather->garbage_q); - rule_list[i].f_keys[j].filename=NULL;//transfer owner to garbage collection. - } - else - { - //Less than 0, don't delete. - } - } - - } } finish(u_para); diff --git a/src/entry/Maat_rule.cpp b/src/entry/Maat_rule.cpp index 57830e7..2e0f512 100644 --- a/src/entry/Maat_rule.cpp +++ b/src/entry/Maat_rule.cpp @@ -33,7 +33,7 @@ #include "stream_fuzzy_hash.h" #include "gram_index_engine.h" -int MAAT_FRAME_VERSION_2_8_20190827=1; +int MAAT_FRAME_VERSION_2_8_20190919=1; int is_valid_table_name(const char* str) { diff --git a/src/inc_internal/Maat_rule_internal.h b/src/inc_internal/Maat_rule_internal.h index c45d457..ecef3d2 100644 --- a/src/inc_internal/Maat_rule_internal.h +++ b/src/inc_internal/Maat_rule_internal.h @@ -350,7 +350,6 @@ struct _Maat_feather_t int n_tags; char foreign_cont_dir[MAX_TABLE_NAME_LEN]; - int foreign_cont_linger; //internal states long long new_version; diff --git a/test/perf_test_maatframe.cpp b/test/perf_test_maatframe.cpp index 806dd2f..f139e39 100644 --- a/test/perf_test_maatframe.cpp +++ b/test/perf_test_maatframe.cpp @@ -84,9 +84,7 @@ protected: const char* foregin_dir="./foreign_files/"; Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_DIR, foregin_dir, strlen(foregin_dir)+1); - int linger_timeout=2; - Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_LINGER, &linger_timeout, sizeof(linger_timeout)); - + Maat_cmd_flushDB(_shared_feather); Maat_initiate_feather(_shared_feather); } diff --git a/test/test_maatframe.cpp b/test/test_maatframe.cpp index 6bfe6d1..dae84dd 100644 --- a/test/test_maatframe.cpp +++ b/test/test_maatframe.cpp @@ -1630,8 +1630,6 @@ protected: const char* foregin_dir="./foreign_files/"; Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_DIR,foregin_dir, strlen(foregin_dir)+1); - linger_timeout=2; - Maat_set_feather_opt(_shared_feather, MAAT_OPT_FOREIGN_CONT_LINGER,&linger_timeout, sizeof(linger_timeout)); Maat_cmd_flushDB(_shared_feather); Maat_initiate_feather(_shared_feather);