--- /data/projets/rel/haproxy/haproxy-1.1.27/haproxy.c Mon Oct 27 16:00:28 2003
+++ haproxy.c-sebastien-brize Tue Mar 16 11:56:20 2004
@@ -94,6 +94,7 @@
#define DEF_CHKINTR 2000
#define DEF_FALLTIME 3
#define DEF_RISETIME 2
+#define DEF_WEIGHT 1 //SB
#define DEF_CHECK_REQ "OPTIONS / HTTP/1.0\r\n\r\n"
/* default connections limit */
@@ -354,6 +355,8 @@
int health; /* 0->rise-1 = bad; rise->rise+fall-1 = good */
int rise, fall; /* time in iterations */
int inter; /* time in milliseconds */
+ int weight; /* initial weight in kilos SB */
+ int fat; /* weight the server loses SB */
int result; /* 0 = connect OK, -1 = connect KO */
int curfd; /* file desc used for current test, or -1 if not in test */
struct proxy *proxy; /* the proxy this server belongs to */
@@ -435,6 +438,9 @@
int conn_retries; /* maximum number of connect retries */
int options; /* PR_O_REDISP, PR_O_TRANSP */
int mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
+ int wactive; /* is weighted mode active SB */
+ int weight; /* overall proxy's server weight SB */
+ int fat; /* weight the proxy looses SB */
struct sockaddr_in source_addr; /* the address to which we want to bind for connect() */
struct proxy *next;
struct sockaddr_in logsrv1, logsrv2; /* 2 syslog servers */
@@ -1424,14 +1430,37 @@
if (srv == NULL)
srv = px->srv;
if (srv->state & SRV_RUNNING
- && !((srv->state & SRV_BACKUP) && ignore_backup))
- return srv;
+ && !((srv->state & SRV_BACKUP) && ignore_backup) && srv->fat > 0) //SB
+ {
+ if(srv->fat > 0 && px->wactive) { //SB
+ srv->fat--; //SB
+ px->fat--; //SB
+ return srv;
+ } //SB
+ else if(!px->wactive) return srv; //SB
+ }
srv = srv->next;
} while (srv != px->cursrv);
} while (ignore_backup--);
return NULL;
}
+void reinit_weights(struct proxy *px) { //SB
+ struct server *srv = px->cursrv; //SB
+ int ignore_backup = 1; //SB
+ do { //SB
+ if (srv == NULL) //SB
+ srv = px->srv; //SB
+ if (srv->state & SRV_RUNNING && !((srv->state & SRV_BACKUP) && ignore_backup)) //SB
+ { //SB
+ srv->fat = srv->weight; //SB
+ } //SB
+ srv = srv->next; //SB
+ } while (srv != px->cursrv); //SB
+ px->fat = px->weight; //SB
+} //SB
+
+
/*
* This function initiates a connection to the current server (s->srv) if (s->direct)
* is set, or to the dispatch server if (s->direct) is 0. It returns 0 if
@@ -1449,9 +1478,9 @@
else if (s->proxy->options & PR_O_BALANCE) {
if (s->proxy->options & PR_O_BALANCE_RR) {
struct server *srv;
-
+ if(!s->proxy->fat && s->proxy->wactive) //SB
+ reinit_weights(s->proxy); //SB
srv = find_server(s->proxy);
-
if (srv == NULL) /* no server left */
return -1;
@@ -4491,6 +4520,9 @@
curproxy->contimeout = defproxy.contimeout;
curproxy->srvtimeout = defproxy.srvtimeout;
curproxy->mode = defproxy.mode;
+ curproxy->wactive = 0; //SB
+ curproxy->weight = 0; //SB
+ curproxy->fat = 0; //SB
curproxy->logfac1 = defproxy.logfac1;
curproxy->logsrv1 = defproxy.logsrv1;
curproxy->loglev1 = defproxy.loglev1;
@@ -4846,6 +4878,8 @@
newsrv->inter = DEF_CHKINTR;
newsrv->rise = DEF_RISETIME;
newsrv->fall = DEF_FALLTIME;
+ newsrv->weight = DEF_WEIGHT; //SB
+ newsrv->fat = DEF_WEIGHT; //SB
newsrv->health = newsrv->rise; /* up, but will fall down at first failure */
cur_arg = 3;
while (*args[cur_arg]) {
@@ -4867,6 +4901,14 @@
newsrv->inter = atol(args[cur_arg + 1]);
cur_arg += 2;
}
+ else if (!strcmp(args[cur_arg], "weight")) { //SB
+ newsrv->weight = atol(args[cur_arg + 1]); //SB
+ newsrv->fat = newsrv->weight; //SB
+ newsrv->proxy->wactive = 1; //SB
+ newsrv->proxy->weight += newsrv->weight; //SB
+ newsrv->proxy->fat += newsrv->weight; //SB
+ cur_arg += 2; //SB
+ } //SB
else if (!strcmp(args[cur_arg], "port")) {
newsrv->check_port = atol(args[cur_arg + 1]);
cur_arg += 2;
@@ -4880,7 +4922,7 @@
cur_arg += 1;
}
else {
- Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'check', 'inter', 'rise' and 'fall'.\n",
+ Alert("parsing [%s:%d] : server %s only supports options 'backup', 'cookie', 'check', 'inter', 'weight', 'rise' and 'fall'.\n", //SB
file, linenum, newsrv->id);
return -1;
}
I am well aware of the popular opinion that such subjects are too abstruse to be understood by practical mechanics—an assumption that is founded mainly in the fact that the subject of heat and motion are not generally studied, and have been too recently demonstrated in a scientific way to command confidence and attention; but the subject is really no more difficult to understand in an elementary sense than that of the relation between movement and force illustrated in the "mechanical powers" of school-books, which no apprentice ever did or ever will understand, except by first studying the principles of force and motion, independent of mechanical agents, such as screws, levers, wedges, and so on. A new design should be based upon one of two suppositions—either that existing mechanism is imperfect in its construction, or that it lacks functions which a new design may supply; and if those who spend their time in making plans for novel machinery would stop to consider this from the beginning, it would save no little of the time wasted in what may be called scheming without a purpose. A man, coming silently from some concealment, in a dory, undetected in their busy absorption, held something menacingly businesslike and sending sun glints from its blue steel. Its hollow nose covered both at the range he had. “Well, Sky Patrol—and Ground Crew,” he hailed them. “We are going to see some excitement at last!” "You're right, Si," shouted the Lieutenant and Shorty. "Hip, hip, hooray for the Army o' the Cumberland and old Pap Thomas!" "Glad ain't no name for it," said Levi. "Did you say you'd got the boys in there? Here, you men, bring me two or three of those cracker-boxes." "The very same company," gasped the woman. And the other asked: "And the raid'll be made ter-morrer?" "My—" But before they had time to answer, something burst from between the stalls and ran down the darkling slope, brandishing a knife. It was Mexico Bill, running amok, as he had sometimes run before, but on less crowded occasions. The women sent up an ear-splitting yell, and made a fresh onslaught on the hedge. Someone grabbed the half-breed from behind, but his knife flashed, and the next moment he was free, dashing through the gorse towards his victims. Such a discovery could not long remain a secret;—the tale reached the ears of young De Boteler, and, already prepossessed in his favour, it was but a natural consequence that Calverley should rise from being first an assistant, to be the steward, the page, and, at length, the esquire to the heir to the barony of Sudley. But the progress of his fortunes did but add to the malevolence of the detractor and the tale-bearer; theft, sacrilege, and even murder were hinted at as probable causes for a youth, who evidently did not belong to the vulgar, being thus a friendless outcast. But the most charitable surmise was, that he was the offspring of the unhallowed love of some dame or damsel who had reared him in privacy, and had destined him for the church; and that either upon the death of his protectress, or through some fault, he had been expelled from his home. Calverley had a distant authoritative manner towards his equals and inferiors, which, despite every effort, checked inquisitiveness; and all the information he ever gave was, that he was the son of a respectable artizan of the city of London, whom his father's death had left friendless. Whether this statement was correct or not, could never be discovered. Calverley was never known to allude to aught that happened in the years previous to his becoming an inmate of the castle: what little he had said was merely in reply to direct questions. It would seem, then, that he stood alone in the world, and such a situation is by no means enviable; and although duplicity, selfishness and tyranny, formed the principal traits in his character; and though independently of tyranny and selfishness, his mind instinctively shrunk from any contact, save that of necessity, with those beneath him, yet had he gazed upon the growing beauty of Margaret till a love pure and deep—a love in which was concentrated all the slumbering affections, had risen and expanded in his breast, until it had, as it were, become a part of his being. HoMEA一级日本l00免费看
ENTER NUMBET 0018gs-hurong.com.cn
seecr26w.com.cn
www.se1rkcfw.com.cn
www.666books.com.cn
slfscrg.com.cn
czht677.com.cn
www.bzjk919.com.cn
fftt638.com.cn
phong.com.cn
www.xiangei.com.cn