22 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) 33 return (*p1)->
weight - (*p2)->weight;
48 double P_last, X_last, Xn;
80 if (n_carp_peers == 0)
96 for (t = p->
name; *t != 0; ++t)
99 p->
carp.hash += p->
carp.hash * 0x62531965;
104 p->
carp.load_factor = ((double) p->
weight) / (double) W;
106 if (floor(p->
carp.load_factor * 1000.0) == 0.0)
107 p->
carp.load_factor = 0.0;
115 qsort(carp_peers, n_carp_peers,
sizeof(*carp_peers),
peerSortWeight);
133 for (k = 1; k <= K; ++k) {
134 double Kk1 = (double) (K - k + 1);
135 p = carp_peers[k - 1];
136 p->
carp.load_multiplier = (Kk1 * (p->
carp.load_factor - P_last)) / Xn;
137 p->
carp.load_multiplier += pow(X_last, Kk1);
138 p->
carp.load_multiplier = pow(p->
carp.load_multiplier, 1.0 / Kk1);
139 Xn *= p->
carp.load_multiplier;
140 X_last = p->
carp.load_multiplier;
141 P_last = p->
carp.load_factor;
154 unsigned int user_hash = 0;
155 unsigned int combined_hash;
157 double high_score = 0;
203 combined_hash = (user_hash ^ tp->
carp.hash);
204 combined_hash += combined_hash * 0x62531965;
206 score = combined_hash * tp->
carp.load_multiplier;
207 debugs(39, 3,
"carpSelectParent: key=" << key <<
" name=" << tp->
name <<
" combined_hash=" << combined_hash <<
208 " score=" << std::setprecision(0) << score);
217 debugs(39, 2,
"carpSelectParent: selected " << p->
name);
240 p->
carp.load_multiplier,
242 sumfetches ? (
double) p->
stats.
fetches / sumfetches : -1.0);
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf & appendf(const char *fmt,...)
#define cbdataReferenceDone(var)
CachePeer * carpSelectParent(PeerSelector *ps)
struct _request * request(char *urlin)
SBuf & append(const SBuf &S)
struct CachePeer::@29 stats
static int peerSortWeight(const void *a, const void *b)
static void carpRegisterWithCacheManager(void)
#define ROTATE_LEFT(x, n)
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
void port(unsigned short p)
#define debugs(SECTION, LEVEL, CONTENT)
#define cbdataReference(var)
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
AnyP::Uri url
the request URI
void host(const char *src)
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
static const size_type npos
struct CachePeer::@31 options
struct CachePeer::@31::@37 carp_key
AnyP::UriScheme const & getScheme() const
MemBlob::size_type size_type
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
const char * rawContent() const