Update MRI projects for Aluminium
[openflowplugin.git] / applications / topology-manager / src / main / java / org / opendaylight / openflowplugin / applications / topology / manager / TopologyManagerUtil.java
index bc2fb8a994f9579c1611903f814ce00ef7a6402c..c2605a334e81ad36c32bc37498cdc21ba56f6cea 100644 (file)
@@ -7,11 +7,9 @@
  */
 package org.opendaylight.openflowplugin.applications.topology.manager;
 
-import com.google.common.base.Optional;
-import java.util.Collections;
-import java.util.List;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import java.util.Optional;
+import java.util.concurrent.ExecutionException;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.common.txchain.TransactionChainManager;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
@@ -30,10 +28,10 @@ final class TopologyManagerUtil {
 
     static void removeAffectedLinks(final NodeId id, final TransactionChainManager manager,
                                     InstanceIdentifier<Topology> topology) {
-        Optional<Topology> topologyOptional = Optional.absent();
+        Optional<Topology> topologyOptional = Optional.empty();
         try {
-            topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).checkedGet();
-        } catch (ReadFailedException e) {
+            topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).get();
+        } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Error reading topology data for topology {}: {}", topology, e.getMessage());
             LOG.debug("Error reading topology data for topology.. ", e);
         }
@@ -49,9 +47,7 @@ final class TopologyManagerUtil {
             return;
         }
 
-        List<Link> linkList =
-                topologyOptional.get().getLink() != null ? topologyOptional.get().getLink() : Collections.emptyList();
-        for (Link link : linkList) {
+        for (Link link : topologyOptional.get().nonnullLink().values()) {
             if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) {
                 manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
             }
@@ -60,10 +56,10 @@ final class TopologyManagerUtil {
 
     static void removeAffectedLinks(final TpId id, final TransactionChainManager manager,
                                     final InstanceIdentifier<Topology> topology) {
-        Optional<Topology> topologyOptional = Optional.absent();
+        Optional<Topology> topologyOptional = Optional.empty();
         try {
-            topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).checkedGet();
-        } catch (ReadFailedException e) {
+            topologyOptional = manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, topology).get();
+        } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Error reading topology data for topology {}: {}", topology, e.getMessage());
             LOG.debug("Error reading topology data for topology..", e);
         }
@@ -79,9 +75,7 @@ final class TopologyManagerUtil {
             return;
         }
 
-        List<Link> linkList = topologyOptional.get().getLink() != null ? topologyOptional.get()
-                .getLink() : Collections.<Link>emptyList();
-        for (Link link : linkList) {
+        for (Link link : topologyOptional.get().nonnullLink().values()) {
             if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) {
                 manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology));
             }
@@ -89,7 +83,7 @@ final class TopologyManagerUtil {
     }
 
     static InstanceIdentifier<Link> linkPath(final Link link, final InstanceIdentifier<Topology> topology) {
-        return topology.child(Link.class, link.getKey());
+        return topology.child(Link.class, link.key());
     }