Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
2676c2e3
Commit
2676c2e3
authored
Dec 11, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shard director vcc enum overhaul
parent
4094cf5b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
182 deletions
+43
-182
Makefile.am
lib/libvmod_directors/Makefile.am
+2
-2
flint.lnt
lib/libvmod_directors/flint.lnt
+1
-0
shard_dir.h
lib/libvmod_directors/shard_dir.h
+13
-1
shard_parse_vcc_enums.c
lib/libvmod_directors/shard_parse_vcc_enums.c
+0
-132
shard_parse_vcc_enums.h
lib/libvmod_directors/shard_parse_vcc_enums.h
+0
-45
tbl_by.h
lib/libvmod_directors/tbl_by.h
+5
-0
tbl_healthy.h
lib/libvmod_directors/tbl_healthy.h
+4
-0
vmod.vcc
lib/libvmod_directors/vmod.vcc
+2
-2
vmod_shard.c
lib/libvmod_directors/vmod_shard.c
+16
-0
No files found.
lib/libvmod_directors/Makefile.am
View file @
2676c2e3
...
@@ -12,8 +12,8 @@ libvmod_directors_la_SOURCES = \
...
@@ -12,8 +12,8 @@ libvmod_directors_la_SOURCES = \
shard_cfg.h
\
shard_cfg.h
\
shard_dir.c
\
shard_dir.c
\
shard_dir.h
\
shard_dir.h
\
shard_parse_vcc_enums
.h
\
tbl_by
.h
\
shard_parse_vcc_enums.c
tbl_healthy.h
# Use vmodtool.py generated automake boilerplate
# Use vmodtool.py generated automake boilerplate
include
$(srcdir)/automake_boilerplate.am
include
$(srcdir)/automake_boilerplate.am
lib/libvmod_directors/flint.lnt
View file @
2676c2e3
-efile(451, "tbl_*.h") // No include guard
lib/libvmod_directors/shard_dir.h
View file @
2676c2e3
...
@@ -27,7 +27,19 @@
...
@@ -27,7 +27,19 @@
* SUCH DAMAGE.
* SUCH DAMAGE.
*/
*/
#include "shard_parse_vcc_enums.h"
enum
by_e
{
_BY_E_INVALID
=
0
,
#define VMODENUM(x) BY_ ## x,
#include "tbl_by.h"
_BY_E_MAX
};
enum
healthy_e
{
_HEALTHY_E_INVALID
=
0
,
#define VMODENUM(x) x,
#include "tbl_healthy.h"
_HEALTHY_E_MAX
};
struct
vbitmap
;
struct
vbitmap
;
...
...
lib/libvmod_directors/shard_parse_vcc_enums.c
deleted
100644 → 0
View file @
4094cf5b
/*
* for the time being, this code is auto-generated outside the varnishd source
* tree, see
* https://code.uplex.de/uplex-varnish/libvmod-vslp/blob/shard/src/gen_enum_parse.pl
*
* TODO: integrate in vmodtool.py or replace with something else
*/
/*lint -e801 */
#include "shard_parse_vcc_enums.h"
#define term(c) ((c) == '\0')
enum
alg_e
parse_alg_e
(
const
char
*
m
)
{
enum
alg_e
r
;
switch
(
m
[
0
])
{
case
'C'
:
goto
_0C
;
// CRC32
case
'R'
:
goto
_0R
;
// RS
case
'S'
:
goto
_0S
;
// SHA256
default:
goto
invalid
;
}
_0C:
//CRC32
if
((
m
[
1
]
==
'R'
)
&&
(
m
[
2
]
==
'C'
)
&&
(
m
[
3
]
==
'3'
)
&&
(
m
[
4
]
==
'2'
)
&&
(
term
(
m
[
5
])))
{
r
=
CRC32
;
goto
ok
;
}
goto
invalid
;
_0R:
//RS
if
((
m
[
1
]
==
'S'
)
&&
(
term
(
m
[
2
])))
{
r
=
RS
;
goto
ok
;
}
goto
invalid
;
_0S:
//SHA256
if
((
m
[
1
]
==
'H'
)
&&
(
m
[
2
]
==
'A'
)
&&
(
m
[
3
]
==
'2'
)
&&
(
m
[
4
]
==
'5'
)
&&
(
m
[
5
]
==
'6'
)
&&
(
term
(
m
[
6
])))
{
r
=
SHA256
;
goto
ok
;
}
goto
invalid
;
ok:
return
r
;
invalid:
return
_ALG_E_INVALID
;
}
enum
by_e
parse_by_e
(
const
char
*
m
)
{
enum
by_e
r
;
switch
(
m
[
0
])
{
case
'B'
:
goto
_0B
;
// BLOB
case
'H'
:
goto
_0H
;
// HASH
case
'K'
:
goto
_0K
;
// KEY
case
'U'
:
goto
_0U
;
// URL
default:
goto
invalid
;
}
_0B:
//BLOB
if
((
m
[
1
]
==
'L'
)
&&
(
m
[
2
]
==
'O'
)
&&
(
m
[
3
]
==
'B'
)
&&
(
term
(
m
[
4
])))
{
r
=
BY_BLOB
;
goto
ok
;
}
goto
invalid
;
_0H:
//HASH
if
((
m
[
1
]
==
'A'
)
&&
(
m
[
2
]
==
'S'
)
&&
(
m
[
3
]
==
'H'
)
&&
(
term
(
m
[
4
])))
{
r
=
BY_HASH
;
goto
ok
;
}
goto
invalid
;
_0K:
//KEY
if
((
m
[
1
]
==
'E'
)
&&
(
m
[
2
]
==
'Y'
)
&&
(
term
(
m
[
3
])))
{
r
=
BY_KEY
;
goto
ok
;
}
goto
invalid
;
_0U:
//URL
if
((
m
[
1
]
==
'R'
)
&&
(
m
[
2
]
==
'L'
)
&&
(
term
(
m
[
3
])))
{
r
=
BY_URL
;
goto
ok
;
}
goto
invalid
;
ok:
return
r
;
invalid:
return
_BY_E_INVALID
;
}
enum
healthy_e
parse_healthy_e
(
const
char
*
m
)
{
enum
healthy_e
r
;
switch
(
m
[
0
])
{
case
'A'
:
goto
_0A
;
// ALL
case
'C'
:
goto
_0C
;
// CHOSEN
case
'I'
:
goto
_0I
;
// IGNORE
default:
goto
invalid
;
}
_0A:
//ALL
if
((
m
[
1
]
==
'L'
)
&&
(
m
[
2
]
==
'L'
)
&&
(
term
(
m
[
3
])))
{
r
=
ALL
;
goto
ok
;
}
goto
invalid
;
_0C:
//CHOSEN
if
((
m
[
1
]
==
'H'
)
&&
(
m
[
2
]
==
'O'
)
&&
(
m
[
3
]
==
'S'
)
&&
(
m
[
4
]
==
'E'
)
&&
(
m
[
5
]
==
'N'
)
&&
(
term
(
m
[
6
])))
{
r
=
CHOSEN
;
goto
ok
;
}
goto
invalid
;
_0I:
//IGNORE
if
((
m
[
1
]
==
'G'
)
&&
(
m
[
2
]
==
'N'
)
&&
(
m
[
3
]
==
'O'
)
&&
(
m
[
4
]
==
'R'
)
&&
(
m
[
5
]
==
'E'
)
&&
(
term
(
m
[
6
])))
{
r
=
IGNORE
;
goto
ok
;
}
goto
invalid
;
ok:
return
r
;
invalid:
return
_HEALTHY_E_INVALID
;
}
lib/libvmod_directors/shard_parse_vcc_enums.h
deleted
100644 → 0
View file @
4094cf5b
/*
* for the time being, this code is auto-generated outside the varnishd source
* tree, see
* https://code.uplex.de/uplex-varnish/libvmod-vslp/blob/shard/src/gen_enum_parse.pl
*
* TODO: integrate in vmodtool.py or replace with something else
*/
enum
alg_e
{
_ALG_E_INVALID
=
0
,
CRC32
,
SHA256
,
RS
,
_ALG_E_MAX
};
enum
alg_e
parse_alg_e
(
const
char
*
);
/*lint -esym(769, by_e::_BY_E_MAX) */
enum
by_e
{
_BY_E_INVALID
=
0
,
BY_HASH
,
BY_URL
,
BY_KEY
,
BY_BLOB
,
_BY_E_MAX
};
enum
by_e
parse_by_e
(
const
char
*
);
/*lint -esym(769, healthy_e::_HEALTHY_E_MAX) */
enum
healthy_e
{
_HEALTHY_E_INVALID
=
0
,
CHOSEN
,
IGNORE
,
ALL
,
_HEALTHY_E_MAX
};
enum
healthy_e
parse_healthy_e
(
const
char
*
);
lib/libvmod_directors/tbl_by.h
0 → 100644
View file @
2676c2e3
VMODENUM
(
HASH
)
VMODENUM
(
URL
)
VMODENUM
(
KEY
)
VMODENUM
(
BLOB
)
#undef VMODENUM
lib/libvmod_directors/tbl_healthy.h
0 → 100644
View file @
2676c2e3
VMODENUM
(
CHOSEN
)
VMODENUM
(
IGNORE
)
VMODENUM
(
ALL
)
#undef VMODENUM
lib/libvmod_directors/vmod.vcc
View file @
2676c2e3
...
@@ -409,13 +409,13 @@ To generate sharding keys using other hashes, use a custom vmod like
...
@@ -409,13 +409,13 @@ To generate sharding keys using other hashes, use a custom vmod like
.. _vmod blobdigest: https://code.uplex.de/uplex-varnish/libvmod-blobdigest/blob/master/README.rst
.. _vmod blobdigest: https://code.uplex.de/uplex-varnish/libvmod-blobdigest/blob/master/README.rst
$Method BACKEND .backend(
$Method BACKEND .backend(
ENUM {HASH, URL, KEY, BLOB} by=
"HASH"
,
ENUM {HASH, URL, KEY, BLOB} by=
HASH
,
INT key=0,
INT key=0,
BLOB key_blob=0,
BLOB key_blob=0,
INT alt=0,
INT alt=0,
REAL warmup=-1,
REAL warmup=-1,
BOOL rampup=1,
BOOL rampup=1,
ENUM {CHOSEN, IGNORE, ALL} healthy=
"CHOSEN"
)
ENUM {CHOSEN, IGNORE, ALL} healthy=
CHOSEN
)
Lookup a backend on the consistent hashing ring.
Lookup a backend on the consistent hashing ring.
...
...
lib/libvmod_directors/vmod_shard.c
View file @
2676c2e3
...
@@ -218,6 +218,22 @@ get_key(VRT_CTX, enum by_e by, VCL_INT key_int, VCL_BLOB key_blob)
...
@@ -218,6 +218,22 @@ get_key(VRT_CTX, enum by_e by, VCL_INT key_int, VCL_BLOB key_blob)
}
}
}
}
static
enum
by_e
parse_by_e
(
VCL_ENUM
e
)
{
#define VMODENUM(n) if (e == vmod_enum_ ## n) return(BY_ ## n);
#include "tbl_by.h"
WRONG
(
"illegal by enum"
);
}
static
enum
healthy_e
parse_healthy_e
(
VCL_ENUM
e
)
{
#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n);
#include "tbl_healthy.h"
WRONG
(
"illegal healthy enum"
);
}
VCL_BACKEND
v_matchproto_
(
td_directors_shard_backend
)
VCL_BACKEND
v_matchproto_
(
td_directors_shard_backend
)
vmod_shard_backend
(
VRT_CTX
,
struct
vmod_directors_shard
*
vshard
,
vmod_shard_backend
(
VRT_CTX
,
struct
vmod_directors_shard
*
vshard
,
VCL_ENUM
by_s
,
VCL_INT
key_int
,
VCL_BLOB
key_blob
,
VCL_INT
alt
,
VCL_ENUM
by_s
,
VCL_INT
key_int
,
VCL_BLOB
key_blob
,
VCL_INT
alt
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment