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;
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.
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+";
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
*/
}
/**
- * 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
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();
}
}
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()) {
}
/**
- * Returns links associated with specified node
+ * Returns links associated with specified node.
*
* @param node openflow node
* @return list of links
*/
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();
}
} 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