projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Don't remove origin directories.
[awesomized/libmemcached]
/
libmemcached
/
hosts.cc
diff --git
a/libmemcached/hosts.cc
b/libmemcached/hosts.cc
index dbfba007bd8d93c9c4d2e648e19e67da4ceab69b..4875615f4ae3c3a2bd37d6d1dbb5443794697e34 100644
(file)
--- a/
libmemcached/hosts.cc
+++ b/
libmemcached/hosts.cc
@@
-62,10
+62,7
@@
static void sort_hosts(memcached_st *ptr)
{
if (memcached_server_count(ptr))
{
{
if (memcached_server_count(ptr))
{
-
qsort(memcached_instance_list(ptr), memcached_server_count(ptr), sizeof(org::libmemcached::Instance), compare_servers);
qsort(memcached_instance_list(ptr), memcached_server_count(ptr), sizeof(org::libmemcached::Instance), compare_servers);
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, 0);
- instance->number_of_hosts= memcached_server_count(ptr);
}
}
}
}
@@
-121,11
+118,17
@@
static int continuum_item_cmp(const void *t1, const void *t2)
/* Why 153? Hmmm... */
WATCHPOINT_ASSERT(ct1->value != 153);
if (ct1->value == ct2->value)
/* Why 153? Hmmm... */
WATCHPOINT_ASSERT(ct1->value != 153);
if (ct1->value == ct2->value)
+ {
return 0;
return 0;
+ }
else if (ct1->value > ct2->value)
else if (ct1->value > ct2->value)
+ {
return 1;
return 1;
+ }
else
else
+ {
return -1;
return -1;
+ }
}
static memcached_return_t update_continuum(memcached_st *ptr)
}
static memcached_return_t update_continuum(memcached_st *ptr)
@@
-170,8
+173,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
live_servers= memcached_server_count(ptr);
}
live_servers= memcached_server_count(ptr);
}
- uint64_t is_ketama_weighted= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- uint32_t points_per_server= (uint32_t) (is_ketama_weighted ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER);
+ uint32_t points_per_server= (uint32_t) (memcached_is_weighted_ketama(ptr) ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER);
if (live_servers == 0)
{
if (live_servers == 0)
{
@@
-194,7
+196,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
}
uint64_t total_weight= 0;
}
uint64_t total_weight= 0;
- if (
is_ketama_weighted
)
+ if (
memcached_is_weighted_ketama(ptr)
)
{
for (uint32_t host_index = 0; host_index < memcached_server_count(ptr); ++host_index)
{
{
for (uint32_t host_index = 0; host_index < memcached_server_count(ptr); ++host_index)
{
@@
-212,7
+214,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
continue;
}
continue;
}
- if (
is_ketama_weighted
)
+ if (
memcached_is_weighted_ketama(ptr)
)
{
float pct= (float)list[host_index].weight / (float)total_weight;
pointer_per_server= (uint32_t) ((::floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
{
float pct= (float)list[host_index].weight / (float)total_weight;
pointer_per_server= (uint32_t) ((::floor((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
@@
-256,7
+258,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
fprintf(stdout, "update_continuum: key is %s\n", sort_host);
}
fprintf(stdout, "update_continuum: key is %s\n", sort_host);
}
- if (
is_ketama_weighted
)
+ if (
memcached_is_weighted_ketama(ptr)
)
{
for (uint32_t x= 0; x < pointer_per_hash; x++)
{
{
for (uint32_t x= 0; x < pointer_per_hash; x++)
{
@@
-304,7
+306,7
@@
static memcached_return_t update_continuum(memcached_st *ptr)
memcached_literal_param("snprintf(sizeof(sort_host)))"));
}
memcached_literal_param("snprintf(sizeof(sort_host)))"));
}
- if (
is_ketama_weighted
)
+ if (
memcached_is_weighted_ketama(ptr)
)
{
for (uint32_t x = 0; x < pointer_per_hash; x++)
{
{
for (uint32_t x = 0; x < pointer_per_hash; x++)
{
@@
-369,15
+371,14
@@
static memcached_return_t server_add(memcached_st *ptr,
if (weight > 1)
{
if (weight > 1)
{
- ptr->ketama.weighted= true;
+ if (memcached_is_consistent_distribution(ptr))
+ {
+ memcached_set_weighted_ketama(ptr, true);
+ }
}
ptr->number_of_hosts++;
}
ptr->number_of_hosts++;
- // @note we place the count in the bottom of the server list
- instance= memcached_instance_fetch(ptr, 0);
- memcached_instance_set_count(instance, memcached_server_count(ptr));
-
return run_distribution(ptr);
}
return run_distribution(ptr);
}
@@
-418,18
+419,12
@@
memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv
if (list[x].weight > 1)
{
if (list[x].weight > 1)
{
-
ptr->ketama.weighted= true
;
+
memcached_set_weighted_ketama(ptr, true)
;
}
ptr->number_of_hosts++;
}
}
ptr->number_of_hosts++;
}
- // Provides backwards compatibility with server list.
- {
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, 0);
- instance->number_of_hosts= memcached_server_count(ptr);
- }
-
return run_distribution(ptr);
}
return run_distribution(ptr);
}
@@
-468,18
+463,12
@@
memcached_return_t memcached_instance_push(memcached_st *ptr, const struct org::
if (list[x].weight > 1)
{
if (list[x].weight > 1)
{
-
ptr->ketama.weighted= true
;
+
memcached_set_weighted_ketama(ptr, true)
;
}
ptr->number_of_hosts++;
}
}
ptr->number_of_hosts++;
}
- // Provides backwards compatibility with server list.
- {
- org::libmemcached::Instance* instance= memcached_instance_fetch(ptr, 0);
- instance->number_of_hosts= memcached_server_count(ptr);
- }
-
return run_distribution(ptr);
}
return run_distribution(ptr);
}