summaryrefslogtreecommitdiff
path: root/python/ovs/reconnect.py
diff options
context:
space:
mode:
authorAndrew Evans <aevans@nicira.com>2011-03-09 18:36:26 -0800
committerAndrew Evans <aevans@nicira.com>2011-03-09 18:40:03 -0800
commiteba18f0044cbe3654b4c796bbe7c056ca1793c70 (patch)
treea079d0ed481c6c8352922baa17e275672307bf9b /python/ovs/reconnect.py
parent926ea16ea3b38df0f34cdccdea92aa4933ca9dd4 (diff)
downloadopenvswitch-eba18f0044cbe3654b4c796bbe7c056ca1793c70.tar.gz
reconnect: Track last-disconnected time.
Commit a4613b01ab (ovsdb: Change the way connection duration time is reported in Manager table.), pushed earlier today, requires this commit, so OVSDB has been unbuildable from then to now.
Diffstat (limited to 'python/ovs/reconnect.py')
-rw-r--r--python/ovs/reconnect.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/python/ovs/reconnect.py b/python/ovs/reconnect.py
index 90485799b..3a7118859 100644
--- a/python/ovs/reconnect.py
+++ b/python/ovs/reconnect.py
@@ -146,6 +146,7 @@ class Reconnect(object):
self.backoff = 0
self.last_received = now
self.last_connected = now
+ self.last_disconnected = now
self.max_tries = None
self.creation_time = now
@@ -341,6 +342,9 @@ class Reconnect(object):
self.info_level("%s: %s attempt timed out"
% (self.name, type))
+ if (self.state in (Reconnect.Active, Reconnect.Idle)):
+ self.last_disconnected = now
+
# Back off
if (self.state in (Reconnect.Active, Reconnect.Idle) and
(self.last_received - self.last_connected >= self.backoff or
@@ -534,17 +538,28 @@ class Reconnect(object):
else:
return 0
+ def get_disconnect_duration(self, now):
+ """Returns the number of milliseconds for which this FSM has been
+ continuously disconnected from its peer. (If this FSM is not currently
+ connected, this is 0.)"""
+ if not self.is_connected():
+ return now - self.last_disconnected
+ else:
+ return 0
+
def get_stats(self, now):
class Stats(object):
pass
stats = Stats()
stats.creation_time = self.creation_time
stats.last_connected = self.last_connected
+ stats.last_disconnected = self.last_disconnected
stats.last_received = self.last_received
stats.backoff = self.backoff
stats.seqno = self.seqno
stats.is_connected = self.is_connected()
stats.current_connection_duration = self.get_connection_duration(now)
+ stats.current_disconnect_duration = self.get_disconnect_duration(now)
stats.total_connected_duration = (stats.current_connection_duration +
self.total_connected_duration)
stats.n_attempted_connections = self.n_attempted_connections