1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#ifndef __CACHE_ASYN_CLIENT_H__
#define __CACHE_ASYN_CLIENT_H__
#include <event2/event.h>
#include <event.h>
#include "tango_cache_client.h"
/* API��ʹ��˵���ο�tango_cache_client.h */
struct cache_evbase_instance
{
struct tango_cache_instance *instance;
evutil_socket_t notify_readfd;
evutil_socket_t notify_sendfd;
struct event_base* evbase;
};
struct cache_evbase_ctx
{
size_t object_size; //tango_ctx�������Ա�����ع�����ֱ�ӻ�ȡ�Ļ����ڶ�дһ��������
struct tango_cache_ctx *ctx;
struct tango_losf_meta *losf_meta; //LOSFһ�����ϴ�ʱû��ctx
struct cache_evbase_instance *instance_asyn;
};
/*����API�̰߳�ȫ������ͬһ��cache_evbase_ctx�����Կ��̷߳��ʡ�*/
enum CACHE_ERR_CODE cache_evbase_get_last_error(const struct cache_evbase_ctx *ctx_asyn);
enum CACHE_ERR_CODE cache_evbase_ctx_error(const struct cache_evbase_instance *instance);
long long cache_evbase_maximum_session(const struct cache_evbase_instance *instance);
void cache_evbase_get_statistics(const struct cache_evbase_instance *instance, struct cache_statistics *out);
void cache_evbase_global_init(void);
//ÿ��minio��Ⱥ��bucket����һ��parameter�����instance�ɹ���һ��parameter��
struct tango_cache_parameter *cache_evbase_parameter_new(const char* profile_path, const char* section, void *runtimelog);
/*����ʵ�����̰߳�ȫ���ڲ�������һ���߳�*/
struct cache_evbase_instance *cache_evbase_instance_new(struct tango_cache_parameter *param, void *runtimelog);
/******************************************* GET�ӿ� ****************************************/
//�ɹ�����0��ʧ�ܷ���-1��future�ص���������������߳���ִ�У���ͬ
int cache_evbase_fetch_object(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_get *meta, enum OBJECT_LOCATION where_to_get);
int cache_evbase_head_object(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_get *meta);
struct tango_cache_result *cache_evbase_read_result(void *promise_result);
/****************************************** DELETE�ӿ� **************************************/
int cache_evbase_delete_object(struct cache_evbase_instance *instance, struct future* f, const char *objkey, const char *minio_addr=NULL, const char *bucket=NULL);
/***************************************** һ�����ϴ��ӿ� **********************************/
int cache_evbase_upload_once_data(struct cache_evbase_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/*OUT*/, size_t pathsize);
int cache_evbase_upload_once_evbuf(struct cache_evbase_instance *instance, struct future* f,
struct evbuffer *evbuf,
struct tango_cache_meta_put *meta,
char *path/*OUT*/, size_t pathsize);
/****************************************** ��ʽ�ϴ��ӿ� ***********************************/
struct cache_evbase_ctx *cache_evbase_update_start(struct cache_evbase_instance *instance, struct future* f, struct tango_cache_meta_put *meta);
int cache_evbase_update_frag_data(struct cache_evbase_ctx *ctx_asyn, enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size);
int cache_evbase_update_frag_evbuf(struct cache_evbase_ctx *ctx_asyn, struct evbuffer *evbuf);
int cache_evbase_update_end(struct cache_evbase_ctx *ctx_asyn, char *path/*OUT*/, size_t pathsize);
void cache_evbase_update_cancel(struct cache_evbase_ctx *ctx_asyn);
#endif
|