ext/nutcracker/src/hashkit/nc_modula.c in nutcracker-0.2.4.mac9 vs ext/nutcracker/src/hashkit/nc_modula.c in nutcracker-0.2.4.1
- old
+ new
@@ -34,22 +34,19 @@
uint32_t pointer_counter; /* # pointers on continuum */
uint32_t points_per_server; /* points per server */
uint32_t continuum_index; /* continuum index */
uint32_t continuum_addition; /* extra space in the continuum */
uint32_t server_index; /* server index */
- uint32_t weight_index; /* weight index */
- uint32_t total_weight; /* total live server weight */
int64_t now; /* current timestamp in usec */
now = nc_usec_now();
if (now < 0) {
return NC_ERROR;
}
nserver = array_n(&pool->server);
nlive_server = 0;
- total_weight = 0;
pool->next_rebuild = 0LL;
for (server_index = 0; server_index < nserver; server_index++) {
struct server *server = array_get(&pool->server, server_index);
@@ -62,17 +59,10 @@
pool->next_rebuild = server->next_retry;
}
} else {
nlive_server++;
}
-
- ASSERT(server->weight > 0);
-
- /* count weight only for live servers */
- if (!pool->auto_eject_hosts || server->next_retry <= now) {
- total_weight += server->weight;
- }
}
pool->nlive_server = nlive_server;
if (nlive_server == 0) {
@@ -93,13 +83,13 @@
/*
* Allocate the continuum for the pool, the first time, and every time we
* add a new server to the pool
*/
- if (total_weight > pool->nserver_continuum) {
+ if (nlive_server > pool->nserver_continuum) {
struct continuum *continuum;
- uint32_t nserver_continuum = total_weight + MODULA_CONTINUUM_ADDITION;
+ uint32_t nserver_continuum = nlive_server + MODULA_CONTINUUM_ADDITION;
uint32_t ncontinuum = nserver_continuum * MODULA_POINTS_PER_SERVER;
continuum = nc_realloc(pool->continuum, sizeof(*continuum) * ncontinuum);
if (continuum == NULL) {
return NC_ENOMEM;
@@ -118,17 +108,15 @@
if (pool->auto_eject_hosts && server->next_retry > now) {
continue;
}
- for (weight_index = 0; weight_index < server->weight; weight_index++) {
- pointer_per_server = 1;
+ pointer_per_server = 1;
- pool->continuum[continuum_index].index = server_index;
- pool->continuum[continuum_index++].value = 0;
+ pool->continuum[continuum_index].index = server_index;
+ pool->continuum[continuum_index++].value = 0;
- pointer_counter += pointer_per_server;
- }
+ pointer_counter += pointer_per_server;
}
pool->ncontinuum = pointer_counter;
log_debug(LOG_VERB, "updated pool %"PRIu32" '%.*s' with %"PRIu32" of "
"%"PRIu32" servers live in %"PRIu32" slots and %"PRIu32" "