修改GET/PUT对外接口;cache miss不算fail;
This commit is contained in:
56
cache/src/tango_cache_client.cpp
vendored
56
cache/src/tango_cache_client.cpp
vendored
@@ -87,7 +87,7 @@ const char *tango_cache_get_errstring(const struct tango_cache_ctx *ctx)
|
||||
case CACHE_OUTOF_MEMORY:return "outof memory";
|
||||
case CACHE_ERR_WIREDLB: return "wiredlb error";
|
||||
case CACHE_ERR_SOCKPAIR:return "socketpair error";
|
||||
case CACHE_ERR_INTERNAL:return "cache Expires or x-amz-meta-lm not found";
|
||||
case CACHE_ERR_INTERNAL:return "internal error";
|
||||
default: return ctx->error;
|
||||
}
|
||||
}
|
||||
@@ -136,10 +136,10 @@ static void update_statistics(struct tango_cache_ctx *ctx, struct cache_statisti
|
||||
case CACHE_REQUEST_GET:
|
||||
if(ctx->fail_state)
|
||||
{
|
||||
if(ctx->error_code == CACHE_ERR_CURL)
|
||||
statistic->get_error_num += 1;
|
||||
else
|
||||
if(ctx->error_code == CACHE_CACHE_MISS || ctx->error_code == CACHE_TIMEOUT)
|
||||
statistic->get_miss_num += 1;
|
||||
else
|
||||
statistic->get_error_num += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -297,7 +297,7 @@ int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COP
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta)
|
||||
struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
char buffer[256]={0};
|
||||
@@ -312,7 +312,7 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *
|
||||
|
||||
ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx));
|
||||
ctx->instance = instance;
|
||||
ctx->future = future;
|
||||
ctx->future = f;
|
||||
ctx->method = CACHE_REQUEST_PUT;
|
||||
|
||||
if(instance->hash_object_key)
|
||||
@@ -375,11 +375,11 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *
|
||||
return ctx;
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta)
|
||||
struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_update_prepare(instance, future, meta);
|
||||
ctx = tango_cache_update_prepare(instance, f, meta);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return NULL;
|
||||
@@ -389,12 +389,12 @@ struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *in
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* future,
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* f,
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta_put *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_update_prepare(instance, future, meta);
|
||||
ctx = tango_cache_update_prepare(instance, f, meta);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -407,12 +407,12 @@ int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct f
|
||||
return tango_cache_upload_once_start_data(ctx, way, data, size);
|
||||
}
|
||||
|
||||
int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* future,
|
||||
enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* f,
|
||||
enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, struct tango_cache_meta_put *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_update_prepare(instance, future, meta);
|
||||
ctx = tango_cache_update_prepare(instance, f, meta);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -425,14 +425,14 @@ int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct
|
||||
return tango_cache_upload_once_start_evbuf(ctx, way, evbuf);
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta)
|
||||
struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
char sha256[72]={0};
|
||||
|
||||
ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx));
|
||||
ctx->instance = instance;
|
||||
ctx->future = future;
|
||||
ctx->future = f;
|
||||
ctx->method = CACHE_REQUEST_GET;
|
||||
ctx->get.state = GET_STATE_START;
|
||||
ctx->get.max_age = meta->get.max_age;
|
||||
@@ -457,11 +457,11 @@ struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *i
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta)
|
||||
int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_fetch_prepare(instance, future, meta);
|
||||
ctx = tango_cache_fetch_prepare(instance, f, meta);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -469,14 +469,14 @@ int tango_cache_fetch_object(struct tango_cache_instance *instance, struct futur
|
||||
return tango_cache_fetch_start(ctx);
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* future, const char *objkey)
|
||||
struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* f, const char *objkey)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
char sha256[72]={0};
|
||||
|
||||
ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx));
|
||||
ctx->instance = instance;
|
||||
ctx->future = future;
|
||||
ctx->future = f;
|
||||
ctx->method = CACHE_REQUEST_DELETE;
|
||||
|
||||
if(instance->hash_object_key)
|
||||
@@ -498,11 +498,11 @@ struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *
|
||||
return ctx;
|
||||
}
|
||||
|
||||
int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* future, const char *objkey)
|
||||
int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* f, const char *objkey)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_delete_prepare(instance, future, objkey);
|
||||
ctx = tango_cache_delete_prepare(instance, f, objkey);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -510,14 +510,14 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu
|
||||
return (cache_delete_minio_object(ctx)==1)?0:-1;
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* future, char *objlist[], u_int32_t num)
|
||||
struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
char md5[48]={0}, content_md5[48];
|
||||
|
||||
ctx = (struct tango_cache_ctx *)calloc(1, sizeof(struct tango_cache_ctx));
|
||||
ctx->instance = instance;
|
||||
ctx->future = future;
|
||||
ctx->future = f;
|
||||
ctx->method = CACHE_REQUEST_DELETE_MUL;
|
||||
ctx->del.succ_num = num;
|
||||
|
||||
@@ -534,15 +534,16 @@ struct tango_cache_ctx *tango_cache_multi_delete_prepare(struct tango_cache_inst
|
||||
sprintf(content_md5, "Content-MD5: %s", md5);
|
||||
ctx->headers = curl_slist_append(ctx->headers, content_md5);
|
||||
ctx->headers = curl_slist_append(ctx->headers, "Content-Type: application/xml");
|
||||
ctx->headers = curl_slist_append(ctx->headers, "Expect:");
|
||||
return ctx;
|
||||
}
|
||||
|
||||
//TODO: AccessDenied
|
||||
int tango_cache_multi_delete(struct tango_cache_instance *instance, struct future* future, char *objlist[], u_int32_t num)
|
||||
int tango_cache_multi_delete(struct tango_cache_instance *instance, struct future* f, char *objlist[], u_int32_t num)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
ctx = tango_cache_multi_delete_prepare(instance, future, objlist, num);
|
||||
ctx = tango_cache_multi_delete_prepare(instance, f, objlist, num);
|
||||
if(ctx == NULL)
|
||||
{
|
||||
return -1;
|
||||
@@ -752,9 +753,8 @@ static int load_local_configure(struct tango_cache_instance *instance, const cha
|
||||
MESA_load_profile_string_def(profile_path, section, "WIREDLB_GROUP", instance->wiredlb_group, 64, "KAZAKHSTAN");
|
||||
MESA_load_profile_string_def(profile_path, section, "WIREDLB_DATACENTER", instance->wiredlb_datacenter, 64, "ASTANA");
|
||||
MESA_load_profile_uint_def(profile_path, section, "WIREDLB_OVERRIDE", &instance->wiredlb_override, 1);
|
||||
|
||||
MESA_load_profile_uint_def(profile_path, section, "WIREDLB_HEALTH_PORT", &intval, 52100);
|
||||
instance->wiredlb_ha_port=(unsigned short)intval;
|
||||
instance->wiredlb_ha_port = (u_int16_t)intval;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user