[ovs-dev] [PATCH 1/4] ovsdb: Rename replication related variable names.

Andy Zhou azhou at ovn.org
Wed Aug 3 23:57:02 UTC 2016


Current replication code refers the other ovsdb-sever instance as
a 'remote'. which is overloaded in ovsdb.

Switching to use active/backup instead to make it less confusing.
Active is the server that should be servicing the client, backup
server is the server that boots with the --sync-from option.

Signed-off-by: Andy Zhou <azhou at ovn.org>
---
 ovsdb/ovsdb-server.1.in | 18 +++++++--------
 ovsdb/ovsdb-server.c    | 58 ++++++++++++++++++++++++-------------------------
 ovsdb/replication.c     | 34 ++++++++++++++---------------
 ovsdb/replication.h     |  8 +++----
 tests/ovsdb-server.at   | 36 +++++++++++++++---------------
 5 files changed, 77 insertions(+), 77 deletions(-)

diff --git a/ovsdb/ovsdb-server.1.in b/ovsdb/ovsdb-server.1.in
index 1d932c0..0667419 100644
--- a/ovsdb/ovsdb-server.1.in
+++ b/ovsdb/ovsdb-server.1.in
@@ -188,20 +188,20 @@ again (with \fBovsdb\-server/add\-db\fR).
 Outputs a list of the currently configured databases added either through
 the command line or through the \fBovsdb\-server/add\-db\fR command.
 .
-.IP "\fBovsdb\-server/set\-remote\-ovsdb\-server \fIserver"
-Sets  the remote \fIserver\fR from which \fBovsdb\-server\fR connects through
-\fBovsdb\-server/connect\-remote\-ovsdb\-server\fR.
+.IP "\fBovsdb\-server/set\-active\-ovsdb\-server \fIserver"
+Sets  the active \fIserver\fR from which \fBovsdb\-server\fR connects through
+\fBovsdb\-server/connect\-active\-ovsdb\-server\fR.
 .
-.IP "\fBovsdb\-server/get\-remote\-ovsdb\-server"
-Gets the remote server from which \fBovsdb\-server\fR is currently synchronizing
+.IP "\fBovsdb\-server/get\-active\-ovsdb\-server"
+Gets the active server from which \fBovsdb\-server\fR is currently synchronizing
 its databases.
 .
-.IP "\fBovsdb\-server/connect\-remote\-ovsdb\-server"
+.IP "\fBovsdb\-server/connect\-active\-ovsdb\-server"
 Causes \fBovsdb\-server\fR to synchronize its databases with the server
-specified by \fBovsdb\-server/set\-remote\-ovsdb\-server\fR.
+specified by \fBovsdb\-server/set\-active\-ovsdb\-server\fR.
 .
-.IP "\fBovsdb\-server/disconnect\-remote\-ovsdb\-server"
-Causes \fBovsdb\-server\fR to  stop  synchronizing  its  databases with a remote server.
+.IP "\fBovsdb\-server/disconnect\-active\-ovsdb\-server"
+Causes \fBovsdb\-server\fR to  stop  synchronizing  its  databases with a active server.
 .
 .IP "\fBovsdb\-server/set\-sync\-excluded\-tables \fIdb\fB:\fItable\fR[\fB,\fIdb\fB:\fItable\fR]..."
 Sets the \fItable\fR whitin \fIdb\fR that will be excluded from synchronization.
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index bb65637..937c36e 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -69,7 +69,7 @@ static char *ca_cert_file;
 static bool bootstrap_ca_cert;
 
 /* Replication configuration. */
-static bool connect_to_remote_server;
+static bool is_backup_server;
 
 static unixctl_cb_func ovsdb_server_exit;
 static unixctl_cb_func ovsdb_server_compact;
@@ -77,10 +77,10 @@ static unixctl_cb_func ovsdb_server_reconnect;
 static unixctl_cb_func ovsdb_server_perf_counters_clear;
 static unixctl_cb_func ovsdb_server_perf_counters_show;
 static unixctl_cb_func ovsdb_server_disable_monitor_cond;
-static unixctl_cb_func ovsdb_server_set_remote_ovsdb_server;
-static unixctl_cb_func ovsdb_server_get_remote_ovsdb_server;
-static unixctl_cb_func ovsdb_server_connect_remote_ovsdb_server;
-static unixctl_cb_func ovsdb_server_disconnect_remote_ovsdb_server;
+static unixctl_cb_func ovsdb_server_set_active_ovsdb_server;
+static unixctl_cb_func ovsdb_server_get_active_ovsdb_server;
+static unixctl_cb_func ovsdb_server_connect_active_ovsdb_server;
+static unixctl_cb_func ovsdb_server_disconnect_active_ovsdb_server;
 static unixctl_cb_func ovsdb_server_set_sync_excluded_tables;
 static unixctl_cb_func ovsdb_server_get_sync_excluded_tables;
 
@@ -161,7 +161,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, struct shash *all_dbs,
         report_error_if_changed(reconfigure_ssl(all_dbs), &ssl_error);
         ovsdb_jsonrpc_server_run(jsonrpc);
 
-        if (connect_to_remote_server) {
+        if (is_backup_server) {
              replication_run(all_dbs);
         }
 
@@ -202,7 +202,7 @@ main_loop(struct ovsdb_jsonrpc_server *jsonrpc, struct shash *all_dbs,
         }
     }
 
-    disconnect_remote_server();
+    disconnect_active_server();
     free(remotes_error);
 }
 
@@ -341,14 +341,14 @@ main(int argc, char *argv[])
     unixctl_command_register("ovsdb-server/perf-counters-clear", "", 0, 0,
                              ovsdb_server_perf_counters_clear, NULL);
 
-    unixctl_command_register("ovsdb-server/set-remote-ovsdb-server", "", 0, 1,
-                              ovsdb_server_set_remote_ovsdb_server, NULL);
-    unixctl_command_register("ovsdb-server/get-remote-ovsdb-server", "", 0, 0,
-                              ovsdb_server_get_remote_ovsdb_server, NULL);
-    unixctl_command_register("ovsdb-server/connect-remote-ovsdb-server", "", 0, 0,
-                              ovsdb_server_connect_remote_ovsdb_server, NULL);
-    unixctl_command_register("ovsdb-server/disconnect-remote-ovsdb-server", "", 0, 0,
-                              ovsdb_server_disconnect_remote_ovsdb_server, NULL);
+    unixctl_command_register("ovsdb-server/set-active-ovsdb-server", "", 0, 1,
+                              ovsdb_server_set_active_ovsdb_server, NULL);
+    unixctl_command_register("ovsdb-server/get-active-ovsdb-server", "", 0, 0,
+                              ovsdb_server_get_active_ovsdb_server, NULL);
+    unixctl_command_register("ovsdb-server/connect-active-ovsdb-server", "", 0, 0,
+                              ovsdb_server_connect_active_ovsdb_server, NULL);
+    unixctl_command_register("ovsdb-server/disconnect-active-ovsdb-server", "", 0, 0,
+                              ovsdb_server_disconnect_active_ovsdb_server, NULL);
     unixctl_command_register("ovsdb-server/set-sync-excluded-tables", "", 0, 1,
                               ovsdb_server_set_sync_excluded_tables, NULL);
     unixctl_command_register("ovsdb-server/get-sync-excluded-tables", "", 0, 0,
@@ -371,7 +371,7 @@ main(int argc, char *argv[])
     sset_destroy(&remotes);
     sset_destroy(&db_filenames);
     unixctl_server_destroy(unixctl);
-    destroy_remote_server();
+    destroy_active_server();
 
     if (run_process && process_exited(run_process)) {
         int status = process_status(run_process);
@@ -1039,17 +1039,17 @@ report_error_if_changed(char *error, char **last_errorp)
 }
 
 static void
-ovsdb_server_set_remote_ovsdb_server(struct unixctl_conn *conn,
+ovsdb_server_set_active_ovsdb_server(struct unixctl_conn *conn,
                                      int argc OVS_UNUSED, const char *argv[],
                                      void *arg_ OVS_UNUSED)
 {
-    set_remote_ovsdb_server(argv[1]);
-    connect_to_remote_server = false;
+    set_active_ovsdb_server(argv[1]);
+    is_backup_server = true;
     unixctl_command_reply(conn, NULL);
 }
 
 static void
-ovsdb_server_get_remote_ovsdb_server(struct unixctl_conn *conn,
+ovsdb_server_get_active_ovsdb_server(struct unixctl_conn *conn,
                                      int argc OVS_UNUSED,
                                      const char *argv[] OVS_UNUSED,
                                      void *arg_ OVS_UNUSED)
@@ -1057,33 +1057,33 @@ ovsdb_server_get_remote_ovsdb_server(struct unixctl_conn *conn,
     struct ds s;
     ds_init(&s);
 
-    ds_put_format(&s, "%s\n", get_remote_ovsdb_server());
+    ds_put_format(&s, "%s\n", get_active_ovsdb_server());
 
     unixctl_command_reply(conn, ds_cstr(&s));
     ds_destroy(&s);
 }
 
 static void
-ovsdb_server_connect_remote_ovsdb_server(struct unixctl_conn *conn,
+ovsdb_server_connect_active_ovsdb_server(struct unixctl_conn *conn,
                                          int argc OVS_UNUSED,
                                          const char *argv[] OVS_UNUSED,
                                          void *arg_ OVS_UNUSED)
 {
-    if (!connect_to_remote_server) {
+    if (!is_backup_server) {
         replication_init();
-        connect_to_remote_server = true;
+        is_backup_server = true;
     }
     unixctl_command_reply(conn, NULL);
 }
 
 static void
-ovsdb_server_disconnect_remote_ovsdb_server(struct unixctl_conn *conn,
+ovsdb_server_disconnect_active_ovsdb_server(struct unixctl_conn *conn,
                                             int argc OVS_UNUSED,
                                             const char *argv[] OVS_UNUSED,
                                             void *arg_ OVS_UNUSED)
 {
-    disconnect_remote_server();
-    connect_to_remote_server = false;
+    disconnect_active_server();
+    is_backup_server = false;
     unixctl_command_reply(conn, NULL);
 }
 
@@ -1448,8 +1448,8 @@ parse_options(int *argcp, char **argvp[],
             break;
 
         case OPT_SYNC_FROM:
-            set_remote_ovsdb_server(optarg);
-            connect_to_remote_server = true;
+            set_active_ovsdb_server(optarg);
+            is_backup_server = true;
             break;
 
         case OPT_SYNC_EXCLUDE:
diff --git a/ovsdb/replication.c b/ovsdb/replication.c
index 099c52d..f49bfe3 100644
--- a/ovsdb/replication.c
+++ b/ovsdb/replication.c
@@ -32,7 +32,7 @@
 #include "table.h"
 #include "transaction.h"
 
-static char *remote_ovsdb_server;
+static char *active_ovsdb_server;
 static struct jsonrpc *rpc;
 static struct sset monitored_tables = SSET_INITIALIZER(&monitored_tables);
 static struct sset tables_blacklist = SSET_INITIALIZER(&tables_blacklist);
@@ -84,7 +84,7 @@ replication_init(void)
 void
 replication_run(struct shash *all_dbs)
 {
-    if (sset_is_empty(&monitored_tables) && remote_ovsdb_server) {
+    if (sset_is_empty(&monitored_tables) && active_ovsdb_server) {
         /* Reset local databases. */
         if (reset_dbs) {
             struct ovsdb_error *error = reset_databases(all_dbs);
@@ -98,7 +98,7 @@ replication_run(struct shash *all_dbs)
 
         /* Open JSON-RPC. */
         jsonrpc_close(rpc);
-        rpc = open_jsonrpc(remote_ovsdb_server);
+        rpc = open_jsonrpc(active_ovsdb_server);
         if (!rpc) {
             return;
         }
@@ -112,15 +112,15 @@ replication_run(struct shash *all_dbs)
 }
 
 void
-set_remote_ovsdb_server(const char *remote_server)
+set_active_ovsdb_server(const char *active_server)
 {
-    remote_ovsdb_server = nullable_xstrdup(remote_server);
+    active_ovsdb_server = nullable_xstrdup(active_server);
 }
 
 const char *
-get_remote_ovsdb_server(void)
+get_active_ovsdb_server(void)
 {
-    return remote_ovsdb_server;
+    return active_ovsdb_server;
 }
 
 void
@@ -139,7 +139,7 @@ get_tables_blacklist(void)
 }
 
 void
-disconnect_remote_server(void)
+disconnect_active_server(void)
 {
     jsonrpc_close(rpc);
     sset_clear(&monitored_tables);
@@ -147,15 +147,15 @@ disconnect_remote_server(void)
 }
 
 void
-destroy_remote_server(void)
+destroy_active_server(void)
 {
     jsonrpc_close(rpc);
     sset_destroy(&monitored_tables);
     sset_destroy(&tables_blacklist);
 
-    if (remote_ovsdb_server) {
-        free(remote_ovsdb_server);
-        remote_ovsdb_server = NULL;
+    if (active_ovsdb_server) {
+        free(active_ovsdb_server);
+        active_ovsdb_server = NULL;
     }
 }
 
@@ -402,10 +402,10 @@ check_for_notifications(struct shash *all_dbs)
         return;
     } else if (error) {
         jsonrpc_close(rpc);
-        rpc = open_jsonrpc(remote_ovsdb_server);
+        rpc = open_jsonrpc(active_ovsdb_server);
         if (!rpc) {
-            /* Remote server went down. */
-            disconnect_remote_server();
+            /* Active server went down. */
+            disconnect_active_server();
         }
         jsonrpc_msg_destroy(msg);
         return;
@@ -466,7 +466,7 @@ process_notification(struct json *table_updates, struct ovsdb *database)
 error:
     if (error) {
         ovsdb_error_assert(error);
-        disconnect_remote_server();
+        disconnect_active_server();
     }
 }
 
@@ -650,7 +650,7 @@ replication_usage(void)
 {
     printf("\n\
 Syncing options:\n\
-  --sync-from=SERVER      sync DATABASE from remote SERVER\n\
+  --sync-from=SERVER      sync DATABASE from active SERVER\n\
   --sync-exclude-tables=DB:TABLE,...\n\
                           exclude the TABLE in DB from syncing\n");
 }
diff --git a/ovsdb/replication.h b/ovsdb/replication.h
index 1b2d3e4..32ea806 100644
--- a/ovsdb/replication.h
+++ b/ovsdb/replication.h
@@ -32,12 +32,12 @@ struct db {
 
 void replication_init(void);
 void replication_run(struct shash *dbs);
-void set_remote_ovsdb_server(const char *remote_server);
-const char *get_remote_ovsdb_server(void);
+void set_active_ovsdb_server(const char *remote_server);
+const char *get_active_ovsdb_server(void);
 void set_tables_blacklist(const char *blacklist);
 struct sset get_tables_blacklist(void);
-void disconnect_remote_server(void);
-void destroy_remote_server(void);
+void disconnect_active_server(void);
+void destroy_active_server(void);
 const struct db *find_db(const struct shash *all_dbs, const char *db_name);
 void replication_usage(void);
 
diff --git a/tests/ovsdb-server.at b/tests/ovsdb-server.at
index e70498d..4044233 100644
--- a/tests/ovsdb-server.at
+++ b/tests/ovsdb-server.at
@@ -1078,29 +1078,29 @@ REPLICATION_EXAMPLES
 
 AT_BANNER([OVSDB -- ovsdb-server replication runtime management commands])
 
-#ovsdb-server/get-remote-ovsdb-server command
-AT_SETUP([ovsdb-server/get-remote-ovsdb-server])
-AT_KEYWORDS([ovsdb server replication get-remote])
+#ovsdb-server/get-active-ovsdb-server command
+AT_SETUP([ovsdb-server/get-active-ovsdb-server])
+AT_KEYWORDS([ovsdb server replication get-active])
 ordinal_schema > schema
 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
 on_exit 'kill `cat *.pid`'
 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile --sync-from=tcp:127.0.0.1:9999 db])
 
-AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server],
   [0], [tcp:127.0.0.1:9999
 ])
 AT_CLEANUP
 
-#*ovsdb-server/set-remote-ovsdb-server command
-AT_SETUP([ovsdb-server/set-remote-ovsdb-server])
-AT_KEYWORDS([ovsdb server replication set-remote])
+#*ovsdb-server/set-active-ovsdb-server command
+AT_SETUP([ovsdb-server/set-active-ovsdb-server])
+AT_KEYWORDS([ovsdb server replication set-active])
 ordinal_schema > schema
 AT_CHECK([ovsdb-tool create db schema], [0], [ignore], [ignore])
 on_exit 'kill `cat *.pid`'
 AT_CHECK([ovsdb-server --detach --no-chdir --pidfile db])
 
-AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-remote-ovsdb-server tcp:127.0.0.1:9999])
-AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-remote-ovsdb-server],
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:127.0.0.1:9999])
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/get-active-ovsdb-server],
   [0], [tcp:127.0.0.1:9999
 ])
 AT_CLEANUP
@@ -1167,9 +1167,9 @@ OVSDB_SERVER_SHUTDOWN
 OVSDB_SERVER_SHUTDOWN2
 AT_CLEANUP
 
-#ovsdb-server/connect-remote-ovsdb-server
-AT_SETUP([ovsdb-server/connect-remote-server])
-AT_KEYWORDS([ovsdb server replication connect-remote-server])
+#ovsdb-server/connect-active-ovsdb-server
+AT_SETUP([ovsdb-server/connect-active-server])
+AT_KEYWORDS([ovsdb server replication connect-active-server])
 replication_schema > schema
 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
@@ -1178,9 +1178,9 @@ AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server1.log --pidfil
 
 AT_CHECK([ovsdb-server --detach --no-chdir --log-file=ovsdb-server2.log --pidfile="`pwd`"/pid2 --remote=punix:db2.sock --unixctl="`pwd`"/unixctl2 db2], [0], [ignore], [ignore])
 
-AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-remote-ovsdb-server unix:db.sock], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/set-active-ovsdb-server unix:db.sock], [0], [ignore], [ignore], [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
 
-AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-remote-ovsdb-server], [0], [ignore], [ignore],
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/connect-active-ovsdb-server], [0], [ignore], [ignore],
         [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
 
 AT_CHECK([ovsdb-client transact unix:db.sock \
@@ -1204,9 +1204,9 @@ OVSDB_SERVER_SHUTDOWN
 OVSDB_SERVER_SHUTDOWN2
 AT_CLEANUP
 
-#ovsdb-server/disconnect-remote-server command
-AT_SETUP([ovsdb-server/disconnect-remote-server])
-AT_KEYWORDS([ovsdb server replication disconnect-remote-server])
+#ovsdb-server/disconnect-active-server command
+AT_SETUP([ovsdb-server/disconnect-active-server])
+AT_KEYWORDS([ovsdb server replication disconnect-active-server])
 replication_schema > schema
 AT_CHECK([ovsdb-tool create db1 schema], [0], [stdout], [ignore])
 AT_CHECK([ovsdb-tool create db2 schema], [0], [stdout], [ignore])
@@ -1224,7 +1224,7 @@ AT_CHECK([ovsdb-client transact unix:db.sock \
 
 OVS_WAIT_UNTIL([ovsdb-client dump unix:db2.sock | grep zero])
 
-AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-remote-ovsdb-server], [0], [ignore], [ignore],
+AT_CHECK([ovs-appctl -t "`pwd`"/unixctl2 ovsdb-server/disconnect-active-ovsdb-server], [0], [ignore], [ignore],
         [test ! -e pid || kill `cat pid`; test ! -e pid2 || kill `cat pid2`])
 
 AT_CHECK([ovsdb-client transact unix:db.sock \
-- 
1.9.1




More information about the dev mailing list