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%2FTerminationPointChangeListenerImpl.java;h=eab8facdb94c32c8e6d8d08dc43d016afc322588;hb=5ae6b8928b7ed3ce989e304c0c57350ca3f692b5;hp=a572b439e2a1aaf984b793d6ab57bb721a8fc893;hpb=4016b1ab46a0df2c1e46f2907bdc27f273988d92;p=openflowplugin.git diff --git a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java index a572b439e2..eab8facdb9 100644 --- a/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java +++ b/applications/topology-manager/src/main/java/org/opendaylight/openflowplugin/applications/topology/manager/TerminationPointChangeListenerImpl.java @@ -34,9 +34,11 @@ import org.slf4j.LoggerFactory; public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerImpl { private static final Logger LOG = LoggerFactory.getLogger(TerminationPointChangeListenerImpl.class); - public TerminationPointChangeListenerImpl(final DataBroker dataBroker, final OperationProcessor operationProcessor) { - super(operationProcessor, dataBroker, InstanceIdentifier.builder(Nodes.class).child(Node.class) - .child(NodeConnector.class).augmentation(FlowCapableNodeConnector.class).build()); + public TerminationPointChangeListenerImpl(final DataBroker dataBroker, + final OperationProcessor operationProcessor) { + super(operationProcessor, dataBroker, + InstanceIdentifier.builder(Nodes.class).child(Node.class).child(NodeConnector.class) + .augmentation(FlowCapableNodeConnector.class).build()); this.operationProcessor = operationProcessor; } @@ -54,8 +56,8 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm processRemovedTerminationPoints(modification); break; default: - throw new IllegalArgumentException("Unhandled modification type: {}" + - modification.getRootNode().getModificationType()); + throw new IllegalArgumentException( + "Unhandled modification type: {}" + modification.getRootNode().getModificationType()); } } } @@ -67,9 +69,15 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm terminationPointId, removedNode); if (iiToTopologyTerminationPoint != null) { - final InstanceIdentifier node = iiToTopologyTerminationPoint.firstIdentifierOf(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node.class); + final InstanceIdentifier + node = iiToTopologyTerminationPoint.firstIdentifierOf( + org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network + .topology.topology.Node.class); operationProcessor.enqueueOperation(manager -> { - Optional nodeOptional = Optional.empty(); + Optional + nodeOptional = Optional.empty(); try { nodeOptional = Optional.ofNullable( manager.readFromTransaction(LogicalDatastoreType.OPERATIONAL, node).checkedGet().orNull()); @@ -79,11 +87,13 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm } if (nodeOptional.isPresent()) { TopologyManagerUtil.removeAffectedLinks(terminationPointId, manager, II_TO_TOPOLOGY); - manager.addDeleteOperationTotTxChain(LogicalDatastoreType.OPERATIONAL, iiToTopologyTerminationPoint); + manager.addDeleteOperationToTxChain(LogicalDatastoreType.OPERATIONAL, + iiToTopologyTerminationPoint); } }); } else { - LOG.debug("Instance identifier to inventory wasn't translated to topology while deleting termination point."); + LOG.debug( + "Instance identifier to inventory wasn't translated to topology while deleting termination point."); } } @@ -92,7 +102,8 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm } private void processAddedTerminationPoints(final DataTreeModification modification) { - final InstanceIdentifier iiToNodeInInventory = modification.getRootPath().getRootIdentifier(); + final InstanceIdentifier iiToNodeInInventory = modification.getRootPath() + .getRootIdentifier(); TpId terminationPointIdInTopology = provideTopologyTerminationPointId(iiToNodeInInventory); if (terminationPointIdInTopology != null) { InstanceIdentifier iiToTopologyTerminationPoint = provideIIToTopologyTerminationPoint( @@ -107,36 +118,47 @@ public class TerminationPointChangeListenerImpl extends DataTreeChangeListenerIm private void removeLinks(final FlowCapableNodeConnector flowCapNodeConnector, final TerminationPoint point) { operationProcessor.enqueueOperation(manager -> { - if ((flowCapNodeConnector.getState() != null && flowCapNodeConnector.getState().isLinkDown()) - || (flowCapNodeConnector.getConfiguration() != null && flowCapNodeConnector.getConfiguration().isPORTDOWN())) { + if ((flowCapNodeConnector.getState() != null && flowCapNodeConnector.getState().isLinkDown()) || ( + flowCapNodeConnector.getConfiguration() != null && flowCapNodeConnector.getConfiguration() + .isPORTDOWN())) { TopologyManagerUtil.removeAffectedLinks(point.getTpId(), manager, II_TO_TOPOLOGY); } }); } private static TerminationPoint prepareTopologyTerminationPoint(final TpId terminationPointIdInTopology, - final InstanceIdentifier iiToNodeInInventory) { + final + InstanceIdentifier + iiToNodeInInventory) { final InventoryNodeConnector inventoryNodeConnector = new InventoryNodeConnectorBuilder() - .setInventoryNodeConnectorRef(new NodeConnectorRef(iiToNodeInInventory.firstIdentifierOf(NodeConnector.class))).build(); + .setInventoryNodeConnectorRef( + new NodeConnectorRef(iiToNodeInInventory.firstIdentifierOf(NodeConnector.class))).build(); final TerminationPointBuilder terminationPointBuilder = new TerminationPointBuilder(); terminationPointBuilder.setTpId(terminationPointIdInTopology); terminationPointBuilder.addAugmentation(InventoryNodeConnector.class, inventoryNodeConnector); return terminationPointBuilder.build(); } - private InstanceIdentifier provideIIToTopologyTerminationPoint(final TpId terminationPointIdInTopology, - final InstanceIdentifier iiToNodeInInventory) { + private InstanceIdentifier provideIIToTopologyTerminationPoint( + final TpId terminationPointIdInTopology, + final InstanceIdentifier iiToNodeInInventory) { NodeId nodeIdInTopology = provideTopologyNodeId(iiToNodeInInventory); if (terminationPointIdInTopology != null && nodeIdInTopology != null) { - InstanceIdentifier iiToTopologyNode = provideIIToTopologyNode(nodeIdInTopology); - return iiToTopologyNode.builder().child(TerminationPoint.class, new TerminationPointKey(terminationPointIdInTopology)).build(); + InstanceIdentifier + iiToTopologyNode = provideIIToTopologyNode(nodeIdInTopology); + return iiToTopologyNode.builder() + .child(TerminationPoint.class, new TerminationPointKey(terminationPointIdInTopology)).build(); } else { - LOG.debug("Value of termination point ID in topology is null. Instance identifier to topology can't be built"); + LOG.debug( + "Value of termination point ID in topology is null. Instance identifier to topology can't be " + + "built"); return null; } } - private static TpId provideTopologyTerminationPointId(final InstanceIdentifier iiToNodeInInventory) { + private static TpId provideTopologyTerminationPointId( + final InstanceIdentifier iiToNodeInInventory) { NodeConnectorKey inventoryNodeConnectorKey = iiToNodeInInventory.firstKeyOf(NodeConnector.class); if (inventoryNodeConnectorKey != null) { return new TpId(inventoryNodeConnectorKey.getId().getValue());