1.修改redis分布式锁,修改接口key设置
2.修改fs显示信息
This commit is contained in:
@@ -61,9 +61,6 @@ static struct fs_stats_t SGstats = {
|
||||
|
||||
rt_mutex entries_mtx = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
uint64_t startTime = 0;
|
||||
uint64_t endTime = 0;
|
||||
|
||||
void connectCallback(const struct redisAsyncContext *c, int status) {
|
||||
if (status != REDIS_OK) {
|
||||
mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Redis connect error : %s\n", c->errstr);
|
||||
@@ -685,7 +682,7 @@ finish:
|
||||
|
||||
static int fs_internal_operate(int id, int id2, int column_id, int column_id2, long long diffTime)
|
||||
{
|
||||
int ret = -1, value = -1;
|
||||
int ret = -1;
|
||||
screen_stat_handle_t handle = SGstats.handle;
|
||||
|
||||
FS_internal_operate(handle, id, column_id, FS_OP_ADD, 1);
|
||||
@@ -698,11 +695,7 @@ static int fs_internal_operate(int id, int id2, int column_id, int column_id2, l
|
||||
if (column_id2 < 0)
|
||||
goto finish;
|
||||
|
||||
value = FS_internal_operate(handle, id, column_id, FS_OP_GET, 0);
|
||||
if (value < 0)
|
||||
goto finish;
|
||||
|
||||
ret = FS_internal_operate(handle, id, column_id2, FS_OP_SET, diffTime/value);
|
||||
ret = FS_internal_operate(handle, id, column_id2, FS_OP_SET, diffTime);
|
||||
finish:
|
||||
return ret;
|
||||
}
|
||||
@@ -784,7 +777,6 @@ void rd_get_callback(redisAsyncContext *c, void *r, void *privdata)
|
||||
break;
|
||||
|
||||
case REDIS_REPLY_NIL:
|
||||
/* Certificate information modification and Strategy to judge**/
|
||||
mesa_runtime_log(RLOG_LV_INFO, MODULE_NAME, "Generating certificate information");
|
||||
|
||||
xret = rd_encode_sendbuf(request, c, sendbuf);
|
||||
@@ -797,7 +789,6 @@ void rd_get_callback(redisAsyncContext *c, void *r, void *privdata)
|
||||
|
||||
evhttp_socket_send(request->evh_req, sendbuf);
|
||||
finish:
|
||||
//kfree(request);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -943,14 +934,6 @@ pthread_work_proc(struct evhttp_request *evh_req, void *arg)
|
||||
|
||||
switch (evhttp_request_get_command(evh_req)) {
|
||||
case EVHTTP_REQ_GET: cmdtype = "GET"; break;
|
||||
case EVHTTP_REQ_POST: cmdtype = "POST"; break;
|
||||
case EVHTTP_REQ_HEAD: cmdtype = "HEAD"; break;
|
||||
case EVHTTP_REQ_PUT: cmdtype = "PUT"; break;
|
||||
case EVHTTP_REQ_DELETE: cmdtype = "DELETE"; break;
|
||||
case EVHTTP_REQ_OPTIONS: cmdtype = "OPTIONS"; break;
|
||||
case EVHTTP_REQ_TRACE: cmdtype = "TRACE"; break;
|
||||
case EVHTTP_REQ_CONNECT: cmdtype = "CONNECT"; break;
|
||||
case EVHTTP_REQ_PATCH: cmdtype = "PATCH"; break;
|
||||
default: cmdtype = "unknown"; break;
|
||||
}
|
||||
fs_internal_operate(thread_info->column_ids, -1, SGstats.line_ids[0], -1, 0);
|
||||
@@ -962,7 +945,7 @@ pthread_work_proc(struct evhttp_request *evh_req, void *arg)
|
||||
|
||||
if (request->host[0] != '\0' && request->evh_req != NULL){
|
||||
#ifdef RD_MUTEX_LOCK
|
||||
rd_mutex_lock("key", 30, &request->mtx, thread_info->sync);
|
||||
rd_mutex_lock(request->host, 30, &request->mtx, thread_info->sync);
|
||||
#endif
|
||||
xret = redisAsyncCommand(thread_info->cl_ctx, rd_get_callback, request, "GET %s", request->host);
|
||||
if (xret < 0)
|
||||
@@ -973,7 +956,6 @@ pthread_work_proc(struct evhttp_request *evh_req, void *arg)
|
||||
evhttp_uri_free(decoded);
|
||||
goto error;
|
||||
}
|
||||
|
||||
evhttp_uri_free(decoded);
|
||||
goto finish;
|
||||
|
||||
@@ -994,7 +976,6 @@ cert_trapper_task_int(struct event_base *base, libevent_thread *me)
|
||||
mesa_runtime_log(RLOG_LV_FATAL, MODULE_NAME, "Initialize the redis connection is failure\n");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
xret = redis_sync_int(&me->sync);
|
||||
|
||||
/* Initialize the X509 CA*/
|
||||
@@ -1207,18 +1188,23 @@ fs_screen_init()
|
||||
value=3;
|
||||
FS_internal_set_para(SGstats.handle, STAT_CYCLE, &value, sizeof(value));
|
||||
|
||||
snprintf(buff,sizeof(buff),"%s", "req");
|
||||
snprintf(buff,sizeof(buff),"%s", "http-get");
|
||||
SGstats.line_ids[0] = FS_internal_register(SGstats.handle, FS_STYLE_COLUMN, FS_CALC_CURRENT, buff);
|
||||
|
||||
snprintf(buff,sizeof(buff),"%s", "store");
|
||||
snprintf(buff,sizeof(buff),"%s", "local-storage");
|
||||
SGstats.line_ids[1] = FS_internal_register(SGstats.handle, FS_STYLE_COLUMN, FS_CALC_CURRENT, buff);
|
||||
|
||||
snprintf(buff,sizeof(buff),"%s", "sign");
|
||||
snprintf(buff,sizeof(buff),"%s", "generate-cert");
|
||||
SGstats.line_ids[2] = FS_internal_register(SGstats.handle, FS_STYLE_COLUMN, FS_CALC_CURRENT, buff);
|
||||
|
||||
snprintf(buff,sizeof(buff),"%s", "ssl(ms)");
|
||||
snprintf(buff,sizeof(buff),"%s", "take-time");
|
||||
SGstats.line_ids[3] = FS_internal_register(SGstats.handle, FS_STYLE_COLUMN, FS_CALC_CURRENT, buff);
|
||||
|
||||
snprintf(buff,sizeof(buff),"average-time");
|
||||
FS_internal_register_ratio(SGstats.handle, SGstats.line_ids[3],
|
||||
SGstats.line_ids[2], 1,
|
||||
FS_STYLE_COLUMN, FS_CALC_CURRENT,
|
||||
buff);
|
||||
FS_internal_start(SGstats.handle);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -22,7 +22,6 @@ struct rd_RedLock{
|
||||
sds m_unlockScript;
|
||||
int m_retryCount;
|
||||
int m_retryDelay;
|
||||
char *m_continueLockScript;
|
||||
};
|
||||
|
||||
static struct rd_RedLock redlock = {
|
||||
@@ -30,7 +29,6 @@ static struct rd_RedLock redlock = {
|
||||
.m_unlockScript = NULL,
|
||||
.m_retryCount = 0,
|
||||
.m_retryDelay = 0,
|
||||
.m_continueLockScript = NULL,
|
||||
};
|
||||
|
||||
struct rd_RedLock *mutx_redlock()
|
||||
@@ -195,9 +193,8 @@ void rd_lock_init()
|
||||
{
|
||||
struct rd_RedLock *rdlock = mutx_redlock();
|
||||
|
||||
rdlock->m_continueLockScript = sdsnew("if redis.call('get', KEYS[1]) == ARGV[1] then redis.call('del', KEYS[1]) end return redis.call('set', KEYS[1], ARGV[2], 'px', ARGV[3], 'nx')");
|
||||
rdlock->m_unlockScript = sdsnew("if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end");
|
||||
rdlock->m_retryCount = 8;
|
||||
rdlock->m_retryCount = 3;
|
||||
rdlock->m_retryDelay = 10;
|
||||
rdlock->m_clockDriftFactor = 0.01;
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ enum field_op
|
||||
{
|
||||
FS_OP_ADD=1,
|
||||
FS_OP_SET,
|
||||
FS_OP_GET,
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ extern "C" int FS_internal_register(screen_stat_handle_t handle,enum field_dsp_s
|
||||
enum field_calc_algo calc_type,const char* name);
|
||||
extern "C" int FS_internal_operate(screen_stat_handle_t handle,int id,int column_id,enum field_op op,long long value);
|
||||
|
||||
extern "C" int FS_internal_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,int scaling,
|
||||
enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name);
|
||||
|
||||
screen_stat_handle_t FS_internal_create_handle(void)
|
||||
{
|
||||
return FS_create_handle();
|
||||
@@ -43,3 +46,9 @@ int FS_internal_operate(screen_stat_handle_t handle,int id,int column_id,enum fi
|
||||
return FS_operate(handle, id, column_id, op, value);
|
||||
}
|
||||
|
||||
int FS_internal_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,int scaling,
|
||||
enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name)
|
||||
{
|
||||
return FS_register_ratio(handle, numerator_id, denominator_id, scaling, style, calc_type, name);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ enum field_op
|
||||
{
|
||||
FS_OP_ADD=1,
|
||||
FS_OP_SET,
|
||||
FS_OP_GET,
|
||||
};
|
||||
|
||||
typedef void* screen_stat_handle_t;
|
||||
@@ -56,4 +55,7 @@ int FS_internal_register(screen_stat_handle_t handle,enum field_dsp_style_t styl
|
||||
|
||||
int FS_internal_operate(screen_stat_handle_t handle,int id,int column_id,enum field_op op,long long value);
|
||||
|
||||
int FS_internal_register_ratio(screen_stat_handle_t handle,int numerator_id,int denominator_id,int scaling,
|
||||
enum field_dsp_style_t style,enum field_calc_algo calc_type,const char* name);
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user