From c5f71aa47f789a3e1cb26760aa1fa55835d0f52f Mon Sep 17 00:00:00 2001 From: mick Date: Wed, 23 Nov 2016 14:24:44 -0500 Subject: [PATCH 1/5] DISPATCH-113 -- expose topology_last_changed to management --- python/qpid_dispatch/management/qdrouter.json | 5 +++++ python/qpid_dispatch_internal/router/node.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json index 53b171d529..107b291dd7 100644 --- a/python/qpid_dispatch/management/qdrouter.json +++ b/python/qpid_dispatch/management/qdrouter.json @@ -1209,7 +1209,12 @@ "cost": { "description": "Reachability cost", "type": "integer" + }, + "lastTopoChange": { + "description": "Timestamp showing the most recent change to this node's neighborhood.", + "type": "string" } + } }, diff --git a/python/qpid_dispatch_internal/router/node.py b/python/qpid_dispatch_internal/router/node.py index 231e3f2298..c0777097f1 100644 --- a/python/qpid_dispatch_internal/router/node.py +++ b/python/qpid_dispatch_internal/router/node.py @@ -59,7 +59,8 @@ def refresh_entity(self, attributes): "linkState": [ls for ls in self.link_state.peers], # List of neighbour nodes "nextHop": "(self)", "validOrigins": [], - "address": Address.topological(self.my_id, area=self.container.area) + "address": Address.topological(self.my_id, area=self.container.area), + "lastTopoChange" : "%10.6f" % self.last_topology_change }) From 356c8ec589d877203bb3d7dd510bdfcd1cc31cf3 Mon Sep 17 00:00:00 2001 From: mick Date: Mon, 28 Nov 2016 09:43:10 -0500 Subject: [PATCH 2/5] DISPATCH-113 -- make qdstat show last topo change. --- tools/qdstat | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tools/qdstat b/tools/qdstat index ee9f6b1408..3c983238f6 100755 --- a/tools/qdstat +++ b/tools/qdstat @@ -25,7 +25,7 @@ import sys import locale import socket import re -from time import ctime +import time import qpid_dispatch_site from qpid_dispatch.management.client import Url, Node, Entity from qpid_dispatch_internal.management.qdrouter import QdSchema @@ -290,13 +290,19 @@ class BusManager(Node): heads.append(Header("valid-origins")) rows = [] - cols = ('id', 'nextHop', 'routerLink') + cols = ('id', 'nextHop', 'routerLink', 'lastTopoChange') if self.opts.verbose: cols += ('cost', 'linkState', 'validOrigins') objects = self.query('org.apache.qpid.dispatch.router.node', cols) + # Find the most recent topo change in this neighborhood. + lastTopoChange = 0.0 + for node in objects: row = [] + if node.lastTopoChange: + if float(node.lastTopoChange) > lastTopoChange: + lastTopoChange = float(node.lastTopoChange) row.append(node.id) if node.nextHop != None: row.append(node.nextHop) @@ -312,6 +318,8 @@ class BusManager(Node): rows.append(row) if len(rows) > 0: title = "Routers in the Network" + topoLine = "\nLast Topology Change: " + time.strftime('%A %b %d %H:%M:%S %Y',time.gmtime(lastTopoChange)) + title += topoLine sort = Sorter(heads, rows, 'router-id') dispRows = sort.getSorted() disp.formattedTable(title, heads, dispRows) From 84cb9222c27248622ecf4e894b79ceb413c423b9 Mon Sep 17 00:00:00 2001 From: mick Date: Mon, 28 Nov 2016 11:10:17 -0500 Subject: [PATCH 3/5] DISPATCH-113 -- use integer: second-granularity is plenty. --- python/qpid_dispatch/management/qdrouter.json | 2 +- python/qpid_dispatch_internal/router/node.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/qpid_dispatch/management/qdrouter.json b/python/qpid_dispatch/management/qdrouter.json index 107b291dd7..4435870f62 100644 --- a/python/qpid_dispatch/management/qdrouter.json +++ b/python/qpid_dispatch/management/qdrouter.json @@ -1212,7 +1212,7 @@ }, "lastTopoChange": { "description": "Timestamp showing the most recent change to this node's neighborhood.", - "type": "string" + "type": "integer" } } diff --git a/python/qpid_dispatch_internal/router/node.py b/python/qpid_dispatch_internal/router/node.py index c0777097f1..2bbd52eccb 100644 --- a/python/qpid_dispatch_internal/router/node.py +++ b/python/qpid_dispatch_internal/router/node.py @@ -60,7 +60,7 @@ def refresh_entity(self, attributes): "nextHop": "(self)", "validOrigins": [], "address": Address.topological(self.my_id, area=self.container.area), - "lastTopoChange" : "%10.6f" % self.last_topology_change + "lastTopoChange" : "%10d" % self.last_topology_change }) From d1dd7ba76113b3689da40abc365ec55590035f36 Mon Sep 17 00:00:00 2001 From: mick Date: Mon, 28 Nov 2016 11:23:38 -0500 Subject: [PATCH 4/5] DISPATCH-113 -- use interegr, not string. Also clarify GMT in printout in qdstat. --- python/qpid_dispatch_internal/router/node.py | 4 ++-- tools/qdstat | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/python/qpid_dispatch_internal/router/node.py b/python/qpid_dispatch_internal/router/node.py index 2bbd52eccb..98221694ab 100644 --- a/python/qpid_dispatch_internal/router/node.py +++ b/python/qpid_dispatch_internal/router/node.py @@ -60,7 +60,7 @@ def refresh_entity(self, attributes): "nextHop": "(self)", "validOrigins": [], "address": Address.topological(self.my_id, area=self.container.area), - "lastTopoChange" : "%10d" % self.last_topology_change + "lastTopoChange" : self.last_topology_change }) @@ -124,7 +124,7 @@ def tick(self, now): ## Enter flux mode if things are changing ## if self.link_state_changed or self.recompute_topology: - self.last_topology_change = now + self.last_topology_change = int(round(now)) if not self.flux_mode: self.flux_mode = True self.container.log(LOG_TRACE, "Entered Router Flux Mode") diff --git a/tools/qdstat b/tools/qdstat index 3c983238f6..6dde34e8f5 100755 --- a/tools/qdstat +++ b/tools/qdstat @@ -318,7 +318,8 @@ class BusManager(Node): rows.append(row) if len(rows) > 0: title = "Routers in the Network" - topoLine = "\nLast Topology Change: " + time.strftime('%A %b %d %H:%M:%S %Y',time.gmtime(lastTopoChange)) + # Use gmtime to make times comparable across large networks. + topoLine = "\nLast Topology Change: " + time.strftime('%A %b %d %H:%M:%S %Y',time.gmtime(lastTopoChange)) + " GMT" title += topoLine sort = Sorter(heads, rows, 'router-id') dispRows = sort.getSorted() From 3a3e7938bfc256e4fcddc75bed074f2ad0a0cbe8 Mon Sep 17 00:00:00 2001 From: mick Date: Mon, 28 Nov 2016 12:40:41 -0500 Subject: [PATCH 5/5] DISPATCH-113 -- messed up the time import statement. --- tools/qdstat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/qdstat b/tools/qdstat index 6dde34e8f5..ed8f7c159d 100755 --- a/tools/qdstat +++ b/tools/qdstat @@ -25,7 +25,7 @@ import sys import locale import socket import re -import time +from time import ctime, strftime, gmtime import qpid_dispatch_site from qpid_dispatch.management.client import Url, Node, Entity from qpid_dispatch_internal.management.qdrouter import QdSchema @@ -319,7 +319,7 @@ class BusManager(Node): if len(rows) > 0: title = "Routers in the Network" # Use gmtime to make times comparable across large networks. - topoLine = "\nLast Topology Change: " + time.strftime('%A %b %d %H:%M:%S %Y',time.gmtime(lastTopoChange)) + " GMT" + topoLine = "\nLast Topology Change: " + strftime('%A %b %d %H:%M:%S %Y',gmtime(lastTopoChange)) + " GMT" title += topoLine sort = Sorter(heads, rows, 'router-id') dispRows = sort.getSorted()