Set Binding RPCs cost to 1 69/50569/2
authorRobert Varga <rovarga@cisco.com>
Tue, 17 Jan 2017 17:57:55 +0000 (18:57 +0100)
committerRobert Varga <rovarga@cisco.com>
Wed, 18 Jan 2017 17:18:49 +0000 (18:18 +0100)
Default DOMRpcImplementation returns cost 0. Since invoking
a binding RPC involves some codec work, we want the binding
implementation to take a back seat of there is a native
RPC implementation (for example implemented in pure DOM terms).

Change-Id: I10e3bc6133980c6fc9750f02e94450655b67020f
Signed-off-by: Robert Varga <rovarga@cisco.com>
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/BindingDOMRpcImplementationAdapter.java

index 52ef07118653697137b300562455a6eab51d442e..095302941a1259555bdd6e2b42895915cec6a4a3 100644 (file)
@@ -37,6 +37,8 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation
 
     private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS
             = CacheBuilder.newBuilder().weakKeys().build();
+    // Default implementations are 0, we need to perform some translation, hence we have a slightly higher cost
+    private static final int COST = 1;
 
     private final BindingNormalizedNodeCodecRegistry codec;
     private final RpcServiceInvoker invoker;
@@ -72,6 +74,11 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation
         return transformResult(bindingResult);
     }
 
+    @Override
+    public long invocationCost() {
+        return COST;
+    }
+
     private DataObject deserilialize(final SchemaPath rpcPath, final NormalizedNode<?, ?> input) {
         if (input instanceof LazySerializedContainerNode) {
             return ((LazySerializedContainerNode) input).bindingData();
@@ -88,5 +95,4 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation
             final ListenableFuture<RpcResult<?>> bindingResult) {
         return LazyDOMRpcResultFuture.create(codec, bindingResult);
     }
-
 }