[ovs-dev] [PATCH 2/2] ovsdb: Change the way connection duration time is reported in Manager table.

Andrew Evans aevans at nicira.com
Tue Mar 8 22:38:18 UTC 2011


Commit 0b3e7a8b71 (ovsdb-server: Write manager status information to Manager
table.) attempted to provide managers with the ability to debug manager-related
connection problems, but it turns out that reporting "time_in_state" is not
very useful, because the state is constantly changing. What people really want
is the time each manager has been connected or disconnected, depending on the
current connection state.

Replace "time_in_state" key with "time_connected" and "time_disconnected"
keys. Only one exists at a time, and time is in seconds.

Bug #4833.
---
 ovsdb/jsonrpc-server.c |    5 ++++-
 ovsdb/jsonrpc-server.h |    2 +-
 ovsdb/ovsdb-server.c   |    5 +++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 92228be..713c518 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -470,7 +470,10 @@ ovsdb_jsonrpc_session_get_status(const struct ovsdb_jsonrpc_remote *remote,
 
     jsonrpc_session_get_reconnect_stats(js, &rstats);
     status->state = rstats.state;
-    status->state_elapsed = rstats.state_elapsed;
+    status->conn_secs = (rstats.is_connected
+                         ? rstats.current_connection_duration
+                         : rstats.current_disconnect_duration
+                         ) / 1000;
 
     return;
 }
diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h
index e404870..691b55e 100644
--- a/ovsdb/jsonrpc-server.h
+++ b/ovsdb/jsonrpc-server.h
@@ -38,7 +38,7 @@ void ovsdb_jsonrpc_server_set_remotes(struct ovsdb_jsonrpc_server *,
 struct ovsdb_jsonrpc_remote_status {
     const char *state;
     int last_error;
-    unsigned int state_elapsed;
+    unsigned int conn_secs;
     bool is_connected;
 };
 void ovsdb_jsonrpc_server_get_remote_status(
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index fac78c8..9eb58eb 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -495,8 +495,9 @@ update_remote_row(const struct ovsdb_row *row, struct ovsdb_txn *txn,
 
     keys[n] = xstrdup("state");
     values[n++] = xstrdup(status->state);
-    keys[n] = xstrdup("time_in_state");
-    values[n++] = xasprintf("%u", status->state_elapsed);
+    keys[n] = xstrdup(status->is_connected ? "time_connected"
+                      : "time_disconnected");
+    values[n++] = xasprintf("%u", status->conn_secs);
     if (status->last_error) {
         keys[n] = xstrdup("last_error");
         values[n++] =
-- 
1.7.2.3




More information about the dev mailing list