Bump mdsal to 4.0.0 30/81130/38
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 22 Mar 2019 18:33:21 +0000 (19:33 +0100)
committerRobert Varga <nite@hq.sk>
Tue, 16 Apr 2019 08:13:31 +0000 (08:13 +0000)
This bumps mdsal to 4.0.0, adjusting for changes it brings, notably:
- FluentFuture removed from DOM RPC invocation services
- ping-pong functionality directly part of DOMDataBroker API and not
  via a dedicated DOMDataBroker instance
- DataContainer.getImplementedInterface() renamed to
  implementedInterface()
- DOMBrokerReadWriteTransaction.close() method being removed
- BindingCodecTreeNode being refactored

Change-Id: I5af13aa82036373826291a54661f7fd20ff387c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
45 files changed:
benchmark/api/pom.xml
benchmark/dsbenchmark/pom.xml
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java
benchmark/dsbenchmark/src/main/resources/OSGI-INF/blueprint/dsbenchmark.xml
benchmark/ntfbenchmark/pom.xml
benchmark/rpcbenchmark/pom.xml
features/benchmark/odl-benchmark-api/pom.xml
features/mdsal/odl-clustering-test-app/pom.xml
features/mdsal/odl-controller-mdsal-common/pom.xml
features/mdsal/odl-controller-model-topology/pom.xml
features/mdsal/odl-mdsal-broker-local/pom.xml
features/mdsal/odl-mdsal-model-inventory/pom.xml
features/mdsal/odl-message-bus-collector/pom.xml
features/mdsal/odl-toaster/pom.xml
karaf/pom.xml
opendaylight/blueprint/pom.xml
opendaylight/config/pom.xml
opendaylight/md-sal/parent/pom.xml
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/compat/NotificationInvoker.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/BindingToNormalizedNodeCodec.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataObjectModification.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazyDataTreeModification.java
opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/LazySerializedDOMNotification.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/ContextExtractorTest.java
opendaylight/md-sal/sal-binding-dom-it/pom.xml
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBroker.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/DOMBrokerReadWriteTransaction.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/ShardProxyProducer.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMRpcRouter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataBrokerAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMDataTreeReadWriteTransactionAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMRpcServiceAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/DOMTransactionChainAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMActionServiceAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMDataBrokerAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcResultFutureAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyDOMRpcServiceAdapter.java
opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java [new file with mode: 0644]
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementation.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcImplementationTest.java
opendaylight/model/model-inventory/pom.xml
opendaylight/model/model-topology/pom.xml

index 929eebc..6784395 100644 (file)
@@ -10,7 +10,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index c8e5ce6..949fe5d 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index 0cf0195..c5232a2 100644 (file)
@@ -59,23 +59,18 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     private final AtomicReference<ExecStatus> execStatus = new AtomicReference<>(ExecStatus.Idle);
     private final DsbenchmarkListenerProvider listenerProvider = new DsbenchmarkListenerProvider();
     private final DOMDataBroker domDataBroker;  // Async DOM Broker for use with all DOM operations
-    private final DataBroker txChainDataBroker; // Async Binding-Aware Broker for use in tx chains; initialized to
-                                                // ping-pong broker in default config (see default-config.xml and
-                                                // dsbenchmark-impl.yang)
-    private final DataBroker simpleTxDataBroker;      // "Legacy" OSGI Data Broker for use in simple transactions
+    private final DataBroker dataBroker; // Async Binding-Aware Broker for use in tx chains
 
     private long testsCompleted = 0;
 
-    public DsbenchmarkProvider(final DOMDataBroker domDataBroker, final DataBroker txChainDataBroker,
-            final DataBroker simpleTxDataBroker) {
+    public DsbenchmarkProvider(final DOMDataBroker domDataBroker, final DataBroker dataBroker) {
         this.domDataBroker = domDataBroker;
-        this.txChainDataBroker = txChainDataBroker;
-        this.simpleTxDataBroker = simpleTxDataBroker;
+        this.dataBroker = dataBroker;
     }
 
     @SuppressWarnings("checkstyle:illegalCatch")
     public void init() {
-        listenerProvider.setDataBroker(simpleTxDataBroker);
+        listenerProvider.setDataBroker(dataBroker);
 
         try {
             // We want to set the initial operation status so users can detect we are ready to start test.
@@ -173,7 +168,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
                 .setTestsCompleted(tstCompl)
                 .build();
 
-        WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.OPERATIONAL, TEST_STATUS_IID, status);
 
         try {
@@ -190,7 +185,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
                 .setOuterList(Collections.<OuterList>emptyList())
                 .build();
 
-        WriteTransaction tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.CONFIGURATION, TEST_EXEC_IID, data);
         try {
             tx.commit().get();
@@ -200,7 +195,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             throw new IllegalStateException(e);
         }
 
-        tx = simpleTxDataBroker.newWriteOnlyTransaction();
+        tx = dataBroker.newWriteOnlyTransaction();
         tx.put(LogicalDatastoreType.OPERATIONAL, TEST_EXEC_IID, data);
         try {
             tx.commit().get();
@@ -228,13 +223,13 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             if (txType == StartTestInput.TransactionType.SIMPLETX) {
                 if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
                     if (StartTestInput.Operation.DELETE == oper) {
-                        retVal = new SimpletxBaDelete(this.simpleTxDataBroker, outerListElem,
+                        retVal = new SimpletxBaDelete(this.dataBroker, outerListElem,
                                 innerListElem,writesPerTx, dataStore);
                     } else if (StartTestInput.Operation.READ == oper) {
-                        retVal = new SimpletxBaRead(this.simpleTxDataBroker, outerListElem,
+                        retVal = new SimpletxBaRead(this.dataBroker, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     } else {
-                        retVal = new SimpletxBaWrite(this.simpleTxDataBroker, oper, outerListElem,
+                        retVal = new SimpletxBaWrite(this.dataBroker, oper, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     }
                 } else {
@@ -252,13 +247,13 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
             } else {
                 if (dataFormat == StartTestInput.DataFormat.BINDINGAWARE) {
                     if (StartTestInput.Operation.DELETE == oper) {
-                        retVal = new TxchainBaDelete(this.txChainDataBroker, outerListElem,
+                        retVal = new TxchainBaDelete(this.dataBroker, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     } else if (StartTestInput.Operation.READ == oper) {
-                        retVal = new TxchainBaRead(this.txChainDataBroker,outerListElem,
+                        retVal = new TxchainBaRead(this.dataBroker, outerListElem,
                                 innerListElem,writesPerTx, dataStore);
                     } else {
-                        retVal = new TxchainBaWrite(this.txChainDataBroker, oper, outerListElem,
+                        retVal = new TxchainBaWrite(this.dataBroker, oper, outerListElem,
                                 innerListElem, writesPerTx, dataStore);
                     }
                 } else {
index 14561a5..75fb892 100644 (file)
@@ -53,7 +53,7 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact
     @Override
     public void executeList() {
         final LogicalDatastoreType dsType = getDataStoreType();
-        final TransactionChain chain = bindingDataBroker.createTransactionChain(this);
+        final TransactionChain chain = bindingDataBroker.createMergingTransactionChain(this);
 
         WriteTransaction tx = chain.newWriteOnlyTransaction();
         int txSubmitted = 0;
index e10f947..b0ee4b4 100644 (file)
@@ -48,7 +48,7 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti
 
     @Override
     public void executeList() {
-        final TransactionChain chain = bindingDataBroker.createTransactionChain(this);
+        final TransactionChain chain = bindingDataBroker.createMergingTransactionChain(this);
         final LogicalDatastoreType dsType = getDataStoreType();
 
         WriteTransaction tx = chain.newWriteOnlyTransaction();
index 7829d2a..5b47231 100644 (file)
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
            odl:use-default-for-reference-types="true">
 
-  <reference id="domDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker" odl:type="pingpong"/>
-  <reference id="txChainDataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker" odl:type="pingpong"/>
-  <reference id="simpleTxDataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
+  <reference id="domDataBroker" interface="org.opendaylight.mdsal.dom.api.DOMDataBroker"/>
+  <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
 
   <bean id="provider" class="org.opendaylight.dsbenchmark.DsbenchmarkProvider"
           init-method="init" destroy-method="close">
     <argument ref="domDataBroker"/>
-    <argument ref="txChainDataBroker"/>
-    <argument ref="simpleTxDataBroker"/>
+    <argument ref="dataBroker"/>
   </bean>
 
   <odl:rpc-implementation ref="provider"/>
index 683dd2e..ae7f68f 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index 99e8ccb..73b022b 100644 (file)
@@ -12,7 +12,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index e7ae979..f45a435 100644 (file)
@@ -27,7 +27,7 @@
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>odl-mdsal-binding-base</artifactId>
-            <version>3.0.6</version>
+            <version>4.0.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
index 6e0ea45..9ab9176 100644 (file)
@@ -26,7 +26,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <scope>import</scope>
                 <type>pom</type>
             </dependency>
index fdb96f1..45fa286 100644 (file)
@@ -28,7 +28,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index ae94f98..a01e5dd 100644 (file)
@@ -27,7 +27,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 6adf223..14e06c7 100644 (file)
@@ -41,7 +41,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index afa75c9..bf2b0a2 100644 (file)
@@ -28,7 +28,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 7a983e4..aaeb7f1 100644 (file)
@@ -37,7 +37,7 @@
             <dependency>
                 <groupId>org.opendaylight.mdsal</groupId>
                 <artifactId>mdsal-artifacts</artifactId>
-                <version>3.0.6</version>
+                <version>4.0.0</version>
                 <type>pom</type>
                 <scope>import</scope>
             </dependency>
index 32924ed..1404018 100644 (file)
@@ -27,7 +27,7 @@
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>odl-mdsal-binding-runtime</artifactId>
-            <version>3.0.6</version>
+            <version>4.0.0</version>
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
index dcb73b6..b84a047 100644 (file)
@@ -55,7 +55,7 @@
     <dependency>
       <groupId>org.opendaylight.mdsal</groupId>
       <artifactId>features-mdsal</artifactId>
-      <version>3.0.6</version>
+      <version>4.0.0</version>
       <classifier>features</classifier>
       <type>xml</type>
       <scope>runtime</scope>
index 5944d69..b839337 100644 (file)
@@ -27,7 +27,7 @@
       <dependency>
         <groupId>org.opendaylight.mdsal</groupId>
         <artifactId>mdsal-artifacts</artifactId>
-        <version>3.0.6</version>
+        <version>4.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index 629c8c0..e7794a2 100644 (file)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index a074df2..71d28dd 100644 (file)
@@ -11,7 +11,7 @@
   <parent>
     <groupId>org.opendaylight.mdsal</groupId>
     <artifactId>binding-parent</artifactId>
-    <version>3.0.6</version>
+    <version>4.0.0</version>
     <relativePath/>
   </parent>
 
index c2fef92..a6d26d4 100644 (file)
@@ -55,7 +55,7 @@ final class NotificationInvoker
 
     @Override
     public void onNotification(final Notification notification) {
-        getContext(notification.getImplementedInterface()).invoke(notification);
+        getContext(notification.implementedInterface()).invoke(notification);
     }
 
     private InvokerContext getContext(final Class<?> type) {
index d8ba10c..f5a1435 100644 (file)
@@ -15,7 +15,7 @@ import java.util.Map;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
 import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizer;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
 import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
 import org.opendaylight.mdsal.binding.generator.api.ClassLoadingStrategy;
 import org.opendaylight.yangtools.yang.binding.DataObject;
@@ -91,7 +91,7 @@ public class BindingToNormalizedNodeCodec
     }
 
     @Override
-    public Map.Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> getSubtreeCodec(
+    public Map.Entry<InstanceIdentifier<?>, BindingDataObjectCodecTreeNode<?>> getSubtreeCodec(
             final YangInstanceIdentifier domIdentifier) {
         return super.getSubtreeCodec(domIdentifier);
     }
index b163285..9bc8421 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.md.sal.binding.impl;
 
+import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
 import static org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType.UNMODIFIED;
 
@@ -20,6 +21,7 @@ import java.util.stream.Stream;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.mdsal.binding.dom.adapter.BindingStructuralType;
 import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.ChildOf;
 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
@@ -48,33 +50,36 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
 
     private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
 
-    private final BindingCodecTreeNode<T> codec;
+    private final BindingDataObjectCodecTreeNode<T> codec;
     private final DataTreeCandidateNode domData;
     private final PathArgument identifier;
 
     private volatile Collection<LazyDataObjectModification<? extends DataObject>> childNodesCache;
     private volatile ModificationType modificationType;
 
-    private LazyDataObjectModification(final BindingCodecTreeNode<T> codec, final DataTreeCandidateNode domData) {
+    private LazyDataObjectModification(final BindingDataObjectCodecTreeNode<T> codec,
+            final DataTreeCandidateNode domData) {
         this.codec = requireNonNull(codec);
         this.domData = requireNonNull(domData);
         this.identifier = codec.deserializePathArgument(domData.getIdentifier());
     }
 
-    static <T extends DataObject> LazyDataObjectModification<T> create(final BindingCodecTreeNode<T> codec,
+    static <T extends DataObject> LazyDataObjectModification<T> create(final BindingDataObjectCodecTreeNode<T> codec,
             final DataTreeCandidateNode domData) {
         return new LazyDataObjectModification<>(codec, domData);
     }
 
     private static Collection<LazyDataObjectModification<? extends DataObject>> from(
-            final BindingCodecTreeNode<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
+            final BindingDataObjectCodecTreeNode<?> parentCodec,
+            final Collection<DataTreeCandidateNode> domChildNodes) {
         final List<LazyDataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
         populateList(result, parentCodec, domChildNodes);
         return result;
     }
 
     private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result,
-            final BindingCodecTreeNode<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
+            final BindingDataObjectCodecTreeNode<?> parentCodec,
+            final Collection<DataTreeCandidateNode> domChildNodes) {
         for (final DataTreeCandidateNode domChildNode : domChildNodes) {
             if (domChildNode.getModificationType() != UNMODIFIED) {
                 final BindingStructuralType type = BindingStructuralType.from(domChildNode);
@@ -85,9 +90,11 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
                      *  debug log.
                      */
                     try {
-                        final BindingCodecTreeNode<?> childCodec =
-                                parentCodec.yangPathArgumentChild(domChildNode.getIdentifier());
-                        populateList(result, type, childCodec, domChildNode);
+                        final BindingCodecTreeNode childCodec = parentCodec.yangPathArgumentChild(
+                            domChildNode.getIdentifier());
+                        verify(childCodec instanceof BindingDataObjectCodecTreeNode, "Unhandled codec %s for type %s",
+                            childCodec, type);
+                        populateList(result, type, (BindingDataObjectCodecTreeNode<?>) childCodec, domChildNode);
                     } catch (final IllegalArgumentException e) {
                         if (type == BindingStructuralType.UNKNOWN) {
                             LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e);
@@ -101,7 +108,7 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
     }
 
     private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result,
-            final BindingStructuralType type, final BindingCodecTreeNode<?> childCodec,
+            final BindingStructuralType type, final BindingDataObjectCodecTreeNode<?> childCodec,
             final DataTreeCandidateNode domChildNode) {
         switch (type) {
             case INVISIBLE_LIST:
@@ -121,7 +128,7 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
     }
 
     private static void populateListWithSingleCodec(final List<LazyDataObjectModification<? extends DataObject>> result,
-            final BindingCodecTreeNode<?> codec, final Collection<DataTreeCandidateNode> childNodes) {
+            final BindingDataObjectCodecTreeNode<?> codec, final Collection<DataTreeCandidateNode> childNodes) {
         for (final DataTreeCandidateNode child : childNodes) {
             if (child.getModificationType() != UNMODIFIED) {
                 result.add(create(codec, child));
@@ -234,7 +241,7 @@ final class LazyDataObjectModification<T extends DataObject> implements DataObje
     @Override
     public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) {
         final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>();
-        final BindingCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList);
+        final BindingDataObjectCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList);
         final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator();
         DataTreeCandidateNode current = domData;
         while (toEnter.hasNext() && current != null) {
index 3b14012..0ec5aa7 100644 (file)
@@ -15,7 +15,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -34,7 +34,7 @@ class LazyDataTreeModification<T extends DataObject> implements DataTreeModifica
     private final DataObjectModification<T> rootNode;
 
     LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path,
-            final BindingCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
+            final BindingDataObjectCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
         this.path = new DataTreeIdentifier<>(datastoreType, path);
         this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode());
     }
@@ -52,7 +52,7 @@ class LazyDataTreeModification<T extends DataObject> implements DataTreeModifica
     @SuppressWarnings({"unchecked", "rawtypes"})
     static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec,
             final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) {
-        final Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> codecCtx =
+        final Entry<InstanceIdentifier<?>, BindingDataObjectCodecTreeNode<?>> codecCtx =
                 codec.getSubtreeCodec(domChange.getRootPath());
         return new LazyDataTreeModification(datastoreType, codecCtx.getKey(), codecCtx.getValue(), domChange);
     }
index 3e3e8be..0373dd2 100644 (file)
@@ -38,7 +38,7 @@ public final class LazySerializedDOMNotification implements DOMNotification {
     }
 
     static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) {
-        final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getImplementedInterface()));
+        final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.implementedInterface()));
         return new LazySerializedDOMNotification(codec, data, type);
     }
 
index 3e1a688..b426c80 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.EncapsulatedRouteInGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.RoutedSimpleRouteInputBuilder;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public final class ContextExtractorTest {
@@ -31,7 +30,7 @@ public final class ContextExtractorTest {
     private static final Transitive TEST_GROUPING = new Transitive() {
 
         @Override
-        public Class<? extends DataContainer> getImplementedInterface() {
+        public Class<? extends Transitive> implementedInterface() {
             return Transitive.class;
         }
 
index bc2c70c..9ef18c4 100644 (file)
@@ -25,7 +25,7 @@
       <dependency>
         <groupId>org.opendaylight.mdsal</groupId>
         <artifactId>mdsal-artifacts</artifactId>
-        <version>3.0.6</version>
+        <version>4.0.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
index f059676..4ab1c15 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.cluster.databroker;
 
 import static com.google.common.base.Preconditions.checkState;
@@ -17,7 +16,6 @@ import java.util.EnumMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
@@ -27,6 +25,7 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker;
 import org.opendaylight.mdsal.dom.spi.store.DOMStore;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTreeChangePublisher;
@@ -34,7 +33,8 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore> implements DOMDataBroker {
+public abstract class AbstractDOMBroker extends AbstractDOMTransactionFactory<DOMStore>
+        implements PingPongMergingDOMDataBroker {
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMBroker.class);
 
index b160d5b..86b915b 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.cluster.databroker;
 
 import com.google.common.util.concurrent.FluentFuture;
@@ -48,9 +47,4 @@ public class DOMBrokerReadWriteTransaction extends AbstractDOMBrokerWriteTransac
     protected DOMStoreReadWriteTransaction createTransaction(LogicalDatastoreType key) {
         return getTxFactory(key).newReadWriteTransaction();
     }
-
-    @Override
-    public void close() {
-        cancel();
-    }
 }
index ae19074..602566b 100644 (file)
@@ -54,4 +54,9 @@ class ShardProxyProducer implements DOMDataTreeShardProducer {
     void setModificationFactory(final DistributedShardModificationFactory modificationFactory) {
         this.modificationFactory = requireNonNull(modificationFactory);
     }
+
+    @Override
+    public void close() {
+        // FIXME: implement this
+    }
 }
index b660423..f5f887a 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.md.sal.dom.broker.impl;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Set;
@@ -76,7 +76,7 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
         org.opendaylight.mdsal.dom.api.DOMRpcImplementation delegateImpl =
             new org.opendaylight.mdsal.dom.api.DOMRpcImplementation() {
                 @Override
-                public FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> invokeRpc(
+                public ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> invokeRpc(
                         final org.opendaylight.mdsal.dom.api.DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
                     return new MdsalDOMRpcResultFutureAdapter(implementation.invokeRpc(DOMRpcIdentifier.fromMdsal(rpc),
                         input));
@@ -107,7 +107,7 @@ public final class DOMRpcRouter implements AutoCloseable, DOMRpcService, DOMRpcP
     @Override
     public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
                                                                   final NormalizedNode<?, ?> input) {
-        final FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future =
+        final ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future =
                 delegateRpcService.invokeRpc(type, input);
         return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate()
                 : new LegacyDOMRpcResultFutureAdapter(future);
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/AbstractLegacyDOMDataBrokerAdapter.java
new file mode 100644 (file)
index 0000000..bd68ea8
--- /dev/null
@@ -0,0 +1,375 @@
+/*
+ * Copyright (c) 2017 Inocybe Technologies and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.sal.core.compat;
+
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ClassToInstanceMap;
+import com.google.common.collect.ForwardingObject;
+import com.google.common.collect.ImmutableClassToInstanceMap;
+import com.google.common.collect.ImmutableClassToInstanceMap.Builder;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.MoreExecutors;
+import com.google.common.util.concurrent.SettableFuture;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Supplier;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadOperations;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainClosedException;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
+
+/**
+ * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker.
+ *
+ * @author Thomas Pantelis
+ */
+public abstract class AbstractLegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMDataBroker {
+    private static final ExceptionMapper<TransactionCommitFailedException> COMMIT_EX_MAPPER =
+            new ExceptionMapper<TransactionCommitFailedException>("commit", TransactionCommitFailedException.class) {
+        @Override
+        protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
+            if (cause instanceof org.opendaylight.mdsal.common.api.OptimisticLockFailedException) {
+                return new OptimisticLockFailedException(cause.getMessage(), cause.getCause());
+            } else if (cause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) {
+                Throwable rootCause = cause.getCause();
+                if (rootCause instanceof org.opendaylight.mdsal.common.api.DataStoreUnavailableException) {
+                    rootCause = new DataStoreUnavailableException(rootCause.getMessage(), rootCause.getCause());
+                }
+
+                return new TransactionCommitFailedException(cause.getMessage(), rootCause);
+            }
+
+            return new TransactionCommitFailedException(message, cause);
+        }
+    };
+
+    private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate;
+    private final ClassToInstanceMap<DOMDataBrokerExtension> extensions;
+
+    public AbstractLegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
+        this.delegate = delegate;
+
+        ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
+                delegate.getExtensions();
+
+        Builder<DOMDataBrokerExtension> extBuilder = ImmutableClassToInstanceMap.builder();
+        final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService =
+                (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get(
+                        org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class);
+        if (delegateTreeChangeService != null) {
+            extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
+                @Override
+                public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
+                        final DOMDataTreeIdentifier treeId, final L listener) {
+                    final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegateListener;
+                    if (listener instanceof ClusteredDOMDataTreeChangeListener) {
+                        delegateListener = new ClusteredProxyListener(listener);
+                    } else {
+                        delegateListener = new ProxyListener(listener);
+                    }
+
+                    final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> reg =
+                        delegateTreeChangeService.registerDataTreeChangeListener(treeId.toMdsal(), delegateListener);
+
+                    return new ListenerRegistration<L>() {
+                        @Override
+                        public L getInstance() {
+                            return listener;
+                        }
+
+                        @Override
+                        public void close() {
+                            reg.close();
+                        }
+                    };
+                }
+            });
+        }
+
+        final org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry delegateCohortRegistry =
+                (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get(
+                        org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class);
+        if (delegateCohortRegistry != null) {
+            extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort);
+        }
+
+        extensions = extBuilder.build();
+    }
+
+    @Override
+    protected org.opendaylight.mdsal.dom.api.DOMDataBroker delegate() {
+        return delegate;
+    }
+
+    @Override
+    public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
+        return extensions;
+    }
+
+    @Override
+    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+        return new DOMDataReadOnlyTransactionAdapter(delegate().newReadOnlyTransaction());
+    }
+
+    @Override
+    public DOMDataReadWriteTransaction newReadWriteTransaction() {
+        return new DOMDataTransactionAdapter(delegate().newReadWriteTransaction());
+    }
+
+    @Override
+    public DOMDataWriteTransaction newWriteOnlyTransaction() {
+        return new DOMDataTransactionAdapter(delegate().newWriteOnlyTransaction());
+    }
+
+    @Override
+    public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
+        AtomicReference<DOMTransactionChain> legacyChain = new AtomicReference<>();
+        DOMTransactionChainListener delegateListener =
+                new DOMTransactionChainListener() {
+            @Override
+            @SuppressWarnings("rawtypes")
+            public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
+                    final DOMDataTreeTransaction transaction, final Throwable cause) {
+                listener.onTransactionChainFailed(legacyChain.get(),
+                    (AsyncTransaction) () -> transaction.getIdentifier(),
+                        cause instanceof Exception ? COMMIT_EX_MAPPER.apply((Exception)cause) : cause);
+            }
+
+            @Override
+            public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
+                listener.onTransactionChainSuccessful(legacyChain.get());
+            }
+        };
+
+        final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain =
+                delegate().createTransactionChain(delegateListener);
+        legacyChain.set(new DOMTransactionChain() {
+            @Override
+            public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
+                return new DOMDataReadOnlyTransactionAdapter(wrapException(delegateChain::newReadOnlyTransaction));
+            }
+
+            @Override
+            public DOMDataReadWriteTransaction newReadWriteTransaction() {
+                return new DOMDataTransactionAdapter(wrapException(delegateChain::newReadWriteTransaction));
+            }
+
+            @Override
+            public DOMDataWriteTransaction newWriteOnlyTransaction() {
+                return new DOMDataTransactionAdapter(wrapException(delegateChain::newWriteOnlyTransaction));
+            }
+
+            @Override
+            public void close() {
+                delegateChain.close();
+            }
+        });
+
+        return legacyChain.get();
+    }
+
+    abstract org.opendaylight.mdsal.dom.api.DOMTransactionChain createDelegateChain(
+            DOMTransactionChainListener listener);
+
+    static <T> T wrapException(final Supplier<T> supplier) {
+        try {
+            return supplier.get();
+        } catch (DOMTransactionChainClosedException e) {
+            throw new TransactionChainClosedException("Transaction chain already closed", e);
+        }
+    }
+
+    private static class DOMDataTransactionAdapter implements DOMDataReadWriteTransaction {
+        private final DOMDataTreeReadOperations readDelegate;
+        private final DOMDataTreeWriteTransaction writeDelegate;
+        private final Object identifier;
+
+        DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadOperations readDelegate, final Object identifier) {
+            this.readDelegate = requireNonNull(readDelegate);
+            this.identifier = requireNonNull(identifier);
+            this.writeDelegate = null;
+        }
+
+        DOMDataTransactionAdapter(final @NonNull DOMDataTreeWriteTransaction writeDelegate) {
+            this.writeDelegate = requireNonNull(writeDelegate);
+            this.identifier = writeDelegate.getIdentifier();
+            this.readDelegate = null;
+        }
+
+        DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadWriteTransaction rwDelegate) {
+            this.readDelegate = requireNonNull(rwDelegate);
+            this.writeDelegate = rwDelegate;
+            this.identifier = rwDelegate.getIdentifier();
+        }
+
+        DOMDataTreeReadOperations readDelegate() {
+            return readDelegate;
+        }
+
+        DOMDataTreeWriteTransaction writeDelegate() {
+            return writeDelegate;
+        }
+
+        @Override
+        public Object getIdentifier() {
+            return identifier;
+        }
+
+        @Override
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate().read(store.toMdsal(), path).transform(
+                Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE);
+        }
+
+        @Override
+        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
+            return MappingCheckedFuture.create(readDelegate().exists(store.toMdsal(), path),
+                    ReadFailedExceptionAdapter.INSTANCE);
+        }
+
+        @Override
+        public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+            writeDelegate().delete(store.toMdsal(), path);
+        }
+
+        @Override
+        public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                final NormalizedNode<?, ?> data) {
+            writeDelegate().put(store.toMdsal(), path, data);
+        }
+
+        @Override
+        public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
+                final NormalizedNode<?, ?> data) {
+            writeDelegate().merge(store.toMdsal(), path, data);
+        }
+
+        @Override
+        public boolean cancel() {
+            return writeDelegate().cancel();
+        }
+
+        @Override
+        public FluentFuture<? extends CommitInfo> commit() {
+            final SettableFuture<CommitInfo> resultFuture = SettableFuture.create();
+            writeDelegate().commit().addCallback(new FutureCallback<CommitInfo>() {
+                @Override
+                public void onSuccess(final CommitInfo result) {
+                    resultFuture.set(result);
+                }
+
+                @Override
+                public void onFailure(final Throwable ex) {
+                    if (ex instanceof Exception) {
+                        resultFuture.setException(COMMIT_EX_MAPPER.apply((Exception)ex));
+                    } else {
+                        resultFuture.setException(ex);
+                    }
+                }
+            }, MoreExecutors.directExecutor());
+
+            return FluentFuture.from(resultFuture);
+        }
+    }
+
+    private static class DOMDataReadOnlyTransactionAdapter implements DOMDataReadOnlyTransaction {
+        private final DOMDataTreeReadTransaction transaction;
+        private final DOMDataTransactionAdapter adapter;
+
+        DOMDataReadOnlyTransactionAdapter(final DOMDataTreeReadTransaction delegateTx) {
+            this.transaction = requireNonNull(delegateTx);
+            adapter = new DOMDataTransactionAdapter(delegateTx, transaction.getIdentifier());
+        }
+
+        @Override
+        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
+            return adapter.read(store, path);
+        }
+
+        @Override
+        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
+                final YangInstanceIdentifier path) {
+            return adapter.exists(store, path);
+        }
+
+        @Override
+        public Object getIdentifier() {
+            return adapter.getIdentifier();
+        }
+
+        @Override
+        public void close() {
+            transaction.close();
+        }
+    }
+
+    private static class ProxyListener extends ForwardingObject
+            implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener {
+        private final DOMDataTreeChangeListener delegate;
+
+        ProxyListener(final DOMDataTreeChangeListener delegate) {
+            this.delegate = requireNonNull(delegate);
+        }
+
+        @Override
+        public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
+            delegate.onDataTreeChanged(changes);
+        }
+
+        @Override
+        protected DOMDataTreeChangeListener delegate() {
+            return delegate;
+        }
+    }
+
+    private static final class ClusteredProxyListener extends ProxyListener
+            implements org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener {
+
+        ClusteredProxyListener(DOMDataTreeChangeListener delegate) {
+            super(delegate);
+        }
+    }
+}
index a5a47bb..b426311 100644 (file)
@@ -23,9 +23,10 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+import org.opendaylight.mdsal.dom.spi.PingPongMergingDOMDataBroker;
 
 @Deprecated
-public class DOMDataBrokerAdapter extends ForwardingObject implements org.opendaylight.mdsal.dom.api.DOMDataBroker {
+public class DOMDataBrokerAdapter extends ForwardingObject implements PingPongMergingDOMDataBroker {
     private final ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> extensions;
     private final DOMDataBroker delegate;
 
index d35ce44..22bafb8 100644 (file)
@@ -43,11 +43,6 @@ public class DOMDataTreeReadWriteTransactionAdapter extends ForwardingObject
         return TransactionUtils.exists(delegate(), store, path);
     }
 
-    @Override
-    public void close() {
-        cancel();
-    }
-
     @Override
     public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
             final NormalizedNode<?, ?> data) {
index 06cf6bc..7158665 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.sal.core.compat;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.Collection;
 import java.util.Set;
 import java.util.stream.Collectors;
@@ -32,7 +32,7 @@ public class DOMRpcServiceAdapter extends ForwardingObject implements org.openda
     }
 
     @Override
-    public FluentFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
+    public ListenableFuture<DOMRpcResult> invokeRpc(final SchemaPath type, final NormalizedNode<?, ?> input) {
         return new MdsalDOMRpcResultFutureAdapter(delegate().invokeRpc(type, input));
     }
 
index 685986c..09f5ba5 100644 (file)
@@ -80,12 +80,6 @@ public class DOMTransactionChainAdapter extends ForwardingObject
                 untrack(delegate());
                 return super.cancel();
             }
-
-            @Override
-            public void close() {
-                untrack(delegate());
-                super.close();
-            }
         });
     }
 
index 8331bad..7e498e3 100644 (file)
@@ -11,7 +11,7 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ClassToInstanceMap;
 import com.google.common.collect.ForwardingObject;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMActionResult;
 import org.opendaylight.mdsal.dom.api.DOMActionServiceExtension;
@@ -33,8 +33,8 @@ public class LegacyDOMActionServiceAdapter extends ForwardingObject implements D
     }
 
     @Override
-    public FluentFuture<? extends DOMActionResult> invokeAction(final SchemaPath type, final DOMDataTreeIdentifier path,
-            final ContainerNode input) {
+    public ListenableFuture<? extends DOMActionResult> invokeAction(final SchemaPath type,
+            final DOMDataTreeIdentifier path, final ContainerNode input) {
         return delegate.invokeAction(type, path, input);
     }
 
index ab92b00..7ae5ec5 100644 (file)
  */
 package org.opendaylight.controller.sal.core.compat;
 
-import static java.util.Objects.requireNonNull;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ForwardingObject;
-import com.google.common.collect.ImmutableClassToInstanceMap;
-import com.google.common.collect.ImmutableClassToInstanceMap.Builder;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.MoreExecutors;
-import com.google.common.util.concurrent.SettableFuture;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Supplier;
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.controller.md.sal.common.api.MappingCheckedFuture;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.ClusteredDOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.mdsal.common.api.CommitInfo;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
-import org.opendaylight.mdsal.dom.api.DOMTransactionChainClosedException;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 
 /**
  * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker.
  *
  * @author Thomas Pantelis
  */
-public class LegacyDOMDataBrokerAdapter extends ForwardingObject implements DOMDataBroker {
-    private static final ExceptionMapper<TransactionCommitFailedException> COMMIT_EX_MAPPER =
-            new ExceptionMapper<TransactionCommitFailedException>("commit", TransactionCommitFailedException.class) {
-        @Override
-        protected TransactionCommitFailedException newWithCause(final String message, final Throwable cause) {
-            if (cause instanceof org.opendaylight.mdsal.common.api.OptimisticLockFailedException) {
-                return new OptimisticLockFailedException(cause.getMessage(), cause.getCause());
-            } else if (cause instanceof org.opendaylight.mdsal.common.api.TransactionCommitFailedException) {
-                Throwable rootCause = cause.getCause();
-                if (rootCause instanceof org.opendaylight.mdsal.common.api.DataStoreUnavailableException) {
-                    rootCause = new DataStoreUnavailableException(rootCause.getMessage(), rootCause.getCause());
-                }
-
-                return new TransactionCommitFailedException(cause.getMessage(), rootCause);
-            }
-
-            return new TransactionCommitFailedException(message, cause);
-        }
-    };
-
-    private final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate;
-    private final ClassToInstanceMap<DOMDataBrokerExtension> extensions;
-
+public class LegacyDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter {
     public LegacyDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
-        this.delegate = delegate;
-
-        ClassToInstanceMap<org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension> delegateExtensions =
-                delegate.getExtensions();
-
-        Builder<DOMDataBrokerExtension> extBuilder = ImmutableClassToInstanceMap.builder();
-        final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService delegateTreeChangeService =
-                (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService) delegateExtensions.get(
-                        org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService.class);
-        if (delegateTreeChangeService != null) {
-            extBuilder.put(DOMDataTreeChangeService.class, new DOMDataTreeChangeService() {
-                @Override
-                public <L extends DOMDataTreeChangeListener> ListenerRegistration<L> registerDataTreeChangeListener(
-                        final DOMDataTreeIdentifier treeId, final L listener) {
-                    final org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener delegateListener;
-                    if (listener instanceof ClusteredDOMDataTreeChangeListener) {
-                        delegateListener = new ClusteredProxyListener(listener);
-                    } else {
-                        delegateListener = new ProxyListener(listener);
-                    }
-
-                    final ListenerRegistration<org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener> reg =
-                        delegateTreeChangeService.registerDataTreeChangeListener(treeId.toMdsal(), delegateListener);
-
-                    return new ListenerRegistration<L>() {
-                        @Override
-                        public L getInstance() {
-                            return listener;
-                        }
-
-                        @Override
-                        public void close() {
-                            reg.close();
-                        }
-                    };
-                }
-            });
-        }
-
-        final org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry delegateCohortRegistry =
-                (org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry) delegateExtensions.get(
-                        org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohortRegistry.class);
-        if (delegateCohortRegistry != null) {
-            extBuilder.put(DOMDataTreeCommitCohortRegistry.class, delegateCohortRegistry::registerCommitCohort);
-        }
-
-        extensions = extBuilder.build();
-    }
-
-    @Override
-    protected org.opendaylight.mdsal.dom.api.DOMDataBroker delegate() {
-        return delegate;
-    }
-
-    @Override
-    public Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> getSupportedExtensions() {
-        return extensions;
+        super(delegate);
     }
 
     @Override
-    public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
-        return new DOMDataReadOnlyTransactionAdapter(delegate().newReadOnlyTransaction());
-    }
-
-    @Override
-    public DOMDataReadWriteTransaction newReadWriteTransaction() {
-        return new DOMDataTransactionAdapter(delegate().newReadWriteTransaction());
-    }
-
-    @Override
-    public DOMDataWriteTransaction newWriteOnlyTransaction() {
-        return new DOMDataTransactionAdapter(delegate().newWriteOnlyTransaction());
-    }
-
-    @Override
-    public DOMTransactionChain createTransactionChain(final TransactionChainListener listener) {
-        AtomicReference<DOMTransactionChain> legacyChain = new AtomicReference<>();
-        DOMTransactionChainListener delegateListener =
-                new DOMTransactionChainListener() {
-            @Override
-            @SuppressWarnings("rawtypes")
-            public void onTransactionChainFailed(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain,
-                    final DOMDataTreeTransaction transaction, final Throwable cause) {
-                listener.onTransactionChainFailed(legacyChain.get(),
-                    (AsyncTransaction) () -> transaction.getIdentifier(),
-                        cause instanceof Exception ? COMMIT_EX_MAPPER.apply((Exception)cause) : cause);
-            }
-
-            @Override
-            public void onTransactionChainSuccessful(final org.opendaylight.mdsal.dom.api.DOMTransactionChain chain) {
-                listener.onTransactionChainSuccessful(legacyChain.get());
-            }
-        };
-
-        final org.opendaylight.mdsal.dom.api.DOMTransactionChain delegateChain =
-                delegate().createTransactionChain(delegateListener);
-        legacyChain.set(new DOMTransactionChain() {
-            @Override
-            public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
-                return new DOMDataReadOnlyTransactionAdapter(wrapException(delegateChain::newReadOnlyTransaction));
-            }
-
-            @Override
-            public DOMDataReadWriteTransaction newReadWriteTransaction() {
-                return new DOMDataTransactionAdapter(wrapException(delegateChain::newReadWriteTransaction));
-            }
-
-            @Override
-            public DOMDataWriteTransaction newWriteOnlyTransaction() {
-                return new DOMDataTransactionAdapter(wrapException(delegateChain::newWriteOnlyTransaction));
-            }
-
-            @Override
-            public void close() {
-                delegateChain.close();
-            }
-        });
-
-        return legacyChain.get();
-    }
-
-    static <T> T wrapException(final Supplier<T> supplier) {
-        try {
-            return supplier.get();
-        } catch (DOMTransactionChainClosedException e) {
-            throw new TransactionChainClosedException("Transaction chain already closed", e);
-        }
-    }
-
-    private static class DOMDataTransactionAdapter implements DOMDataReadWriteTransaction {
-        private final DOMDataTreeReadTransaction readDelegate;
-        private final DOMDataTreeWriteTransaction writeDelegate;
-        private final Object identifier;
-
-        DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadTransaction readDelegate) {
-            this.readDelegate = requireNonNull(readDelegate);
-            this.identifier = readDelegate.getIdentifier();
-            this.writeDelegate = null;
-        }
-
-        DOMDataTransactionAdapter(final @NonNull DOMDataTreeWriteTransaction writeDelegate) {
-            this.writeDelegate = requireNonNull(writeDelegate);
-            this.identifier = writeDelegate.getIdentifier();
-            this.readDelegate = null;
-        }
-
-        DOMDataTransactionAdapter(final @NonNull DOMDataTreeReadWriteTransaction rwDelegate) {
-            this.readDelegate = requireNonNull(rwDelegate);
-            this.writeDelegate = rwDelegate;
-            this.identifier = readDelegate.getIdentifier();
-        }
-
-        DOMDataTreeReadTransaction readDelegate() {
-            return readDelegate;
-        }
-
-        DOMDataTreeWriteTransaction writeDelegate() {
-            return writeDelegate;
-        }
-
-        @Override
-        public Object getIdentifier() {
-            return identifier;
-        }
-
-        @Override
-        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
-                final YangInstanceIdentifier path) {
-            return MappingCheckedFuture.create(readDelegate().read(store.toMdsal(), path).transform(
-                Optional::fromJavaUtil, MoreExecutors.directExecutor()), ReadFailedExceptionAdapter.INSTANCE);
-        }
-
-        @Override
-        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
-                final YangInstanceIdentifier path) {
-            return MappingCheckedFuture.create(readDelegate().exists(store.toMdsal(), path),
-                    ReadFailedExceptionAdapter.INSTANCE);
-        }
-
-        @Override
-        public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
-            writeDelegate().delete(store.toMdsal(), path);
-        }
-
-        @Override
-        public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
-                final NormalizedNode<?, ?> data) {
-            writeDelegate().put(store.toMdsal(), path, data);
-        }
-
-        @Override
-        public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
-                final NormalizedNode<?, ?> data) {
-            writeDelegate().merge(store.toMdsal(), path, data);
-        }
-
-        @Override
-        public boolean cancel() {
-            return writeDelegate().cancel();
-        }
-
-        @Override
-        public FluentFuture<? extends CommitInfo> commit() {
-            final SettableFuture<CommitInfo> resultFuture = SettableFuture.create();
-            writeDelegate().commit().addCallback(new FutureCallback<CommitInfo>() {
-                @Override
-                public void onSuccess(final CommitInfo result) {
-                    resultFuture.set(result);
-                }
-
-                @Override
-                public void onFailure(final Throwable ex) {
-                    if (ex instanceof Exception) {
-                        resultFuture.setException(COMMIT_EX_MAPPER.apply((Exception)ex));
-                    } else {
-                        resultFuture.setException(ex);
-                    }
-                }
-            }, MoreExecutors.directExecutor());
-
-            return resultFuture;
-        }
-    }
-
-    private static class DOMDataReadOnlyTransactionAdapter implements DOMDataReadOnlyTransaction {
-        private final DOMDataTransactionAdapter adapter;
-
-        DOMDataReadOnlyTransactionAdapter(final DOMDataTreeReadTransaction delegateTx) {
-            adapter = new DOMDataTransactionAdapter(delegateTx);
-        }
-
-        @Override
-        public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
-                final YangInstanceIdentifier path) {
-            return adapter.read(store, path);
-        }
-
-        @Override
-        public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
-                final YangInstanceIdentifier path) {
-            return adapter.exists(store, path);
-        }
-
-        @Override
-        public Object getIdentifier() {
-            return adapter.getIdentifier();
-        }
-
-        @Override
-        public void close() {
-            adapter.readDelegate().close();
-        }
-    }
-
-    private static class ProxyListener extends ForwardingObject
-            implements org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener {
-        private final DOMDataTreeChangeListener delegate;
-
-        ProxyListener(final DOMDataTreeChangeListener delegate) {
-            this.delegate = requireNonNull(delegate);
-        }
-
-        @Override
-        public void onDataTreeChanged(Collection<DataTreeCandidate> changes) {
-            delegate.onDataTreeChanged(changes);
-        }
-
-        @Override
-        protected DOMDataTreeChangeListener delegate() {
-            return delegate;
-        }
-    }
-
-    private static final class ClusteredProxyListener extends ProxyListener
-            implements org.opendaylight.mdsal.dom.api.ClusteredDOMDataTreeChangeListener {
-
-        ClusteredProxyListener(DOMDataTreeChangeListener delegate) {
-            super(delegate);
-        }
+    DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) {
+        return delegate().createTransactionChain(listener);
     }
 }
index 10a85fe..de397db 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.sal.core.compat;
 
 import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
@@ -26,7 +26,7 @@ import org.opendaylight.yangtools.util.concurrent.ExceptionMapper;
  * @author Thomas Pantelis
  */
 public class LegacyDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureAdapter<DOMRpcResult,
-        org.opendaylight.mdsal.dom.api.DOMRpcResult, FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult>,
+        org.opendaylight.mdsal.dom.api.DOMRpcResult, ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult>,
         DOMRpcException> implements CheckedFuture<DOMRpcResult, DOMRpcException> {
 
     private static final ExceptionMapper<DOMRpcException> LEGACY_DOM_RPC_EX_MAPPER =
@@ -40,7 +40,7 @@ public class LegacyDOMRpcResultFutureAdapter extends AbstractDOMRpcResultFutureA
         }
     };
 
-    public LegacyDOMRpcResultFutureAdapter(FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> delegate) {
+    public LegacyDOMRpcResultFutureAdapter(ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> delegate) {
         super(delegate, LEGACY_DOM_RPC_EX_MAPPER);
     }
 
index 170d9c9..851ee09 100644 (file)
@@ -11,7 +11,7 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ForwardingObject;
 import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
@@ -32,7 +32,7 @@ public class LegacyDOMRpcServiceAdapter extends ForwardingObject implements DOMR
     @Override
     public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(final SchemaPath type,
                                                                   final NormalizedNode<?, ?> input) {
-        final FluentFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future = delegate().invokeRpc(type, input);
+        final ListenableFuture<org.opendaylight.mdsal.dom.api.DOMRpcResult> future = delegate().invokeRpc(type, input);
         return future instanceof MdsalDOMRpcResultFutureAdapter ? ((MdsalDOMRpcResultFutureAdapter)future).delegate()
                 : new LegacyDOMRpcResultFutureAdapter(future);
     }
diff --git a/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java b/opendaylight/md-sal/sal-dom-compat/src/main/java/org/opendaylight/controller/sal/core/compat/LegacyPingPongDOMDataBrokerAdapter.java
new file mode 100644 (file)
index 0000000..a28561f
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2019 PANTHEON.tech and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.sal.core.compat;
+
+import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
+
+/**
+ * Adapter between the legacy controller API-based DOMDataBroker and the mdsal API-based DOMDataBroker, equivalent
+ * to PingPongDOMDataBroker.
+ */
+public class LegacyPingPongDOMDataBrokerAdapter extends AbstractLegacyDOMDataBrokerAdapter {
+    public LegacyPingPongDOMDataBrokerAdapter(final org.opendaylight.mdsal.dom.api.DOMDataBroker delegate) {
+        super(delegate);
+    }
+
+    @Override
+    DOMTransactionChain createDelegateChain(DOMTransactionChainListener listener) {
+        return delegate().createMergingTransactionChain(listener);
+    }
+}
index 45a847f..71b2759 100644 (file)
@@ -5,14 +5,14 @@
  * 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.remote.rpc;
 
+import static java.util.Objects.requireNonNull;
+
 import akka.actor.ActorRef;
 import akka.pattern.Patterns;
 import akka.util.Timeout;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
 import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
@@ -32,12 +32,12 @@ final class RemoteRpcImplementation implements DOMRpcImplementation {
     private final Timeout askDuration;
 
     RemoteRpcImplementation(final ActorRef remoteInvoker, final RemoteRpcProviderConfig config) {
-        this.remoteInvoker = Preconditions.checkNotNull(remoteInvoker);
+        this.remoteInvoker = requireNonNull(remoteInvoker);
         this.askDuration = config.getAskDuration();
     }
 
     @Override
-    public FluentFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc,
+    public ListenableFuture<DOMRpcResult> invokeRpc(final DOMRpcIdentifier rpc,
             final NormalizedNode<?, ?> input) {
         final RemoteDOMRpcFuture ret = RemoteDOMRpcFuture.create(rpc.getType().getLastComponent());
         ret.completeWith(Patterns.ask(remoteInvoker, ExecuteRpc.from(rpc, input), askDuration));
index 6e755f1..5b3394e 100644 (file)
@@ -11,12 +11,12 @@ package org.opendaylight.controller.remote.rpc;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.when;
 
-import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.junit.Ignore;
@@ -53,7 +53,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
         when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn(
                 FluentFutures.immediateFluentFuture(rpcResult));
 
-        final FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
+        final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
@@ -75,7 +75,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
         when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn(
                 FluentFutures.immediateFluentFuture(rpcResult));
 
-        FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, null);
+        ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, null);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
@@ -98,7 +98,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
         when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn(
                 FluentFutures.immediateFluentFuture(rpcResult));
 
-        final FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
+        final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
@@ -119,7 +119,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
         when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn(
                 FluentFutures.immediateFailedFluentFuture(new RemoteDOMRpcException("Test Exception", null)));
 
-        final FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
+        final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         try {
@@ -137,7 +137,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
     @Test(expected = RemoteDOMRpcException.class)
     public void testInvokeRpcWithAkkaTimeoutException() throws Exception {
         final NormalizedNode<?, ?> invokeRpcInput = makeRPCInput("foo");
-        final FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
+        final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         frontEndFuture.get(20, TimeUnit.SECONDS);
@@ -155,7 +155,7 @@ public class RemoteRpcImplementationTest extends AbstractRpcTest {
         doThrow(new RuntimeException("test")).when(domRpcService2).invokeRpc(any(SchemaPath.class),
             any(NormalizedNode.class));
 
-        final FluentFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
+        final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
         assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
 
         try {
index e75d24d..680a9bf 100644 (file)
@@ -13,7 +13,7 @@
     <parent>
         <groupId>org.opendaylight.mdsal</groupId>
         <artifactId>binding-parent</artifactId>
-        <version>3.0.6</version>
+        <version>4.0.0</version>
         <relativePath/>
     </parent>
 
index d197981..e7548a6 100644 (file)
@@ -13,7 +13,7 @@
     <parent>
         <groupId>org.opendaylight.mdsal</groupId>
         <artifactId>binding-parent</artifactId>
-        <version>3.0.6</version>
+        <version>4.0.0</version>
         <relativePath/>
     </parent>
 

©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.