增加HTTP Post上传配置接口,支持主从双机备份与同步(冷备)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
set (DORIS_CLIENT_SRC doris_client_fetch.cpp doris_client_http.cpp doris_client_transfer.cpp nirvana_conhash.cpp nirvana_murmurhash.cpp)
|
||||
set (DORIS_CLIENT_SRC doris_client_fetch.cpp doris_client_produce.cpp doris_client_http.cpp doris_client_transfer.cpp nirvana_conhash.cpp nirvana_murmurhash.cpp)
|
||||
|
||||
add_definitions(-fPIC -Wall -g)
|
||||
|
||||
|
||||
@@ -35,29 +35,6 @@ static int doris_md5_final_string(MD5_CTX *c, char *result, unsigned int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void easy_string_destroy(struct easy_string *estr)
|
||||
{
|
||||
if(estr->buff != NULL)
|
||||
{
|
||||
free(estr->buff);
|
||||
estr->buff = NULL;
|
||||
estr->len = estr->size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len)
|
||||
{
|
||||
if(estr->size-estr->len < len+1)
|
||||
{
|
||||
estr->size += len*4+1;
|
||||
estr->buff = (char*)realloc(estr->buff, estr->size);
|
||||
}
|
||||
|
||||
memcpy(estr->buff+estr->len, data, len);
|
||||
estr->len += len;
|
||||
estr->buff[estr->len]='\0';
|
||||
}
|
||||
|
||||
void doris_confile_ctx_reset(struct doris_confile_ctx *ctx)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
|
||||
@@ -75,12 +52,12 @@ void doris_confile_ctx_destry(struct doris_confile_ctx *ctx)
|
||||
ctx->httpctx = NULL;
|
||||
}
|
||||
|
||||
void doris_update_new_version(struct doris_instance *instance)
|
||||
void doris_update_new_version(struct doris_csum_instance *instance)
|
||||
{
|
||||
instance->cur_version = instance->new_version;
|
||||
}
|
||||
|
||||
void doris_request_restart_timer(struct doris_instance *instance, time_t wait_s)
|
||||
void doris_request_restart_timer(struct doris_csum_instance *instance, time_t wait_s)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
@@ -89,7 +66,7 @@ void doris_request_restart_timer(struct doris_instance *instance, time_t wait_s)
|
||||
event_add(&instance->timer_fetch, &tv);
|
||||
}
|
||||
|
||||
void doris_fetch_next_confile_meta(struct doris_instance *instance)
|
||||
void doris_fetch_next_confile_meta(struct doris_csum_instance *instance)
|
||||
{
|
||||
cJSON *cur_a_item, *sub;
|
||||
|
||||
@@ -125,7 +102,7 @@ void doris_fetch_next_confile_meta(struct doris_instance *instance)
|
||||
|
||||
void doris_http_confile_header_cb(const char *start, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
const char *pos_colon;
|
||||
size_t datalen;
|
||||
char buffer[64];
|
||||
@@ -180,7 +157,7 @@ void doris_http_confile_header_cb(const char *start, size_t bytes, CURLcode code
|
||||
|
||||
void doris_http_confile_body_cb(const char *ptr, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
|
||||
if(code!=CURLE_OK || (instance->ctx.res_code!=200 && instance->ctx.res_code!=206) || (res_code!=200 && res_code!=206))
|
||||
{
|
||||
@@ -193,10 +170,10 @@ void doris_http_confile_body_cb(const char *ptr, size_t bytes, CURLcode code, lo
|
||||
instance->statistic.field[DRS_FS_FILED_RES_BYTES] += bytes;
|
||||
}
|
||||
|
||||
void doris_http_fetch_confile(struct doris_instance *instance);
|
||||
void doris_http_fetch_confile(struct doris_csum_instance *instance);
|
||||
void doris_http_confile_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
char md5buffer[64];
|
||||
bool direct_fail=false;
|
||||
|
||||
@@ -284,7 +261,7 @@ out_md5:
|
||||
doris_request_restart_timer(instance, instance->param->retry_interval);
|
||||
}
|
||||
|
||||
void doris_http_fetch_confile(struct doris_instance *instance)
|
||||
void doris_http_fetch_confile(struct doris_csum_instance *instance)
|
||||
{
|
||||
struct doris_http_callback curlcbs;
|
||||
char metauri[128], range[64]={0};
|
||||
@@ -319,7 +296,7 @@ void doris_http_fetch_confile(struct doris_instance *instance)
|
||||
|
||||
void doris_http_meta_header_cb(const char *ptr, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
|
||||
//check code only once
|
||||
if(instance->ctx.res_code != 0)
|
||||
@@ -331,14 +308,14 @@ void doris_http_meta_header_cb(const char *ptr, size_t bytes, CURLcode code, lon
|
||||
|
||||
if(res_code != 200)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_DEBUG, "No new meta found, server: %s, cur_version=%lu, req_version=%lu, curlcode = %d",
|
||||
instance->ctx.server, instance->cur_version, instance->req_version, code);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_DEBUG, "business: %s, No new meta found, server: %s, cur_version=%lu, req_version=%lu, curlcode = %d",
|
||||
instance->args.bizname, instance->ctx.server, instance->cur_version, instance->req_version, code);
|
||||
}
|
||||
}
|
||||
|
||||
void doris_http_meta_body_cb(const char *ptr, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
|
||||
if(code!=CURLE_OK || res_code!=200)
|
||||
{
|
||||
@@ -350,14 +327,14 @@ void doris_http_meta_body_cb(const char *ptr, size_t bytes, CURLcode code, long
|
||||
|
||||
void doris_http_meta_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
cJSON *sub;
|
||||
int64_t new_version;
|
||||
|
||||
if(res!=CURLE_OK)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "Request meta failed, server: %s, cur_version=%lu, req_version=%lu, curlcode = %d, error: %s",
|
||||
instance->ctx.server, instance->cur_version, instance->req_version, res_code, err);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "business: %s, Request meta failed, server: %s, cur_version=%lu, req_version=%lu, curlcode = %d, error: %s",
|
||||
instance->args.bizname, instance->ctx.server, instance->cur_version, instance->req_version, res_code, err);
|
||||
goto out_error;
|
||||
}
|
||||
|
||||
@@ -369,16 +346,16 @@ void doris_http_meta_done_cb(CURLcode res, long res_code, const char *err, void
|
||||
instance->meta = cJSON_Parse(instance->estr.buff);
|
||||
if(instance->meta == NULL)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "Parse meta failed, server: %s, req_version=%lu, invalid json: %s",
|
||||
instance->ctx.server, instance->req_version, instance->estr.buff);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "business: %s, Parse meta failed, server: %s, req_version=%lu, invalid json: %s",
|
||||
instance->args.bizname, instance->ctx.server, instance->req_version, instance->estr.buff);
|
||||
goto out_error;
|
||||
}
|
||||
sub = cJSON_GetObjectItem(instance->meta, "version");
|
||||
new_version = sub->valuedouble;
|
||||
if(new_version <= instance->cur_version)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "An older version received, abandon it. server: %s, cur_version=%lu, invalid json: %s",
|
||||
instance->ctx.server, instance->cur_version, instance->estr.buff);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "business: %s, An older version received, abandon it. server: %s, cur_version=%lu, invalid json: %s",
|
||||
instance->args.bizname, instance->ctx.server, instance->cur_version, instance->estr.buff);
|
||||
cJSON_Delete(instance->meta);
|
||||
instance->meta = NULL;
|
||||
goto out_error;
|
||||
@@ -386,8 +363,8 @@ void doris_http_meta_done_cb(CURLcode res, long res_code, const char *err, void
|
||||
instance->new_version = new_version;
|
||||
instance->req_version = instance->new_version;
|
||||
instance->statistic.field[DRS_FS_FILED_RES_META] += 1;
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_INFO, "NEW_META found, server: %s, cur_version=%lu, newjson: %s",
|
||||
instance->ctx.server, instance->cur_version, instance->estr.buff);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_INFO, "business: %s, NEW_META found, server: %s, cur_version=%lu, newjson: %s",
|
||||
instance->args.bizname, instance->ctx.server, instance->cur_version, instance->estr.buff);
|
||||
|
||||
instance->cbs.version_start(instance, instance->meta, instance->cbs.userdata);
|
||||
instance->array = cJSON_GetObjectItem(instance->meta, "configs");
|
||||
@@ -405,13 +382,21 @@ out_error:
|
||||
doris_request_restart_timer(instance, instance->param->retry_interval);
|
||||
easy_string_destroy(&instance->estr);
|
||||
doris_confile_ctx_destry(&instance->ctx);
|
||||
if(res_code==304 && instance->cbs.version_updated!=NULL) //<2F>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
||||
{
|
||||
instance->cbs.version_updated(instance, instance->cbs.userdata);
|
||||
}
|
||||
if(res_code==300 && instance->param->client_sync_on) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>;<EFBFBD>еİ汾<C4B0>ϴ<EFBFBD>
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "business: %s, Server is busy processing version requests, waiting it done...", instance->args.bizname);
|
||||
}
|
||||
}
|
||||
|
||||
static void doris_http_fetch_meta(struct doris_instance *instance)
|
||||
static void doris_http_fetch_meta(struct doris_csum_instance *instance)
|
||||
{
|
||||
u_int64_t balance_seed;
|
||||
struct doris_http_callback curlcbs;
|
||||
char metauri[128];
|
||||
char metauri[128], cur_version[128];
|
||||
|
||||
balance_seed = (((u_int64_t)rand()&0xFFFF) << 48) | (((u_int64_t)rand()&0xFFFF) << 32) |
|
||||
(((u_int64_t)rand()&0xFFFF) << 16) | ((u_int64_t)rand()&0xFFFF);
|
||||
@@ -439,6 +424,13 @@ static void doris_http_fetch_meta(struct doris_instance *instance)
|
||||
instance->req_version = instance->cur_version + 1; //ֻ<>а汾<D0B0><E6B1BE><EFBFBD>³ɹ<C2B3><C9B9><EFBFBD><EFBFBD><EFBFBD>cur_version<6F>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(instance->ctx.httpctx != NULL)
|
||||
{
|
||||
if(instance->param->client_sync_on)
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD>ѣ<EFBFBD><D1A3><EFBFBD><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD>Ǵ<EFBFBD>Client<6E><74><EFBFBD><EFBFBD>
|
||||
sprintf(cur_version, "X-Doris-Sync-Current-Version: %lu", instance->cur_version);
|
||||
doris_http_ctx_add_header(instance->ctx.httpctx, cur_version);
|
||||
}
|
||||
|
||||
snprintf(metauri, 128, "configmeta?version=%lu&business=%s", instance->req_version, instance->args.bizname);
|
||||
if(!doris_http_launch_get_request(instance->ctx.httpctx, metauri))
|
||||
{
|
||||
@@ -464,7 +456,7 @@ static void doris_http_fetch_meta(struct doris_instance *instance)
|
||||
|
||||
static void instance_fetch_cfg_timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
|
||||
switch(instance->status)
|
||||
{
|
||||
@@ -482,7 +474,7 @@ static void instance_fetch_cfg_timer_cb(int fd, short kind, void *userp)
|
||||
|
||||
static void doris_client_fs_output_timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
struct doris_parameter *param=(struct doris_parameter *)userp;
|
||||
struct doris_csum_param *param=(struct doris_csum_param *)userp;
|
||||
struct timeval tv;
|
||||
|
||||
FS_operate(param->fsstat_handle, param->fsstat_status[DRS_FS_STAT_MST_CNN_SRV], 0, FS_OP_SET, param->param_master->connected_hosts);
|
||||
@@ -503,7 +495,7 @@ static void doris_client_fs_output_timer_cb(int fd, short kind, void *userp)
|
||||
evtimer_add(¶m->fs_timer_output, &tv);
|
||||
}
|
||||
|
||||
static int doris_client_register_field_stat(struct doris_parameter *param, void *runtime_log, struct event_base *evbase)
|
||||
static int doris_client_register_field_stat(struct doris_csum_param *param, void *runtime_log, struct event_base *evbase)
|
||||
{
|
||||
const char *field_names[FSSTAT_DORIS_FILED_NUM]={"ReqFail", "ReqMetas", "ResMetas", "ResNoNew", "ReqFiles",
|
||||
"ResFiles", "ResFrags", "ResFragErr", "ResBytes", "ResVerErr", "ReqBackup1", "ReqBackup2"};
|
||||
@@ -549,19 +541,44 @@ static int doris_client_register_field_stat(struct doris_parameter *param, void
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct doris_parameter *doris_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog)
|
||||
u_int32_t doris_csum_param_get_refernces(struct doris_csum_param *param)
|
||||
{
|
||||
struct doris_parameter *param;
|
||||
pthread_mutex_lock(¶m->mutex_lock);
|
||||
u_int32_t references = param->references;
|
||||
pthread_mutex_unlock(¶m->mutex_lock);
|
||||
return references;
|
||||
}
|
||||
|
||||
param = (struct doris_parameter *)calloc(1, sizeof(struct doris_parameter));
|
||||
void doris_csum_parameter_destroy(struct doris_csum_param *param)
|
||||
{
|
||||
evtimer_del(¶m->fs_timer_output);
|
||||
FS_stop(¶m->fsstat_handle);
|
||||
doris_http_parameter_destroy(param->param_master);
|
||||
if(param->param_backup1 != NULL)
|
||||
{
|
||||
doris_http_parameter_destroy(param->param_backup1);
|
||||
}
|
||||
if(param->param_backup2 != NULL)
|
||||
{
|
||||
doris_http_parameter_destroy(param->param_backup2);
|
||||
}
|
||||
free(param);
|
||||
}
|
||||
|
||||
struct doris_csum_param *doris_csum_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog)
|
||||
{
|
||||
struct doris_csum_param *param;
|
||||
|
||||
param = (struct doris_csum_param *)calloc(1, sizeof(struct doris_csum_param));
|
||||
param->manage_evbase = manage_evbase;
|
||||
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "fetch_fail_retry_interval", ¶m->retry_interval, 10);
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "fetch_fragmet_size", ¶m->fetch_frag_size, 5242880);
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "fetch_confile_max_tries", ¶m->fetch_max_tries, 3);
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "master_slave_sync_on", ¶m->client_sync_on, 0);
|
||||
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_appname", param->fsstat_appname, 16, "DorisClient");
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_filepath", param->fsstat_filepath, 256, "./log/doris_client.fs");
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_appname", param->fsstat_appname, 16, "DrsCsmClient");
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_filepath", param->fsstat_filepath, 256, "./log/doris_client_csm.fs");
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "fsstat_log_interval", ¶m->fsstat_period, 10);
|
||||
MESA_load_profile_int_def(confile, "DORIS_CLIENT", "fsstat_log_print_mode", ¶m->fsstat_print_mode, 1);
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_dst_ip", param->fsstat_dst_ip, 64, "127.0.0.1");
|
||||
@@ -578,14 +595,15 @@ struct doris_parameter *doris_parameter_new(const char *confile, struct event_ba
|
||||
}
|
||||
param->param_backup1 = doris_http_parameter_new(confile, "DORIS_CLIENT.backup1_server", manage_evbase, runtimelog);
|
||||
param->param_backup2 = doris_http_parameter_new(confile, "DORIS_CLIENT.backup2_server", manage_evbase, runtimelog);
|
||||
pthread_mutex_init(¶m->mutex_lock, NULL);
|
||||
return param;
|
||||
}
|
||||
|
||||
static void doris_instance_statistic_timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
struct doris_instance *instance = (struct doris_instance *)userp;
|
||||
struct doris_csum_instance *instance = (struct doris_csum_instance *)userp;
|
||||
struct timeval tv;
|
||||
struct doris_statistics incr_statistic;
|
||||
struct doris_csum_statistics incr_statistic;
|
||||
long long *plast_statistic = (long long*)&instance->statistic_last;
|
||||
long long *pnow_statistic = (long long*)&instance->statistic;
|
||||
long long *pinc_statistic = (long long*)&incr_statistic;
|
||||
@@ -594,9 +612,9 @@ static void doris_instance_statistic_timer_cb(int fd, short kind, void *userp)
|
||||
http_sessions += caculate_http_sessions_sum(instance->httpins_master);
|
||||
http_sessions += caculate_http_sessions_sum(instance->httpins_backup1);
|
||||
http_sessions += caculate_http_sessions_sum(instance->httpins_backup2);
|
||||
instance->statistic.field[DRS_FS_STAT_HTTP_SESSIONS] = http_sessions;
|
||||
instance->statistic.status[DRS_FS_STAT_HTTP_SESSIONS] = http_sessions;
|
||||
|
||||
for(u_int32_t i=0; i<sizeof(struct doris_statistics)/sizeof(long long); i++)
|
||||
for(u_int32_t i=0; i<sizeof(struct doris_csum_statistics)/sizeof(long long); i++)
|
||||
{
|
||||
pinc_statistic[i] = pnow_statistic[i] - plast_statistic[i];
|
||||
}
|
||||
@@ -615,13 +633,38 @@ static void doris_instance_statistic_timer_cb(int fd, short kind, void *userp)
|
||||
event_add(&instance->timer_statistic, &tv);
|
||||
}
|
||||
|
||||
struct doris_instance *doris_instance_new(struct doris_parameter *param, struct event_base *worker_evbase,
|
||||
struct doris_csum_param *doris_csum_instance_get_param(struct doris_csum_instance *instance)
|
||||
{
|
||||
return instance->param;
|
||||
}
|
||||
|
||||
void doris_csum_instance_destroy(struct doris_csum_instance *instance)
|
||||
{
|
||||
pthread_mutex_lock(&instance->param->mutex_lock);
|
||||
instance->param->references--;
|
||||
pthread_mutex_unlock(&instance->param->mutex_lock);
|
||||
|
||||
evtimer_del(&instance->timer_fetch);
|
||||
evtimer_del(&instance->timer_statistic);
|
||||
/*doris_http_instance_destroy(instance->httpins_master);
|
||||
if(instance->httpins_backup1 != NULL)
|
||||
{
|
||||
doris_http_instance_destroy(instance->httpins_backup1);
|
||||
}
|
||||
if(instance->httpins_backup2 != NULL)
|
||||
{
|
||||
doris_http_instance_destroy(instance->httpins_backup2);
|
||||
}*/
|
||||
free(instance);
|
||||
}
|
||||
|
||||
struct doris_csum_instance *doris_csum_instance_new(struct doris_csum_param *param, struct event_base *worker_evbase,
|
||||
struct doris_callbacks *cbs, struct doris_arguments *args, void *runtimelog)
|
||||
{
|
||||
struct doris_instance *instance;
|
||||
struct doris_csum_instance *instance;
|
||||
struct timeval tv;
|
||||
|
||||
instance = (struct doris_instance *)calloc(1, sizeof(struct doris_instance));
|
||||
instance = (struct doris_csum_instance *)calloc(1, sizeof(struct doris_csum_instance));
|
||||
instance->param = param;
|
||||
instance->worker_evbase = worker_evbase;
|
||||
instance->runtime_log = runtimelog;
|
||||
@@ -646,6 +689,10 @@ struct doris_instance *doris_instance_new(struct doris_parameter *param, struct
|
||||
instance->httpins_backup2 = doris_http_instance_new(param->param_backup2, worker_evbase, runtimelog);
|
||||
}
|
||||
|
||||
pthread_mutex_lock(¶m->mutex_lock);
|
||||
param->references++;
|
||||
pthread_mutex_unlock(¶m->mutex_lock);
|
||||
|
||||
evtimer_assign(&instance->timer_statistic, worker_evbase, doris_instance_statistic_timer_cb, instance);
|
||||
tv.tv_sec = param->fsstat_period;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
#ifndef __DORIS_CLIENT_FETCH_IN_H__
|
||||
#define __DORIS_CLIENT_FETCH_IN_H__
|
||||
|
||||
#include <pthread.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
|
||||
#include "doris_client.h"
|
||||
#include "doris_consumer_client.h"
|
||||
#include "doris_client_http.h"
|
||||
|
||||
struct easy_string
|
||||
{
|
||||
char* buff;
|
||||
size_t len;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
enum FETCH_CFG_STATUS
|
||||
{
|
||||
FETCH_STATUS_IDLE=0,
|
||||
@@ -21,11 +15,14 @@ enum FETCH_CFG_STATUS
|
||||
FETCH_STATUS_FILE,
|
||||
};
|
||||
|
||||
struct doris_parameter
|
||||
struct doris_csum_param
|
||||
{
|
||||
u_int32_t retry_interval;
|
||||
u_int32_t fetch_frag_size;
|
||||
u_int32_t fetch_max_tries;
|
||||
u_int32_t client_sync_on;
|
||||
pthread_mutex_t mutex_lock;
|
||||
u_int32_t references;
|
||||
|
||||
struct doris_http_parameter *param_master;
|
||||
struct doris_http_parameter *param_backup1;
|
||||
@@ -76,7 +73,7 @@ struct doris_confile_ctx
|
||||
size_t contl_total;
|
||||
};
|
||||
|
||||
struct doris_instance
|
||||
struct doris_csum_instance
|
||||
{
|
||||
struct doris_callbacks cbs;
|
||||
struct doris_arguments args;
|
||||
@@ -102,9 +99,9 @@ struct doris_instance
|
||||
|
||||
struct event_base *worker_evbase;
|
||||
struct event timer_fetch;
|
||||
struct doris_parameter *param;
|
||||
struct doris_csum_param *param;
|
||||
struct event timer_statistic;
|
||||
struct doris_statistics statistic, statistic_last;
|
||||
struct doris_csum_statistics statistic, statistic_last;
|
||||
void *runtime_log;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,38 @@
|
||||
|
||||
#include "doris_client_http.h"
|
||||
|
||||
void easy_string_destroy(struct easy_string *estr)
|
||||
{
|
||||
if(estr->buff != NULL)
|
||||
{
|
||||
free(estr->buff);
|
||||
estr->buff = NULL;
|
||||
estr->len = estr->size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len)
|
||||
{
|
||||
if(estr->size-estr->len < len+1)
|
||||
{
|
||||
estr->size += len*4+1;
|
||||
estr->buff = (char*)realloc(estr->buff, estr->size);
|
||||
}
|
||||
|
||||
memcpy(estr->buff+estr->len, data, len);
|
||||
estr->len += len;
|
||||
estr->buff[estr->len]='\0';
|
||||
}
|
||||
|
||||
static inline void drsclient_set_sockopt_keepalive(int sd, int keepidle, int keepintvl, int keepcnt)
|
||||
{
|
||||
int keepalive = 1;
|
||||
setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (void*)&keepalive, sizeof(keepalive));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPIDLE, (void*)&keepidle, sizeof(keepidle));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPINTVL, (void*)&keepintvl, sizeof(keepintvl));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPCNT, (void*)&keepcnt, sizeof(keepcnt));
|
||||
}
|
||||
|
||||
int32_t param_get_connected_hosts(struct doris_http_parameter *param)
|
||||
{
|
||||
return param->connected_hosts;
|
||||
@@ -199,6 +231,7 @@ static void client_bufferevent_error_cb(struct bufferevent *bev, short event, vo
|
||||
conhash_insert_dest_host(balance);
|
||||
assert(balance->param->connected_hosts > 0);
|
||||
assert(balance->param->failed_hosts >= 0);
|
||||
drsclient_set_sockopt_keepalive(bufferevent_getfd(bev), 10, 5, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -303,6 +336,24 @@ static int32_t doris_launch_group_connection(struct doris_http_parameter *param,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void doris_http_parameter_destroy(struct doris_http_parameter *param)
|
||||
{
|
||||
for(u_int32_t i=0; i<param->ipgroup.dstaddr_num; i++) //<2F><><EFBFBD><EFBFBD>
|
||||
{
|
||||
if(evtimer_pending(¶m->balance[i].timer_detect, NULL))
|
||||
{
|
||||
evtimer_del(¶m->balance[i].timer_detect);
|
||||
}
|
||||
if(param->balance[i].bev != NULL)
|
||||
{
|
||||
bufferevent_free(param->balance[i].bev);
|
||||
}
|
||||
}
|
||||
conhash_instance_free(param->conhash);
|
||||
free(param->ipgroup.dstaddrs);
|
||||
free(param);
|
||||
}
|
||||
|
||||
struct doris_http_parameter *doris_http_parameter_new(const char* profile_path, const char* section, struct event_base* evbase, void *runtime_log)
|
||||
{
|
||||
struct doris_http_parameter *param;
|
||||
@@ -352,6 +403,38 @@ struct doris_http_parameter *doris_http_parameter_new(const char* profile_path,
|
||||
return param;
|
||||
}
|
||||
|
||||
void doris_http_instance_destroy(struct doris_http_instance *instance)
|
||||
{
|
||||
map<u_int32_t, doris_curl_multihd*>::iterator iter;
|
||||
struct doris_curl_multihd *multihd;
|
||||
CURLMsg *msg;
|
||||
int msgs_left;
|
||||
struct doris_http_ctx *ctx;
|
||||
CURL *easy;
|
||||
|
||||
for(iter=instance->server_hosts->begin(); iter!=instance->server_hosts->end(); )
|
||||
{
|
||||
multihd = iter->second;
|
||||
|
||||
while((msg = curl_multi_info_read(multihd->multi_hd, &msgs_left)))
|
||||
{
|
||||
easy = msg->easy_handle;
|
||||
curl_easy_getinfo(easy, CURLINFO_PRIVATE, &ctx);
|
||||
curl_multi_remove_handle(multihd->multi_hd, easy);
|
||||
curl_easy_cleanup(easy);
|
||||
ctx->curl = NULL;
|
||||
ctx->transfering = 0;
|
||||
ctx->res = CURLE_ABORTED_BY_CALLBACK;
|
||||
ctx->res_code = 0;
|
||||
ctx->cb.transfer_done_cb(ctx->res, 0, ctx->error, ctx->cb.userp);
|
||||
}
|
||||
curl_multi_cleanup(multihd->multi_hd);
|
||||
|
||||
instance->server_hosts->erase(iter++);
|
||||
}
|
||||
free(instance);
|
||||
}
|
||||
|
||||
struct doris_http_instance *doris_http_instance_new(struct doris_http_parameter *param, struct event_base* evbase, void *runtimelog)
|
||||
{
|
||||
struct doris_http_instance *instance;
|
||||
|
||||
@@ -28,6 +28,15 @@ using namespace std;
|
||||
#define DEFAULT_HOST_CAPACITY 4
|
||||
#define LOAD_BALANC_VIRT_TIMES 16
|
||||
|
||||
struct easy_string
|
||||
{
|
||||
char* buff;
|
||||
size_t len;
|
||||
size_t size;
|
||||
};
|
||||
void easy_string_destroy(struct easy_string *estr);
|
||||
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len);
|
||||
|
||||
enum TCP_CONNECTION_STATUS
|
||||
{
|
||||
TCP_STATUS_IDLE=0,
|
||||
@@ -83,7 +92,6 @@ struct doris_http_parameter
|
||||
struct doris_http_instance
|
||||
{
|
||||
struct event_base* evbase;
|
||||
SSL_CTX *ssl_instance;
|
||||
void *privdata;
|
||||
|
||||
map<u_int32_t, doris_curl_multihd*> *server_hosts;
|
||||
@@ -102,7 +110,9 @@ int32_t param_get_connected_hosts(struct doris_http_parameter *param);
|
||||
int32_t param_get_failed_hosts(struct doris_http_parameter *param);
|
||||
|
||||
struct doris_http_parameter *doris_http_parameter_new(const char* profile_path, const char* section, struct event_base* evbase, void *runtime_log);
|
||||
void doris_http_parameter_destroy(struct doris_http_parameter *param);
|
||||
struct doris_http_instance *doris_http_instance_new(struct doris_http_parameter *param, struct event_base* evbase, void *runtimelog);
|
||||
void doris_http_instance_destroy(struct doris_http_instance *instance);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
518
client/doris_client_produce.cpp
Normal file
518
client/doris_client_produce.cpp
Normal file
@@ -0,0 +1,518 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
|
||||
#include "doris_client_produce.h"
|
||||
|
||||
void doris_prod_upload_ctx_destroy(struct doris_upload_ctx *ctx)
|
||||
{
|
||||
doris_http_ctx_destroy(ctx->httpctx);
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
static enum PROD_VEROP_RES version_common_result_assign_val(CURLcode res, long res_code)
|
||||
{
|
||||
if(res != CURLE_OK)
|
||||
{
|
||||
return VERSIONOP_CURL_ERROR;
|
||||
}
|
||||
|
||||
switch(res_code)
|
||||
{
|
||||
case 200: return VERSIONOP_RES_OK;
|
||||
case 201: return VERSIONOP_RES_OK; //<2F>ļ<EFBFBD><C4BC>ֶ<EFBFBD><D6B6>ظ<EFBFBD><D8B8>ϴ<EFBFBD><CFB4>Ż᷵<C5BB><E1B7B5>201
|
||||
default: return VERSIONOP_RES_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void version_cancel_transfer_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
enum PROD_VEROP_RES result;
|
||||
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] -= 1;
|
||||
|
||||
result = version_common_result_assign_val(res, res_code);
|
||||
|
||||
if(result != VERSIONOP_RES_OK)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_FATAL, "business: %s, version cancel sync failed, res_code: %ld, err: %s", ctx->business, res_code, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_DEBUG, "business: %s, version cancel sync succ, res_code: %ld", ctx->business, res_code);
|
||||
}
|
||||
|
||||
if(ctx->vercancel_cb != NULL)
|
||||
{
|
||||
ctx->vercancel_cb(result, ctx->userdata);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t doris_prod_version_cancel(struct doris_upload_ctx *ctx, void (*vercancel_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata)
|
||||
{
|
||||
struct doris_http_callback cb;
|
||||
char uri[256];
|
||||
|
||||
ctx->instance->statistic.field[DRS_FSPRD_FILED_VERCANCEL] += 1;
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] += 1;
|
||||
|
||||
ctx->vercancel_cb = vercancel_cb;
|
||||
ctx->userdata = userdata;
|
||||
|
||||
cb.userp = ctx;
|
||||
cb.header_cb = NULL;
|
||||
cb.write_cb = NULL;
|
||||
cb.read_process_cb = NULL;
|
||||
cb.transfer_done_cb = version_cancel_transfer_done_cb;
|
||||
doris_http_ctx_reset(ctx->httpctx, &cb);
|
||||
|
||||
if(ctx->instance->param->client_sync_on)
|
||||
{
|
||||
doris_http_ctx_add_header(ctx->httpctx, "X-Doris-Master-Slave-Sync: 1");
|
||||
}
|
||||
snprintf(uri, sizeof(uri), "version/cancel?token=%s", ctx->token);
|
||||
return doris_http_launch_post_request(ctx->httpctx, uri, NULL, 0);
|
||||
}
|
||||
|
||||
void version_end_header_cb(const char *start, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
const char *pos_colon;
|
||||
char buffer[64];
|
||||
int datalen;
|
||||
|
||||
if((pos_colon=(const char*)memchr(start, ':', bytes)) == NULL)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
datalen = pos_colon - start;
|
||||
switch(datalen)
|
||||
{
|
||||
case 13:
|
||||
if(!strncasecmp(start, "X-Set-Version:", 14))
|
||||
{
|
||||
memcpy(buffer, start+14, bytes-14);
|
||||
buffer[bytes-14] = '\0';
|
||||
ctx->res_version = atol(buffer);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void version_end_transfer_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
enum PROD_VEROP_RES result;
|
||||
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] -= 1;
|
||||
|
||||
result = version_common_result_assign_val(res, res_code);
|
||||
|
||||
if(result != VERSIONOP_RES_OK)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_FATAL, "business: %s, version end sync failed, res_code: %ld, err: %s", ctx->business, res_code, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(ctx->res_version != 0);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_INFO, "business: %s, version end sync succ, res_code: %ld, new version: %lu", ctx->business, res_code, ctx->res_version);
|
||||
}
|
||||
|
||||
if(ctx->verend_cb != NULL)
|
||||
{
|
||||
ctx->verend_cb(result, ctx->res_version, ctx->userdata);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t doris_prod_version_end(struct doris_upload_ctx *ctx,
|
||||
void (*verend_cb)(enum PROD_VEROP_RES result, int64_t version, void *userdata), void *userdata)
|
||||
{
|
||||
struct doris_http_callback cb;
|
||||
char uri[256];
|
||||
|
||||
ctx->instance->statistic.field[DRS_FSPRD_FILED_VEREND] += 1;
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] += 1;
|
||||
|
||||
ctx->verend_cb = verend_cb;
|
||||
ctx->userdata = userdata;
|
||||
|
||||
cb.userp = ctx;
|
||||
cb.header_cb = version_end_header_cb;
|
||||
cb.write_cb = NULL;
|
||||
cb.read_process_cb = NULL;
|
||||
cb.transfer_done_cb = version_end_transfer_done_cb;
|
||||
doris_http_ctx_reset(ctx->httpctx, &cb);
|
||||
|
||||
if(ctx->instance->param->client_sync_on)
|
||||
{
|
||||
doris_http_ctx_add_header(ctx->httpctx, "X-Doris-Master-Slave-Sync: 1");
|
||||
}
|
||||
snprintf(uri, sizeof(uri), "version/finish?token=%s", ctx->token);
|
||||
return doris_http_launch_post_request(ctx->httpctx, uri, NULL, 0);
|
||||
}
|
||||
|
||||
void upload_frag_transfer_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
enum PROD_VEROP_RES result;
|
||||
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] -= 1;
|
||||
|
||||
result = version_common_result_assign_val(res, res_code);
|
||||
|
||||
if(result != VERSIONOP_RES_OK)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_FATAL, "business: %s, upload frag sync failed, res_code: %ld, err: %s", ctx->business, res_code, err);
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_DEBUG, "business: %s, upload frag sync succ, filename: %s, offset: %lu", ctx->business, ctx->filename, ctx->req_offset);
|
||||
}
|
||||
|
||||
if(ctx->upfrag_cb != NULL)
|
||||
{
|
||||
ctx->upfrag_cb(result, ctx->userdata);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t do_doris_prod_upload_with_cb(struct doris_upload_ctx *ctx, char *data, size_t size,
|
||||
struct table_meta *meta, const char *uri)
|
||||
{
|
||||
struct doris_http_callback cb;
|
||||
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] += 1;
|
||||
|
||||
cb.userp = ctx;
|
||||
cb.header_cb = NULL;
|
||||
cb.write_cb = NULL;
|
||||
cb.read_process_cb = NULL;
|
||||
cb.transfer_done_cb = upload_frag_transfer_done_cb;
|
||||
doris_http_ctx_reset(ctx->httpctx, &cb);
|
||||
|
||||
if(ctx->instance->param->client_sync_on)
|
||||
{
|
||||
doris_http_ctx_add_header(ctx->httpctx, "X-Doris-Master-Slave-Sync: 1");
|
||||
}
|
||||
if(meta->userregion != NULL)
|
||||
{
|
||||
doris_http_ctx_add_header_kvstr(ctx->httpctx, "X-User-Info", meta->userregion);
|
||||
}
|
||||
doris_http_ctx_add_header_kvint(ctx->httpctx, "X-Config-Num", meta->cfgnum);
|
||||
doris_http_ctx_add_header_kvstr(ctx->httpctx, "Content-MD5", meta->md5);
|
||||
|
||||
return doris_http_launch_put_request_data(ctx->httpctx, uri, data, size);
|
||||
}
|
||||
|
||||
int32_t doris_prod_upload_frag_with_cb(struct doris_upload_ctx *ctx, char *data, size_t size, size_t offset,
|
||||
bool last, struct table_meta *meta, void (*upfrag_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata)
|
||||
{
|
||||
char uri[256];
|
||||
|
||||
ctx->instance->statistic.field[DRS_FSPRD_FILED_FILEFRAG] += 1;
|
||||
|
||||
ctx->upfrag_cb = upfrag_cb;
|
||||
ctx->userdata = userdata;
|
||||
ctx->req_offset = offset;
|
||||
snprintf(ctx->filename, 256, "%s", ctx->filename);
|
||||
|
||||
if(last)
|
||||
{
|
||||
snprintf(uri, sizeof(uri), "filefrag/upload?token=%s&tablename=%s&filename=%s&offset=%lu&last=true",
|
||||
ctx->token, meta->tablename, meta->filename, offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(uri, sizeof(uri), "filefrag/upload?token=%s&tablename=%s&filename=%s&offset=%lu",
|
||||
ctx->token, meta->tablename, meta->filename, offset);
|
||||
}
|
||||
return do_doris_prod_upload_with_cb(ctx, data, size, meta, uri);
|
||||
}
|
||||
|
||||
int32_t doris_prod_upload_once_with_cb(struct doris_upload_ctx *ctx, char *data, size_t size,
|
||||
struct table_meta *meta, void (*upfrag_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata)
|
||||
{
|
||||
char uri[256];
|
||||
|
||||
ctx->instance->statistic.field[DRS_FSPRD_FILED_FILEONCE] += 1;
|
||||
|
||||
ctx->upfrag_cb = upfrag_cb;
|
||||
ctx->userdata = userdata;
|
||||
ctx->req_offset = 0;
|
||||
snprintf(ctx->filename, 256, "%s", ctx->filename);
|
||||
|
||||
snprintf(uri, sizeof(uri), "fileonce/upload?token=%s&tablename=%s&filename=%s",
|
||||
ctx->token, meta->tablename, meta->filename);
|
||||
return do_doris_prod_upload_with_cb(ctx, data, size, meta, uri);
|
||||
}
|
||||
|
||||
void verstart_body_write_cb(const char *ptr, size_t bytes, CURLcode code, long res_code, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
|
||||
easy_string_savedata(&ctx->estr, (const char*)ptr, bytes);
|
||||
}
|
||||
|
||||
static enum PROD_VERSTART_RES version_start_result_assign_val(CURLcode res, long res_code)
|
||||
{
|
||||
if(res != CURLE_OK)
|
||||
{
|
||||
return VERSTART_CURL_ERROR;
|
||||
}
|
||||
|
||||
switch(res_code)
|
||||
{
|
||||
case 200: return VERSTART_RES_OK;
|
||||
case 300: return VERSTART_RES_BUSY;
|
||||
default: return VERSTART_RES_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
void verstart_transfer_done_cb(CURLcode res, long res_code, const char *err, void *userp)
|
||||
{
|
||||
struct doris_upload_ctx *ctx=(struct doris_upload_ctx *)userp;
|
||||
cJSON *meta, *token;
|
||||
enum PROD_VERSTART_RES result;
|
||||
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] -= 1;
|
||||
|
||||
result = version_start_result_assign_val(res, res_code);
|
||||
switch(result)
|
||||
{
|
||||
case VERSTART_RES_OK:
|
||||
case VERSTART_RES_BUSY: //server<65><72><EFBFBD><EFBFBD>300<30><30><EFBFBD><EFBFBD>token<65><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB><EFBFBD>Լ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>(<28>Լ<EFBFBD>֮ǰ<D6AE><C7B0><EFBFBD>˻ָ<CBBB>)
|
||||
meta = cJSON_Parse(ctx->estr.buff);
|
||||
token = cJSON_GetObjectItem(meta, "token");
|
||||
assert(token->valuestring != NULL);
|
||||
snprintf(ctx->token, 64, "%s", token->valuestring);
|
||||
cJSON_Delete(meta);
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_DEBUG, "business: %s, version start sync %s, res_code: %ld, body: %s",
|
||||
(result==VERSTART_RES_OK)?"succ":"busy", ctx->business, res_code, ctx->estr.buff);
|
||||
break;
|
||||
|
||||
case VERSTART_RES_ERROR:
|
||||
case VERSTART_CURL_ERROR:
|
||||
MESA_HANDLE_RUNTIME_LOGV2(ctx->instance->runtime_log, RLOG_LV_FATAL, "business: %s, version start sync failed, res_code: %ld, err: %s",
|
||||
ctx->business, res_code, err);
|
||||
break;
|
||||
default: assert(0);break;
|
||||
}
|
||||
|
||||
if(ctx->verstart_cb != NULL)
|
||||
{
|
||||
ctx->verstart_cb(result, ctx->estr.buff, ctx->userdata);
|
||||
}
|
||||
easy_string_destroy(&ctx->estr);
|
||||
}
|
||||
|
||||
struct doris_upload_ctx *doris_prod_upload_ctx_new(struct doris_prod_instance *instance,const char *business, int32_t cfgtype)
|
||||
{
|
||||
struct doris_upload_ctx *ctx;
|
||||
struct doris_http_callback cb;
|
||||
|
||||
if(cfgtype!=1 && cfgtype!=2)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
ctx = (struct doris_upload_ctx *)calloc(1, sizeof(struct doris_upload_ctx));
|
||||
snprintf(ctx->business, 32, "%s", business);
|
||||
ctx->instance = instance;
|
||||
ctx->cfg_type = cfgtype;
|
||||
|
||||
cb.userp = ctx;
|
||||
cb.header_cb = NULL;
|
||||
cb.write_cb = verstart_body_write_cb;
|
||||
cb.read_process_cb = NULL;
|
||||
cb.transfer_done_cb = verstart_transfer_done_cb;
|
||||
if(NULL == (ctx->httpctx = doris_http_ctx_new(instance->http_instance, &cb, rand(), NULL, 0)))
|
||||
{
|
||||
free(ctx);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int32_t doris_prod_version_start_with_cb(struct doris_upload_ctx *ctx,
|
||||
void (*verstart_cb)(enum PROD_VERSTART_RES result, const char *body, void *userdata), void *userdata)
|
||||
{
|
||||
char uri[256];
|
||||
|
||||
ctx->userdata = userdata;
|
||||
ctx->verstart_cb = verstart_cb;
|
||||
|
||||
if(ctx->instance->param->client_sync_on)
|
||||
{
|
||||
doris_http_ctx_add_header(ctx->httpctx, "X-Doris-Master-Slave-Sync: 1");
|
||||
}
|
||||
|
||||
snprintf(uri, sizeof(uri), "version/start?business=%s&type=%d", ctx->business, ctx->cfg_type);
|
||||
if(doris_http_launch_post_request(ctx->httpctx, uri, NULL, 0))
|
||||
{
|
||||
free(ctx);
|
||||
return -1;
|
||||
}
|
||||
ctx->instance->statistic.field[DRS_FSPRD_FILED_VERSTART] += 1;
|
||||
ctx->instance->statistic.status[DRS_FSPRD_STAT_REQ_SESSIONS] += 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t doris_prod_version_start(struct doris_upload_ctx *ctx)
|
||||
{
|
||||
return doris_prod_version_start_with_cb(ctx, NULL, NULL);
|
||||
}
|
||||
|
||||
static void doris_prod_fsoutput_timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
struct doris_prod_param *param=(struct doris_prod_param *)userp;
|
||||
struct timeval tv;
|
||||
|
||||
FS_operate(param->fsstat_handle, param->fsstat_status[DRS_FSPRD_STAT_CNNED_SERVERS], 0, FS_OP_SET, param->param->connected_hosts);
|
||||
FS_operate(param->fsstat_handle, param->fsstat_status[DRS_FSPRD_STAT_FAILED_SERVERS], 0, FS_OP_SET, param->param->failed_hosts);
|
||||
FS_passive_output(param->fsstat_handle);
|
||||
|
||||
tv.tv_sec = param->fsstat_period;
|
||||
tv.tv_usec = 0;
|
||||
evtimer_add(¶m->fs_timer_output, &tv);
|
||||
}
|
||||
|
||||
static int doris_prod_register_fsstat(struct doris_prod_param *param, void *runtime_log, struct event_base *evbase)
|
||||
{
|
||||
const char *field_names[FSSTAT_DORIS_PRD_FILED_NUM]={"VerStart", "VerEnd", "VerCancel", "FileFrag", "FileOnce"};
|
||||
const char *status_names[FSSTAT_DORIS_PRD_STATUS_NUM]={"ServerCnned", "ServerFail", "MemoryUsed", "HttpSession", "ReqSession"};
|
||||
struct timeval tv;
|
||||
int value;
|
||||
|
||||
param->fsstat_handle = FS_create_handle();
|
||||
FS_set_para(param->fsstat_handle, OUTPUT_DEVICE, param->fsstat_filepath, strlen(param->fsstat_filepath)+1);
|
||||
if(param->fsstat_print_mode == 1)
|
||||
{
|
||||
FS_set_para(param->fsstat_handle, PRINT_MODE, ¶m->fsstat_print_mode, sizeof(param->fsstat_print_mode));
|
||||
}
|
||||
else
|
||||
{
|
||||
FS_set_para(param->fsstat_handle, PRINT_MODE, ¶m->fsstat_print_mode, sizeof(param->fsstat_print_mode));
|
||||
value = 1;
|
||||
FS_set_para(param->fsstat_handle, FLUSH_BY_DATE, &value, sizeof(value));
|
||||
}
|
||||
value = param->fsstat_period;
|
||||
FS_set_para(param->fsstat_handle, STAT_CYCLE, &value, sizeof(value));
|
||||
value = 0;
|
||||
FS_set_para(param->fsstat_handle, CREATE_THREAD, &value, sizeof(value));
|
||||
FS_set_para(param->fsstat_handle, APP_NAME, param->fsstat_appname, strlen(param->fsstat_appname)+1);
|
||||
FS_set_para(param->fsstat_handle, STATS_SERVER_IP, param->fsstat_dst_ip, strlen(param->fsstat_dst_ip)+1);
|
||||
FS_set_para(param->fsstat_handle, STATS_SERVER_PORT, ¶m->fsstat_dst_port, sizeof(param->fsstat_dst_port));
|
||||
|
||||
for(int i=0; i<FSSTAT_DORIS_PRD_FILED_NUM; i++)
|
||||
{
|
||||
param->fsstat_field[i] = FS_register(param->fsstat_handle, FS_STYLE_FIELD, FS_CALC_CURRENT, field_names[i]);
|
||||
}
|
||||
for(int i=0; i<FSSTAT_DORIS_PRD_STATUS_NUM; i++)
|
||||
{
|
||||
param->fsstat_status[i] = FS_register(param->fsstat_handle, FS_STYLE_STATUS, FS_CALC_CURRENT, status_names[i]);
|
||||
}
|
||||
FS_start(param->fsstat_handle);
|
||||
|
||||
evtimer_assign(¶m->fs_timer_output, evbase, doris_prod_fsoutput_timer_cb, param);
|
||||
tv.tv_sec = param->fsstat_period;
|
||||
tv.tv_usec = 0;
|
||||
evtimer_add(¶m->fs_timer_output, &tv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct doris_prod_param *doris_prod_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog)
|
||||
{
|
||||
struct doris_prod_param *param;
|
||||
|
||||
param = (struct doris_prod_param *)calloc(1, sizeof(struct doris_prod_param));
|
||||
param->manage_evbase = manage_evbase;
|
||||
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "upload_fragmet_size", ¶m->upload_frag_size, 5242880);
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "master_slave_sync_on", ¶m->client_sync_on, 0);
|
||||
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_appname", param->fsstat_appname, 16, "DrsPrdClient");
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_filepath_p", param->fsstat_filepath, 256, "./log/doris_client_prd.fs");
|
||||
MESA_load_profile_uint_def(confile, "DORIS_CLIENT", "fsstat_log_interval", ¶m->fsstat_period, 10);
|
||||
MESA_load_profile_int_def(confile, "DORIS_CLIENT", "fsstat_log_print_mode", ¶m->fsstat_print_mode, 1);
|
||||
MESA_load_profile_string_def(confile, "DORIS_CLIENT", "fsstat_log_dst_ip", param->fsstat_dst_ip, 64, "127.0.0.1");
|
||||
MESA_load_profile_int_def(confile, "DORIS_CLIENT", "fsstat_log_dst_port", ¶m->fsstat_dst_port, 8125);
|
||||
|
||||
/*ͬ<><CDAC>ʱֻ<CAB1><D6BB>˫<EFBFBD><CBAB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
param->param = doris_http_parameter_new(confile, "DORIS_CLIENT.produce", manage_evbase, runtimelog);
|
||||
if(param->param == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
assert(param->param->ipgroup.dstaddr_num == 1);
|
||||
if(doris_prod_register_fsstat(param, runtimelog, manage_evbase))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
static void doris_prod_statistic_timer_cb(int fd, short kind, void *userp)
|
||||
{
|
||||
struct doris_prod_instance *instance = (struct doris_prod_instance *)userp;
|
||||
struct timeval tv;
|
||||
struct doris_prod_statistics incr_statistic;
|
||||
long long *plast_statistic = (long long*)&instance->statistic_last;
|
||||
long long *pnow_statistic = (long long*)&instance->statistic;
|
||||
long long *pinc_statistic = (long long*)&incr_statistic;
|
||||
|
||||
instance->statistic.status[DRS_FSPRD_STAT_HTTP_SESSIONS] = caculate_http_sessions_sum(instance->http_instance);
|
||||
|
||||
for(u_int32_t i=0; i<sizeof(struct doris_prod_statistics)/sizeof(long long); i++)
|
||||
{
|
||||
pinc_statistic[i] = pnow_statistic[i] - plast_statistic[i];
|
||||
}
|
||||
instance->statistic_last = instance->statistic;
|
||||
|
||||
for(u_int32_t i=0; i<FSSTAT_DORIS_PRD_FILED_NUM; i++)
|
||||
{
|
||||
FS_operate(instance->param->fsstat_handle, instance->param->fsstat_field[i], 0, FS_OP_ADD, incr_statistic.field[i]);
|
||||
}
|
||||
for(u_int32_t i=0; i<FSSTAT_DORIS_PRD_STATUS_NUM; i++)
|
||||
{
|
||||
FS_operate(instance->param->fsstat_handle, instance->param->fsstat_status[i], 0, FS_OP_ADD, incr_statistic.status[i]);
|
||||
}
|
||||
tv.tv_sec = instance->param->fsstat_period;
|
||||
tv.tv_usec = 0;
|
||||
event_add(&instance->timer_statistic, &tv);
|
||||
}
|
||||
|
||||
struct doris_prod_instance *doris_prod_instance_new(struct doris_prod_param *param, struct event_base *worker_evbase, void *runtimelog)
|
||||
{
|
||||
struct doris_prod_instance *instance;
|
||||
struct timeval tv;
|
||||
|
||||
instance = (struct doris_prod_instance *)calloc(1, sizeof(struct doris_prod_instance));
|
||||
instance->param = param;
|
||||
instance->worker_evbase = worker_evbase;
|
||||
instance->runtime_log = runtimelog;
|
||||
|
||||
instance->http_instance = doris_http_instance_new(param->param, worker_evbase, runtimelog);
|
||||
if(instance->http_instance == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
srand((int64_t)param);
|
||||
|
||||
evtimer_assign(&instance->timer_statistic, worker_evbase, doris_prod_statistic_timer_cb, instance);
|
||||
tv.tv_sec = param->fsstat_period;
|
||||
tv.tv_usec = 0;
|
||||
evtimer_add(&instance->timer_statistic, &tv);
|
||||
return instance;
|
||||
}
|
||||
|
||||
61
client/doris_client_produce.h
Normal file
61
client/doris_client_produce.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef __DORIS_CLIENT_PRODUCE_H__
|
||||
#define __DORIS_CLIENT_PRODUCE_H__
|
||||
|
||||
#include <openssl/md5.h>
|
||||
#include <MESA/field_stat2.h>
|
||||
|
||||
#include "doris_producer_client.h"
|
||||
#include "doris_client_http.h"
|
||||
|
||||
struct doris_prod_param
|
||||
{
|
||||
u_int32_t upload_frag_size;
|
||||
u_int32_t client_sync_on;
|
||||
|
||||
struct doris_http_parameter *param;
|
||||
struct event_base *manage_evbase;
|
||||
|
||||
screen_stat_handle_t fsstat_handle;
|
||||
struct event fs_timer_output;
|
||||
char fsstat_dst_ip[64];
|
||||
char fsstat_appname[16];
|
||||
char fsstat_filepath[256];
|
||||
u_int32_t fsstat_period;
|
||||
int32_t fsstat_print_mode;
|
||||
int32_t fsstat_dst_port;
|
||||
int32_t fsstat_field[FSSTAT_DORIS_PRD_FILED_NUM];
|
||||
int32_t fsstat_status[FSSTAT_DORIS_PRD_STATUS_NUM];
|
||||
};
|
||||
|
||||
struct doris_prod_instance
|
||||
{
|
||||
struct doris_prod_param *param;
|
||||
struct doris_http_instance *http_instance;
|
||||
|
||||
struct event_base *worker_evbase;
|
||||
struct event timer_statistic;
|
||||
struct doris_prod_statistics statistic, statistic_last;
|
||||
void *runtime_log;
|
||||
};
|
||||
|
||||
struct doris_upload_ctx
|
||||
{
|
||||
struct doris_http_ctx *httpctx;
|
||||
char token[64];
|
||||
char business[32];
|
||||
char filename[256];
|
||||
struct easy_string estr;
|
||||
int32_t cfg_type;
|
||||
size_t req_offset;
|
||||
int64_t res_version;
|
||||
|
||||
void *userdata;
|
||||
void (*verstart_cb)(enum PROD_VERSTART_RES result, const char *body, void *userdata);
|
||||
void (*upfrag_cb)(enum PROD_VEROP_RES result, void *userdata);
|
||||
void (*verend_cb)(enum PROD_VEROP_RES result, int64_t version, void *userdata);
|
||||
void (*vercancel_cb)(enum PROD_VEROP_RES result, void *userdata);
|
||||
struct doris_prod_instance *instance;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,7 @@ void doris_http_ctx_destroy(struct doris_http_ctx *ctx)
|
||||
}
|
||||
|
||||
struct doris_http_ctx *doris_http_ctx_new(struct doris_http_instance *instance,
|
||||
struct doris_http_callback *cb, u_int64_t balance_seed, char *host, int32_t size)
|
||||
struct doris_http_callback *cb, u_int64_t balance_seed, char *host/*OUT*/, int32_t size)
|
||||
{
|
||||
struct doris_http_ctx *ctx;
|
||||
struct doris_curl_multihd *multidata;
|
||||
@@ -62,8 +62,10 @@ struct doris_http_ctx *doris_http_ctx_new(struct doris_http_instance *instance,
|
||||
}
|
||||
assert(instance->server_hosts->find(result.bucket_id) != instance->server_hosts->end());
|
||||
multidata = instance->server_hosts->find(result.bucket_id)->second;
|
||||
if(host != NULL)
|
||||
{
|
||||
snprintf(host, size, multidata->host->srvaddr);
|
||||
|
||||
}
|
||||
ctx = (struct doris_http_ctx *)calloc(1, sizeof(struct doris_http_ctx));
|
||||
ctx->instance = instance;
|
||||
ctx->multidata = multidata;
|
||||
@@ -92,8 +94,8 @@ static inline void curl_set_common_options(CURL *curl, long transfer_timeout, ch
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 1000L);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEOUT, transfer_timeout); //<2F><><EFBFBD>Է<EFBFBD><D4B7>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>ӽ<EFBFBD><D3BD>տ<EFBFBD>ס<EFBFBD><D7A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//ctx->error="Operation too slow. Less than 100 bytes/sec transferred the last 10 seconds"
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L);
|
||||
//ctx->error="Operation too slow. Less than 100 bytes/sec transferred the last 30 seconds"
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 30L);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 100L);
|
||||
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Doris Client Linux X64");
|
||||
}
|
||||
@@ -136,6 +138,21 @@ void doris_http_ctx_add_header(struct doris_http_ctx *ctx, const char *header)
|
||||
ctx->headers = curl_slist_append(ctx->headers, header);
|
||||
}
|
||||
|
||||
/*maximum length 1024*/
|
||||
void doris_http_ctx_add_header_kvstr(struct doris_http_ctx *ctx, const char *headername, const char *value)
|
||||
{
|
||||
char header[1024];
|
||||
snprintf(header, 1024, "%s: %s", headername, value);
|
||||
ctx->headers = curl_slist_append(ctx->headers, header);
|
||||
}
|
||||
|
||||
void doris_http_ctx_add_header_kvint(struct doris_http_ctx *ctx, const char *headername, u_int64_t value)
|
||||
{
|
||||
char header[1024];
|
||||
snprintf(header, 1024, "%s: %lu", headername, value);
|
||||
ctx->headers = curl_slist_append(ctx->headers, header);
|
||||
}
|
||||
|
||||
int doris_http_launch_get_request(struct doris_http_ctx *ctx, const char *uri)
|
||||
{
|
||||
char minio_url[2048];
|
||||
@@ -143,7 +160,7 @@ int doris_http_launch_get_request(struct doris_http_ctx *ctx, const char *uri)
|
||||
assert(ctx->curl == NULL);
|
||||
if(NULL == (ctx->curl=curl_easy_init()))
|
||||
{
|
||||
return -1;
|
||||
assert(0);return -1;
|
||||
}
|
||||
|
||||
if(ctx->instance->param->ssl_connection)
|
||||
@@ -171,8 +188,7 @@ int doris_http_launch_get_request(struct doris_http_ctx *ctx, const char *uri)
|
||||
|
||||
if(CURLM_OK != curl_multi_add_handle(ctx->multidata->multi_hd, ctx->curl))
|
||||
{
|
||||
assert(0);
|
||||
return -2;
|
||||
assert(0);return -2;
|
||||
}
|
||||
ctx->transfering = 1;
|
||||
return 0;
|
||||
@@ -185,7 +201,7 @@ int doris_http_launch_post_request(struct doris_http_ctx *ctx, const char *uri,
|
||||
assert(ctx->curl == NULL);
|
||||
if(NULL == (ctx->curl=curl_easy_init()))
|
||||
{
|
||||
return -1;
|
||||
assert(0);return -1;
|
||||
}
|
||||
|
||||
doris_http_ctx_add_header(ctx, "Expect:"); //ע<><D7A2>POST<53><54><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Expect<63><74>ϵ<EFBFBD><CFB5>Ҫ<EFBFBD><D2AA>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>CURLOPT_POSTFIELDSIZE
|
||||
@@ -219,8 +235,153 @@ int doris_http_launch_post_request(struct doris_http_ctx *ctx, const char *uri,
|
||||
|
||||
if(CURLM_OK != curl_multi_add_handle(ctx->multidata->multi_hd, ctx->curl))
|
||||
{
|
||||
assert(0);
|
||||
return -2;
|
||||
assert(0);return -2;
|
||||
}
|
||||
ctx->transfering = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t curl_put_data_request_send_cb(void *ptr, size_t size, size_t count, void *userp)
|
||||
{
|
||||
size_t len;
|
||||
struct doris_http_ctx *ctx = (struct doris_http_ctx *)userp;
|
||||
|
||||
if(size==0 || count==0 || ctx->put_offset>=ctx->put_length)
|
||||
{
|
||||
return 0; //<2F><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
len = ctx->put_length - ctx->put_offset; //ʣ<><CAA3><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>ij<EFBFBD><C4B3><EFBFBD>
|
||||
if(len > size * count)
|
||||
{
|
||||
len = size * count;
|
||||
}
|
||||
|
||||
memcpy(ptr, ctx->put_data + ctx->put_offset, len);
|
||||
ctx->put_offset += len;
|
||||
|
||||
if(ctx->cb.read_process_cb != NULL)
|
||||
{
|
||||
ctx->cb.read_process_cb(ctx->put_data, ctx->put_offset, ctx->cb.userp);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
int doris_http_launch_put_request_data(struct doris_http_ctx *ctx, const char *uri, char *data, size_t data_len)
|
||||
{
|
||||
char minio_url[2048];
|
||||
|
||||
assert(ctx->curl == NULL);
|
||||
if(NULL == (ctx->curl=curl_easy_init()))
|
||||
{
|
||||
assert(0);return -1;
|
||||
}
|
||||
ctx->put_data = data;
|
||||
ctx->put_length = data_len;
|
||||
ctx->put_offset = 0;
|
||||
|
||||
if(ctx->instance->param->ssl_connection)
|
||||
{
|
||||
snprintf(minio_url, sizeof(minio_url), "https://%s/%s", ctx->multidata->host->srvaddr, uri);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(minio_url, sizeof(minio_url), "http://%s/%s", ctx->multidata->host->srvaddr, uri);
|
||||
}
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_WRITEFUNCTION, curl_response_write_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_WRITEDATA, ctx);
|
||||
if(ctx->cb.header_cb != NULL)
|
||||
{
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERFUNCTION, curl_response_header_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERDATA, ctx);
|
||||
}
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_INFILESIZE, ctx->put_length);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_READFUNCTION, curl_put_data_request_send_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_READDATA, ctx);
|
||||
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_PRIVATE, ctx);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HTTPHEADER, ctx->headers);
|
||||
curl_set_common_options(ctx->curl, ctx->instance->param->transfer_timeout, ctx->error);
|
||||
|
||||
if(CURLM_OK != curl_multi_add_handle(ctx->multidata->multi_hd, ctx->curl))
|
||||
{
|
||||
assert(0);return -2;
|
||||
}
|
||||
ctx->transfering = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t curl_put_evbuf_request_send_cb(void *ptr, size_t size, size_t count, void *userp)
|
||||
{
|
||||
size_t len, space=size*count, send_len;
|
||||
struct doris_http_ctx *ctx = (struct doris_http_ctx *)userp;
|
||||
|
||||
if(size==0 || count==0 || ctx->put_offset>=ctx->put_length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = ctx->put_length - ctx->put_offset;
|
||||
if(len > space)
|
||||
{
|
||||
len = space;
|
||||
}
|
||||
|
||||
send_len = evbuffer_remove(ctx->put_evbuf, ptr, len);
|
||||
assert(send_len>0);
|
||||
ctx->put_offset += send_len;
|
||||
|
||||
ctx->cb.read_process_cb(ctx->put_evbuf, ctx->put_offset, ctx->cb.userp);
|
||||
return send_len;
|
||||
}
|
||||
|
||||
int doris_http_launch_put_request_evbuf(struct doris_http_ctx *ctx, const char *uri, struct evbuffer *evbuf, size_t data_len)
|
||||
{
|
||||
char minio_url[2048];
|
||||
|
||||
assert(ctx->curl == NULL);
|
||||
if(NULL == (ctx->curl=curl_easy_init()))
|
||||
{
|
||||
assert(0);return -1;
|
||||
}
|
||||
ctx->put_evbuf = evbuf;
|
||||
ctx->put_length = data_len;
|
||||
ctx->put_offset = 0;
|
||||
|
||||
if(ctx->instance->param->ssl_connection)
|
||||
{
|
||||
snprintf(minio_url, sizeof(minio_url), "https://%s/%s", ctx->multidata->host->srvaddr, uri);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(minio_url, sizeof(minio_url), "http://%s/%s", ctx->multidata->host->srvaddr, uri);
|
||||
}
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_UPLOAD, 1L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_WRITEFUNCTION, curl_response_write_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_WRITEDATA, ctx);
|
||||
if(ctx->cb.header_cb != NULL)
|
||||
{
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERFUNCTION, curl_response_header_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERDATA, ctx);
|
||||
}
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_INFILESIZE, ctx->put_length);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_READFUNCTION, curl_put_evbuf_request_send_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_READDATA, ctx);
|
||||
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_PRIVATE, ctx);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HTTPHEADER, ctx->headers);
|
||||
curl_set_common_options(ctx->curl, ctx->instance->param->transfer_timeout, ctx->error);
|
||||
|
||||
if(CURLM_OK != curl_multi_add_handle(ctx->multidata->multi_hd, ctx->curl))
|
||||
{
|
||||
assert(0);return -2;
|
||||
}
|
||||
ctx->transfering = 1;
|
||||
return 0;
|
||||
|
||||
@@ -49,9 +49,13 @@ void doris_http_ctx_destroy(struct doris_http_ctx *ctx);
|
||||
void doris_http_ctx_reset(struct doris_http_ctx *ctx, struct doris_http_callback *cb);
|
||||
|
||||
void doris_http_ctx_add_header(struct doris_http_ctx *ctx, const char *header);
|
||||
void doris_http_ctx_add_header_kvstr(struct doris_http_ctx *ctx, const char *headername, const char *value);
|
||||
void doris_http_ctx_add_header_kvint(struct doris_http_ctx *ctx, const char *headername, u_int64_t value);
|
||||
|
||||
int doris_http_launch_get_request(struct doris_http_ctx *ctx, const char *uri);
|
||||
int doris_http_launch_post_request(struct doris_http_ctx *ctx, const char *uri, const char *data, size_t data_len);
|
||||
int doris_http_launch_put_request_data(struct doris_http_ctx *ctx, const char *uri, char *data, size_t data_len);
|
||||
int doris_http_launch_put_request_evbuf(struct doris_http_ctx *ctx, const char *uri, struct evbuffer *evbuf, size_t data_len);
|
||||
long long caculate_http_sessions_sum(const struct doris_http_instance *instance);
|
||||
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#ifndef __DORIS_CLIENT_H__
|
||||
#define __DORIS_CLIENT_H__
|
||||
|
||||
#include <event.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
enum FSSTAT_DORIS_FILED_ITEMS
|
||||
{
|
||||
DRS_FS_FILED_REQ_FAIL=0,
|
||||
DRS_FS_FILED_REQ_META,
|
||||
DRS_FS_FILED_RES_META,
|
||||
DRS_FS_FILED_RES_NOMETA,
|
||||
DRS_FS_FILED_REQ_FILES,
|
||||
DRS_FS_FILED_RES_FILES,
|
||||
DRS_FS_FILED_RES_FRAGS,
|
||||
DRS_FS_FILED_RES_FRAGERR,
|
||||
DRS_FS_FILED_RES_BYTES,
|
||||
DRS_FS_FILED_RES_VERERR,
|
||||
|
||||
DRS_FS_FILED_BACKUP1_REQ,
|
||||
DRS_FS_FILED_BACKUP2_REQ,
|
||||
|
||||
FSSTAT_DORIS_FILED_NUM,
|
||||
};
|
||||
|
||||
enum FSSTAT_DORIS_STATUS_ITEMS
|
||||
{
|
||||
DRS_FS_STAT_MST_CNN_SRV=0,
|
||||
DRS_FS_STAT_MST_FAIL_SRV,
|
||||
DRS_FS_STAT_BCK1_CNN_SRV,
|
||||
DRS_FS_STAT_BCK1_FAIL_SRV,
|
||||
DRS_FS_STAT_BCK2_CNN_SRV,
|
||||
DRS_FS_STAT_BCK2_FAIL_SRV,
|
||||
DRS_FS_STAT_MEMORY_USED,
|
||||
DRS_FS_STAT_HTTP_SESSIONS,
|
||||
|
||||
FSSTAT_DORIS_STATUS_NUM,
|
||||
};
|
||||
|
||||
struct doris_statistics
|
||||
{
|
||||
long long field[FSSTAT_DORIS_FILED_NUM];
|
||||
long long status[FSSTAT_DORIS_STATUS_NUM];
|
||||
};
|
||||
|
||||
struct doris_arguments
|
||||
{
|
||||
char bizname[32];
|
||||
int64_t current_version; //<2F><>ǰ<EFBFBD>ѻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>°汾<C2B0>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>汾ȡ<E6B1BE><C8A1><EFBFBD><EFBFBD>
|
||||
int32_t judian_id;
|
||||
};
|
||||
|
||||
struct tablemeta
|
||||
{
|
||||
const char *tablename; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽmaat<61><74><EFBFBD>䣻<EFBFBD><E4A3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ<CABD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *filename; //<2F><><EFBFBD><EFBFBD>ʱҪ<CAB1><D2AA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *userregion;
|
||||
size_t size;
|
||||
u_int32_t cfgnum;
|
||||
};
|
||||
|
||||
struct doris_instance;
|
||||
struct doris_callbacks
|
||||
{
|
||||
void *userdata;
|
||||
void (*version_start)(struct doris_instance *instance, cJSON *meta, void *userdata); //meta<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ч
|
||||
void (*cfgfile_start)(struct doris_instance *instance, const struct tablemeta *meta, const char *unused, void *userdata);
|
||||
void (*cfgfile_update)(struct doris_instance *instance, const char *data, size_t len, void *userdata);
|
||||
void (*cfgfile_finish)(struct doris_instance *instance, const char *md5, void *userdata);
|
||||
void (*version_error)(struct doris_instance *instance, void *userdata); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3>ð汾<C3B0><E6B1BE>Ҫ<EFBFBD>ع<EFBFBD>
|
||||
void (*version_finish)(struct doris_instance *instance, void *userdata);
|
||||
};
|
||||
|
||||
struct doris_parameter *doris_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog);
|
||||
struct doris_instance *doris_instance_new(struct doris_parameter *param, struct event_base *worker_evbase,
|
||||
struct doris_callbacks *cbs, struct doris_arguments *args, void *runtimelog);
|
||||
|
||||
#endif
|
||||
|
||||
86
include/doris_consumer_client.h
Normal file
86
include/doris_consumer_client.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#ifndef __DORIS_CONSUMER_CLIENT_H__
|
||||
#define __DORIS_CONSUMER_CLIENT_H__
|
||||
|
||||
#include <event.h>
|
||||
#include <cjson/cJSON.h>
|
||||
|
||||
enum FSSTAT_DORIS_FILED_ITEMS
|
||||
{
|
||||
DRS_FS_FILED_REQ_FAIL=0,
|
||||
DRS_FS_FILED_REQ_META,
|
||||
DRS_FS_FILED_RES_META,
|
||||
DRS_FS_FILED_RES_NOMETA,
|
||||
DRS_FS_FILED_REQ_FILES,
|
||||
DRS_FS_FILED_RES_FILES,
|
||||
DRS_FS_FILED_RES_FRAGS,
|
||||
DRS_FS_FILED_RES_FRAGERR,
|
||||
DRS_FS_FILED_RES_BYTES,
|
||||
DRS_FS_FILED_RES_VERERR,
|
||||
|
||||
DRS_FS_FILED_BACKUP1_REQ,
|
||||
DRS_FS_FILED_BACKUP2_REQ,
|
||||
|
||||
FSSTAT_DORIS_FILED_NUM,
|
||||
};
|
||||
|
||||
enum FSSTAT_DORIS_STATUS_ITEMS
|
||||
{
|
||||
DRS_FS_STAT_MST_CNN_SRV=0,
|
||||
DRS_FS_STAT_MST_FAIL_SRV,
|
||||
DRS_FS_STAT_BCK1_CNN_SRV,
|
||||
DRS_FS_STAT_BCK1_FAIL_SRV,
|
||||
DRS_FS_STAT_BCK2_CNN_SRV,
|
||||
DRS_FS_STAT_BCK2_FAIL_SRV,
|
||||
DRS_FS_STAT_MEMORY_USED,
|
||||
DRS_FS_STAT_HTTP_SESSIONS,
|
||||
|
||||
FSSTAT_DORIS_STATUS_NUM,
|
||||
};
|
||||
|
||||
struct doris_csum_statistics
|
||||
{
|
||||
long long field[FSSTAT_DORIS_FILED_NUM];
|
||||
long long status[FSSTAT_DORIS_STATUS_NUM];
|
||||
};
|
||||
|
||||
struct doris_arguments
|
||||
{
|
||||
char bizname[32];
|
||||
int64_t current_version; //<2F><>ǰ<EFBFBD>ѻ<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>°汾<C2B0>ţ<EFBFBD><C5A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>汾ȡ<E6B1BE><C8A1><EFBFBD><EFBFBD>
|
||||
int32_t judian_id;
|
||||
};
|
||||
|
||||
struct tablemeta
|
||||
{
|
||||
const char *tablename; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽmaat<61><74><EFBFBD>䣻<EFBFBD><E4A3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ<CABD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *filename; //<2F><><EFBFBD><EFBFBD>ʱҪ<CAB1><D2AA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *userregion;
|
||||
size_t size;
|
||||
u_int32_t cfgnum;
|
||||
};
|
||||
|
||||
struct doris_csum_param;
|
||||
struct doris_csum_instance;
|
||||
struct doris_callbacks
|
||||
{
|
||||
void *userdata;
|
||||
void (*version_start)(struct doris_csum_instance *instance, cJSON *meta, void *userdata); //meta<74><61><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>Ч
|
||||
void (*cfgfile_start)(struct doris_csum_instance *instance, const struct tablemeta *meta, const char *unused, void *userdata);
|
||||
void (*cfgfile_update)(struct doris_csum_instance *instance, const char *data, size_t len, void *userdata);
|
||||
void (*cfgfile_finish)(struct doris_csum_instance *instance, const char *md5, void *userdata);
|
||||
void (*version_error)(struct doris_csum_instance *instance, void *userdata); //<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3>ð汾<C3B0><E6B1BE>Ҫ<EFBFBD>ع<EFBFBD>
|
||||
void (*version_finish)(struct doris_csum_instance *instance, void *userdata);
|
||||
void (*version_updated)(struct doris_csum_instance *instance, void *userdata); //<2F><>ʱû<CAB1><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
|
||||
struct doris_csum_param *doris_csum_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog);
|
||||
void doris_csum_parameter_destroy(struct doris_csum_param *param);
|
||||
u_int32_t doris_csum_param_get_refernces(struct doris_csum_param *param);
|
||||
|
||||
struct doris_csum_instance *doris_csum_instance_new(struct doris_csum_param *param, struct event_base *worker_evbase,
|
||||
struct doris_callbacks *cbs, struct doris_arguments *args, void *runtimelog);
|
||||
struct doris_csum_param *doris_csum_instance_get_param(struct doris_csum_instance *instance);
|
||||
void doris_csum_instance_destroy(struct doris_csum_instance *instance);
|
||||
|
||||
#endif
|
||||
|
||||
80
include/doris_producer_client.h
Normal file
80
include/doris_producer_client.h
Normal file
@@ -0,0 +1,80 @@
|
||||
#ifndef __DORIS_PRODUCER_CLIENT_H__
|
||||
#define __DORIS_PRODUCER_CLIENT_H__
|
||||
|
||||
enum FSSTAT_DRS_PROD_FILED_ITEMS
|
||||
{
|
||||
DRS_FSPRD_FILED_VERSTART=0,
|
||||
DRS_FSPRD_FILED_VEREND,
|
||||
DRS_FSPRD_FILED_VERCANCEL,
|
||||
DRS_FSPRD_FILED_FILEFRAG,
|
||||
DRS_FSPRD_FILED_FILEONCE,
|
||||
|
||||
FSSTAT_DORIS_PRD_FILED_NUM,
|
||||
};
|
||||
|
||||
enum FSSTAT_DRS_PROD_STATUS_ITEMS
|
||||
{
|
||||
DRS_FSPRD_STAT_CNNED_SERVERS=0,
|
||||
DRS_FSPRD_STAT_FAILED_SERVERS,
|
||||
DRS_FSPRD_STAT_MEMORY_USED,
|
||||
DRS_FSPRD_STAT_HTTP_SESSIONS,
|
||||
DRS_FSPRD_STAT_REQ_SESSIONS,
|
||||
|
||||
FSSTAT_DORIS_PRD_STATUS_NUM,
|
||||
};
|
||||
|
||||
struct doris_prod_statistics
|
||||
{
|
||||
long long field[FSSTAT_DORIS_PRD_FILED_NUM];
|
||||
long long status[FSSTAT_DORIS_PRD_STATUS_NUM];
|
||||
};
|
||||
|
||||
struct doris_prod_param;
|
||||
struct doris_prod_instance;
|
||||
struct doris_upload_ctx;
|
||||
|
||||
struct doris_prod_param *doris_prod_parameter_new(const char *confile, struct event_base *manage_evbase, void *runtimelog);
|
||||
struct doris_prod_instance *doris_prod_instance_new(struct doris_prod_param *param, struct event_base *worker_evbase, void *runtimelog);
|
||||
|
||||
enum PROD_VERSTART_RES
|
||||
{
|
||||
VERSTART_RES_OK=0,
|
||||
VERSTART_RES_BUSY, //<2F><>Ӧ<EFBFBD><D3A6>300<30><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>server<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>start<72><74><EFBFBD><EFBFBD>;<EFBFBD>汾
|
||||
VERSTART_RES_ERROR, //ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6>400<30><30>Ҫô<D2AA>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫô<D2AA><C3B4>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>start<72>İ汾<C4B0><E6B1BE>
|
||||
VERSTART_CURL_ERROR, //curlԭ<6C><D4AD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ӧ
|
||||
};
|
||||
|
||||
/*cfgtype: 1-ȫ<><C8AB><EFBFBD><EFBFBD>2-<2D><><EFBFBD><EFBFBD>*/
|
||||
struct doris_upload_ctx *doris_prod_upload_ctx_new(struct doris_prod_instance *instance,const char *business, int32_t cfgtype);
|
||||
void doris_prod_upload_ctx_destroy(struct doris_upload_ctx *ctx);
|
||||
|
||||
int32_t doris_prod_version_start(struct doris_upload_ctx *ctx);
|
||||
int32_t doris_prod_version_start_with_cb(struct doris_upload_ctx *ctx,
|
||||
void (*verstart_cb)(enum PROD_VERSTART_RES result, const char *body, void *userdata), void *userdata);
|
||||
|
||||
enum PROD_VEROP_RES
|
||||
{
|
||||
VERSIONOP_RES_OK=0,
|
||||
VERSIONOP_RES_ERROR,
|
||||
VERSIONOP_CURL_ERROR,
|
||||
};
|
||||
|
||||
struct table_meta
|
||||
{
|
||||
const char *tablename; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽmaat<61><74><EFBFBD>䣻<EFBFBD><E4A3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽΪ<CABD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *filename; //<2F><><EFBFBD><EFBFBD>ʱҪ<CAB1><D2AA><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
|
||||
const char *userregion;
|
||||
const char *md5;
|
||||
u_int32_t cfgnum;
|
||||
};
|
||||
|
||||
int32_t doris_prod_upload_once_with_cb(struct doris_upload_ctx *ctx, char *data, size_t size,
|
||||
struct table_meta *meta, void (*upfrag_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata);
|
||||
int32_t doris_prod_upload_frag_with_cb(struct doris_upload_ctx *ctx, char *data, size_t size, size_t offset,
|
||||
bool last, struct table_meta *meta, void (*upfrag_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata);
|
||||
|
||||
int32_t doris_prod_version_end(struct doris_upload_ctx *ctx, void (*verend_cb)(enum PROD_VEROP_RES result, int64_t version, void *userdata), void *userdata);
|
||||
int32_t doris_prod_version_cancel(struct doris_upload_ctx *ctx, void (*vercancel_cb)(enum PROD_VEROP_RES result, void *userdata), void *userdata);
|
||||
|
||||
#endif
|
||||
|
||||
BIN
monitor/monitor_expamle.png
Normal file
BIN
monitor/monitor_expamle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -65,7 +65,7 @@
|
||||
"scroll": true,
|
||||
"showHeader": true,
|
||||
"sort": {
|
||||
"col": 13,
|
||||
"col": 2,
|
||||
"desc": false
|
||||
},
|
||||
"styles": [
|
||||
@@ -218,7 +218,7 @@
|
||||
"pattern": "Value #D",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "MAXfds",
|
||||
@@ -266,7 +266,7 @@
|
||||
"pattern": "Value #G",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "Restart24H",
|
||||
@@ -337,7 +337,7 @@
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "LatestVersion",
|
||||
"alias": "LatestVer-T1",
|
||||
"colorMode": null,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
@@ -353,7 +353,7 @@
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "TotalCfgNum",
|
||||
"alias": "TotalCfgs-T1",
|
||||
"colorMode": null,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
@@ -361,12 +361,77 @@
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 2,
|
||||
"decimals": null,
|
||||
"mappingType": 1,
|
||||
"pattern": "Value #L",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "LatestVer-VoIP",
|
||||
"colorMode": null,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"mappingType": 1,
|
||||
"pattern": "Value #M",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "PostServer",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(40, 233, 13, 0.9)",
|
||||
"#cca300",
|
||||
"#bf1b00"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 2,
|
||||
"mappingType": 1,
|
||||
"pattern": "Value #N",
|
||||
"thresholds": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"type": "string",
|
||||
"unit": "short"
|
||||
"unit": "short",
|
||||
"valueMaps": [
|
||||
{
|
||||
"text": "OK",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"text": "uping",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"text": "down",
|
||||
"value": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"alias": "TotalCfgs-VoIP",
|
||||
"colorMode": null,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": null,
|
||||
"mappingType": 1,
|
||||
"pattern": "Value #O",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
@@ -449,14 +514,21 @@
|
||||
"refId": "D"
|
||||
},
|
||||
{
|
||||
"expr": "0+latest_cfg_version{job=~\"doris\"}",
|
||||
"expr": "0+http_post_server_status{job=~\"doris\"}",
|
||||
"format": "table",
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
"refId": "N"
|
||||
},
|
||||
{
|
||||
"expr": "0+latest_cfg_version_T1_1{job=~\"doris\"}",
|
||||
"format": "table",
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
"refId": "K"
|
||||
},
|
||||
{
|
||||
"expr": "0+total_config_num{job=~\"doris\"}",
|
||||
"expr": "0+total_config_num_T1_1{job=~\"doris\"}",
|
||||
"format": "table",
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
@@ -468,6 +540,20 @@
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
"refId": "I"
|
||||
},
|
||||
{
|
||||
"expr": "0+latest_cfg_version_VoIP{job=~\"doris\"}",
|
||||
"format": "table",
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
"refId": "M"
|
||||
},
|
||||
{
|
||||
"expr": "0+total_config_num_VoIP{job=~\"doris\"}",
|
||||
"format": "table",
|
||||
"instant": true,
|
||||
"intervalFactor": 1,
|
||||
"refId": "O"
|
||||
}
|
||||
],
|
||||
"title": "Doris运行状态",
|
||||
@@ -514,5 +600,5 @@
|
||||
"timezone": "",
|
||||
"title": "配置分发网络运行状态",
|
||||
"uid": "HZfW8wi7k",
|
||||
"version": 7
|
||||
"version": 14
|
||||
}
|
||||
@@ -4,7 +4,7 @@ add_definitions(-fPIC -Wall -g)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__FILENAME__='\"$(subst ${CMAKE_CURRENT_SOURCE_DIR}/,,$(abspath $<))\"'")
|
||||
|
||||
add_executable(doris ${NIRVANA_PLATFORM_SRC})
|
||||
target_link_libraries(doris doris_client_static libMesaMonitor libevent-static libevent-pthreads-static libcurl-static libevent-openssl-static openssl-ssl-static openssl-crypto-static cjson libLevelDB)
|
||||
target_link_libraries(doris doris_client_static libMesaMonitor libevent-static libevent-pthreads-static libcurl-static libevent-openssl-static openssl-ssl-static openssl-crypto-static cjson)
|
||||
target_link_libraries(doris MESA_handle_logger MESA_htable MESA_prof_load MESA_field_stat2 pthread z dl)
|
||||
set_target_properties(doris PROPERTIES CLEAN_DIRECT_OUTPUT 1)
|
||||
target_include_directories(doris PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
[DORIS_CLIENT]
|
||||
fetch_fail_retry_interval=5
|
||||
fetch_fragmet_size=5242880
|
||||
fetch_confile_max_tries=3
|
||||
|
||||
fsstat_log_appname=DorisClient
|
||||
fsstat_log_filepath=./log/doris_client.fs
|
||||
fsstat_log_interval=2
|
||||
fsstat_log_print_mode=1
|
||||
fsstat_log_dst_ip=192.168.10.90
|
||||
fsstat_log_dst_port=8125
|
||||
|
||||
[DORIS_CLIENT.master_server]
|
||||
max_connection_per_host=1
|
||||
max_cnnt_pipeline_num=10
|
||||
https_connection_on=0
|
||||
max_curl_session_num=10
|
||||
|
||||
http_server_listen_port=9897
|
||||
http_server_manage_port=9897
|
||||
http_server_ip_list=192.168.10.8
|
||||
|
||||
[DORIS_CLIENT.backup1_server]
|
||||
max_connection_per_host=1
|
||||
max_cnnt_pipeline_num=10
|
||||
https_connection_on=0
|
||||
max_curl_session_num=10
|
||||
|
||||
http_server_listen_port=9897
|
||||
http_server_manage_port=9897
|
||||
http_server_ip_list=192.168.11.241
|
||||
|
||||
[DORIS_CLIENT.backup2_server]
|
||||
|
||||
|
||||
30
server/bin/conf/doris_client_csum.conf
Normal file
30
server/bin/conf/doris_client_csum.conf
Normal file
@@ -0,0 +1,30 @@
|
||||
[DORIS_CLIENT]
|
||||
fetch_fail_retry_interval=5
|
||||
fetch_fragmet_size=5242880
|
||||
fetch_confile_max_tries=3
|
||||
|
||||
fsstat_log_appname=DrsCsmClient
|
||||
fsstat_log_filepath=./log/doris_client_csm.fs
|
||||
fsstat_log_interval=2
|
||||
fsstat_log_print_mode=1
|
||||
fsstat_log_dst_ip=192.168.10.90
|
||||
fsstat_log_dst_port=8125
|
||||
|
||||
[DORIS_CLIENT.master_server]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9898
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.10.8
|
||||
|
||||
[DORIS_CLIENT.backup1_server]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9898
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.11.241
|
||||
|
||||
[DORIS_CLIENT.backup2_server]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9898
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.11.242
|
||||
|
||||
28
server/bin/conf/doris_client_sync_t1.conf
Normal file
28
server/bin/conf/doris_client_sync_t1.conf
Normal file
@@ -0,0 +1,28 @@
|
||||
[DORIS_CLIENT]
|
||||
fetch_fail_retry_interval=5
|
||||
fetch_fragmet_size=5242880
|
||||
fetch_confile_max_tries=3
|
||||
|
||||
upload_fragmet_size=5242880
|
||||
master_slave_sync_on=1
|
||||
|
||||
fsstat_log_appname=DrsPrdClient
|
||||
fsstat_log_filepath=./log/doris_sync_t1c.fs
|
||||
fsstat_log_filepath_p=./log/doris_sync_t1p.fs
|
||||
fsstat_log_interval=2
|
||||
fsstat_log_print_mode=1
|
||||
fsstat_log_dst_ip=192.168.10.90
|
||||
fsstat_log_dst_port=8125
|
||||
|
||||
[DORIS_CLIENT.master_server]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9898
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.10.9
|
||||
|
||||
[DORIS_CLIENT.produce]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9800
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.10.9
|
||||
|
||||
28
server/bin/conf/doris_client_sync_voip.conf
Normal file
28
server/bin/conf/doris_client_sync_voip.conf
Normal file
@@ -0,0 +1,28 @@
|
||||
[DORIS_CLIENT]
|
||||
fetch_fail_retry_interval=5
|
||||
fetch_fragmet_size=5242880
|
||||
fetch_confile_max_tries=3
|
||||
|
||||
upload_fragmet_size=5242880
|
||||
master_slave_sync_on=1
|
||||
|
||||
fsstat_log_appname=DrsPrdClient
|
||||
fsstat_log_filepath=./log/doris_sync_voipc.fs
|
||||
fsstat_log_filepath_p=./log/doris_sync_voipp.fs
|
||||
fsstat_log_interval=2
|
||||
fsstat_log_print_mode=1
|
||||
fsstat_log_dst_ip=192.168.10.90
|
||||
fsstat_log_dst_port=8125
|
||||
|
||||
[DORIS_CLIENT.master_server]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9898
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.10.9
|
||||
|
||||
[DORIS_CLIENT.produce]
|
||||
https_connection_on=1
|
||||
http_server_listen_port=9801
|
||||
http_server_manage_port=2233
|
||||
http_server_ip_list=192.168.10.9
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
[DORIS_SERVER]
|
||||
worker_thread_num=2
|
||||
server_listen_port=9898
|
||||
manage_listen_port=2233
|
||||
consumer_listen_port=9898
|
||||
manager_listen_port=2233
|
||||
https_connection_on=1
|
||||
cache_file_frag_size=100
|
||||
#doris_server_role_on=1
|
||||
#cache_file_frag_size=67108864
|
||||
#index_file_format_maat=0
|
||||
local_net_name=em1
|
||||
http_post_cluster_on=1
|
||||
#http_post_max_concurrence=100000
|
||||
|
||||
business_system_list=T1_1;VoIP
|
||||
business_system_list=VoIP;T1_1
|
||||
|
||||
run_log_dir=./log
|
||||
run_log_lv=20
|
||||
@@ -19,20 +21,25 @@ fsstat_log_dst_ip=192.168.10.90
|
||||
fsstat_log_dst_port=8125
|
||||
|
||||
[T1_1]
|
||||
#1-Doris client; 2-local file
|
||||
receive_config_way=2
|
||||
#1-Doris client; 2-local file; 3-HTTP post server
|
||||
receive_config_way=1
|
||||
grafana_monitor_status_id=3
|
||||
#producer_listen_port=9800
|
||||
#producer_concurrence_allowed=0
|
||||
store_config_path=./doris_store_t1
|
||||
receive_config_path_full=./doris_receive_t1/full/index
|
||||
receive_config_path_inc=./doris_receive_t1/inc/index
|
||||
#doris_client_confile=./conf/doris_client.conf
|
||||
doris_client_confile=./conf/doris_client_csum.conf
|
||||
#doris_client_confile=./conf/doris_client_sync_t1.conf
|
||||
|
||||
[VoIP]
|
||||
receive_config_way=2
|
||||
receive_config_way=3
|
||||
producer_listen_port=9801
|
||||
producer_concurrence_allowed=1
|
||||
mem_cache_max_versions=2
|
||||
grafana_monitor_status_id=4
|
||||
store_config_path=./doris_store_voip
|
||||
receive_config_path_full=./doris_receive_voip/full/index
|
||||
receive_config_path_inc=./doris_receive_voip/inc/index
|
||||
#doris_client_confile=./conf/doris_client.conf
|
||||
doris_client_confile=./conf/doris_client_sync_voip.conf
|
||||
|
||||
|
||||
@@ -16,64 +16,11 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <event2/bufferevent_ssl.h>
|
||||
|
||||
#include "doris_server_main.h"
|
||||
#include "doris_server_http.h"
|
||||
|
||||
extern struct doris_global_info g_doris_server_info;
|
||||
|
||||
static inline void set_sockopt_keepalive(int sd, int keepidle, int keepintvl, int keepcnt)
|
||||
{
|
||||
int keepalive = 1;
|
||||
setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (void*)&keepalive, sizeof(keepalive));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPIDLE, (void*)&keepidle, sizeof(keepidle));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPINTVL, (void*)&keepintvl, sizeof(keepintvl));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPCNT, (void*)&keepcnt, sizeof(keepcnt));
|
||||
}
|
||||
|
||||
static inline void set_listen_sockopt(int sd)
|
||||
{
|
||||
if(g_doris_server_info.sock_recv_bufsize > 0)
|
||||
{
|
||||
setsockopt(sd, SOL_SOCKET, SO_RCVBUF, &g_doris_server_info.sock_recv_bufsize, sizeof(u_int32_t));
|
||||
}
|
||||
}
|
||||
|
||||
int doris_create_listen_socket(int bind_port)
|
||||
{
|
||||
evutil_socket_t listener;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
listener = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(listener < 0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "create socket error!\n");
|
||||
return -1;
|
||||
}
|
||||
set_sockopt_keepalive(listener, 300, 10, 2);
|
||||
set_listen_sockopt(listener);
|
||||
evutil_make_listen_socket_reuseable(listener);
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr=htonl(INADDR_ANY);
|
||||
sin.sin_port = htons(bind_port);
|
||||
|
||||
if (bind(listener, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
printf("bind socket to port: %d error: %s!\n", bind_port, strerror(errno));
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "bind socket to port: %d error: %s!\n", bind_port, strerror(errno));
|
||||
assert(0);return -2;
|
||||
}
|
||||
if (listen(listener, 1024)<0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "listen socket 1024 error!\n");
|
||||
return -3;
|
||||
}
|
||||
evutil_make_socket_nonblocking(listener);
|
||||
return listener;
|
||||
}
|
||||
|
||||
struct version_list_node *lookup_vernode_accord_version(struct version_list_handle *handle, int64_t version)
|
||||
{
|
||||
struct version_list_node *vernode;
|
||||
@@ -96,16 +43,49 @@ struct version_list_node *lookup_vernode_accord_version(struct version_list_hand
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>ֵ:
|
||||
*304-<2D>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD>Ѵﵽ<D1B4><EFB5BD><EFBFBD>°汾<C2B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>consumer<65><72><EFBFBD><D7BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*300-<2D><>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Client<6E><74><EFBFBD>ð汾<C3B0><E6B1BE><EFBFBD><EFBFBD>*/
|
||||
static int32_t check_producer_ready_sync(struct doris_business *business, struct evhttp_request *req, int64_t cur_version)
|
||||
{
|
||||
const char *client_version;
|
||||
int64_t clientversion;
|
||||
|
||||
if(NULL == (client_version=evhttp_find_header(evhttp_request_get_input_headers(req), "X-Doris-Sync-Current-Version")))
|
||||
{
|
||||
return HTTP_NOTMODIFIED;
|
||||
}
|
||||
|
||||
/*request from sync client, check http posts-on-the-way first*/
|
||||
if(business->posts_on_the_way)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_DEBUG, "HttpProducer, posts-on-the-way: %d, meta response 300", business->posts_on_the_way);
|
||||
return 300;
|
||||
}
|
||||
|
||||
/*Client<6E>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>? <20><><EFBFBD><EFBFBD><EFBFBD>˴ӻ<CBB4><D3BB><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>Client<6E><74><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD><EFBFBD>ȡ*/
|
||||
/*<2A><><EFBFBD><EFBFBD>ȡʱ<C8A1><CAB1><EFBFBD>õ<EFBFBD>300<30><30>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡʱ<C8A1><CAB1>ֱ<EFBFBD><D6B1>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>İ汾<C4B0><E6B1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE><EFBFBD><EFBFBD>һ<EFBFBD>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD>304*/
|
||||
if((clientversion=atol(client_version)) > cur_version)
|
||||
{
|
||||
business_set_sync_peer_abnormal(business);
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_INFO, "HttpProducer, client version(%lu) is newer than server(%lu)", clientversion, cur_version);
|
||||
return 300;
|
||||
}
|
||||
|
||||
business_resume_sync_peer_normal(business);
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "HttpProducer, doris client is OK to sync for business: %s", business->bizname);
|
||||
return HTTP_NOTMODIFIED;
|
||||
}
|
||||
|
||||
void doris_http_server_meta_cb(struct evhttp_request *req, void *arg)
|
||||
{
|
||||
struct evkeyvalq params;
|
||||
const char *version, *bizname;
|
||||
const char *version;
|
||||
int64_t verlong;
|
||||
char *endptr=NULL, length[64];
|
||||
struct version_list_node *vernode;
|
||||
struct evbuffer *evbuf;
|
||||
struct doris_business *business;
|
||||
map<string, struct doris_business*>::iterator iter;
|
||||
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_META_REQ], 0, FS_OP_ADD, 1);
|
||||
if(evhttp_parse_query(evhttp_request_get_uri(req), ¶ms))
|
||||
@@ -128,29 +108,21 @@ void doris_http_server_meta_cb(struct evhttp_request *req, void *arg)
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameter version invalid");
|
||||
return;
|
||||
}
|
||||
if(NULL == (bizname = evhttp_find_header(¶ms, "business")))
|
||||
if(NULL == (business = lookup_bizstruct_from_name(¶ms)))
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_clear_headers(¶ms);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, no business found");
|
||||
return;
|
||||
}
|
||||
if((iter = g_doris_server_info.name2business->find(string(bizname)))==g_doris_server_info.name2business->end())
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_clear_headers(¶ms);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, business invalid");
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameter business invalid");
|
||||
return;
|
||||
}
|
||||
evhttp_clear_headers(¶ms);
|
||||
business = iter->second;
|
||||
|
||||
pthread_rwlock_rdlock(&business->rwlock);
|
||||
if(NULL == (vernode = lookup_vernode_accord_version(business->cfgver_head, verlong)))
|
||||
{
|
||||
int code = check_producer_ready_sync(business, req, business->cfgver_head->latest_version);
|
||||
pthread_rwlock_unlock(&business->rwlock);
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_SEND_META_NONEW], 0, FS_OP_ADD, 1);
|
||||
evhttp_send_error(req, HTTP_NOTMODIFIED, "No new configs found");
|
||||
evhttp_send_error(req, code, "No new configs found");
|
||||
return;
|
||||
}
|
||||
evbuf = evbuffer_new();
|
||||
@@ -210,24 +182,14 @@ struct evbuffer *evbuf_content_from_disk(struct table_list_node *tablenode, size
|
||||
return evbuf;
|
||||
}
|
||||
|
||||
void doris_response_file_range(struct evhttp_request *req, const char *bizname, const char *tablename,
|
||||
int64_t verlong, size_t start, size_t end, bool range)
|
||||
void doris_response_file_range(struct evhttp_request *req, struct doris_business *business,
|
||||
const char *tablename, int64_t verlong, size_t start, size_t end, bool range)
|
||||
{
|
||||
struct version_list_node *vernode;
|
||||
struct table_list_node *tablenode;
|
||||
struct evbuffer *evbuf;
|
||||
char length[128];
|
||||
size_t filesize, res_length;
|
||||
struct doris_business *business;
|
||||
map<string, struct doris_business*>::iterator iter;
|
||||
|
||||
if((iter = g_doris_server_info.name2business->find(string(bizname)))==g_doris_server_info.name2business->end())
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, business invalid");
|
||||
return;
|
||||
}
|
||||
business = iter->second;
|
||||
|
||||
pthread_rwlock_rdlock(&business->rwlock);
|
||||
if(NULL == (vernode = lookup_vernode_accord_version(business->cfgver_head, verlong)))
|
||||
@@ -266,24 +228,29 @@ void doris_response_file_range(struct evhttp_request *req, const char *bizname,
|
||||
|
||||
assert(res_length == end + 1 - start);
|
||||
sprintf(length, "%lu", res_length);
|
||||
FS_operate(g_doris_server_info.fsstat_handle, business->fs_lineid, g_doris_server_info.fsstat_column[DRS_FSCLM_SEND_FILE_RES], FS_OP_ADD, 1);
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_SEND_FILES], 0, FS_OP_ADD, 1);
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_SEND_FILE_BYTES], 0, FS_OP_ADD, res_length);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Length", length);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "application/stream");
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Connection", "keep-alive");
|
||||
if(range)
|
||||
{
|
||||
sprintf(length, "bytes %lu-%lu/%lu", start, end, filesize);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Range", length);
|
||||
evhttp_send_reply(req, 206, "Partial Content", evbuf);
|
||||
}
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Content-Type", "application/stream");
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Connection", "keep-alive");
|
||||
else
|
||||
{
|
||||
evhttp_send_reply(req, HTTP_OK, "OK", evbuf);
|
||||
}
|
||||
evbuffer_free(evbuf);
|
||||
}
|
||||
|
||||
void doris_http_server_file_cb(struct evhttp_request *req, void *arg)
|
||||
{
|
||||
struct evkeyvalq params;
|
||||
const char *version, *tablename, *content_range, *bizname;
|
||||
struct doris_business *business;
|
||||
const char *version, *tablename, *content_range;
|
||||
int64_t verlong;
|
||||
char *endptr=NULL;
|
||||
size_t req_start=0, req_end=0;
|
||||
@@ -317,24 +284,21 @@ void doris_http_server_file_cb(struct evhttp_request *req, void *arg)
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Header Range invalid");
|
||||
return;
|
||||
}
|
||||
if(NULL == (bizname = evhttp_find_header(¶ms, "business")))
|
||||
if(NULL == (business = lookup_bizstruct_from_name(¶ms)))
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_clear_headers(¶ms);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, no business found");
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameter business invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
doris_response_file_range(req, bizname, tablename, verlong, req_start, req_end, (content_range==NULL)?false:true);
|
||||
doris_response_file_range(req, business, tablename, verlong, req_start, req_end, (content_range==NULL)?false:true);
|
||||
evhttp_clear_headers(¶ms);
|
||||
}
|
||||
|
||||
void doris_http_server_version_cb(struct evhttp_request *req, void *arg)
|
||||
{
|
||||
struct evkeyvalq params;
|
||||
const char *bizname;
|
||||
struct doris_business *business;
|
||||
map<string, struct doris_business*>::iterator iter;
|
||||
char verbuf[32];
|
||||
|
||||
if(evhttp_parse_query(evhttp_request_get_uri(req), ¶ms))
|
||||
@@ -343,23 +307,13 @@ void doris_http_server_version_cb(struct evhttp_request *req, void *arg)
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid");
|
||||
return;
|
||||
}
|
||||
|
||||
if(NULL == (bizname = evhttp_find_header(¶ms, "business")))
|
||||
if(NULL == (business = lookup_bizstruct_from_name(¶ms)))
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_clear_headers(¶ms);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, no business found");
|
||||
return;
|
||||
}
|
||||
if((iter = g_doris_server_info.name2business->find(string(bizname)))==g_doris_server_info.name2business->end())
|
||||
{
|
||||
FS_operate(g_doris_server_info.fsstat_handle, g_doris_server_info.fsstat_field[DRS_FSSTAT_CLIENT_INVALID_REQ], 0, FS_OP_ADD, 1);
|
||||
evhttp_clear_headers(¶ms);
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameters invalid, business invalid");
|
||||
evhttp_send_error(req, HTTP_BADREQUEST, "Parameter business invalid");
|
||||
return;
|
||||
}
|
||||
evhttp_clear_headers(¶ms);
|
||||
business = iter->second;
|
||||
|
||||
pthread_rwlock_rdlock(&business->rwlock);
|
||||
sprintf(verbuf, "%lu", business->cfgver_head->latest_version);
|
||||
@@ -464,13 +418,6 @@ SSL_CTX *doris_connections_create_ssl_ctx(void)
|
||||
return ssl_ctx;
|
||||
}
|
||||
|
||||
struct bufferevent *doris_https_bufferevent_cb(struct event_base *evabse, void *arg)
|
||||
{
|
||||
SSL_CTX *ssl_instance = (SSL_CTX *)arg;
|
||||
|
||||
return bufferevent_openssl_socket_new(evabse, -1, SSL_new(ssl_instance), BUFFEREVENT_SSL_ACCEPTING, BEV_OPT_CLOSE_ON_FREE);
|
||||
}
|
||||
|
||||
void* thread_doris_http_server(void *arg)
|
||||
{
|
||||
struct event_base *worker_evbase;
|
||||
@@ -492,9 +439,9 @@ void* thread_doris_http_server(void *arg)
|
||||
evhttp_set_gencb(worker_http, doris_http_server_generic_cb, NULL);
|
||||
evhttp_set_allowed_methods(worker_http, EVHTTP_REQ_GET|EVHTTP_REQ_HEAD);
|
||||
|
||||
if(evhttp_accept_socket(worker_http, g_doris_server_info.listener))
|
||||
if(evhttp_accept_socket(worker_http, g_doris_server_info.listener_csum))
|
||||
{
|
||||
printf("evhttp_accept_socket %d error!\n", g_doris_server_info.listener);
|
||||
printf("evhttp_accept_socket %d error!\n", g_doris_server_info.listener_csum);
|
||||
assert(0); return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
|
||||
int doris_create_listen_socket(int bind_port);
|
||||
SSL_CTX *doris_connections_create_ssl_ctx(void);
|
||||
void* thread_doris_http_server(void *arg);
|
||||
|
||||
|
||||
@@ -7,17 +7,24 @@
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <event2/thread.h>
|
||||
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
|
||||
#include "doris_client.h"
|
||||
#include "doris_consumer_client.h"
|
||||
#include "doris_producer_client.h"
|
||||
#include "doris_server_main.h"
|
||||
#include "doris_server_http.h"
|
||||
|
||||
struct doris_global_info g_doris_server_info;
|
||||
static unsigned long doris_vesion_20210804=20210804L;
|
||||
static unsigned long doris_version_20210825=20210825L;
|
||||
|
||||
int doris_mkdir_according_path(const char * path)
|
||||
{
|
||||
@@ -54,6 +61,79 @@ int doris_mkdir_according_path(const char * path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t get_ip_by_ifname(const char *ifname)
|
||||
{
|
||||
int sockfd;
|
||||
struct ifreq ifr;
|
||||
int32_t ip;
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (-1 == sockfd)
|
||||
return INADDR_NONE;
|
||||
|
||||
strcpy(ifr.ifr_name,ifname);
|
||||
if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0)
|
||||
{
|
||||
close(sockfd);
|
||||
return INADDR_NONE;
|
||||
}
|
||||
|
||||
ip = ((struct sockaddr_in*)&(ifr.ifr_addr))->sin_addr.s_addr;
|
||||
close(sockfd);
|
||||
return ip;
|
||||
}
|
||||
|
||||
static inline void set_sockopt_keepalive(int sd, int keepidle, int keepintvl, int keepcnt)
|
||||
{
|
||||
int keepalive = 1;
|
||||
setsockopt(sd, SOL_SOCKET, SO_KEEPALIVE, (void*)&keepalive, sizeof(keepalive));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPIDLE, (void*)&keepidle, sizeof(keepidle));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPINTVL, (void*)&keepintvl, sizeof(keepintvl));
|
||||
setsockopt(sd, SOL_TCP, TCP_KEEPCNT, (void*)&keepcnt, sizeof(keepcnt));
|
||||
}
|
||||
|
||||
static inline void set_listen_sockopt(int sd)
|
||||
{
|
||||
if(g_doris_server_info.sock_recv_bufsize > 0)
|
||||
{
|
||||
setsockopt(sd, SOL_SOCKET, SO_RCVBUF, &g_doris_server_info.sock_recv_bufsize, sizeof(u_int32_t));
|
||||
}
|
||||
}
|
||||
|
||||
int doris_create_listen_socket(int bind_port)
|
||||
{
|
||||
evutil_socket_t listener;
|
||||
struct sockaddr_in sin;
|
||||
|
||||
listener = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if(listener < 0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "create socket error!\n");
|
||||
return -1;
|
||||
}
|
||||
set_sockopt_keepalive(listener, 300, 10, 2);
|
||||
set_listen_sockopt(listener);
|
||||
evutil_make_listen_socket_reuseable(listener);
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr=htonl(INADDR_ANY);
|
||||
sin.sin_port = htons(bind_port);
|
||||
|
||||
if (bind(listener, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
printf("bind socket to port: %d error: %s!\n", bind_port, strerror(errno));
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "bind socket to port: %d error: %s!\n", bind_port, strerror(errno));
|
||||
assert(0);return -2;
|
||||
}
|
||||
if (listen(listener, 1024)<0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "listen socket 1024 error!\n");
|
||||
return -3;
|
||||
}
|
||||
evutil_make_socket_nonblocking(listener);
|
||||
return listener;
|
||||
}
|
||||
|
||||
static int doris_chech_name_valid(const char *name)
|
||||
{
|
||||
size_t i, namelen=strlen(name);
|
||||
@@ -100,8 +180,11 @@ int32_t doris_read_profile_configs(const char *config_file)
|
||||
assert(0);return -1;
|
||||
}
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "cache_file_frag_size", &g_doris_server_info.cache_frag_size, 67108864);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "doris_server_role_on", &g_doris_server_info.server_role_sw, 1);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "http_post_max_frag_size", &g_doris_server_info.max_http_body_size, 67108864);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "index_file_format_maat", &g_doris_server_info.idx_file_maat, 0);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "http_post_max_concurrence", &g_doris_server_info.max_concurrent_reqs, 100000);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "http_post_cluster_on", &g_doris_server_info.cluster_sync_mode, 0);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "http_post_op_expires", &g_doris_server_info.post_vernode_ttl, 1200);
|
||||
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "scan_index_file_interval", &g_doris_server_info.scan_idx_interval, 10);
|
||||
MESA_load_profile_uint_def(config_file, "DORIS_SERVER", "https_connection_on", &g_doris_server_info.ssl_conn_on, 0);
|
||||
@@ -122,18 +205,19 @@ int32_t doris_read_profile_configs(const char *config_file)
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "fsstat_log_dst_port", &g_doris_server_info.fsstat_dst_port, 8125);
|
||||
|
||||
//LIBEVENT
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "server_listen_port", &g_doris_server_info.server_port, 9898);
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "manage_listen_port", &g_doris_server_info.manager_port, 2233);
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "consumer_listen_port", &g_doris_server_info.consumer_port, 0);
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "manager_listen_port", &g_doris_server_info.manager_port, 2233);
|
||||
MESA_load_profile_int_def(config_file, "DORIS_SERVER", "socket_recv_bufsize", &g_doris_server_info.sock_recv_bufsize, 524288);
|
||||
pthread_mutex_init(&g_doris_server_info.mutex_lock, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int doris_server_register_field_stat(struct doris_global_info *param)
|
||||
{
|
||||
const char *field_names[DRS_FSSTAT_FIELD_NUM]={"RecvErrVer", "FileStarts", "FileComplete", "ClientInvReq",
|
||||
"ClientMetaReq", "SendNoNewMeta", "ClientFileReq", "SendBytes", "SendFile404"};
|
||||
"ClientMetaReq", "SendNoNewMeta", "ClientFileReq", "SendFiles", "SendBytes", "SendFile404", "VerExpire"};
|
||||
const char *status_names[DRS_FSSTAT_STATUS_NUM]={"MemoryUsed"};
|
||||
const char *column_names[DRS_FSSTAT_CLUMN_NUM]={"RecvFullVer", "RecvIncVer", "RecvFiles", "SendResMeta", "SendFiles",
|
||||
const char *column_names[DRS_FSSTAT_CLUMN_NUM]={"RecvFullVer", "RecvIncVer", "RecvFiles", "PostOnWay", "SendResMeta",
|
||||
"CurFullVer", "CurIncVer", "TotalCfgNum"};
|
||||
int value;
|
||||
|
||||
@@ -188,7 +272,8 @@ static int32_t doris_init_config_for_business(struct doris_global_info *info, st
|
||||
{
|
||||
char tmpbuffer[4096], tmp_dir[256], tmp_dir2[256], *bizname, *save=NULL;
|
||||
struct doris_business *business;
|
||||
map<string, struct doris_parameter *>::iterator iter;
|
||||
map<string, struct doris_csum_param *>::iterator iter_csm;
|
||||
map<string, struct doris_prod_param *>::iterator iter_prd;
|
||||
|
||||
if(0>=MESA_load_profile_string_nodef(config_file, "DORIS_SERVER", "business_system_list", tmpbuffer, sizeof(tmpbuffer)))
|
||||
{
|
||||
@@ -214,7 +299,7 @@ static int32_t doris_init_config_for_business(struct doris_global_info *info, st
|
||||
}
|
||||
info->name2business->insert(make_pair(string(business->bizname), business));
|
||||
|
||||
MESA_load_profile_uint_def(config_file, business->bizname, "grafana_monitor_status_id", &business->mm_status_codeid, 3);
|
||||
MESA_load_profile_uint_def(config_file, business->bizname, "grafana_monitor_status_id", &business->mmval_status_codeid, 3);
|
||||
MESA_load_profile_uint_def(config_file, business->bizname, "mem_cache_max_versions", &business->cache_max_versions, 0);
|
||||
if(0>MESA_load_profile_string_nodef(config_file, business->bizname, "store_config_path", business->store_path_root, sizeof(business->store_path_root)))
|
||||
{
|
||||
@@ -230,28 +315,8 @@ static int32_t doris_init_config_for_business(struct doris_global_info *info, st
|
||||
}
|
||||
|
||||
MESA_load_profile_uint_def(config_file, business->bizname, "receive_config_way", &business->recv_way, RECV_WAY_DRS_CLIENT);
|
||||
if(business->recv_way == RECV_WAY_DRS_CLIENT)
|
||||
{
|
||||
if(0>=MESA_load_profile_string_nodef(config_file, business->bizname, "doris_client_confile", tmp_dir, sizeof(tmp_dir)))
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "%s: [DORIS_SERVER]doris_client_confile not found!", config_file);
|
||||
assert(0);return -1;
|
||||
}
|
||||
if((iter=info->confile2param->find(string(tmp_dir))) != info->confile2param->end())
|
||||
{
|
||||
business->param = iter->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
business->param = doris_parameter_new(tmp_dir, manage_evbase, info->log_runtime);
|
||||
if(business->param == NULL)
|
||||
{
|
||||
assert(0);return -2;
|
||||
}
|
||||
info->confile2param->insert(make_pair(string(tmp_dir), business->param));
|
||||
}
|
||||
}
|
||||
else
|
||||
assert(business->recv_way==RECV_WAY_IDX_FILE || business->recv_way==RECV_WAY_DRS_CLIENT || business->recv_way==RECV_WAY_HTTP_POST);
|
||||
if(business->recv_way == RECV_WAY_IDX_FILE)
|
||||
{
|
||||
if(0>MESA_load_profile_string_nodef(config_file, business->bizname, "receive_config_path_full", business->recv_path_full, sizeof(business->recv_path_full)))
|
||||
{
|
||||
@@ -264,12 +329,52 @@ static int32_t doris_init_config_for_business(struct doris_global_info *info, st
|
||||
assert(0);return -1;
|
||||
}
|
||||
}
|
||||
else //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>Ҳ<EFBFBD><D2B2>Ҫ
|
||||
{
|
||||
if(business->recv_way==RECV_WAY_DRS_CLIENT || g_doris_server_info.cluster_sync_mode)
|
||||
{
|
||||
if(0>=MESA_load_profile_string_nodef(config_file, business->bizname, "doris_client_confile", tmp_dir, sizeof(tmp_dir)))
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "%s: [DORIS_SERVER]doris_client_confile not found!", config_file);
|
||||
assert(0);return -1;
|
||||
}
|
||||
if((iter_csm=info->confile2csmparam->find(string(tmp_dir))) != info->confile2csmparam->end())
|
||||
{
|
||||
business->param_csum = iter_csm->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
business->param_csum = doris_csum_parameter_new(tmp_dir, manage_evbase, info->log_runtime);
|
||||
if(business->param_csum == NULL)
|
||||
{
|
||||
assert(0);return -2;
|
||||
}
|
||||
info->confile2csmparam->insert(make_pair(string(tmp_dir), business->param_csum));
|
||||
}
|
||||
}
|
||||
if(business->recv_way == RECV_WAY_HTTP_POST) //<2F><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>
|
||||
{
|
||||
MESA_load_profile_uint_def(config_file, business->bizname, "producer_concurrence_allowed", &business->concurrency_allowed, 0);
|
||||
if(MESA_load_profile_int_nodef(config_file, business->bizname, "producer_listen_port", &business->producer_port)<0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "%s: [%s]producer_listen_port not found!", config_file, business->bizname);
|
||||
assert(0);return -1;
|
||||
}
|
||||
if(g_doris_server_info.cluster_sync_mode &&
|
||||
NULL==(business->param_prod = doris_prod_parameter_new(tmp_dir, manage_evbase, info->log_runtime)))
|
||||
{
|
||||
assert(0);return -2;
|
||||
}
|
||||
g_doris_server_info.business_post_num++;
|
||||
business->token2node = new map<string, struct version_list_node *>;
|
||||
}
|
||||
}
|
||||
business->fs_lineid = FS_register(info->fsstat_handle, FS_STYLE_LINE, FS_CALC_CURRENT, business->bizname);;
|
||||
|
||||
snprintf(tmp_dir, 512, "latest_cfg_version_%s", business->bizname);
|
||||
business->mm_latest_ver = MESA_Monitor_register(info->monitor, tmp_dir, MONITOR_METRICS_GAUGE, "Latest doris config version.");
|
||||
business->mmid_latest_ver = MESA_Monitor_register(info->monitor, tmp_dir, MONITOR_METRICS_GAUGE, "Latest doris config version.");
|
||||
snprintf(tmp_dir, 512, "total_config_num_%s", business->bizname);
|
||||
business->mm_total_cfgnum = MESA_Monitor_register(info->monitor, tmp_dir, MONITOR_METRICS_GAUGE, "Total config num from latest full version till now.");
|
||||
business->mmid_total_cfgnum = MESA_Monitor_register(info->monitor, tmp_dir, MONITOR_METRICS_GAUGE, "Total config num from latest full version till now.");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -302,14 +407,16 @@ int main(int argc, char **argv)
|
||||
struct timeval tv;
|
||||
struct event timer_statistic_fsstat;
|
||||
struct evhttp *manager_http;
|
||||
char netname[32];
|
||||
|
||||
memset(&g_doris_server_info, 0, sizeof(struct doris_global_info));
|
||||
if(doris_read_profile_configs(NIRVANA_CONFIG_FILE) || doris_server_register_field_stat(&g_doris_server_info))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
evthread_use_pthreads();
|
||||
g_doris_server_info.name2business = new map<string, struct doris_business*>;
|
||||
g_doris_server_info.confile2param = new map<string, struct doris_parameter *>;
|
||||
g_doris_server_info.confile2csmparam = new map<string, struct doris_csum_param *>;
|
||||
manage_evbase = event_base_new();
|
||||
|
||||
/*Doris manager server*/
|
||||
@@ -327,7 +434,7 @@ int main(int argc, char **argv)
|
||||
evhttp_set_cb(manager_http, "/doris/statistic/status", manager_statistic_status_requests_cb, NULL);
|
||||
evhttp_set_cb(manager_http, "/doris/statistic/threads", manager_statistic_threads_requests_cb, NULL);
|
||||
evhttp_set_gencb(manager_http, manager_generic_requests_cb, NULL);
|
||||
g_doris_server_info.monitor = MESA_Monitor_instance_evhttp_new(manager_http, doris_vesion_20210804);
|
||||
g_doris_server_info.monitor = MESA_Monitor_instance_evhttp_new(manager_http, doris_version_20210825);
|
||||
if(evhttp_accept_socket(manager_http, g_doris_server_info.manager))
|
||||
{
|
||||
printf("evhttp_accept_socket %d error!\n", g_doris_server_info.manager);
|
||||
@@ -340,6 +447,24 @@ int main(int argc, char **argv)
|
||||
{
|
||||
return -4;
|
||||
}
|
||||
if(g_doris_server_info.business_post_num > 0)
|
||||
{
|
||||
if((MESA_load_profile_string_nodef(NIRVANA_CONFIG_FILE, "DORIS_SERVER", "local_net_name", netname, sizeof(netname))<0) ||
|
||||
(g_doris_server_info.local_ip = get_ip_by_ifname(netname))<0)
|
||||
{
|
||||
printf("%s: [DORIS_SERVER]local_net_name not valid", NIRVANA_CONFIG_FILE);
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "%s: [DORIS_SERVER]local_net_name not valid", NIRVANA_CONFIG_FILE);
|
||||
assert(0);return -11;
|
||||
}
|
||||
g_doris_server_info.mmid_post_server = MESA_Monitor_register(g_doris_server_info.monitor,
|
||||
"http_post_server_status", MONITOR_METRICS_GAUGE, "Running status of doris http post server.");
|
||||
MESA_Monitor_operation(g_doris_server_info.monitor, g_doris_server_info.mmid_post_server, MONITOR_VALUE_SET, PROMETHUES_POST_SERVER_DOWN);
|
||||
}
|
||||
|
||||
if(g_doris_server_info.ssl_conn_on && NULL==(g_doris_server_info.ssl_instance=doris_connections_create_ssl_ctx()))
|
||||
{
|
||||
assert(0);return -8;
|
||||
}
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
@@ -353,6 +478,14 @@ int main(int argc, char **argv)
|
||||
assert(0);return -5;
|
||||
}
|
||||
}
|
||||
else if(g_doris_server_info.business[i].recv_way == RECV_WAY_HTTP_POST)
|
||||
{
|
||||
if(pthread_create(&thread_desc, &attr, thread_http_post_recv_cfg, &g_doris_server_info.business[i]))
|
||||
{
|
||||
MESA_RUNTIME_LOGV3(g_doris_server_info.log_runtime, RLOG_LV_FATAL, "pthread_create(): %s", strerror(errno));
|
||||
assert(0);return -6;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(pthread_create(&thread_desc, &attr, thread_index_file_recv_cfg, &g_doris_server_info.business[i]))
|
||||
@@ -364,17 +497,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/*Doris http server*/
|
||||
if(g_doris_server_info.server_role_sw)
|
||||
if(g_doris_server_info.consumer_port)
|
||||
{
|
||||
g_doris_server_info.listener = doris_create_listen_socket(g_doris_server_info.server_port);
|
||||
if(g_doris_server_info.listener < 0)
|
||||
g_doris_server_info.listener_csum = doris_create_listen_socket(g_doris_server_info.consumer_port);
|
||||
if(g_doris_server_info.listener_csum < 0)
|
||||
{
|
||||
return -7;
|
||||
}
|
||||
if(g_doris_server_info.ssl_conn_on && NULL==(g_doris_server_info.ssl_instance=doris_connections_create_ssl_ctx()))
|
||||
{
|
||||
assert(0);return -8;
|
||||
}
|
||||
for(u_int32_t i=0; i<g_doris_server_info.iothreads; i++)
|
||||
{
|
||||
if(pthread_create(&thread_desc, &attr, thread_doris_http_server, NULL))
|
||||
@@ -396,4 +525,3 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "MESA_Monitor.h"
|
||||
|
||||
#include "doris_client.h"
|
||||
#include "doris_consumer_client.h"
|
||||
#include "doris_server_receive.h"
|
||||
|
||||
#include <map>
|
||||
@@ -39,35 +39,65 @@ using namespace std;
|
||||
#define RECV_WAY_IDX_FILE 2
|
||||
#define RECV_WAY_HTTP_POST 3
|
||||
|
||||
#define PROMETHUES_POST_SERVER_OK 0
|
||||
#define PROMETHUES_POST_SERVER_UPING 1
|
||||
#define PROMETHUES_POST_SERVER_DOWN 2
|
||||
|
||||
struct doris_business
|
||||
{
|
||||
/*first for configuration*/
|
||||
char bizname[32];
|
||||
u_int32_t recv_way;
|
||||
u_int32_t cache_max_versions;
|
||||
u_int32_t concurrency_allowed;
|
||||
char recv_path_full[256];
|
||||
char recv_path_inc[256];
|
||||
char store_path_root[256];
|
||||
struct version_list_handle *cfgver_head;
|
||||
struct doris_parameter *param;
|
||||
|
||||
struct doris_csum_param *param_csum;
|
||||
struct doris_prod_param *param_prod;
|
||||
u_int32_t ready_to_sync;
|
||||
u_int32_t posts_on_the_way;
|
||||
int32_t producer_port; //<2F><>֤ÿ<D6A4><C3BF>biz<69><7A><EFBFBD><EFBFBD>server<65>߳<EFBFBD>ֻ<EFBFBD><D6BB>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⽻<EFBFBD><E2BDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>instance
|
||||
evutil_socket_t listener_prod;
|
||||
int64_t total_cfgnum;
|
||||
int32_t mm_latest_ver;
|
||||
int32_t mm_total_cfgnum;
|
||||
u_int32_t mm_status_codeid; //MM<4D>ڲ<EFBFBD><DAB2>쳣״̬id
|
||||
int32_t mmid_latest_ver;
|
||||
int32_t mmid_total_cfgnum;
|
||||
u_int32_t mmval_status_codeid; //MM<4D>ڲ<EFBFBD><DAB2>쳣״̬id<EFBFBD><EFBFBD>Grafana<EFBFBD><EFBFBD>value
|
||||
u_int32_t fs_lineid;
|
||||
pthread_rwlock_t rwlock;
|
||||
|
||||
/*next for updating*/
|
||||
struct event_base *worker_evbase;
|
||||
struct doris_prod_instance *instance;
|
||||
map<string, struct version_list_node *> *token2node;
|
||||
int64_t version;
|
||||
int32_t source_from;
|
||||
int32_t type;
|
||||
int64_t version_cfgnum;
|
||||
char inc_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char tmp_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char full_index_path[256]; //fullĿ¼<C4BF>µ<EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char cfg_file_path[256];
|
||||
FILE *fp_cfg_file; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6>ļ<EFBFBD><C4BC><EFBFBD>DRS Client<6E>ӿ<EFBFBD>
|
||||
FILE *fp_idx_file; //<2F><><EFBFBD><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6>ļ<EFBFBD><C4BC><EFBFBD>DRS Client<6E>ӿ<EFBFBD>
|
||||
struct version_list_node *cur_vernode;
|
||||
};
|
||||
|
||||
struct doris_global_info
|
||||
{
|
||||
u_int32_t iothreads;
|
||||
int32_t server_port;
|
||||
int32_t consumer_port;
|
||||
int32_t manager_port;
|
||||
int32_t sock_recv_bufsize;
|
||||
u_int32_t ssl_conn_on;
|
||||
u_int32_t scan_idx_interval;
|
||||
u_int32_t cache_frag_size;
|
||||
u_int32_t server_role_sw;
|
||||
u_int32_t max_http_body_size;
|
||||
u_int32_t idx_file_maat;
|
||||
u_int32_t max_concurrent_reqs;
|
||||
u_int32_t cluster_sync_mode;
|
||||
u_int32_t post_vernode_ttl;
|
||||
|
||||
char ssl_CA_path[256];
|
||||
char ssl_cert_file[256];
|
||||
@@ -76,16 +106,21 @@ struct doris_global_info
|
||||
pthread_mutex_t *lock_cs;
|
||||
SSL_CTX *ssl_instance;
|
||||
|
||||
evutil_socket_t listener;
|
||||
evutil_socket_t listener_csum;
|
||||
evutil_socket_t manager;
|
||||
u_int32_t token_seq;
|
||||
int32_t local_ip;
|
||||
|
||||
struct doris_business business[MAX_BUSINESS_NUM];
|
||||
u_int32_t business_num;
|
||||
u_int32_t idx_file_maat;
|
||||
u_int32_t business_post_num; //postģʽ<C4A3>м<EFBFBD><D0BC><EFBFBD>
|
||||
int32_t business_post_ups; //<2F><><EFBFBD><EFBFBD><EFBFBD>˼<EFBFBD><CBBC><EFBFBD>
|
||||
int32_t mmid_post_server; //value=PROMETHUES_POST_*
|
||||
map<string, struct doris_business*> *name2business;
|
||||
map<string, struct doris_parameter *> *confile2param;
|
||||
map<string, struct doris_csum_param *> *confile2csmparam;
|
||||
|
||||
struct MESA_MonitorHandler *monitor;
|
||||
pthread_mutex_t mutex_lock;
|
||||
|
||||
/*logs*/
|
||||
u_int32_t log_level;
|
||||
@@ -106,6 +141,7 @@ struct doris_global_info
|
||||
};
|
||||
|
||||
int doris_mkdir_according_path(const char * path);
|
||||
int doris_create_listen_socket(int bind_port);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,23 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/queue.h>
|
||||
#include <event.h>
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#include <cjson/cJSON.h>
|
||||
#include <evhttp.h>
|
||||
|
||||
#include "doris_producer_client.h"
|
||||
|
||||
#if(__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__ >= 410)
|
||||
#define atomic_inc(x) __sync_add_and_fetch((x),1)
|
||||
#define atomic_dec(x) __sync_sub_and_fetch((x),1)
|
||||
#define atomic_add(x,y) __sync_add_and_fetch((x),(y))
|
||||
#define atomic_sub(x,y) __sync_sub_and_fetch((x),(y))
|
||||
#define atomic_read(x) __sync_add_and_fetch((x),0)
|
||||
#define atomic_set(x,y) __sync_lock_test_and_set((x),y)
|
||||
#else
|
||||
#error "GCC version should be 4.1.2 later"
|
||||
#endif
|
||||
|
||||
#include <map>
|
||||
using namespace std;
|
||||
@@ -20,8 +35,10 @@ enum DORIS_SERVER_FS_FILED
|
||||
DRS_FSSTAT_CLIENT_META_REQ,
|
||||
DRS_FSSTAT_SEND_META_NONEW,
|
||||
DRS_FSSTAT_CLIENT_FILE_REQ,
|
||||
DRS_FSSTAT_SEND_FILES,
|
||||
DRS_FSSTAT_SEND_FILE_BYTES,
|
||||
DRS_FSSTAT_SEND_FILE_RES_404,
|
||||
DRS_FSSTAT_VERSION_EXPIRES,
|
||||
|
||||
DRS_FSSTAT_FIELD_NUM,
|
||||
};
|
||||
@@ -31,8 +48,8 @@ enum DORIS_SERVER_FS_COLUMN
|
||||
DRS_FSCLM_RECV_FULL_VER=0,
|
||||
DRS_FSCLM_RECV_INC_VER,
|
||||
DRS_FSCLM_RECV_FILES,
|
||||
DRS_FSCLM_POST_ON_THE_WAY,
|
||||
DRS_FSCLM_SEND_META_RES,
|
||||
DRS_FSCLM_SEND_FILE_RES,
|
||||
DRS_FSCLM_CUR_FULL_VERSION,
|
||||
DRS_FSCLM_CUR_INC_VERSION,
|
||||
DRS_FSCLM_CONFIG_TOTAL_NUM,
|
||||
@@ -58,6 +75,14 @@ struct cont_frag_node
|
||||
TAILQ_ENTRY(cont_frag_node) frag_node;
|
||||
};
|
||||
|
||||
struct internal_tablemeta
|
||||
{
|
||||
char tablename[64];
|
||||
char filename[64];
|
||||
size_t offset;
|
||||
int32_t islast;
|
||||
};
|
||||
|
||||
struct table_list_node
|
||||
{
|
||||
char tablename[64];
|
||||
@@ -65,20 +90,49 @@ struct table_list_node
|
||||
size_t filesize;
|
||||
size_t cur_totallen;
|
||||
|
||||
/*this part for http post server*/
|
||||
bool onceupload;
|
||||
int32_t finished;
|
||||
MD5_CTX md5ctx;
|
||||
char tmppath[256];
|
||||
char filename[128];
|
||||
char fragmd5[36];
|
||||
u_int32_t cfgnum;
|
||||
char *fragcontent;
|
||||
size_t fragsize;
|
||||
cJSON *table_meta;
|
||||
|
||||
FILE *fp_cfg_file;
|
||||
struct cont_frag_node *cur_frag;
|
||||
TAILQ_HEAD(__table_cont_node, cont_frag_node) frag_head;
|
||||
TAILQ_ENTRY(table_list_node) table_node;
|
||||
};
|
||||
|
||||
struct doris_business;
|
||||
struct version_list_node
|
||||
{
|
||||
int64_t version;
|
||||
char *metacont;
|
||||
int32_t metalen;
|
||||
int16_t cfg_type; //1-full, 2-inc
|
||||
int16_t cont_in_disk;
|
||||
int8_t cont_in_disk;
|
||||
int8_t version_finished;
|
||||
cJSON *metajson, *arrayjson;
|
||||
cJSON *table_meta;
|
||||
|
||||
/*this part for http post server*/
|
||||
FILE *fp_idx_file;
|
||||
char token[64];
|
||||
char tmp_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱÿ<CAB1><C3BF><EFBFBD>汾<EFBFBD><E6B1BE>һ<EFBFBD><D2BB>
|
||||
int16_t retry_times;
|
||||
int16_t syncing;
|
||||
int32_t total_cfgs;
|
||||
struct doris_business *business;
|
||||
struct evhttp_request *req;
|
||||
struct doris_upload_ctx *synctx;
|
||||
struct table_list_node *cur_table;
|
||||
struct event timer_expire;
|
||||
|
||||
TAILQ_HEAD(__table_list_node, table_list_node) table_head;
|
||||
TAILQ_ENTRY(version_list_node) version_node;
|
||||
};
|
||||
@@ -95,35 +149,21 @@ struct version_list_handle
|
||||
|
||||
struct version_list_handle *config_version_handle_new(void);
|
||||
|
||||
struct doris_business;
|
||||
struct confile_save
|
||||
{
|
||||
struct event_base *evbase;
|
||||
struct doris_business *business;
|
||||
int64_t version;
|
||||
int32_t source_from;
|
||||
int32_t type;
|
||||
int64_t version_cfgnum;
|
||||
char inc_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char tmp_index_path[256]; //incĿ¼<C4BF>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char full_index_path[256]; //fullĿ¼<C4BF>µ<EFBFBD>ȫ<EFBFBD><C8AB>
|
||||
char cfg_file_path[256];
|
||||
FILE *fp_cfg_file;
|
||||
FILE *fp_idx_file;
|
||||
|
||||
struct version_list_node *cur_vernode;
|
||||
struct table_list_node *cur_table;
|
||||
struct cont_frag_node *cur_frag;
|
||||
};
|
||||
|
||||
struct common_timer_event
|
||||
{
|
||||
struct event timer_event;
|
||||
void *data;
|
||||
};
|
||||
|
||||
struct doris_business;
|
||||
struct bufferevent *doris_https_bufferevent_cb(struct event_base *evabse, void *arg);
|
||||
struct doris_business *lookup_bizstruct_from_name(const struct evkeyvalq *params);
|
||||
void business_set_sync_peer_abnormal(struct doris_business *business);
|
||||
void business_resume_sync_peer_normal(struct doris_business *business);
|
||||
|
||||
void* thread_doris_client_recv_cfg(void *arg);
|
||||
void* thread_index_file_recv_cfg(void *arg);
|
||||
void* thread_http_post_recv_cfg(void *arg);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#define MESA_RUNTIME_LOGV4(handle, lv, fmt, args...) \
|
||||
MESA_handle_runtime_log((handle), (lv), "DorisServer", "%s:%d, " fmt, __FILENAME__, __LINE__, ##args)
|
||||
|
||||
static int scandir_md5_final_string(MD5_CTX *c, char *result, unsigned int size)
|
||||
int scandir_md5_final_string(MD5_CTX *c, char *result, unsigned int size)
|
||||
{
|
||||
unsigned char md5[17]={0};
|
||||
int i;
|
||||
@@ -202,12 +202,12 @@ int cm_read_cfg_index_file(const char* path, struct cfg_table_info* idx/*OUT*/,
|
||||
memset(line, 0, sizeof(line));
|
||||
fgets(line, sizeof(line), fp);
|
||||
ret=sscanf(line,"%[^ \t]%*[ \t]%d%*[ \t]%s%*[ \t]%s", idx[i].table_name, &(idx[i].cfg_num), idx[i].cfg_path, idx[i].user_region);
|
||||
if((ret!=3 && ret!=4) || idx[i].cfg_num==0)//jump over empty line
|
||||
if((ret!=3 && ret!=4))//jump over empty line
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ret=stat(idx[i].cfg_path, &file_info);
|
||||
if(ret!=0)
|
||||
if(ret!=0 || file_info.st_size==0) //<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>·<EFBFBD>
|
||||
{
|
||||
MESA_RUNTIME_LOGV4(logger,RLOG_LV_FATAL, "%s of %s not exisit", idx[i].cfg_path, path);
|
||||
fclose(fp);
|
||||
@@ -315,12 +315,14 @@ enum DORIS_UPDATE_TYPE doris_index_file_traverse(struct doris_idxfile_scanner *s
|
||||
{
|
||||
MESA_RUNTIME_LOGV4(logger, RLOG_LV_INFO, "load %s", idx_path_array[i].path);
|
||||
table_num=cm_read_cfg_index_file(idx_path_array[i].path, table_array, CM_MAX_TABLE_NUM, logger);
|
||||
if(table_num<0)
|
||||
if(table_num<=0)
|
||||
{
|
||||
MESA_RUNTIME_LOGV4(logger,RLOG_LV_FATAL, "load %s faild, abandon udpate.", idx_path_array[i].path);
|
||||
MESA_RUNTIME_LOGV4(logger,RLOG_LV_FATAL, "\033[1;31;40mAlert! Load %s failed, skip this wrong version!!!!\033[0m\n", idx_path_array[i].path);
|
||||
update_type = CFG_UPDATE_TYPE_ERR;
|
||||
scanner->cur_version = idx_path_array[i].version; //<2F><><EFBFBD><EFBFBD><EFBFBD>İ汾<C4B0><E6B1BE><EFBFBD><EFBFBD>
|
||||
break;
|
||||
}
|
||||
scanner->cur_version = idx_path_array[i].version;
|
||||
|
||||
cJSON *meta = doris_index_version_start(idx_path_array[i].version, table_array, table_num, update_type, doris_cbs);
|
||||
for(j=0; j<table_num && update_rslt; j++)
|
||||
@@ -329,7 +331,6 @@ enum DORIS_UPDATE_TYPE doris_index_file_traverse(struct doris_idxfile_scanner *s
|
||||
}
|
||||
if(update_rslt)
|
||||
{
|
||||
scanner->cur_version = idx_path_array[i].version;
|
||||
doris_cbs->version_finish(NULL, doris_cbs->userdata);
|
||||
}
|
||||
else
|
||||
@@ -337,6 +338,7 @@ enum DORIS_UPDATE_TYPE doris_index_file_traverse(struct doris_idxfile_scanner *s
|
||||
update_type = CFG_UPDATE_TYPE_ERR;
|
||||
doris_cbs->version_error(NULL, doris_cbs->userdata);
|
||||
cJSON_Delete(meta);
|
||||
MESA_RUNTIME_LOGV4(logger,RLOG_LV_FATAL, "\033[1;31;40mAlert! Load %s failed, skip this wrong version!!!!\033[0m\n", idx_path_array[i].path);
|
||||
break;
|
||||
}
|
||||
cJSON_Delete(meta);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __DORIS_SERVER_SCANDIR_H__
|
||||
#define __DORIS_SERVER_SCANDIR_H__
|
||||
|
||||
#include "doris_client.h"
|
||||
#include "doris_consumer_client.h"
|
||||
|
||||
#define CM_MAX_TABLE_NUM 256
|
||||
#define MAX_CONFIG_FN_LEN 256
|
||||
@@ -45,6 +45,8 @@ struct doris_idxfile_scanner
|
||||
char oncebuf[ONCE_BUF_SIZE];
|
||||
};
|
||||
|
||||
int scandir_md5_final_string(MD5_CTX *c, char *result, unsigned int size);
|
||||
|
||||
struct doris_idxfile_scanner *doris_index_file_scanner(int64_t start_version);
|
||||
enum DORIS_UPDATE_TYPE doris_index_file_traverse(struct doris_idxfile_scanner *scanner, const char*idx_dir,
|
||||
struct doris_callbacks *doris_cbs, const char* dec_key, void* logger);
|
||||
|
||||
Reference in New Issue
Block a user