fix CheckedFutures deprecated warnings
[transportpce.git] / common / src / main / java / org / opendaylight / transportpce / common / mapping / PortMappingVersion121.java
index c9ec9779aac1e41b63a2904a9f2312572124f9ec..6a03fe952464ae895c8d5394ba5393046f09b3f9 100644 (file)
@@ -8,7 +8,7 @@
 
 package org.opendaylight.transportpce.common.mapping;
 
-import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -16,13 +16,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
+import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
 
 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.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.transportpce.common.StringConstants;
 import org.opendaylight.transportpce.common.Timeouts;
 import org.opendaylight.transportpce.common.device.DeviceTransactionManager;
@@ -160,14 +160,13 @@ public class PortMappingVersion121 {
                         .child(Nodes.class, new NodesKey(nodeId))
                         .child(Mapping.class, new MappingKey(oldMapping.getLogicalConnectionPoint()));
                     writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, mapIID, newMapping);
-                    CheckedFuture<Void, TransactionCommitFailedException> submit = writeTransaction.submit();
-                    submit.checkedGet();
+                    ListenableFuture<Void> submit = writeTransaction.submit();
+                    submit.get();
                     return true;
                 }
                 return false;
-            } catch (TransactionCommitFailedException e) {
-                LOG.error("Transaction Commit Error updating Mapping {} for node {}",
-                    oldMapping.getLogicalConnectionPoint(), nodeId, e);
+            } catch (InterruptedException | ExecutionException e) {
+                LOG.error("Error updating Mapping {} for node {}", oldMapping.getLogicalConnectionPoint(), nodeId, e);
                 return false;
             }
         } else {
@@ -189,7 +188,8 @@ public class PortMappingVersion121 {
         int client = 1;
         if (!deviceObject.isPresent() || deviceObject.get().getCircuitPacks() == null) {
             LOG.warn("Circuit Packs are not present for {}", nodeId);
-            return false; // TODO return false or continue?
+            return false;
+            // TODO return false or continue?
         }
         Map<String, String> lcpMap = new HashMap<>();
         Map<String, Mapping> mappingMap = new HashMap<>();
@@ -342,7 +342,8 @@ public class PortMappingVersion121 {
         return cpPerSrg;
     }
 
-    @SuppressWarnings("checkstyle:linelength")  //last LOG info message in this method is too long
+    //last LOG info message in this method is too long
+    @SuppressWarnings("checkstyle:linelength")
     private boolean createPpPortMapping(String nodeId, Info deviceInfo, List<Mapping> portMapList) {
         // Creating mapping data for SRG's PP
         HashMap<Integer, List<org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev170206.srg.CircuitPacks>> srgCps
@@ -589,12 +590,12 @@ public class PortMappingVersion121 {
         InstanceIdentifier<Network> nodesIID = InstanceIdentifier.builder(Network.class).build();
         Network network = nwBldr.build();
         writeTransaction.merge(LogicalDatastoreType.CONFIGURATION, nodesIID, network);
-        CheckedFuture<Void, TransactionCommitFailedException> submit = writeTransaction.submit();
+        ListenableFuture<Void> submit = writeTransaction.submit();
         try {
-            submit.checkedGet();
+            submit.get();
             return true;
 
-        } catch (TransactionCommitFailedException e) {
+        } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Failed to post {}", network, e);
             return false;
         }
@@ -670,7 +671,8 @@ public class PortMappingVersion121 {
         return mpBldr.build();
     }
 
-    @SuppressWarnings("checkstyle:linelength")  // some LOG messages are too long
+    // some LOG messages are too long
+    @SuppressWarnings("checkstyle:linelength")
     private boolean createTtpPortMapping(String nodeId, Info deviceInfo, List<Mapping> portMapList) {
         // Creating mapping data for degree TTP's
         List<Degree> degrees = getDegrees(nodeId, deviceInfo);