diff options
author | Han Zhou <hzhou8@ebay.com> | 2019-08-19 09:30:00 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-08-21 11:30:08 -0700 |
commit | 8e35461419a63fc5ca1e492994d08c02295137e1 (patch) | |
tree | e6d5ad83245237d78a1cf139eae9d74eda3010d9 /ovsdb/raft-private.c | |
parent | 923f01cad678228224ae4fe86466e2f61ab2c9d0 (diff) | |
download | openvswitch-8e35461419a63fc5ca1e492994d08c02295137e1.tar.gz |
ovsdb raft: Support leader election time change online.
A new unixctl command cluster/change-election-timer is implemented to
change leader election timeout base value according to the scale needs.
The change takes effect upon consensus of the cluster, implemented through
the append-request RPC. A new field "election-timer" is added to raft log
entry for this purpose.
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb/raft-private.c')
-rw-r--r-- | ovsdb/raft-private.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ovsdb/raft-private.c b/ovsdb/raft-private.c index e5e2c29cf..98c68a958 100644 --- a/ovsdb/raft-private.c +++ b/ovsdb/raft-private.c @@ -307,6 +307,10 @@ raft_entry_to_json(const struct raft_entry *e) if (e->servers) { json_object_put(json, "servers", json_clone(e->servers)); } + if (e->election_timer) { + raft_put_uint64(json, "election_timer", e->election_timer); + } + return json; } @@ -326,6 +330,7 @@ raft_entry_from_json(struct json *json, struct raft_entry *e) if (e->servers) { ovsdb_parser_put_error(&p, raft_servers_validate_json(e->servers)); } + e->election_timer = raft_parse_optional_uint64(&p, "election_timer"); struct ovsdb_error *error = ovsdb_parser_finish(&p); if (error) { @@ -556,6 +561,8 @@ raft_record_from_json__(struct raft_record *r, struct ovsdb_parser *p) ovsdb_parser_put_error( p, raft_servers_validate_json(r->entry.servers)); } + r->entry.election_timer = raft_parse_optional_uint64( + p, "election_timer"); r->entry.data = json_nullable_clone( ovsdb_parser_member(p, "data", OP_OBJECT | OP_ARRAY | OP_OPTIONAL)); @@ -597,6 +604,9 @@ raft_record_to_json(const struct raft_record *r) if (r->entry.servers) { json_object_put(json, "servers", json_clone(r->entry.servers)); } + if (r->entry.election_timer) { + raft_put_uint64(json, "election_timer", r->entry.election_timer); + } if (!uuid_is_zero(&r->entry.eid)) { json_object_put_format(json, "eid", UUID_FMT, UUID_ARGS(&r->entry.eid)); |