summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/consumer.c41
-rw-r--r--src/inc/write_file.h9
-rw-r--r--src/tensor.c2
-rw-r--r--src/write_file.c55
4 files changed, 57 insertions, 50 deletions
diff --git a/src/consumer.c b/src/consumer.c
index 60a6064..ddf3840 100644
--- a/src/consumer.c
+++ b/src/consumer.c
@@ -125,7 +125,8 @@ void notify_table_update_end(void* u_para)
int consumer_t::consumer_load_profile()
{
int ret = 0;char buf_dir[MAX_PATH_LENGTH];
- char full_path[MAX_PATH_LENGTH],inc_path[MAX_PATH_LENGTH];
+ char full_path[MAX_PATH_LENGTH]={'0'};
+ char inc_path[MAX_PATH_LENGTH]={'0'};
unsigned int write_null_index_file;
ret = snprintf(buf_dir, MAX_PATH_LENGTH, "%s/%s",common->config_path, COMMON_CONFIG_NAME);
@@ -148,18 +149,11 @@ int consumer_t::consumer_load_profile()
else
{
snprintf (tmp_path, MAX_PATH_LENGTH, "%s/tmp/", dest_path);
- if(common->pz_type ==0)
- {
- snprintf (full_path, MAX_PATH_LENGTH, "%s/full/index/", dest_path);
- check_file_path(full_path);
- snprintf (inc_path, MAX_PATH_LENGTH, "%s/inc/index/", dest_path);
- check_file_path(inc_path);
- }
- else
- {
- snprintf (full_path, MAX_PATH_LENGTH, "%s/full/", dest_path);
- check_file_path(full_path);
- }
+ check_file_path(tmp_path);
+ snprintf (full_path, MAX_PATH_LENGTH, "%s/full/index/", dest_path);
+ check_file_path(full_path);
+ snprintf (inc_path, MAX_PATH_LENGTH, "%s/inc/index/", dest_path);
+ check_file_path(inc_path);
}
//MESA_load_profile_int_def(buf_dir, "CONSUMER", "gc_time", &consumer->gc_time, 60*60);
@@ -289,7 +283,8 @@ int status_for_register_t::persist_msg2local_file_consumer_service_start()
file_status_for_persistence->tmp_file_name,
NORMAL_FILE,
common->error_logger);
- ret = write_file_add_num(file_status_for_persistence->file_fp,0);
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ ret = write_file_add_num(file_status_for_persistence->file_fp,0);
}
assert(ret >=0);
MESA_HANDLE_RUNTIME_LOG(common->runtime_logger,RLOG_LV_DEBUG,"[PERSISTENT_SERVICE_START]","Start success");
@@ -331,14 +326,14 @@ int status_for_register_t::business_related_manager_service_ing(char * control_l
// ret = get_then_remove_user_info(dest_msg_line,file_status_for_manager->user_info);
///dest_msg_line[strlen(dest_msg_line)]='\n';
ret = parse_user_info(file_status_for_manager->user_info,&(common->local_state_for_manager->start_time));
- //INDETERMINANT:get dest_file_name here
+ //INDETERMINANT:get dest_sample_file_name here
if(indeterminant_line_info.is_valid == 1)
{
- strcpy(file_status_for_persistence->dest_file_name,indeterminant_line_info.file_path);
+ strcpy(file_status_for_persistence->dest_sample_file_name,indeterminant_line_info.file_path);
}
else
{
- memset(file_status_for_persistence->dest_file_name,0,MAX_PATH_LENGTH);
+ memset(file_status_for_persistence->dest_sample_file_name,0,MAX_PATH_LENGTH);
}
common->local_state_for_manager->end_time=common::Func::curr_time();
@@ -399,17 +394,17 @@ int status_for_register_t::persist_msg2local_file_consumer_service_ing(char * co
MESA_HANDLE_RUNTIME_LOG(common->perf_logger,RLOG_LV_INFO, "[PERSISTENT_SERVICE_ING]", "the file:%s, download from fdfs"
,file_status_for_persistence->dest_file_name);
//if dest file name not none download file from fdfs
- if(strlen(file_status_for_persistence->dest_file_name) != 0)
+ if(strlen(file_status_for_persistence->dest_sample_file_name) != 0)
{
- check_file_path(file_status_for_persistence->dest_file_name);//check the file path
- ret = download_file_from_fdfs(local_fdfs_id,file_status_for_persistence->dest_file_name);
+ check_file_path(file_status_for_persistence->dest_sample_file_name);//check the file path
+ ret = download_file_from_fdfs(local_fdfs_id,file_status_for_persistence->dest_sample_file_name);
//If download failed then Retry once
if(ret < 0)
{
do
{
sleep(3);
- ret = download_file_from_fdfs(local_fdfs_id,file_status_for_persistence->dest_file_name);
+ ret = download_file_from_fdfs(local_fdfs_id,file_status_for_persistence->dest_sample_file_name);
i++;
}while((ret<0)&&(i<retry_times));
}
@@ -417,14 +412,14 @@ int status_for_register_t::persist_msg2local_file_consumer_service_ing(char * co
if(ret < 0)
{
MESA_HANDLE_RUNTIME_LOG(common->error_logger,RLOG_LV_FATAL, "[PERSISTENT_SERVICE_ING]", "the file:%s, download from fdfs failed"
- ,file_status_for_persistence->dest_file_name);
+ ,file_status_for_persistence->dest_sample_file_name);
file_status_for_manager->total_line_num--;
break;
}
else
{
MESA_HANDLE_RUNTIME_LOG(common->runtime_logger,RLOG_LV_INFO, "[PERSISTENT_SERVICE_ING]", "the file:%s, download from fdfs finish"
- ,file_status_for_persistence->dest_file_name);
+ ,file_status_for_persistence->dest_sample_file_name);
}
//append index_fp(dest_msg_line)
diff --git a/src/inc/write_file.h b/src/inc/write_file.h
index 1443cb7..5a80d79 100644
--- a/src/inc/write_file.h
+++ b/src/inc/write_file.h
@@ -18,8 +18,10 @@ struct status_for_persistence
char tmp_index_file_name[MAX_PATH_LENGTH];//rename tmp_index_file_name dest_index_file_name
char dest_index_file_name[MAX_PATH_LENGTH];
- char tmp_file_name[MAX_PATH_LENGTH];//only for determinant business
- char dest_file_name[MAX_PATH_LENGTH];//only for determinant business
+ char tmp_file_name[MAX_PATH_LENGTH];
+ char dest_file_name[MAX_PATH_LENGTH];
+
+ char dest_sample_file_name[MAX_PATH_LENGTH];//only for indeterminant business
FILE *index_fp;
FILE *file_fp;
@@ -46,7 +48,8 @@ public:
memset(tmp_index_file_name,0,MAX_PATH_LENGTH);
memset(dest_index_file_name,0,MAX_PATH_LENGTH);
memset(tmp_file_name,0,MAX_PATH_LENGTH);
- memset(dest_file_name,0,MAX_PATH_LENGTH);
+ memset(dest_file_name,0,MAX_PATH_LENGTH);
+ memset(dest_sample_file_name,0,MAX_PATH_LENGTH);
memset(time_str,0,MAX_TIME_STR_LENGTH);
index_version = 0;
total_line_num = 0;
diff --git a/src/tensor.c b/src/tensor.c
index a19712c..863d125 100644
--- a/src/tensor.c
+++ b/src/tensor.c
@@ -11,7 +11,7 @@
#include "tensor.h"
-const char * TENSOR_K18_version_VERSION_20180920 = "TENSOR_K18_version_VERSION_20180920";
+const char * TENSOR_K18_version_VERSION_20180921 = "TENSOR_K18_version_VERSION_20180921";
int common_module_init(common_module_t **common_module,int run_mode,char *config_path,char *log_path,char *project_name,void *main_logger)
diff --git a/src/write_file.c b/src/write_file.c
index 3849973..c44cf9e 100644
--- a/src/write_file.c
+++ b/src/write_file.c
@@ -79,16 +79,25 @@ int status_for_persistence::write_file_create_file_name(char *part_path_name,cha
char com[MAX_PATH_LENGTH] = {0};int ret = 0;
void *err_logger=common->error_logger;
-////DETERMINANT : generate tmp_file_name
- ret = snprintf(tmp_file_name,MAX_PATH_LENGTH, "%s/%s/%s.%010lld", tmp_path,part_path_name,file_name, index_version);
+ //DETERMINANT : generate tmp_file_name
+ ret = snprintf(tmp_file_name,MAX_PATH_LENGTH, "%s%s/%s.%010lld", tmp_path,part_path_name,file_name, index_version);
if (ret >= MAX_PATH_LENGTH)
{
MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","file path too long:%s, should not bigger than %d!",tmp_file_name, MAX_PATH_LENGTH);
return -1;
}
-
-//DETERMINANT : generate dest_path_dir
- sprintf(com, "%s/%s/%s", dest_path,part_path_name,time_str);
+ sprintf(com, "%s/%s", tmp_path,part_path_name);
+ ret = create_path_p(com);
+ if(ret != 0)
+ {
+ MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","can not create dir, com:%s!", com);
+ return -1;
+ }
+ //DETERMINANT : generate dest_path_dir
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ sprintf(com, "%s/%s/%s", dest_path,part_path_name,time_str);
+ else
+ sprintf(com, "%s/%s", dest_path,part_path_name);
ret = create_path_p(com);
if(ret != 0)
{
@@ -96,8 +105,12 @@ int status_for_persistence::write_file_create_file_name(char *part_path_name,cha
return -1;
}
-//DETERMINANT generate dest_file_name
- ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s/%s.%010lld", dest_path,part_path_name,part_time_name,file_name,index_version);
+ //DETERMINANT generate dest_file_name
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s/%s.%010lld", dest_path,part_path_name,part_time_name,file_name,index_version);
+ else
+ ret = snprintf(dest_file_name,MAX_PATH_LENGTH, "%s/%s/%s.%010lld", dest_path,part_path_name,file_name,index_version);
+
if (ret >= MAX_PATH_LENGTH)
{
MESA_HANDLE_RUNTIME_LOG(err_logger,RLOG_LV_FATAL,"[write_file]","file path too long:%s, should not bigger than %d!",dest_file_name, MAX_PATH_LENGTH);
@@ -170,26 +183,22 @@ int status_for_persistence::write_file_init(int update_type)
// PZ_TYPE_INDETERMINANT :prefix is null
// PZ_TYPE_INDETERMINANT :part_index_name is full_config_index
// PZ_TYPE_INDETERMINANT :part_time_name s null
- if(common->pz_type == PZ_TYPE_DETERMINANT)
+
+ strncpy(part_time_name,time_str,10);
+ if (update_type == UPDATE_TYPE_FULL)
{
- strncpy(part_time_name,time_str,10);
- if (update_type == UPDATE_TYPE_FULL)
- {
- strncpy(part_path_name,"full",5);
- strncpy(part_index_name,"full_config_index",18);
- }
- else
- {
- strncpy(part_path_name,"inc",4);
- strncpy(part_index_name,"inc_config_index",17);
- }
+ strncpy(part_path_name,"full",5);
+ strncpy(part_index_name,"full_config_index",18);
}
else
{
- strncpy(part_index_name,"full_config_index",18);
+ strncpy(part_path_name,"inc",4);
+ strncpy(part_index_name,"inc_config_index",17);
}
+
//get index file path
- ret = write_file_create_index_name(part_path_name,part_index_name);
+ if(common->pz_type == PZ_TYPE_DETERMINANT)
+ ret = write_file_create_index_name(part_path_name,part_index_name);
if (ret != 0)
{
MESA_HANDLE_RUNTIME_LOG(common->error_logger,RLOG_LV_FATAL,"[write_file]","create:%s name fail",tmp_index_file_name);
@@ -198,8 +207,8 @@ int status_for_persistence::write_file_init(int update_type)
MESA_HANDLE_RUNTIME_LOG(common->runtime_logger,RLOG_LV_FATAL,"[write_file]","create:%s name suceess",tmp_index_file_name);
//get file path
- if(common->pz_type == PZ_TYPE_DETERMINANT)
- ret = write_file_create_file_name(part_path_name,part_time_name);
+ ret = write_file_create_file_name(part_path_name,part_time_name);
+
if (ret != 0)
{
MESA_HANDLE_RUNTIME_LOG(common->error_logger,RLOG_LV_FATAL,"[write_file]","create:%s fail",tmp_file_name);