+ for (host_index = 0; host_index < ptr->number_of_hosts; ++host_index)
+ {
+ if (is_auto_ejecting && list[host_index].next_retry > now.tv_sec)
+ continue;
+
+ if (is_ketama_weighted)
+ {
+ float pct = (float)list[host_index].weight / (float)total_weight;
+ pointer_per_server= (uint32_t) ((floorf((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
+ pointer_per_hash= 4;
+#ifdef DEBUG
+ printf("ketama_weighted:%s|%d|%llu|%u\n",
+ list[host_index].hostname,
+ list[host_index].port,
+ (unsigned long long)list[host_index].weight,
+ pointer_per_server);
+#endif
+ }
+
+
+ if (ptr->distribution == MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY)
+ {
+ for (pointer_index= 0;
+ pointer_index < pointer_per_server / pointer_per_hash;
+ pointer_index++)
+ {
+ char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+ size_t sort_host_length;
+
+ // Spymemcached ketema key format is: hostname/ip:port-index
+ // If hostname is not available then: /ip:port-index
+ sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "/%s:%d-%d",
+ list[host_index].hostname,
+ list[host_index].port,
+ pointer_index);
+#ifdef DEBUG
+ printf("update_continuum: key is %s\n", sort_host);
+#endif
+
+ WATCHPOINT_ASSERT(sort_host_length);
+
+ if (is_ketama_weighted)
+ {
+ unsigned int i;
+ for (i = 0; i < pointer_per_hash; i++)
+ {
+ value= ketama_server_hash(sort_host, (uint32_t) sort_host_length, (int) i);
+ ptr->continuum[continuum_index].index= host_index;
+ ptr->continuum[continuum_index++].value= value;
+ }
+ }
+ else
+ {
+ value= memcached_generate_hash_value(sort_host, sort_host_length, ptr->hash_continuum);
+ ptr->continuum[continuum_index].index= host_index;
+ ptr->continuum[continuum_index++].value= value;
+ }
+ }
+ }
+ else
+ {
+ for (pointer_index= 1;
+ pointer_index <= pointer_per_server / pointer_per_hash;
+ pointer_index++)
+ {
+ char sort_host[MEMCACHED_MAX_HOST_SORT_LENGTH]= "";
+ size_t sort_host_length;
+
+ if (list[host_index].port == MEMCACHED_DEFAULT_PORT)
+ {
+ sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "%s-%d",
+ list[host_index].hostname,
+ pointer_index - 1);
+ }
+ else
+ {
+ sort_host_length= (size_t) snprintf(sort_host, MEMCACHED_MAX_HOST_SORT_LENGTH,
+ "%s:%d-%d",
+ list[host_index].hostname,
+ list[host_index].port, pointer_index - 1);
+ }
+
+ WATCHPOINT_ASSERT(sort_host_length);
+
+ if (is_ketama_weighted)
+ {
+ unsigned int i;
+ for (i = 0; i < pointer_per_hash; i++)
+ {
+ value= ketama_server_hash(sort_host, (uint32_t) sort_host_length, (int) i);
+ ptr->continuum[continuum_index].index= host_index;
+ ptr->continuum[continuum_index++].value= value;
+ }
+ }
+ else
+ {
+ value= memcached_generate_hash_value(sort_host, sort_host_length, ptr->hash_continuum);
+ ptr->continuum[continuum_index].index= host_index;
+ ptr->continuum[continuum_index++].value= value;
+ }
+ }
+ }
+
+ pointer_counter+= pointer_per_server;
+ }
+
+ WATCHPOINT_ASSERT(ptr);
+ WATCHPOINT_ASSERT(ptr->continuum);