Change monitor to support flexible shard config.
authorGary Wu <Gary.Wu1@huawei.com>
Tue, 19 May 2015 23:32:45 +0000 (16:32 -0700)
committerGary Wu <Gary.Wu1@huawei.com>
Wed, 20 May 2015 00:03:47 +0000 (17:03 -0700)
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 <Gary.Wu1@huawei.com>
test/tools/clustering/cluster-monitor/monitor.py
test/tools/clustering/cluster-monitor/readme.txt

index 8cafbf5763fdac709756d44665968c3678c141c5..403ec84f3de1a91a6b8e2a5fae931f33cd012a71 100644 (file)
@@ -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()
index b0cceca81bb84aa404e7135ac5652121d66b3546..6a1b2bb960b1644101dabae5f75608f1c30553be 100644 (file)
@@ -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.