HEAD object元信息来源选择由宏定义改为配置文件。
This commit is contained in:
54
cache/src/tango_cache_client.cpp
vendored
54
cache/src/tango_cache_client.cpp
vendored
@@ -17,9 +17,7 @@
|
||||
#include "tango_cache_transfer.h"
|
||||
#include "tango_cache_tools.h"
|
||||
#include "tango_cache_xml.h"
|
||||
#ifdef HEAD_OBJECT_FROM_REDIS
|
||||
#include "tango_cache_redis.h"
|
||||
#endif
|
||||
|
||||
int TANGO_CACHE_VERSION_20181009=0;
|
||||
|
||||
@@ -491,11 +489,15 @@ int tango_cache_head_object(struct tango_cache_instance *instance, struct future
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#ifdef HEAD_OBJECT_FROM_REDIS
|
||||
return tango_cache_head_redis(ctx);
|
||||
#else
|
||||
return tango_cache_fetch_start(ctx);
|
||||
#endif
|
||||
|
||||
if(ctx->instance->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
{
|
||||
return tango_cache_head_redis(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
return tango_cache_fetch_start(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* f, const char *objkey)
|
||||
@@ -761,15 +763,18 @@ static int load_local_configure(struct tango_cache_instance *instance, const cha
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "Load config %s [%s] CACHE_BUCKET_NAME not found.\n", profile_path, section);
|
||||
return -1;
|
||||
}
|
||||
#ifdef HEAD_OBJECT_FROM_REDIS
|
||||
MESA_load_profile_string_def(profile_path, section, "CACHE_REDIS_KEY", instance->redis_key, 256, instance->bucketname);
|
||||
if(MESA_load_profile_string_nodef(profile_path, section, "CACHE_REDIS_IP", instance->redis_ip, 256) < 0)
|
||||
|
||||
MESA_load_profile_int_def(profile_path, section, "CACHE_HEAD_FROM_SOURCE", &instance->head_meta_source, HEAD_META_FROM_MINIO);
|
||||
if(instance->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "Load config %s [%s] CACHE_REDIS_IP not found.\n", profile_path, section);
|
||||
return -1;
|
||||
MESA_load_profile_string_def(profile_path, section, "CACHE_HEAD_REDIS_KEY", instance->redis_key, 256, instance->bucketname);
|
||||
if(MESA_load_profile_string_nodef(profile_path, section, "CACHE_HEAD_REDIS_IP", instance->redis_ip, 256) < 0)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "Load config %s [%s] CACHE_HEAD_REDIS_IP not found.\n", profile_path, section);
|
||||
return -1;
|
||||
}
|
||||
MESA_load_profile_int_def(profile_path, section, "CACHE_HEAD_REDIS_PORT", &instance->redis_port, 6379);
|
||||
}
|
||||
MESA_load_profile_int_def(profile_path, section, "CACHE_REDIS_PORT", &instance->redis_port, 6379);
|
||||
#endif
|
||||
MESA_load_profile_uint_def(profile_path, section, "CACHE_OBJECT_KEY_HASH_SWITCH", &instance->hash_object_key, 1);
|
||||
MESA_load_profile_uint_def(profile_path, section, "MINIO_LISTEN_PORT", &instance->minio_port, 9000);
|
||||
if(MESA_load_profile_string_nodef(profile_path, section, "MINIO_IP_LIST", instance->minio_iplist, 4096) < 0)
|
||||
@@ -829,18 +834,19 @@ struct tango_cache_instance *tango_cache_instance_new(struct event_base* evbase,
|
||||
curl_multi_setopt(instance->multi_hd, CURLMOPT_TIMERFUNCTION, curl_timer_function_cb);
|
||||
curl_multi_setopt(instance->multi_hd, CURLMOPT_TIMERDATA, instance);
|
||||
|
||||
#ifdef HEAD_OBJECT_FROM_REDIS
|
||||
if(redis_asyn_connect_init(instance, instance->redis_ip, instance->redis_port))
|
||||
if(instance->head_meta_source == HEAD_META_FROM_REDIS)
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "redis_asyn_connect_init %s:%u failed.", instance->redis_ip, instance->redis_port);
|
||||
free(instance);
|
||||
return NULL;
|
||||
if(redis_asyn_connect_init(instance))
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "redis_asyn_connect_init %s:%u failed.", instance->redis_ip, instance->redis_port);
|
||||
free(instance);
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "redis_asyn_connect_init %s:%u success.", instance->redis_ip, instance->redis_port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_HANDLE_RUNTIME_LOGV2(instance->runtime_log, RLOG_LV_FATAL, "redis_asyn_connect_init %s:%u success.", instance->redis_ip, instance->redis_port);
|
||||
}
|
||||
#endif
|
||||
evtimer_assign(&instance->timer_event, evbase, libevent_timer_event_cb, instance);
|
||||
return instance;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user