fix some AsyncWriteTransaction.submit warnings 23/83623/3
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 14 Aug 2019 09:56:34 +0000 (11:56 +0200)
committerguillaume.lambert <guillaume.lambert@orange.com>
Mon, 19 Aug 2019 14:28:51 +0000 (16:28 +0200)
AsyncWriteTransaction.submit() is deprecated and is replaced by commit()
that rely on FluentFuture<? extends @NonNull CommitInfo>
instead of ListenableFuture<Void>.

https://git.opendaylight.org/gerrit/c/netconf/+/71545
https://git.opendaylight.org/gerrit/c/controller/+/71547
https://git.opendaylight.org/gerrit/c/netconf/+/71582

- fix most AsyncWriteTransaction.submit deprecated warnings by replacing
  AsyncWriteTransaction.submit by commit
- deprecate NetworkTransactionService, NetworkTransactionImpl
  RequestProcessor and DeviceTransaction submit functions that relies on
  AsyncWriteTransaction.submit()

Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I99689f54a6d41209c38c8a266f3f5226edcda6a6

18 files changed:
common/src/main/java/org/opendaylight/transportpce/common/device/DeviceTransaction.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingImpl.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java
common/src/main/java/org/opendaylight/transportpce/common/network/NetworkTransactionImpl.java
common/src/main/java/org/opendaylight/transportpce/common/network/NetworkTransactionService.java
common/src/main/java/org/opendaylight/transportpce/common/network/RequestProcessor.java
common/src/test/java/org/opendaylight/transportpce/common/device/DeviceTransactionManagerTest.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/NetworkUtilsImpl.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/OrdLink.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/Rdm2XpdrLink.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/ClliNetwork.java
networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/util/OpenRoadmNetwork.java
pce/src/test/java/org/opendaylight/transportpce/pce/utils/PceTestUtils.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/NetworkModelWavelengthServiceImpl.java
renderer/src/main/java/org/opendaylight/transportpce/renderer/provisiondevice/DeviceRendererServiceImpl.java
servicehandler/src/main/java/org/opendaylight/transportpce/servicehandler/service/ServiceDataStoreOperationsImpl.java
test-common/src/main/java/org/opendaylight/transportpce/test/DeviceWrapper.java

index baee138a2a302d995c0cdba73186d49b378a6680..5aa093fd89b71420f5f0faeb7a21e7b2c29ba385 100644 (file)
@@ -104,6 +104,7 @@ public class DeviceTransaction {
      * @param timeUnit a time unit
      * @return ListenableFuture which indicates when is submit completed.
      */
+    @Deprecated
     public ListenableFuture<Void> submit(long timeout, TimeUnit timeUnit) {
         if (wasSubmittedOrCancelled.get()) {
             String msg = "Transaction was already submitted or canceled!";
@@ -125,8 +126,8 @@ public class DeviceTransaction {
 
             @Override
             public void onFailure(Throwable throwable) {
-                LOG.error("Device transaction submit failed or submit took longer than {} {}!"
-                        + " Unlocking device.", timeout, timeUnit, throwable);
+                LOG.error("Device transaction submit failed or submit took longer than {} {}! Unlocking device.",
+                    timeout, timeUnit, throwable);
                 afterClose();
             }
         }, scheduledExecutorService);
index 6008f4f2b7baec0445eec47d67bbe9b691e69c09..0054e390f361a0ef5b3ffac6ff4f033b5b42aa83 100644 (file)
@@ -98,7 +98,7 @@ public class PortMappingImpl implements PortMapping {
             .child(Nodes.class, new NodesKey(nodeId));
         rw.delete(LogicalDatastoreType.CONFIGURATION, nodesIID);
         try {
-            rw.submit().get(1, TimeUnit.SECONDS);
+            rw.commit().get(1, TimeUnit.SECONDS);
             LOG.info("Port mapping removal for node '{}'", nodeId);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.error("Error for removing port mapping infos for node '{}'", nodeId);
index 6a03fe952464ae895c8d5394ba5393046f09b3f9..8da3ec21ba646c721e7ac0bfe007f4c217159ab7 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.transportpce.common.mapping;
 
-import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -18,11 +18,12 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-
+import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
@@ -68,7 +69,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev161014.Opti
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.Protocols1;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.Lldp;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev161014.lldp.container.lldp.PortConfig;
-
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -160,8 +160,8 @@ public class PortMappingVersion121 {
                         .child(Nodes.class, new NodesKey(nodeId))
                         .child(Mapping.class, new MappingKey(oldMapping.getLogicalConnectionPoint()));
                     writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, mapIID, newMapping);
-                    ListenableFuture<Void> submit = writeTransaction.submit();
-                    submit.get();
+                    FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
+                    commit.get();
                     return true;
                 }
                 return false;
@@ -590,9 +590,9 @@ public class PortMappingVersion121 {
         InstanceIdentifier<Network> nodesIID = InstanceIdentifier.builder(Network.class).build();
         Network network = nwBldr.build();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, network);
-        ListenableFuture<Void> submit = writeTransaction.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
         try {
-            submit.get();
+            commit.get();
             return true;
 
         } catch (InterruptedException | ExecutionException e) {
index 2ff91ffe1acd53b1b37a1f2d5e83cf924d34ccbd..92a547c9d1686a1f53b156724834796d5e6c8c7e 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.transportpce.common.mapping;
 
-import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -18,10 +18,11 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
@@ -60,7 +61,6 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.open
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroup;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.org.openroadm.device.SharedRiskGroupKey;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.port.Interfaces;
-
 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev170626.InterfaceType;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev170626.OpenROADMOpticalMultiplex;
 import org.opendaylight.yang.gen.v1.http.org.openroadm.interfaces.rev170626.OpticalTransport;
@@ -157,8 +157,8 @@ public class PortMappingVersion221 {
                         .child(Nodes.class, new NodesKey(nodeId))
                         .child(Mapping.class, new MappingKey(oldMapping.getLogicalConnectionPoint()));
                     writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, mapIID, newMapping);
-                    ListenableFuture<Void> submit = writeTransaction.submit();
-                    submit.get();
+                    FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
+                    commit.get();
                     return true;
                 }
                 return false;
@@ -585,9 +585,9 @@ public class PortMappingVersion221 {
         InstanceIdentifier<Network> nodesIID = InstanceIdentifier.builder(Network.class).build();
         Network network = nwBldr.build();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, network);
-        ListenableFuture<Void> submit = writeTransaction.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
         try {
-            submit.get();
+            commit.get();
             return true;
 
         } catch (InterruptedException | ExecutionException e) {
index ff99c6842550746d562f39ac1ce93da2b4f4905e..232e4d906d482fd37cea5cb490a76c78b5cf6891 100644 (file)
@@ -48,6 +48,7 @@ public class NetworkTransactionImpl implements NetworkTransactionService {
         requestProcessor.put(store, path, data);
     }
 
+    @Deprecated
     public ListenableFuture<Void> submit() {
         return requestProcessor.submit();
     }
index 83020f128a739a9c6b37369a776118a95ff5dbbd..bbdefd44796e2ae8cdbffa26dab620ea5454d92a 100644 (file)
@@ -36,6 +36,7 @@ public interface NetworkTransactionService {
     <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
                                       boolean createMissingParents);
 
+    @Deprecated
     ListenableFuture<Void> submit();
 
     void close();
index 02d5a8644fb5a8b0964068bd4c181c437b9df945..807589fd0c9a27a894478e2502e78ab3b5a31c26 100644 (file)
@@ -9,15 +9,11 @@ package org.opendaylight.transportpce.common.network;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
-
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -95,6 +91,7 @@ public class RequestProcessor {
         rwTx.merge(store, path, data);
     }
 
+    @Deprecated
     public ListenableFuture<Void> submit() {
         acquireLock();
         ListenableFuture<Void> future = null;
index 8512c6811adb9a9e3b7f9cbf44c496fa4cead0ca..3f64af4960aa839e3e51d121ba02a90f008f4921 100644 (file)
@@ -65,7 +65,7 @@ public class DeviceTransactionManagerTest {
         Mockito.when(mountPointServiceMock.getMountPoint(any())).thenReturn(Optional.of(mountPointMock));
         Mockito.when(mountPointMock.getService(any())).thenReturn(Optional.of(dataBrokerMock));
         Mockito.when(dataBrokerMock.newReadWriteTransaction()).thenReturn(rwTransactionMock);
-        Mockito.doReturn(FluentFutures.immediateNullFluentFuture()).when(rwTransactionMock.submit());
+        Mockito.doReturn(FluentFutures.immediateNullFluentFuture()).when(rwTransactionMock.commit());
 
         this.transactionManager = new DeviceTransactionManagerImpl(mountPointServiceMock, 3000);
     }
@@ -85,7 +85,7 @@ public class DeviceTransactionManagerTest {
         }
 
         Mockito.verify(rwTransactionMock, Mockito.times(1)).put(defaultDatastore, defaultIid, defaultData);
-        Mockito.verify(rwTransactionMock, Mockito.times(1)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(1)).commit();
     }
 
     @Test
@@ -133,7 +133,7 @@ public class DeviceTransactionManagerTest {
             thirdDeviceTx.submit(defaultTimeout, defaultTimeUnit);
 
             Mockito.verify(rwTransactionMock, Mockito.times(3)).put(defaultDatastore, defaultIid, defaultData);
-            Mockito.verify(rwTransactionMock, Mockito.times(4)).submit();
+            Mockito.verify(rwTransactionMock, Mockito.times(4)).commit();
         } catch (InterruptedException | ExecutionException e) {
             Assert.fail("Exception catched! " + e);
         }
@@ -227,7 +227,7 @@ public class DeviceTransactionManagerTest {
 
         Mockito.verify(rwTransactionMock, Mockito.times(1)).cancel();
         Mockito.verify(rwTransactionMock, Mockito.times(1)).put(defaultDatastore, defaultIid, defaultData);
-        Mockito.verify(rwTransactionMock, Mockito.times(1)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(1)).commit();
     }
 
     @Test
@@ -243,7 +243,7 @@ public class DeviceTransactionManagerTest {
             Assert.fail("Exception catched! " + e);
         }
 
-        Mockito.verify(rwTransactionMock, Mockito.times(1)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(1)).commit();
 
         Mockito.when(dataBrokerMock.newReadWriteTransaction()).thenReturn(rwTransactionMock); // remove sleep
 
@@ -255,7 +255,7 @@ public class DeviceTransactionManagerTest {
         }
 
         Mockito.verify(rwTransactionMock, Mockito.times(2)).put(defaultDatastore, defaultIid, defaultData);
-        Mockito.verify(rwTransactionMock, Mockito.times(2)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(2)).commit();
     }
 
     @Test
@@ -292,13 +292,13 @@ public class DeviceTransactionManagerTest {
         }
 
         Mockito.verify(rwTransactionMock, Mockito.times(1)).put(defaultDatastore, defaultIid, defaultData);
-        Mockito.verify(rwTransactionMock, Mockito.times(1)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(1)).commit();
     }
 
     @Test
     public void submitTxTimeoutTransactionTest() {
         ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor());
-        Mockito.when(rwTransactionMock.submit()).then(invocation -> Futures.makeChecked(executor.submit(() -> {
+        Mockito.when(rwTransactionMock.commit()).then(invocation -> Futures.makeChecked(executor.submit(() -> {
             try {
                 Thread.sleep(3000);
             } catch (InterruptedException e) {
@@ -337,7 +337,7 @@ public class DeviceTransactionManagerTest {
         }
 
 
-        Mockito.doReturn(FluentFutures.immediateNullFluentFuture()).when(rwTransactionMock.submit());
+        Mockito.doReturn(FluentFutures.immediateNullFluentFuture()).when(rwTransactionMock.commit());
 
         try {
             putAndSubmit(transactionManager, defaultDeviceId, defaultDatastore, defaultIid, defaultData);
@@ -347,7 +347,7 @@ public class DeviceTransactionManagerTest {
         }
 
         Mockito.verify(rwTransactionMock, Mockito.times(2)).put(defaultDatastore, defaultIid, defaultData);
-        Mockito.verify(rwTransactionMock, Mockito.times(2)).submit();
+        Mockito.verify(rwTransactionMock, Mockito.times(2)).commit();
 
         executor.shutdown();
     }
index 83d9ecacb072592cf6cd02369daed469e1a47b59..72418f432e7b5d9e1bcc304da5c51fc8a1a776f8 100644 (file)
@@ -88,7 +88,7 @@ public class NetworkUtilsImpl implements TransportpceNetworkutilsService {
         WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
         writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, linkIID.build());
         try {
-            writeTransaction.submit().get();
+            writeTransaction.commit().get();
             LOG.info("Link with linkId: {} deleted from {} layer.",
                 input.getLinkId(), NetworkUtils.OVERLAY_NETWORK_ID);
             return RpcResultBuilder
index a479b1f646f6a4452d5d2a5f15efd4bb5bc9b347..ecac8a7737ed9943630c9952b88e7e3b6d3ff49c 100644 (file)
@@ -76,7 +76,7 @@ final class OrdLink {
         WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, linkIID.build(), linkBuilder.build());
         try {
-            writeTransaction.submit().get();
+            writeTransaction.commit().get();
             LOG.info("A new link with linkId: {} added into {} layer.",
                 linkId.getValue(), NetworkUtils.OVERLAY_NETWORK_ID);
             return true;
index 794ef8e575c7184a21b59e291090516fb4fc46fb..1dd992ca81c1b499046ea6a7731662ff002b29a9 100644 (file)
@@ -9,11 +9,13 @@
 package org.opendaylight.transportpce.networkmodel;
 
 import com.google.common.collect.ImmutableList;
-import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.concurrent.ExecutionException;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.transportpce.common.NetworkUtils;
 import org.opendaylight.transportpce.networkmodel.util.LinkIdUtil;
 import org.opendaylight.transportpce.networkmodel.util.OpenRoadmFactory;
@@ -55,10 +57,10 @@ final class Rdm2XpdrLink {
         WriteTransaction wrtx = dataBroker.newWriteOnlyTransaction();
         wrtx.merge(LogicalDatastoreType.CONFIGURATION, nwIID.build(), topoNetowkLayer);
 
-        ListenableFuture<Void> submit = wrtx.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = wrtx.commit();
 
         try {
-            submit.get();
+            commit.get();
             LOG.info("Post successful");
             return true;
 
@@ -86,9 +88,9 @@ final class Rdm2XpdrLink {
             new NetworkKey(new NetworkId(NetworkUtils.OVERLAY_NETWORK_ID)));
         WriteTransaction wrtx = dataBroker.newWriteOnlyTransaction();
         wrtx.merge(LogicalDatastoreType.CONFIGURATION, nwIID.build(), topoNetowkLayer);
-        ListenableFuture<Void> submit = wrtx.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = wrtx.commit();
         try {
-            submit.get();
+            commit.get();
             LOG.info("Post successful");
             return true;
 
index e4200f382e7877e7c53570791d5c7a9de6fa0052..32254ee056be619c2a904de6540136d53e832332 100644 (file)
@@ -56,7 +56,7 @@ public final class ClliNetwork {
                 new NetworkKey(new NetworkId(NetworkUtils.CLLI_NETWORK_ID)));
             WriteTransaction wrtx = controllerdb.newWriteOnlyTransaction();
             wrtx.put(LogicalDatastoreType.CONFIGURATION, nwIID.build(), clliNetwork);
-            wrtx.submit().get(1, TimeUnit.SECONDS);
+            wrtx.commit().get(1, TimeUnit.SECONDS);
             LOG.info("CLLI-Network created successfully.");
         } catch (ExecutionException | TimeoutException | InterruptedException e) {
             LOG.warn("Failed to create CLLI-Network", e);
index 3297a648a1afa375901bb9bdf34432a8fe656c18..856732b4f733de126d31271c32fa78be0c143e8c 100644 (file)
@@ -63,7 +63,7 @@ public final class OpenRoadmNetwork {
                 new NetworkKey(new NetworkId(NetworkUtils.UNDERLAY_NETWORK_ID)));
             WriteTransaction wrtx = controllerdb.newWriteOnlyTransaction();
             wrtx.put(LogicalDatastoreType.CONFIGURATION, nwIID.build(), openRoadmNetwork);
-            wrtx.submit().get(1, TimeUnit.SECONDS);
+            wrtx.commit().get(1, TimeUnit.SECONDS);
             LOG.info("OpenRoadm-Network created successfully.");
         } catch (ExecutionException | TimeoutException | InterruptedException e) {
             LOG.warn("Failed to create OpenRoadm-Network", e);
index 5c468c92276c32f40804f7dc582ce08fff817877..9e7415165fad39a581f5d611f495dca8df743141 100644 (file)
@@ -61,7 +61,7 @@ public final class PceTestUtils {
             .build();
         WriteTransaction dataWriteTransaction = dataBroker.newWriteOnlyTransaction();
         dataWriteTransaction.put(LogicalDatastoreType.CONFIGURATION, nwInstanceIdentifier, (Network) dataObject.get());
-        dataWriteTransaction.submit().get();
+        dataWriteTransaction.commit().get();
     }
 
     public static void checkConfigurationResponse(PathComputationRequestOutput output,
index 4e654a745fee5f7321673a6bd67423f4d2e55e92..7c7812f0643ef57524e951cec4e9deccdbf4eb55 100644 (file)
@@ -236,7 +236,7 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
             nodeWriteTx.put(LogicalDatastoreType.CONFIGURATION, createNode1IID(nodeId), node1Builder.build(), true);
         }
         try {
-            nodeWriteTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            nodeWriteTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.error("Unable to add available WL {} for nodes {}!", wavelengthNumber, String.join(", ", nodeIds), e);
         }
@@ -285,7 +285,7 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
             nodeWriteTx.delete(LogicalDatastoreType.CONFIGURATION, availableWlIID);
         }
         try {
-            nodeWriteTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            nodeWriteTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.error("Unable to delete available WL {} for nodes {}!", wavelengthNumber, String.join(", ", nodeIds),
                     e);
@@ -386,7 +386,7 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
             deleteUsedWlTx.delete(LogicalDatastoreType.CONFIGURATION, usedWlIID);
         }
         try {
-            deleteUsedWlTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            deleteUsedWlTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             List<String> tpIdsString = tpIds.stream().map(NodeIdPair::toString).collect(Collectors.toList());
             LOG.error("Unable to delete used WL {} from TPs {}!", wavelengthIndex, String.join(", ", tpIdsString), e);
@@ -404,8 +404,9 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
             if (tpOpt.isPresent()) {
                 tp = tpOpt.get();
             } else {
-                LOG.error("Unable to get termination point {} from topology {}! Skipping removal of used wavelength"
-                        + " for this node.", idPair.getTpID(), NetworkUtils.OVERLAY_NETWORK_ID);
+                LOG.error(
+                    "Unable to get termination point {} from topology {}! Skip removal of used wavelength for the node",
+                         idPair.getTpID(), NetworkUtils.OVERLAY_NETWORK_ID);
                 continue;
             }
 
@@ -550,7 +551,7 @@ public class NetworkModelWavelengthServiceImpl implements NetworkModelWavelength
                     idPair.getTpID()).build(), tp1Builder.build(), true);
         }
         try {
-            addUsedWlTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            addUsedWlTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             List<String> tpIdsString = tpIds.stream().map(NodeIdPair::toString).collect(Collectors.toList());
             LOG.error("Unable to add used WL {} for TPs {}!", wavelengthIndex, String.join(", ", tpIdsString), e);
index bfd232880859173cac04d65c1d0662c5053753a1..51bd3c022dbd1abbe5e27fcceb1cfe6864dad73b 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.transportpce.renderer.provisiondevice;
 
 import com.google.common.collect.Sets;
+import com.google.common.util.concurrent.FluentFuture;
 
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -23,10 +24,12 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.crossconnect.CrossConnect;
@@ -401,9 +404,9 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                                 new NodelistKey(input.getServiceName()));
         final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodeListIID, nodeListBuilder.build());
-        Future<Void> submit = writeTransaction.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
         try {
-            submit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            commit.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
             LOG.info("Nodes are register for alarm suppression for service: {}", input.getServiceName());
             return true;
         } catch (ExecutionException | InterruptedException | TimeoutException e) {
@@ -421,9 +424,9 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
                                 new NodelistKey(serviceName));
         final WriteTransaction writeTransaction = this.dataBroker.newWriteOnlyTransaction();
         writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, nodeListIID);
-        Future<Void> submit = writeTransaction.submit();
+        FluentFuture<? extends @NonNull CommitInfo> commit = writeTransaction.commit();
         try {
-            submit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            commit.get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
             LOG.info("Nodes are unregister for alarm suppression for service: {}", serviceName);
             return true;
         } catch (InterruptedException | TimeoutException | ExecutionException e) {
@@ -453,7 +456,7 @@ public class DeviceRendererServiceImpl implements DeviceRendererService {
             servicesBuilder.setTopology(topo);
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
             writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, servicesBuilder.build());
-            writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
         } else {
             LOG.warn("Service {} does not exist - topology can not be updated", name);
         }
index d6bf58df8776fd2262c6efa9e93ceb01e4497e59..db79be7b110c60620889e812993d4a66e1520947 100644 (file)
@@ -7,16 +7,18 @@
  */
 package org.opendaylight.transportpce.servicehandler.service;
 
+import com.google.common.util.concurrent.FluentFuture;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.transportpce.common.OperationResult;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.servicehandler.ModelMappingUtils;
@@ -61,7 +63,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             InstanceIdentifier<ServiceList> iid = InstanceIdentifier.create(ServiceList.class);
             ServiceList initialRegistry = new ServiceListBuilder().build();
             transaction.put(LogicalDatastoreType.OPERATIONAL, iid, initialRegistry);
-            Future<Void> future = transaction.submit();
+            FluentFuture<? extends @NonNull CommitInfo> future = transaction.commit();
             future.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn("init failed: {}", e.getMessage());
@@ -75,7 +77,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             InstanceIdentifier<TempServiceList> iid = InstanceIdentifier.create(TempServiceList.class);
             TempServiceList initialRegistry = new TempServiceListBuilder().build();
             transaction.put(LogicalDatastoreType.OPERATIONAL, iid, initialRegistry);
-            Future<Void> future = transaction.submit();
+            FluentFuture<? extends @NonNull CommitInfo> future = transaction.commit();
             future.get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             LOG.warn("init failed: {}", e.getMessage());
@@ -124,7 +126,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             InstanceIdentifier<Services> iid =
                     InstanceIdentifier.create(ServiceList.class).child(Services.class, new ServicesKey(serviceName));
             writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
-            writeTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             String message = "Failed to delete service " + serviceName + " from Service List";
@@ -144,7 +146,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
                         new org.opendaylight.yang.gen.v1.http.org.openroadm.service.rev161014.temp.service.list
                             .ServicesKey(commonId));
             writeTx.delete(LogicalDatastoreType.OPERATIONAL, iid);
-            writeTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             String message = "Failed to delete service " + commonId + " from Service List";
@@ -166,7 +168,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
                         .setAdministrativeState(administrativeState)
                         .build();
                 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, services);
-                writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+                writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
                 return OperationResult.ok(SUCCESSFUL_MESSAGE);
             } catch (TimeoutException | InterruptedException | ExecutionException e) {
                 String message = "Failed to modify service " + serviceName + " from Service List";
@@ -199,7 +201,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
                             .setAdministrativeState(administrativeState)
                             .build();
                 writeTx.merge(LogicalDatastoreType.OPERATIONAL, iid, services);
-                writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+                writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
                 return OperationResult.ok(SUCCESSFUL_MESSAGE);
             } catch (TimeoutException | InterruptedException | ExecutionException e) {
                 String message = "Failed to modify temp service " + serviceName + " from Temp Service List";
@@ -222,7 +224,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             Services service = ModelMappingUtils.mappingServices(serviceCreateInput, null);
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
             writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
-            writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             String message = "Failed to create service " + serviceCreateInput.getServiceName() + " to Service List";
@@ -244,7 +246,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
                 .Services service = ModelMappingUtils.mappingServices(tempServiceCreateInput);
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
             writeTx.put(LogicalDatastoreType.OPERATIONAL, iid, service);
-            writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             String message = "Failed to create Temp service " + tempServiceCreateInput.getCommonId()
@@ -263,7 +265,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
             ServicePaths servicePath = ModelMappingUtils.mappingServicePaths(serviceInput, outputFromPce);
             WriteTransaction writeTx = this.dataBroker.newWriteOnlyTransaction();
             writeTx.put(LogicalDatastoreType.OPERATIONAL, servicePathsIID, servicePath);
-            writeTx.submit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
+            writeTx.commit().get(Timeouts.DATASTORE_WRITE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (TimeoutException | InterruptedException | ExecutionException e) {
             String message = "Failed to create servicePath " + serviceInput.getCommonId() + " to ServicePath List";
@@ -280,7 +282,7 @@ public class ServiceDataStoreOperationsImpl implements ServiceDataStoreOperation
         WriteTransaction servicePathsWriteTx = this.dataBroker.newWriteOnlyTransaction();
         servicePathsWriteTx.delete(LogicalDatastoreType.OPERATIONAL, servicePathsIID);
         try {
-            servicePathsWriteTx.submit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
+            servicePathsWriteTx.commit().get(Timeouts.DATASTORE_DELETE, TimeUnit.MILLISECONDS);
             return OperationResult.ok(SUCCESSFUL_MESSAGE);
         } catch (InterruptedException | ExecutionException | TimeoutException e) {
             String message = "Unable to delete service path " + serviceName;
index 861cb948d75c4c12d7b2f3c68ffa58004bd7b039..6675f5db0fcafce357fc3a51a1cab90fc821a93f 100644 (file)
@@ -141,7 +141,7 @@ public final class DeviceWrapper {
         DOMDataWriteTransaction writeOnlyTransaction = domDataBroker.newWriteOnlyTransaction();
         writeOnlyTransaction.put(LogicalDatastoreType.OPERATIONAL, initialDataIi, dataNormalizedNodes.get());
         try {
-            writeOnlyTransaction.submit().get();
+            writeOnlyTransaction.commit().get();
         } catch (InterruptedException | ExecutionException e) {
             LOG.error("This should be not reached {}", e.getMessage(), e);
             throw new IllegalStateException(e);