Switch blockdev_getmirrorstatus_multi to per-node bodies
authorIustin Pop <iustin@google.com>
Wed, 21 Dec 2011 13:48:13 +0000 (14:48 +0100)
committerIustin Pop <iustin@google.com>
Wed, 21 Dec 2011 16:02:59 +0000 (17:02 +0100)
Even for a small 4-node node-group, this reduces the payload of this
RPC call by half for each node; for a big node group, previous testing
(using a different patch) showed a general reduction in traffic over
the entire cluster verify from 9MB to ~2MB.

We only need to change the RPC call, not its return value, since that
was already in an "optimised" form.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/rpc_defs.py
lib/server/noded.py

index 13cb094..f4b0c46 100644 (file)
@@ -105,6 +105,17 @@ def _BlockdevGetMirrorStatusPostProc(result):
   return result
 
 
+def _BlockdevGetMirrorStatusMultiPreProc(node, args):
+  """Prepares the appropriate node values for blockdev_getmirrorstatus_multi.
+
+  """
+  # there should be only one argument to this RPC, already holding a
+  # node->disks dictionary, we just need to extract the value for the
+  # current node
+  assert len(args) == 1
+  return [args[0][node]]
+
+
 def _BlockdevGetMirrorStatusMultiPostProc(result):
   """Post-processor for L{rpc.RpcRunner.call_blockdev_getmirrorstatus_multi}.
 
@@ -396,7 +407,8 @@ _BLOCKDEV_CALLS = [
     "Request status of a (mirroring) device"),
   ("blockdev_getmirrorstatus_multi", MULTI, TMO_NORMAL, [
     ("node_disks", ED_NODE_TO_DISK_DICT, None),
-    ], None, _BlockdevGetMirrorStatusMultiPostProc,
+    ], _BlockdevGetMirrorStatusMultiPreProc,
+   _BlockdevGetMirrorStatusMultiPostProc,
     "Request status of (mirroring) devices from multiple nodes"),
   ]
 
index b8f848c..22091d7 100644 (file)
@@ -288,10 +288,7 @@ class NodeHttpServer(http.server.HttpServer):
     """
     (node_disks, ) = params
 
-    node_name = netutils.Hostname.GetSysName()
-
-    disks = [objects.Disk.FromDict(dsk_s)
-             for dsk_s in node_disks.get(node_name, [])]
+    disks = [objects.Disk.FromDict(dsk_s) for dsk_s in node_disks]
 
     result = []