Instantiate faster RpcServiceInvokers 23/21223/3
authorRobert Varga <rovarga@cisco.com>
Wed, 27 May 2015 15:00:07 +0000 (17:00 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 27 May 2015 20:18:06 +0000 (20:18 +0000)
Now that we have the SchemaPath->Method mapping available and
RpcServiceInvoker can instantiate efficient invokers based on the
QName->Method mapping, switch over to them by creating an intermediate
map.

Change-Id: If5e17924d9deb494045965578cfcec6d321d04d2
Signed-off-by: Robert Varga <rovarga@cisco.com>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java

index c81cce5a4b752e998b7b1b07015be77e24f60da5..2023840e97d4d0df50185602994ef7aeed16ada2 100644 (file)
@@ -14,7 +14,9 @@ import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
 import java.lang.reflect.Method;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
@@ -47,7 +49,12 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation
             this.invoker = SERVICE_INVOKERS.get(type, new Callable<RpcServiceInvoker>() {
                 @Override
                 public RpcServiceInvoker call() {
-                    return RpcServiceInvoker.from(type);
+                    final Map<QName, Method> map = new HashMap<>();
+                    for (Entry<SchemaPath, Method> e : localNameToMethod.entrySet()) {
+                        map.put(e.getKey().getLastComponent(), e.getValue());
+                    }
+
+                    return RpcServiceInvoker.from(map);
                 }
             });
         } catch (ExecutionException e) {