Go to the documentation of this file.
28 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
40 return (*p1)->
weight - (*p2)->weight;
49 double P_last, X_last, Xn;
95 for (t = p->
name; *t != 0; ++t)
105 if (floor(p->
userhash.load_factor * 1000.0) == 0.0)
131 for (k = 1; k <= K; ++k) {
132 double Kk1 = (
double) (K - k + 1);
134 p->
userhash.load_multiplier = (Kk1 * (p->
userhash.load_factor - P_last)) / Xn;
135 p->
userhash.load_multiplier += pow(X_last, Kk1);
138 X_last = p->
userhash.load_multiplier;
157 unsigned int user_hash = 0;
158 unsigned int combined_hash;
160 double high_score = 0;
161 const char *key =
NULL;
170 key =
request->auth_user_request->username();
176 debugs(39, 2,
"peerUserHashSelectParent: Calculating hash for " << key);
178 for (c = key; *c != 0; ++c)
184 combined_hash = (user_hash ^ tp->
userhash.hash);
185 combined_hash += combined_hash * 0x62531965;
187 score = combined_hash * tp->
userhash.load_multiplier;
188 debugs(39, 3,
"peerUserHashSelectParent: " << tp->
name <<
" combined_hash " << combined_hash <<
189 " score " << std::setprecision(0) << score);
198 debugs(39, 2,
"peerUserHashSelectParent: selected " << p->
name);
223 sumfetches ? (
double) p->
stats.
fetches / sumfetches : -1.0);
void * xcalloc(size_t n, size_t sz)
static CachePeer ** userhash_peers
struct CachePeer::@30 options
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
CachePeer * peerUserHashSelectParent(PeerSelector *ps)
static int n_userhash_peers
static int peerSortWeight(const void *a, const void *b)
static void peerUserHashRegisterWithCacheManager(void)
#define cbdataReference(var)
static OBJH peerUserHashCachemgr
struct CachePeer::@28 stats
#define cbdataReferenceDone(var)
#define ROTATE_LEFT(x, n)
void peerUserHashInit(void)
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
struct _request * request(char *urlin)
#define debugs(SECTION, LEVEL, CONTENT)