# All paths should be given relative to the root
if HAVE_LIBEVENT
-noinst_PROGRAMS += example/memcached_light
+noinst_PROGRAMS+= example/memcached_light
endif
-noinst_HEADERS+= \
- example/byteorder.h \
- example/memcached_light.h \
- example/storage.h
+noinst_HEADERS+= example/byteorder.h
+noinst_HEADERS+= example/memcached_light.h
+noinst_HEADERS+= example/storage.h
-example_memcached_light_SOURCES= \
- example/byteorder.cc \
- example/interface_v0.cc \
- example/interface_v1.cc \
- example/memcached_light.cc \
- util/daemon.cc \
- util/pidfile.cc
-
-example_memcached_light_LDADD= libmemcached/libmemcachedprotocol.la \
- $(LIBEVENT_LDFLAGS)
+example_memcached_light_SOURCES=
+example_memcached_light_LDADD=
+example_memcached_light_SOURCES+= example/byteorder.cc
+example_memcached_light_SOURCES+= example/interface_v0.cc
+example_memcached_light_SOURCES+= example/interface_v1.cc
+example_memcached_light_SOURCES+= example/memcached_light.cc
example_memcached_light_SOURCES+= example/storage.cc
+example_memcached_light_SOURCES+= util/daemon.cc
+example_memcached_light_SOURCES+= util/pidfile.cc
+
+example_memcached_light_LDADD+= libmemcached/libmemcachedprotocol.la
+example_memcached_light_LDADD+= $(LIBEVENT_LDFLAGS)
include example/t/include.am
libmemcached/libmemcachedutil.la \
libtest/libtest.la
-example_t_memcached_light_SOURCES=
+example_t_memcached_light_CXXFLAGS=
+example_t_memcached_light_DEPENDENCIES=
example_t_memcached_light_LDADD=
+example_t_memcached_light_SOURCES=
example_t_memcached_light_SOURCES+= example/t/memcached_light.cc
example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc
example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc
example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc
-example_t_memcached_light_CXXFLAGS = $(AM_CXXFLAGS)
-example_t_memcached_light_DEPENDENCIES= $(MEMCACHED_LIGHT_TESTS_LDADDS) example/memcached_light
+example_t_memcached_light_CXXFLAGS+= $(AM_CXXFLAGS)
+example_t_memcached_light_DEPENDENCIES+= $(MEMCACHED_LIGHT_TESTS_LDADDS)
+example_t_memcached_light_DEPENDENCIES+= example/memcached_light
example_t_memcached_light_LDADD+= $(MEMCACHED_LIGHT_TESTS_LDADDS)
example_t_memcached_light_LDADD+= $(LIBUUID_LDFLAGS)
check_PROGRAMS+= example/t/memcached_light
static void *world_create(server_startup_st& servers, test_return_t& error)
{
+ if (access(executable.c_str(), X_OK) != 0)
+ {
+ error= TEST_SKIPPED;
+ return NULL;
+ }
+
if (HAVE_MEMCACHED_LIGHT_BINARY == 0)
{
error= TEST_SKIPPED;
if (server_startup(servers, "memcached-light", libtest::default_port(), 0, NULL) == 0)
{
error= TEST_FAILURE;
+ return NULL;
}
case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED:
{
+ if (bool(data) == false)
+ {
+ return memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_KETAMA, true);
+ }
+
(void)memcached_behavior_set_key_hash(ptr, MEMCACHED_HASH_MD5);
(void)memcached_behavior_set_distribution_hash(ptr, MEMCACHED_HASH_MD5);
- ptr->ketama.weighted= bool(data);
/**
@note We try to keep the same distribution going. This should be deprecated and rewritten.
*/
- return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA);
+ return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED);
}
case MEMCACHED_BEHAVIOR_HASH:
memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type)
{
- if (type < MEMCACHED_DISTRIBUTION_CONSISTENT_MAX)
+ switch (type)
{
- if (type == MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED)
- {
- ptr->ketama.weighted= true;
- }
- else
- {
- ptr->ketama.weighted= false;
- }
+ case MEMCACHED_DISTRIBUTION_MODULA:
+ break;
- ptr->distribution= type;
- return run_distribution(ptr);
+ case MEMCACHED_DISTRIBUTION_CONSISTENT:
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
+ ptr->ketama.weighted= false;
+ break;
+
+ case MEMCACHED_DISTRIBUTION_RANDOM:
+ break;
+
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY:
+ break;
+
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED:
+ ptr->ketama.weighted= true;
+ break;
+
+ case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET:
+ break;
+
+ default:
+ case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX:
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ memcached_literal_param("Invalid memcached_server_distribution_t"));
}
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
- memcached_literal_param("Invalid memcached_server_distribution_t"));
+ return run_distribution(ptr);
}
memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type)
{
if (hashkit_success(hashkit_set_distribution_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type)))
+ {
return MEMCACHED_SUCCESS;
+ }
return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
memcached_literal_param("Invalid memcached_hash_t()"));
test_return_t pre_behavior_ketama_weighted(memcached_st *memc)
{
- memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, true), MEMCACHED_SUCCESS);
- uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- test_compare(value, uint64_t(1));
+ test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED), uint64_t(1));
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5));
+ test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5), MEMCACHED_SUCCESS);
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
- test_compare(MEMCACHED_HASH_MD5, memcached_hash_t(value));
+ test_compare(memcached_hash_t(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH)), MEMCACHED_HASH_MD5);
return TEST_SUCCESS;
}