From 6a3025837b6cdd7d6fc09518ecd51f21d0425da5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 17 Mar 2015 11:05:28 -0400 Subject: [PATCH] Batch nodes to plugin calls Every node was serialized in being passed to plugins. Fix this by grouping the nodes by the handler function, and then calling them by batch. This still serializes each plugin, but for now this should suffice. --- confluent_server/confluent/core.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 9800cdc8..f11d4816 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -426,16 +426,22 @@ def handle_node_request(configmanager, inputdata, operation, plugpath = None if 'default' in plugroute: plugpath = plugroute['default'] + nodesbyhandler = {} for node in nodes: for attrname in plugroute['pluginattrs']: if attrname in nodeattr[node]: plugpath = nodeattr[node][attrname]['value'] if plugpath is not None: hfunc = getattr(pluginmap[plugpath], operation) - passvalues.append(hfunc( - nodes=(node,), element=pathcomponents, - configmanager=configmanager, - inputdata=inputdata)) + if hfunc in nodesbyhandler: + nodesbyhandler[hfunc].append(node) + else: + nodesbyhandler[hfunc] = [node] + for hfunc in nodesbyhandler.iterkeys(): + passvalues.append(hfunc( + nodes=nodesbyhandler[hfunc], element=pathcomponents, + configmanager=configmanager, + inputdata=inputdata)) if isnoderange: return itertools.chain(*passvalues) elif isinstance(passvalues[0], console.Console):