上传时输出对象的路径
This commit is contained in:
16
cache/cache_evbase_client.cpp
vendored
16
cache/cache_evbase_client.cpp
vendored
@@ -57,9 +57,9 @@ struct tango_cache_result *cache_evbase_read_result(void *promise_result)
|
||||
return tango_cache_read_result(promise_result);
|
||||
}
|
||||
|
||||
const char *cache_evbase_get_object_key(struct cache_evbase_ctx *ctx_asyn)
|
||||
void cache_evbase_get_object_path(const struct cache_evbase_ctx *ctx_asyn, char *path, size_t pathsize)
|
||||
{
|
||||
return tango_cache_get_object_key(ctx_asyn->ctx);
|
||||
tango_cache_get_object_path(ctx_asyn->ctx, path, pathsize);
|
||||
}
|
||||
|
||||
static int create_notification_pipe(evutil_socket_t sv[2])
|
||||
@@ -344,7 +344,7 @@ struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance
|
||||
}
|
||||
|
||||
int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* future,
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *objectkey, size_t keysize)
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct cache_evbase_ctx *ctx_asyn;
|
||||
struct tango_cache_ctx *ctx;
|
||||
@@ -355,9 +355,9 @@ int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(objectkey != NULL)
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(objectkey, keysize, "%s", ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx));
|
||||
@@ -390,7 +390,7 @@ int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct
|
||||
}
|
||||
|
||||
int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* future,
|
||||
struct evbuffer *evbuf, struct tango_cache_meta *meta, char *objectkey, size_t keysize)
|
||||
struct evbuffer *evbuf, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct cache_evbase_ctx *ctx_asyn;
|
||||
struct tango_cache_ctx *ctx;
|
||||
@@ -401,9 +401,9 @@ int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struc
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(objectkey != NULL)
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(objectkey, keysize, "%s", ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->instance->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
ctx_asyn = (struct cache_evbase_ctx *)calloc(1, sizeof(struct cache_evbase_ctx));
|
||||
|
||||
6
cache/include/cache_evbase_client.h
vendored
6
cache/include/cache_evbase_client.h
vendored
@@ -41,11 +41,11 @@ int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct fu
|
||||
int cache_evbase_upload_once_data(struct cache_evbase_instance *instance, struct future* future,
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size,
|
||||
struct tango_cache_meta *meta,
|
||||
char *objectkey, size_t keysize);
|
||||
char *path, size_t pathsize);
|
||||
int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* future,
|
||||
struct evbuffer *evbuf,
|
||||
struct tango_cache_meta *meta,
|
||||
char *objectkey, size_t keysize);
|
||||
char *path, size_t pathsize);
|
||||
|
||||
//<2F><>ʽ<EFBFBD>ϴ<EFBFBD><CFB4>ӿ<EFBFBD>
|
||||
struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* future, struct tango_cache_meta *meta);
|
||||
@@ -53,7 +53,7 @@ int cache_evbase_update_frag_data(struct cache_evbase_ctx *ctx_asyn, enum PUT_ME
|
||||
int cache_evbase_update_frag_evbuf(struct cache_evbase_ctx *ctx_asyn, struct evbuffer *evbuf);
|
||||
void cache_evbase_update_end(struct cache_evbase_ctx *ctx_asyn);
|
||||
|
||||
const char *cache_evbase_get_object_key(struct cache_evbase_ctx *ctx_asyn);
|
||||
void cache_evbase_get_object_path(const struct cache_evbase_ctx *ctx, char *path, size_t pathsize);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
8
cache/include/tango_cache_client.h
vendored
8
cache/include/tango_cache_client.h
vendored
@@ -113,16 +113,16 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu
|
||||
*/
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ϴ<EFBFBD>API*/
|
||||
//<2F><>objectkey<EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>KEY<EFBFBD><EFBFBD><EFBFBD><EFBFBD>CACHE_OBJECT_KEY_HASH_SWITCH=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ϣʱ<CFA3><CAB1><EFBFBD>ã<EFBFBD>
|
||||
//<2F><>path<EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ洢·<EFBFBD><EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ: 0-<2D>ɹ<EFBFBD><C9B9><EFBFBD><0ʧ<30>ܣ<EFBFBD><DCA3><EFBFBD>ͬ
|
||||
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 *objectkey, size_t keysize);
|
||||
char *path, size_t pathsize);
|
||||
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 *objectkey, size_t keysize);
|
||||
char *path, size_t pathsize);
|
||||
/*<2A><>ʽ<EFBFBD>ϴ<EFBFBD>API*/
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ: <20><>ΪNULL<4C><4C><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD>tango_cache_ctx_error<6F>鿴<EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>CACHE_OUTOF_MEMORY(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<29><>
|
||||
struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
|
||||
@@ -132,7 +132,7 @@ int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COP
|
||||
void tango_cache_update_end(struct tango_cache_ctx *ctx);
|
||||
|
||||
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>keyֵ<79><D6B5><EFBFBD><EFBFBD>CACHE_OBJECT_KEY_HASH_SWITCH=1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>URL/<2F>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ϣʱ<CFA3><CAB1><EFBFBD><EFBFBD>
|
||||
const char *tango_cache_get_object_key(struct tango_cache_ctx *ctx);
|
||||
void tango_cache_get_object_path(const struct tango_cache_ctx *ctx, char *path, size_t pathsize);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BIN
cache/pangu_tango_cache.a
vendored
Normal file
BIN
cache/pangu_tango_cache.a
vendored
Normal file
Binary file not shown.
19
cache/tango_cache_client.cpp
vendored
19
cache/tango_cache_client.cpp
vendored
@@ -63,9 +63,9 @@ struct tango_cache_result *tango_cache_read_result(void *promise_result)
|
||||
return (struct tango_cache_result *)promise_result;
|
||||
}
|
||||
|
||||
const char *tango_cache_get_object_key(struct tango_cache_ctx *ctx)
|
||||
void tango_cache_get_object_path(const struct tango_cache_ctx *ctx, char *path, size_t pathsize)
|
||||
{
|
||||
return ctx->object_key;
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
static inline void update_statistics(enum CACHE_REQUEST_METHOD method, bool fail_state, enum CACHE_ERR_CODE error_code, struct cache_statistics *statistic)
|
||||
@@ -262,6 +262,7 @@ struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *
|
||||
{
|
||||
snprintf(ctx->object_key, 256, "%s", meta->url);
|
||||
}
|
||||
sprintf(ctx->hostaddr, "%s", instance->minio_hostlist);
|
||||
|
||||
//Expires<65>ֶΣ<D6B6><CEA3><EFBFBD><EFBFBD>ڻ<EFBFBD><DABB><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ʱ
|
||||
now = time(NULL);
|
||||
@@ -319,7 +320,7 @@ struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *in
|
||||
}
|
||||
|
||||
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 *objectkey, size_t keysize)
|
||||
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
@@ -328,16 +329,16 @@ int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct f
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(objectkey != NULL)
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(objectkey, keysize, "%s", ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
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 *objectkey, size_t keysize)
|
||||
enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf, struct tango_cache_meta *meta, char *path, size_t pathsize)
|
||||
{
|
||||
struct tango_cache_ctx *ctx;
|
||||
|
||||
@@ -346,9 +347,9 @@ int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(objectkey != NULL)
|
||||
if(path != NULL)
|
||||
{
|
||||
snprintf(objectkey, keysize, "%s", ctx->object_key);
|
||||
snprintf(path, pathsize, "http://%s/%s/%s", ctx->hostaddr, instance->bucketname, ctx->object_key);
|
||||
}
|
||||
|
||||
return tango_cache_upload_once_start_evbuf(ctx, way, evbuf);
|
||||
@@ -377,6 +378,7 @@ struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *i
|
||||
{
|
||||
snprintf(ctx->object_key, 256, "%s", meta->url);
|
||||
}
|
||||
sprintf(ctx->hostaddr, "%s", instance->minio_hostlist);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -405,6 +407,7 @@ struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *
|
||||
{
|
||||
snprintf(ctx->object_key, 256, "%s", objkey);
|
||||
}
|
||||
sprintf(ctx->hostaddr, "%s", instance->minio_hostlist);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
|
||||
1
cache/tango_cache_client_in.h
vendored
1
cache/tango_cache_client_in.h
vendored
@@ -98,6 +98,7 @@ struct tango_cache_ctx
|
||||
struct future* future;
|
||||
char error[CURL_ERROR_SIZE];
|
||||
char object_key[256];
|
||||
char hostaddr[24];
|
||||
|
||||
enum CACHE_REQUEST_METHOD method;
|
||||
enum CACHE_ERR_CODE error_code;
|
||||
|
||||
16
cache/tango_cache_transfer.cpp
vendored
16
cache/tango_cache_transfer.cpp
vendored
@@ -110,11 +110,11 @@ static int http_put_bodypart_request_evbuf(struct tango_cache_ctx *ctx, bool ful
|
||||
ctx->put.upload_offset = 0;
|
||||
if(full)
|
||||
{
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?partNumber=%d&uploadId=%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key, ++ctx->put.part_index, ctx->put.uploadID);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?partNumber=%d&uploadId=%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key, ++ctx->put.part_index, ctx->put.uploadID);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERFUNCTION, curl_put_multipart_header_cb);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_HEADERDATA, ctx);
|
||||
}
|
||||
@@ -179,7 +179,7 @@ int curl_get_minio_uploadID(struct tango_cache_ctx *ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploads", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploads", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_POST, 1L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
@@ -209,7 +209,7 @@ int cache_delete_minio_object(struct tango_cache_ctx *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
@@ -237,7 +237,7 @@ bool cache_cancel_upload_minio(struct tango_cache_ctx *ctx)
|
||||
return false;
|
||||
}
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploadId=%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key, ctx->put.uploadID);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploadId=%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key, ctx->put.uploadID);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
@@ -267,7 +267,7 @@ bool cache_kick_combine_minio(struct tango_cache_ctx *ctx)
|
||||
}
|
||||
construct_complete_xml(ctx, &ctx->put.combine_xml, &len);
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploadId=%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key, ctx->put.uploadID);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s?uploadId=%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key, ctx->put.uploadID);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_POST, 1L);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
@@ -516,7 +516,7 @@ int tango_cache_upload_once_start_data(struct tango_cache_ctx *ctx, enum PUT_MEM
|
||||
}
|
||||
ctx->put.state = PUT_STATE_END;
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_NOSIGNAL, 1L);
|
||||
@@ -797,7 +797,7 @@ int tango_cache_fetch_start(struct tango_cache_ctx *ctx)
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->instance->minio_hostlist, ctx->instance->bucketname, ctx->object_key);
|
||||
snprintf(minio_url, 256, "http://%s/%s/%s", ctx->hostaddr, ctx->instance->bucketname, ctx->object_key);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_URL, minio_url);
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_USERAGENT, "aws-sdk-cpp/1.5.24 Linux/3.10.0-327.el7.x86_64 x86_64 pangu_cache");
|
||||
curl_easy_setopt(ctx->curl, CURLOPT_NOSIGNAL,1L);
|
||||
|
||||
2
cache/test_demo/cache_evbase_test.cpp
vendored
2
cache/test_demo/cache_evbase_test.cpp
vendored
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
|
||||
promise_set_ctx(future_to_promise(pdata->future), NULL, NULL);
|
||||
|
||||
ctx = cache_evbase_update_start(instance_asyn, pdata->future, &meta);
|
||||
sprintf(pdata->filename, "%s", cache_evbase_get_object_key(ctx));
|
||||
cache_evbase_get_object_path(ctx, pdata->filename, 256);
|
||||
|
||||
char buffer[1024];
|
||||
FILE *fp = fopen(filename_in, "r");
|
||||
|
||||
2
cache/test_demo/tango_cache_test.c
vendored
2
cache/test_demo/tango_cache_test.c
vendored
@@ -213,7 +213,7 @@ static void dummy_accept_callback(evutil_socket_t fd, short events, void *arg)
|
||||
promise_set_ctx(future_to_promise(pdata->future), NULL, NULL);
|
||||
|
||||
ctx = tango_cache_update_start(tango_instance, pdata->future, &meta);
|
||||
sprintf(pdata->filename, "%s", tango_cache_get_object_key(ctx));
|
||||
tango_cache_get_object_path(ctx, pdata->filename, 256);
|
||||
|
||||
FILE *fp = fopen(s, "r");
|
||||
while(!feof(fp))
|
||||
|
||||
Reference in New Issue
Block a user