r3098 - in trunk/varnish-cache: include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Mon Aug 18 10:18:43 CEST 2008
Author: phk
Date: 2008-08-18 10:18:43 +0200 (Mon, 18 Aug 2008)
New Revision: 3098
Modified:
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
Log:
Implement parsing of .window and .threshold in backend polling specifications.
.window is how many of the latest polls we examine.
.threshold is how many must have succeeded for the backend to be healthy.
.window = 40;
.threshold = 30;
// Thirty of the last fourty polls must have succeed.
.threshold = 4;
// The last four polls must have succeeded.
Default values:
.window = 8;
.threshold = 3;
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2008-08-18 08:00:21 UTC (rev 3097)
+++ trunk/varnish-cache/include/vrt.h 2008-08-18 08:18:43 UTC (rev 3098)
@@ -51,6 +51,8 @@
char *request;
double timeout;
double interval;
+ unsigned window;
+ unsigned threshold;
};
/*
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-08-18 08:00:21 UTC (rev 3097)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-08-18 08:18:43 UTC (rev 3098)
@@ -336,18 +336,23 @@
{
struct fld_spec *fs;
struct token *t_field;
- struct token *t_did = NULL;
+ struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
+ unsigned window, threshold;
fs = vcc_FldSpec(tl,
"?url",
"?request",
"?timeout",
"?interval",
+ "?window",
+ "?threshold",
NULL);
ExpectErr(tl, '{');
vcc_NextToken(tl);
+ window = 8;
+ threshold = 3;
Fb(tl, 0, "\t.probe = {\n");
while (tl->t->tok != '}') {
@@ -388,6 +393,16 @@
vcc_TimeVal(tl);
ERRCHK(tl);
Fb(tl, 0, ",\n");
+ } else if (vcc_IdIs(t_field, "window")) {
+ t_window = tl->t;
+ window = vcc_UintVal(tl);
+ vcc_NextToken(tl);
+ ERRCHK(tl);
+ } else if (vcc_IdIs(t_field, "threshold")) {
+ t_threshold = tl->t;
+ threshold = vcc_UintVal(tl);
+ vcc_NextToken(tl);
+ ERRCHK(tl);
} else {
vcc_ErrToken(tl, t_field);
vcc_ErrWhere(tl, t_field);
@@ -398,6 +413,33 @@
ExpectErr(tl, ';');
vcc_NextToken(tl);
}
+
+ if (t_threshold == NULL && t_window != NULL) {
+ vsb_printf(tl->sb, "Must specify .threshold with .window\n");
+ vcc_ErrWhere(tl, t_window);
+ return;
+ } else if (t_threshold != NULL && t_window == NULL) {
+ if (threshold > 64) {
+ vsb_printf(tl->sb, "Threshold must be 64 or less.\n");
+ vcc_ErrWhere(tl, t_threshold);
+ return;
+ }
+ window = threshold + 1;
+ } else if (window > 64) {
+ AN(t_window);
+ vsb_printf(tl->sb, "Window must be 64 or less.\n");
+ vcc_ErrWhere(tl, t_window);
+ return;
+ }
+ if (threshold > window ) {
+ vsb_printf(tl->sb,
+ "Threshold can not be greater than window.\n");
+ vcc_ErrWhere(tl, t_threshold);
+ AN(t_window);
+ vcc_ErrWhere(tl, t_window);
+ }
+ Fb(tl, 0, "\t\t.window = %u,\n", window);
+ Fb(tl, 0, "\t\t.threshold = %u\n", threshold);
Fb(tl, 0, "\t},\n");
ExpectErr(tl, '}');
vcc_NextToken(tl);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-08-18 08:00:21 UTC (rev 3097)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-08-18 08:18:43 UTC (rev 3098)
@@ -331,6 +331,8 @@
vsb_cat(sb, " char *request;\n");
vsb_cat(sb, " double timeout;\n");
vsb_cat(sb, " double interval;\n");
+ vsb_cat(sb, " unsigned window;\n");
+ vsb_cat(sb, " unsigned threshold;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
vsb_cat(sb, "/*\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2008-08-18 08:00:21 UTC (rev 3097)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl 2008-08-18 08:18:43 UTC (rev 3098)
@@ -214,6 +214,7 @@
puts $fo "#include \"config.h\""
puts $fo "#include <stdio.h>"
puts $fo "#include <ctype.h>"
+puts $fo "#include \"config.h\""
puts $fo "#include \"vcc_priv.h\""
puts $fo "#include \"vsb.h\""
More information about the varnish-commit
mailing list