X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Ftopology-manager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Ftopology%2Fmanager%2FTopologyManagerUtil.java;h=f99fb50c06050e915dd8bd23b526f810c541c9a2;hb=38f326861531f68cb5aa48cc2b1fbdcc2d75885c;hp=2193a13576b0d9958dd98bbca8939b533ac94f5e;hpb=b5dfc8eb1e58ecb3fdfde4ec170248c1c37b60ba;p=openflowplugin.git diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java index 2193a13576..f99fb50c06 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TopologyManagerUtil.java @@ -20,64 +20,46 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; final class TopologyManagerUtil { - private static final Logger LOG = LoggerFactory.getLogger(TopologyManagerUtil.class); private TopologyManagerUtil() { + // Hidden on purpose } static void removeAffectedLinks(final NodeId id, final TransactionChainManager manager, - InstanceIdentifier topology) { - Optional topologyOptional = Optional.empty(); + final InstanceIdentifier topology) { + final Optional topologyOptional; try { 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); - } - if (topologyOptional.isPresent()) { - removeAffectedLinks(id, topologyOptional, manager, topology); - } - } - - private static void removeAffectedLinks(final NodeId id, Optional topologyOptional, - TransactionChainManager manager, - final InstanceIdentifier topology) { - if (!topologyOptional.isPresent()) { return; } - - for (Link link : topologyOptional.get().nonnullLink()) { - if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { - manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); + if (topologyOptional.isPresent()) { + for (Link link : topologyOptional.orElseThrow().nonnullLink().values()) { + if (id.equals(link.getSource().getSourceNode()) || id.equals(link.getDestination().getDestNode())) { + manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); + } } } } static void removeAffectedLinks(final TpId id, final TransactionChainManager manager, final InstanceIdentifier topology) { - Optional topologyOptional = Optional.empty(); + final Optional topologyOptional; try { 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); - } - if (topologyOptional.isPresent()) { - removeAffectedLinks(id, topologyOptional, manager, topology); - } - } - - private static void removeAffectedLinks(final TpId id, Optional topologyOptional, - TransactionChainManager manager, - final InstanceIdentifier topology) { - if (!topologyOptional.isPresent()) { return; } - - for (Link link : topologyOptional.get().nonnullLink()) { - if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { - manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); + if (topologyOptional.isPresent()) { + for (Link link : topologyOptional.orElseThrow().nonnullLink().values()) { + if (id.equals(link.getSource().getSourceTp()) || id.equals(link.getDestination().getDestTp())) { + manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, linkPath(link, topology)); + } } } } @@ -85,6 +67,4 @@ final class TopologyManagerUtil { static InstanceIdentifier linkPath(final Link link, final InstanceIdentifier topology) { return topology.child(Link.class, link.key()); } - - }