Merge dev/fluorine work across to master
[unimgr.git] / ovs-driver / src / main / java / org / opendaylight / unimgr / mef / nrp / ovs / transaction / TopologyTransaction.java
index ce3a8023121824dde10cfe9fdfbeab0cbf606166..1f6c977d1f1b956e225d14d8e229a278f631264a 100644 (file)
@@ -8,11 +8,16 @@
 package org.opendaylight.unimgr.mef.nrp.ovs.transaction;
 
 import com.google.common.base.Optional;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.unimgr.mef.nrp.common.ResourceNotAvailableException;
+import org.opendaylight.unimgr.mef.nrp.ovs.util.MdsalUtilsExt;
+import org.opendaylight.unimgr.mef.nrp.ovs.util.NullAwareDatastoreGetter;
 import org.opendaylight.unimgr.utils.MdsalUtils;
-import org.opendaylight.unimgr.utils.NullAwareDatastoreGetter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
@@ -23,9 +28,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-import java.util.stream.Collectors;
-
 /**
  * Performs reading transactions related to openflow topology
  * during OvsDriver activation/deactivation.
@@ -35,9 +37,12 @@ import java.util.stream.Collectors;
 public class TopologyTransaction {
     private DataBroker dataBroker;
 
-    private static final String NODE_NOT_FOUND_ERROR_MESSAGE = "Node with port '%s' not found in OPERATIONAL data store.";
-    private static final String LINKS_NOT_FOUND_ERROR_MESSAGE = "Links for node '%s' not found in OPERATIONAL data store.";
-    private static final String TOPOLOGY_NOT_FOUND_ERROR_MESSAGE = "Topology '%s' not found in OPERATIONAL data store.";
+    private static final String NODE_NOT_FOUND_ERROR_MESSAGE
+            = "Node with port '%s' not found in OPERATIONAL data store.";
+    private static final String LINKS_NOT_FOUND_ERROR_MESSAGE
+            = "Links for node '%s' not found in OPERATIONAL data store.";
+    private static final String TOPOLOGY_NOT_FOUND_ERROR_MESSAGE
+            = "Topology '%s' not found in OPERATIONAL data store.";
 
     private static final String FLOW_TOPOLOGY_NAME = "flow:1";
     private static final String INTERSWITCH_LINK_ID_REGEX = "openflow:\\d+:\\d+";
@@ -45,7 +50,7 @@ public class TopologyTransaction {
     private static final Logger LOG = LoggerFactory.getLogger(TopologyTransaction.class);
 
     /**
-     * Creates and initialize TopologyTransaction object
+     * Creates and initialize TopologyTransaction object.
      *
      * @param dataBroker access to data tree store
      */
@@ -54,16 +59,18 @@ public class TopologyTransaction {
     }
 
     /**
-     * Returns list of nodes in openflow topology
+     * Returns list of nodes in openflow topology.
      *
      * @return list of nodes
      */
     public List<NullAwareDatastoreGetter<Node>> readNodes() {
-        return new NullAwareDatastoreGetter<Nodes>(MdsalUtils.readOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, getNodesInstanceId())).collectMany(x -> x::getNode);
+        return new NullAwareDatastoreGetter<Nodes>(MdsalUtils
+                .readOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, getNodesInstanceId()))
+                .collectMany(x -> x::getNode);
     }
 
     /**
-     * Returns openflow node containing port portName
+     * Returns openflow node containing port portName.
      *
      * @param portName node's port name
      * @return node
@@ -74,7 +81,7 @@ public class TopologyTransaction {
             if (node.get().isPresent()) {
                 for (NodeConnector nodeConnector:node.get().get().getNodeConnector()) {
                     FlowCapableNodeConnector flowCapableNodeConnector
-                            = nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+                            = nodeConnector.augmentation(FlowCapableNodeConnector.class);
                     if (portName.equals(flowCapableNodeConnector.getName())) {
                         return node.get().get();
                     }
@@ -87,7 +94,7 @@ public class TopologyTransaction {
     }
 
     public Node readNodeOF(String ofportName) throws ResourceNotAvailableException {
-        String ofNodeName = ofportName.split(":")[0]+":"+ofportName.split(":")[1];
+        String ofNodeName = ofportName.split(":")[0] + ":" + ofportName.split(":")[1];
         Nodes nodes = readOpenFLowTopology(dataBroker);
         if (nodes != null) {
             for (Node node: nodes.getNode()) {
@@ -105,7 +112,7 @@ public class TopologyTransaction {
     }
 
     /**
-     * Returns links associated with specified node
+     * Returns links associated with specified node.
      *
      * @param node openflow node
      * @return list of links
@@ -113,7 +120,7 @@ public class TopologyTransaction {
      */
     public List<Link> readLinks(Node node) throws ResourceNotAvailableException {
         Optional<Topology> flowTopology
-                = MdsalUtils.readTopology(dataBroker, LogicalDatastoreType.OPERATIONAL, FLOW_TOPOLOGY_NAME);
+                = MdsalUtilsExt.readTopology(dataBroker, LogicalDatastoreType.OPERATIONAL, FLOW_TOPOLOGY_NAME);
 
         if (flowTopology.isPresent()) {
             String nodeId = node.getId().getValue();
@@ -129,12 +136,13 @@ public class TopologyTransaction {
             }
         } else {
             LOG.warn(String.format(TOPOLOGY_NOT_FOUND_ERROR_MESSAGE, FLOW_TOPOLOGY_NAME));
-            throw new ResourceNotAvailableException(String.format(TOPOLOGY_NOT_FOUND_ERROR_MESSAGE, FLOW_TOPOLOGY_NAME));
+            throw new ResourceNotAvailableException(String
+                    .format(TOPOLOGY_NOT_FOUND_ERROR_MESSAGE, FLOW_TOPOLOGY_NAME));
         }
     }
 
     /**
-     * Returns interswitch links (links between openflow nodes) associated with specified node
+     * Returns interswitch links (links between openflow nodes) associated with specified node.
      *
      * @param node openflow node
      * @return list of links