Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-vslp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-vslp
Commits
ce30412a
Commit
ce30412a
authored
Feb 04, 2016
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whitespace cleanup
parent
5e913b62
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
57 deletions
+68
-57
vslp_dir.c
src/vslp_dir.c
+68
-57
No files found.
src/vslp_dir.c
View file @
ce30412a
/*-
* Copyright 2009-201
5
UPLEX - Nils Goroll Systemoptimierung
* Copyright 2009-201
6
UPLEX - Nils Goroll Systemoptimierung
* All rights reserved.
*
* Authors: Nils Goroll <nils.goroll@uplex.de>
...
...
@@ -73,7 +73,8 @@ vslp_get_prefered_idx(const struct vslpdir *vslpd, const uint32_t key)
idx
=
i
;
else
if
(
i
==
n
-
1
)
idx
=
n
-
1
;
else
if
(
vslpd
->
hashcircle
[
i
].
point
<
key
&&
vslpd
->
hashcircle
[
i
+
1
].
point
>=
key
)
else
if
(
vslpd
->
hashcircle
[
i
].
point
<
key
&&
vslpd
->
hashcircle
[
i
+
1
].
point
>=
key
)
idx
=
i
+
1
;
else
if
(
vslpd
->
hashcircle
[
i
].
point
>
key
)
if
(
i
==
0
)
...
...
@@ -102,7 +103,8 @@ vslp_be_healthy(struct vslp_state *state, int chosen)
now
=
time
(
NULL
);
if
(
state
->
vslpd
->
bstate
[
chosen
].
recover_time
==
0
)
state
->
vslpd
->
bstate
[
chosen
].
recover_time
=
now
;
if
(
now
>=
(
state
->
vslpd
->
bstate
[
chosen
].
recover_time
+
state
->
vslpd
->
rampup_time
))
if
(
now
>=
(
state
->
vslpd
->
bstate
[
chosen
].
recover_time
+
state
->
vslpd
->
rampup_time
))
{
state
->
vslpd
->
bstate
[
chosen
].
state
=
1
;
state
->
vslpd
->
bstate
[
chosen
].
recover_time
=
0
;
...
...
@@ -148,10 +150,11 @@ vslp_choose_next(struct vslp_state *state, uint32_t n_retry)
if
(
i
>=
(
state
->
vslpd
->
n_backend
*
state
->
vslpd
->
replicas
))
i
=
i
-
(
state
->
vslpd
->
n_backend
*
state
->
vslpd
->
replicas
);
chosen
=
state
->
vslpd
->
hashcircle
[
i
].
host
;
n_retry
++
;
if
(
n_retry
>
(
state
->
vslpd
->
n_backend
*
state
->
vslpd
->
replicas
)
+
state
->
vslpd
->
n_backend
)
if
(
n_retry
>
state
->
vslpd
->
n_backend
*
state
->
vslpd
->
replicas
+
state
->
vslpd
->
n_backend
)
return
-
1
;
}
while
(
state
->
picklist
&
(
1
<<
chosen
));
state
->
picklist
|=
1
<<
chosen
;
...
...
@@ -300,7 +303,6 @@ vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas)
}
vslpd
->
replicas
=
replicas
;
for
(
i
=
0
;
i
<
vslpd
->
n_backend
;
i
++
)
{
for
(
j
=
0
;
j
<
replicas
;
j
++
)
{
int
len
=
strlen
(
vslpd
->
backend
[
i
]
->
vcl_name
)
...
...
@@ -312,7 +314,8 @@ vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas)
vslp_hash_sha256
(
s
);
vslpd
->
hashcircle
[
i
*
replicas
+
j
].
host
=
i
;
}
vslpd
->
bstate
[
i
].
canon_point
=
vslpd
->
hashcircle
[
i
*
replicas
].
point
;
vslpd
->
bstate
[
i
].
canon_point
=
vslpd
->
hashcircle
[
i
*
replicas
].
point
;
}
qsort
(
(
void
*
)
vslpd
->
hashcircle
,
vslpd
->
n_backend
*
replicas
,
sizeof
(
struct
vslp_hostnode
),
(
compar
)
hostnode_compare
);
...
...
@@ -321,7 +324,9 @@ vslpdir_init_hashcircle(struct vslpdir *vslpd, VCL_INT replicas)
{
for
(
j
=
0
;
j
<
replicas
;
j
++
)
{
VSL
(
SLT_Debug
,
0
,
"VSLP hashcircle[%5ld] = {point = %8x, host = %2d}
\n
"
,
VSL
(
SLT_Debug
,
0
,
"VSLP hashcircle[%5ld] = "
"{point = %8x, host = %2d}
\n
"
,
i
*
replicas
+
j
,
vslpd
->
hashcircle
[
i
*
replicas
+
j
].
point
,
vslpd
->
hashcircle
[
i
*
replicas
+
j
].
host
);
...
...
@@ -378,7 +383,8 @@ vslpdir_any_healthy(struct vslpdir *vslpd)
return
(
retval
);
}
VCL_BACKEND
vslpdir_pick_be
(
struct
vslpdir
*
vslpd
,
const
struct
vrt_ctx
*
ctx
,
uint32_t
hash
,
VCL_BACKEND
vslpdir_pick_be
(
struct
vslpdir
*
vslpd
,
const
struct
vrt_ctx
*
ctx
,
uint32_t
hash
,
VCL_INT
n_retry
,
VCL_BOOL
altsrv_p
,
VCL_BOOL
healthy
)
{
VCL_BACKEND
be
;
...
...
@@ -435,11 +441,13 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
if
(
chosen
<
0
)
{
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"VSLP failed to find other healthy backend for key %8x in restarts: %2i/%2i - using previous"
,
"VSLP failed to find other healthy backend "
"for key %8x in restarts: %2i/%2i - using previous"
,
hash
,
restarts
,
restarts_o
);
}
else
{
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"VSLP picked backend %2i for key %8x in restarts: %2i/%2i"
,
"VSLP picked backend %2i "
"for key %8x in restarts: %2i/%2i"
,
chosen
,
hash
,
restarts
,
restarts_o
);
be
=
vslpd
->
backend
[
chosen
];
AN
(
be
);
...
...
@@ -469,10 +477,12 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
chosen
=
vslp_choose_next_healthy
(
&
state
,
n_retry
);
if
(
chosen
<
0
)
{
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"VSLP found no alternative backend in healthy"
);
"VSLP found no alternative backend "
"in healthy"
);
}
else
{
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"VSLP picked alternative backend %2i for key %8x in healthy"
,
"VSLP picked alternative backend %2i "
"for key %8x in healthy"
,
chosen
,
hash
);
be
=
vslpd
->
backend
[
chosen
];
}
...
...
@@ -487,7 +497,8 @@ VCL_BACKEND vslpdir_pick_be(struct vslpdir *vslpd, const struct vrt_ctx *ctx, ui
"VSLP found no alternative backend in unhealthy"
);
}
else
{
VSLb
(
ctx
->
vsl
,
SLT_Debug
,
"VSLP picked alternative backend %2i for key %8x in unhealthy"
,
"VSLP picked alternative backend %2i "
"for key %8x in unhealthy"
,
chosen
,
hash
);
be
=
vslpd
->
backend
[
chosen
];
}
...
...
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