Search in sources :

Example 1 with NodeConnectorInfoBuilder

use of org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder in project genius by opendaylight.

the class TunnelInventoryStateListener method add.

@Override
public void add(@NonNull InstanceIdentifier<FlowCapableNodeConnector> key, @NonNull FlowCapableNodeConnector fcNodeConnectorNew) {
    LOG.info("Received NodeConnector Add Event: {}, {}", key, fcNodeConnectorNew);
    EVENT_LOGGER.debug("ITM-TunnelInventoryState,ADD DTCN received for {}", fcNodeConnectorNew.getName());
    String portName = fcNodeConnectorNew.getName();
    // Return if its not tunnel port and if its not Internal
    if (!DirectTunnelUtils.TUNNEL_PORT_PREDICATE.test(portName) && !portName.startsWith("of")) {
        LOG.debug("Node Connector Add {} Interface is not a tunnel I/f, so no-op", portName);
        return;
    }
    if (!directTunnelUtils.isEntityOwner()) {
        LOG.debug("Not an entity owner.");
        return;
    }
    // Optional<OfDpnTep> dpnTepOptional = Optional.ofNullable(null);
    NodeConnectorInfo nodeConnectorInfo = new NodeConnectorInfoBuilder().setNodeConnectorId(key).setNodeConnector(fcNodeConnectorNew).build();
    if (portName.startsWith("of") && interfaceManager.isItmOfTunnelsEnabled()) {
        NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
        Uint64 srcDpn = DirectTunnelUtils.getDpnFromNodeConnectorId(nodeConnectorId);
        OfDpnTep dpntep = null;
        try (Acquired lock = directTunnelUtils.lockTunnel(portName)) {
            try {
                Optional<OfDpnTep> dpnTepOptional = ofDpnTepConfigCache.get(srcDpn.toJava());
                if (!dpnTepOptional.isPresent()) {
                    // Park the notification
                    LOG.debug("Unable to process the NodeConnector ADD event for {} as Config not available." + "Hence parking it", portName);
                    unprocessedOFNCCache.add(portName, nodeConnectorInfo);
                    return;
                } else {
                    dpntep = dpnTepOptional.get();
                }
            } catch (ReadFailedException e) {
                LOG.error("unable to get ofDpnTepConfigCache");
            }
        }
        if (dpntep != null) {
            OfPortStateAddWorkerForNodeConnector ifOfStateAddWorker = new OfPortStateAddWorkerForNodeConnector(new OfPortStateAddWorker(directTunnelUtils, dpntep, txRunner), nodeConnectorInfo);
            EVENT_LOGGER.debug("ITM-Of-tepInventoryState Entity Owner,ADD {} {}", nodeConnectorId.getValue(), portName);
            coordinator.enqueueJob(portName, ifOfStateAddWorker, ITMConstants.JOB_MAX_RETRIES);
        }
    } else {
        addTunnelState(nodeConnectorInfo, portName);
    }
}
Also used : NodeConnectorInfoBuilder(org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder) ReadFailedException(org.opendaylight.mdsal.common.api.ReadFailedException) Acquired(org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired) OfPortStateAddWorker(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) OfPortStateAddWorkerForNodeConnector(org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector) OfDpnTep(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep) NodeConnectorInfo(org.opendaylight.genius.itm.utils.NodeConnectorInfo) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Aggregations

OfPortStateAddWorker (org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorker)1 OfPortStateAddWorkerForNodeConnector (org.opendaylight.genius.itm.itmdirecttunnels.workers.OfPortStateAddWorkerForNodeConnector)1 NodeConnectorInfo (org.opendaylight.genius.itm.utils.NodeConnectorInfo)1 NodeConnectorInfoBuilder (org.opendaylight.genius.itm.utils.NodeConnectorInfoBuilder)1 Acquired (org.opendaylight.infrautils.utils.concurrent.NamedSimpleReentrantLock.Acquired)1 ReadFailedException (org.opendaylight.mdsal.common.api.ReadFailedException)1 OfDpnTep (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.tep.config.OfDpnTep)1 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)1 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)1