diff options
author | Ben Pfaff <blp@ovn.org> | 2017-12-31 21:15:58 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2018-03-24 12:04:53 -0700 |
commit | 1b1d2e6daa563cc91f974ffdc082fb3a8b424801 (patch) | |
tree | 9cc5df01b7af35962d5f40d0ffd8882fb277e047 /lib/jsonrpc.c | |
parent | 53178986d7fc86bcfc2f297b547a97ee71a21bb7 (diff) | |
download | openvswitch-1b1d2e6daa563cc91f974ffdc082fb3a8b424801.tar.gz |
ovsdb: Introduce experimental support for clustered databases.
This commit adds support for OVSDB clustering via Raft. Please read
ovsdb(7) for information on how to set up a clustered database. It is
simple and boils down to running "ovsdb-tool create-cluster" on one server
and "ovsdb-tool join-cluster" on each of the others and then starting
ovsdb-server in the usual way on all of them.
One you have a clustered database, you configure ovn-controller and
ovn-northd to use it by pointing them to all of the servers, e.g. where
previously you might have said "tcp:1.2.3.4" was the database server,
now you say that it is "tcp:1.2.3.4,tcp:5.6.7.8,tcp:9.10.11.12".
This also adds support for database clustering to ovs-sandbox.
Acked-by: Justin Pettit <jpettit@ovn.org>
Tested-by: aginwala <aginwala@asu.edu>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/jsonrpc.c')
-rw-r--r-- | lib/jsonrpc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/jsonrpc.c b/lib/jsonrpc.c index 036bdf469..f71026271 100644 --- a/lib/jsonrpc.c +++ b/lib/jsonrpc.c @@ -562,6 +562,16 @@ jsonrpc_create_error(struct json *error, const struct json *id) json_clone(id)); } +struct jsonrpc_msg * +jsonrpc_msg_clone(const struct jsonrpc_msg *old) +{ + return jsonrpc_create(old->type, old->method, + json_nullable_clone(old->params), + json_nullable_clone(old->result), + json_nullable_clone(old->error), + json_nullable_clone(old->id)); +} + const char * jsonrpc_msg_type_to_string(enum jsonrpc_msg_type type) { @@ -753,6 +763,16 @@ jsonrpc_msg_to_json(struct jsonrpc_msg *m) return json; } + +char * +jsonrpc_msg_to_string(const struct jsonrpc_msg *m) +{ + struct jsonrpc_msg *copy = jsonrpc_msg_clone(m); + struct json *json = jsonrpc_msg_to_json(copy); + char *s = json_to_string(json, JSSF_SORT); + json_destroy(json); + return s; +} /* A JSON-RPC session with reconnection. */ @@ -877,6 +897,15 @@ jsonrpc_session_close(struct jsonrpc_session *s) } } +struct jsonrpc * +jsonrpc_session_steal(struct jsonrpc_session *s) +{ + struct jsonrpc *rpc = s->rpc; + s->rpc = NULL; + jsonrpc_session_close(s); + return rpc; +} + static void jsonrpc_session_disconnect(struct jsonrpc_session *s) { |