Use Binding{Data,RpcFuture}Aware 25/73825/6
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 9 Jul 2018 02:33:16 +0000 (04:33 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Sat, 14 Jul 2018 01:54:37 +0000 (21:54 -0400)
In order to bridge mdsal and controller binding interfaces, we need
to have a common way of accessing the binding future. Companion MDSAL
patch added Binding{Data,RpcFuture}Aware interfaces, which exposes
just that, and his patch makes use of it in the controller.

JIRA: SFC-222
Change-Id: If2407f4950de1b34e809b275cc2afc4cfefc8a10
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingDOMRpcImplementationAdapter.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDOMRpcResultFuture.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedContainerNode.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/RpcServiceAdapter.java

index 7e07901..1e75039 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.RpcService;
@@ -74,8 +75,8 @@ public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation
     }
 
     private DataObject deserialize(final SchemaPath rpcPath, final NormalizedNode<?, ?> input) {
-        if (input instanceof LazySerializedContainerNode) {
-            return ((LazySerializedContainerNode) input).bindingData();
+        if (input instanceof BindingDataAware) {
+            return ((BindingDataAware) input).bindingData();
         }
         final SchemaPath inputSchemaPath = rpcPath.createChild(inputQname);
         return codec.fromNormalizedNodeRpcData(inputSchemaPath, (ContainerNode) input);
index f22b881..f16f34e 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.md.sal.binding.impl;
 
 import com.google.common.base.Preconditions;
@@ -19,12 +18,13 @@ import java.util.concurrent.TimeoutException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 
-final class LazyDOMRpcResultFuture implements CheckedFuture<DOMRpcResult, DOMRpcException> {
+final class LazyDOMRpcResultFuture implements CheckedFuture<DOMRpcResult, DOMRpcException>, BindingRpcFutureAware {
 
     private final ListenableFuture<RpcResult<?>> bindingFuture;
     private final BindingNormalizedNodeSerializer codec;
@@ -41,7 +41,8 @@ final class LazyDOMRpcResultFuture implements CheckedFuture<DOMRpcResult, DOMRpc
         return new LazyDOMRpcResultFuture(bindingResult, codec);
     }
 
-    ListenableFuture<RpcResult<?>> getBindingFuture() {
+    @Override
+    public ListenableFuture<RpcResult<?>> getBindingFuture() {
         return bindingFuture;
     }
 
index 5066ed5..bed7d31 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.controller.md.sal.binding.impl;
 import java.util.Collection;
 import java.util.Map;
 import java.util.Optional;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingDataAware;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -23,7 +24,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
  // FIXME: Should be this moved to binding-data-codec?
-class LazySerializedContainerNode implements ContainerNode {
+class LazySerializedContainerNode implements ContainerNode, BindingDataAware {
 
     private final NodeIdentifier identifier;
     private final DataObject bindingData;
@@ -87,7 +88,8 @@ class LazySerializedContainerNode implements ContainerNode {
         return delegate().getAttributeValue(name);
     }
 
-    final DataObject bindingData() {
+    @Override
+    public final DataObject bindingData() {
         return bindingData;
     }
 
index 5e24c90..d61c9a4 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.md.sal.binding.impl;
 
 import com.google.common.base.Preconditions;
@@ -23,6 +22,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
 import org.opendaylight.controller.md.sal.dom.broker.spi.rpc.RpcRoutingStrategy;
+import org.opendaylight.mdsal.binding.dom.adapter.BindingRpcFutureAware;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -66,8 +66,8 @@ class RpcServiceAdapter implements InvocationHandler {
 
     ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
         final CheckedFuture<DOMRpcResult, DOMRpcException> result = delegate.invokeRpc(schemaPath, input);
-        if (result instanceof LazyDOMRpcResultFuture) {
-            return ((LazyDOMRpcResultFuture) result).getBindingFuture();
+        if (result instanceof BindingRpcFutureAware) {
+            return ((BindingRpcFutureAware) result).getBindingFuture();
         }
 
         return transformFuture(schemaPath, result, codec.getCodecFactory());

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.