From 81b8a0502b19237f88319025e43fc789353bb62f Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Tue, 19 May 2015 16:32:45 -0700 Subject: [PATCH] Change monitor to support flexible shard config. Change cluster monitor.py to not require that all nodes have the same shards. This is useful for monitoring large clusters that have small replication factors. Change-Id: I20d437b3b3bc21f65fdc0e496b6c1b38e23f95b5 Signed-off-by: Gary Wu --- test/tools/clustering/cluster-monitor/monitor.py | 16 +++++++--------- test/tools/clustering/cluster-monitor/readme.txt | 5 ++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/test/tools/clustering/cluster-monitor/monitor.py b/test/tools/clustering/cluster-monitor/monitor.py index 8cafbf5763..403ec84f3d 100644 --- a/test/tools/clustering/cluster-monitor/monitor.py +++ b/test/tools/clustering/cluster-monitor/monitor.py @@ -5,8 +5,7 @@ Author: Phillip Shea Updated: 2015-May-07 This tool provides real-time visualization of the cluster member roles for all -shards in the config datastore. It is assumed that all cluster members have the -same shards. +shards in the config datastore. A file named 'cluster.json' contaning a list of the IP addresses of the controllers is required. This resides in the same directory as monitor.py. @@ -109,6 +108,7 @@ except: exit(1) controller_names = [] +Shards = set() # Retrieve controller names and shard names. for controller in controllers: url = "http://" + controller + ":8181/jolokia/read/org.opendaylight.controller:" @@ -129,14 +129,12 @@ for controller in controllers: print pos print name[:8] controller_names.append(name[:name.find('-shard-')]) + + # collect shards found in any controller; does not require all controllers to have the same shards + for localShard in data['value']['LocalShards']: + shardName = localShard[(localShard.find("-shard-")+7):localShard.find("-config")] + Shards.add(shardName) print controller_names -# Putting shard names in a list, assuming all controllers have the same shards. -Shards = data['value']['LocalShards'] -for i, shard in enumerate(Shards): - Shards[i] = Shards[i].replace('member-', '') - Shards[i] = Shards[i].replace('-shard-', '') - Shards[i] = Shards[i].replace('-config', '') - Shards[i] = Shards[i].replace(Shards[i][0], '') print Shards stdscr = curses.initscr() diff --git a/test/tools/clustering/cluster-monitor/readme.txt b/test/tools/clustering/cluster-monitor/readme.txt index b0cceca81b..6a1b2bb960 100644 --- a/test/tools/clustering/cluster-monitor/readme.txt +++ b/test/tools/clustering/cluster-monitor/readme.txt @@ -4,8 +4,7 @@ Updated: 2015-May-07 This tool provides real-time visualization of the cluster member roles for all shards in the config datastore. It is useful for understanding cluster behavior -in when controllers are isolated, downed, or rebooted. The tool assumes that all -cluster members have the same shards. +in when controllers are isolated, downed, or rebooted. A file named 'cluster.json' containg a list of the IP addresses of the controllers is required. This resides in the same directory as monitor.py. @@ -72,4 +71,4 @@ timed_isolation.py Future enhancements: - Add operational shards. \ No newline at end of file + Add operational shards. -- 2.36.6