Skip to content

Commit

Permalink
Merge pull request #89 from unicell/maglev
Browse files Browse the repository at this point in the history
Add Maglev hashing to scheduler options in config.proto
  • Loading branch information
liuyuan10 committed Jun 12, 2020
2 parents 5027e13 + e6d1760 commit 3e9b09e
Show file tree
Hide file tree
Showing 6 changed files with 173 additions and 84 deletions.
2 changes: 2 additions & 0 deletions common/seesaw/seesaw.go
Expand Up @@ -316,6 +316,7 @@ const (
LBSchedulerLC
LBSchedulerWLC
LBSchedulerSH
LBSchedulerMH
)

var schedulerNames = map[LBScheduler]string{
Expand All @@ -325,6 +326,7 @@ var schedulerNames = map[LBScheduler]string{
LBSchedulerLC: "lc",
LBSchedulerWLC: "wlc",
LBSchedulerSH: "sh",
LBSchedulerMH: "mh",
}

// String returns the string representation of a LBScheduler.
Expand Down
2 changes: 2 additions & 0 deletions engine/config/config.go
Expand Up @@ -468,6 +468,8 @@ func addVservers(c *Cluster, p *pb.Cluster) error {
scheduler = seesaw.LBSchedulerWLC
case pb.VserverEntry_SH:
scheduler = seesaw.LBSchedulerSH
case pb.VserverEntry_MH:
scheduler = seesaw.LBSchedulerMH
default:
// TODO(angusc): Consider this VServer broken.
log.Errorf("%v: Unsupported scheduler %v", vs.GetName(), ve.GetScheduler())
Expand Down
40 changes: 40 additions & 0 deletions engine/config/config_test.go
Expand Up @@ -532,6 +532,46 @@ var vserverTests = []struct {
},
},
},
{
"1 Vserver with Unicast address and Maglev scheduler",
"vservers2.pb",
map[string]*Vserver{
"api.gateway1@as-hkg": {
"api.gateway1@as-hkg",
seesaw.Host{
Hostname: "gateway1-vip1.example.com.",
IPv4Addr: net.ParseIP("192.168.36.1").To4(),
IPv4Mask: net.CIDRMask(26, 32),
IPv6Addr: net.ParseIP("2015:cafe:36::a800:1ff:ffee:dd01"),
IPv6Mask: net.CIDRMask(64, 128),
},
map[string]*VserverEntry{
"443/TCP": {
Port: 443,
Proto: seesaw.IPProtoTCP,
Scheduler: seesaw.LBSchedulerMH,
Mode: seesaw.LBModeDSR, // protobuf default
Healthchecks: make(map[string]*Healthcheck),
},
},
make(map[string]*seesaw.Backend),
make(map[string]*Healthcheck),
map[string]*seesaw.VIP{
"192.168.36.1 (Unicast)": {
seesaw.NewIP(net.ParseIP("192.168.36.1")),
seesaw.UnicastVIP,
},
"2015:cafe:36:0:a800:1ff:ffee:dd01 (Unicast)": {
seesaw.NewIP(net.ParseIP("2015:cafe:36::a800:1ff:ffee:dd01")),
seesaw.UnicastVIP,
},
},
true,
false,
nil,
},
},
},
}

func readHealthcheck(f string) (*pb.Healthcheck, error) {
Expand Down
20 changes: 20 additions & 0 deletions engine/config/testdata/vservers2.pb
@@ -0,0 +1,20 @@
seesaw_vip <
fqdn: "seesaw-vip1.example.com."
ipv4: "192.168.36.16/26"
status: PRODUCTION
>
vserver <
name: "api.gateway1@as-hkg"
rp: "foo"
entry_address <
fqdn: "gateway1-vip1.example.com."
ipv4: "192.168.36.1/26"
ipv6: "2015:cafe:36::a800:1ff:ffee:dd01/64"
status: PRODUCTION
>
vserver_entry <
protocol: TCP
port: 443
scheduler: MH
>
>

0 comments on commit 3e9b09e

Please sign in to comment.