23#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
34 return (*p1)->
weight - (*p2)->weight;
49 double P_last, X_last, Xn;
97 for (t = p->
name; *t != 0; ++t)
100 p->
carp.hash += p->
carp.hash * 0x62531965;
107 if (floor(p->
carp.load_factor * 1000.0) == 0.0)
108 p->
carp.load_factor = 0.0;
134 for (k = 1; k <= K; ++k) {
135 double Kk1 = (
double) (K - k + 1);
137 p->
carp.load_multiplier = (Kk1 * (p->
carp.load_factor - P_last)) / Xn;
138 p->
carp.load_multiplier += pow(X_last, Kk1);
139 p->
carp.load_multiplier = pow(p->
carp.load_multiplier, 1.0 / Kk1);
140 Xn *= p->
carp.load_multiplier;
141 X_last = p->
carp.load_multiplier;
142 P_last = p->
carp.load_factor;
155 unsigned int user_hash = 0;
156 unsigned int combined_hash;
158 double high_score = 0;
204 combined_hash = (user_hash ^ tp->
carp.hash);
205 combined_hash += combined_hash * 0x62531965;
207 score = combined_hash * tp->
carp.load_multiplier;
208 debugs(39, 3, *tp <<
" key=" << key <<
" combined_hash=" << combined_hash <<
209 " score=" << std::setprecision(0) << score);
218 debugs(39, 2,
"selected " << *p);
241 p->
carp.load_multiplier,
243 sumfetches ? (
double) p->
stats.
fetches / sumfetches : -1.0);
static void carpRegisterWithCacheManager(void)
CachePeer * carpSelectParent(PeerSelector *ps)
#define ROTATE_LEFT(x, n)
static int peerSortWeight(const void *a, const void *b)
static CachePeer ** carp_peers
#define cbdataReferenceDone(var)
#define cbdataReference(var)
AnyP::UriScheme const & getScheme() const
void port(unsigned short p)
void host(const char *src)
struct CachePeer::@27 stats
struct CachePeer::@29 options
struct CachePeer::@29::@35 carp_key
AnyP::Uri url
the request URI
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
const char * rawContent() const
static const size_type npos
size_type length() const
Returns the number of bytes stored in SBuf.
SBuf & append(const SBuf &S)
MemBlob::size_type size_type
SBuf & appendf(const char *fmt,...)
#define debugs(SECTION, LEVEL, CONTENT)
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
int peerHTTPOkay(const CachePeer *p, PeerSelector *ps)
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)
void * xcalloc(size_t n, size_t sz)