Search in sources :

Example 1 with Edge

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.

the class AbstractPathComputation method pruneEdge.

/**
 * Check if Edge need to be prune regarding all constraints including
 * address family.
 *
 * @return True if Edge must be prune, False if Edge must be keep
 */
protected boolean pruneEdge(final ConnectedEdge edge, final CspfPath path) {
    /* Check that Constraints are initialized */
    if (constraints == null) {
        LOG.warn("Constraints not set");
        return true;
    }
    /* Edge could point to an unknown Vertex e.g. with inter-domain link */
    if (edge.getDestination() == null || edge.getDestination().getVertex() == null) {
        LOG.debug("No Destination");
        return true;
    }
    /* Check that Edge have attributes */
    EdgeAttributes attributes = edge.getEdge() != null ? edge.getEdge().getEdgeAttributes() : null;
    if (attributes == null) {
        LOG.debug("No attributes");
        return true;
    }
    /* Check that Edge belongs to the requested address family */
    switch(constraints.getAddressFamily()) {
        case Ipv4:
            if (attributes.getRemoteAddress() == null || attributes.getRemoteAddress().getIpv4Address() == null) {
                LOG.debug("No Ipv4 address");
                return true;
            }
            break;
        case Ipv6:
            if (attributes.getRemoteAddress() == null || attributes.getRemoteAddress().getIpv6Address() == null) {
                LOG.debug("No Ipv6 address");
                return true;
            }
            break;
        case SrIpv4:
            if (getIpv4NodeSid(edge.getDestination()) == null) {
                LOG.debug("No Node-SID for IPv4");
                return true;
            }
            if (attributes.getAdjSid() == null) {
                LOG.debug("No Adjacency-SID");
                return true;
            }
            break;
        case SrIpv6:
            if (getIpv6NodeSid(edge.getDestination()) == null) {
                LOG.debug("No Node-SID for IPv6");
                return true;
            }
            if (attributes.getAdjSid() == null) {
                LOG.debug("No SR Adjacency-SID");
                return true;
            }
            break;
        default:
            return true;
    }
    /* Skip checking other Constraints for simple SPF algorithm */
    if (this instanceof ShortestPathFirst) {
        LOG.trace("Edge {} is valid for Simple Path Computation", edge);
        return false;
    }
    /*
         * If specified, check that total TE Metric up to this edge respects the
         * initial constraints
         */
    if (constraints.getTeMetric() != null) {
        if (attributes.getTeMetric() == null) {
            return true;
        } else {
            int totalCost = attributes.getTeMetric().intValue() + path.getCost();
            if (totalCost > constraints.getTeMetric().intValue()) {
                LOG.debug("TeMetric {} exceed constraint {}", totalCost, constraints.getTeMetric().intValue());
                return true;
            }
        }
    }
    /*
         * If specified, check that total Delay up to this edge respects the
         * initial constraints
         */
    if (constraints.getDelay() != null) {
        if (attributes.getDelay() == null) {
            return true;
        } else {
            int totalDelay = attributes.getDelay().getValue().intValue() + path.getDelay();
            if (totalDelay > constraints.getDelay().getValue().intValue()) {
                LOG.debug("Delay {} exceed constraint {}", totalDelay, constraints.getDelay().getValue().intValue());
                return true;
            }
        }
    }
    /* Check that Edge respect Loss constraint */
    if (constraints.getLoss() != null) {
        if (attributes.getLoss() == null || attributes.getLoss().getValue().intValue() > constraints.getLoss().getValue().intValue()) {
            return true;
        }
    }
    /* Check that Edge meet Bandwidth constraint */
    int cos = 0;
    if (constraints.getClassType() != null) {
        cos = constraints.getClassType().intValue();
    }
    if (constraints.getBandwidth() != null) {
        if (attributes.getMaxLinkBandwidth() == null || attributes.getMaxResvLinkBandwidth() == null || attributes.getUnreservedBandwidth() == null || attributes.getUnreservedBandwidth().get(cos) == null) {
            return true;
        } else {
            Long bandwidth = constraints.getBandwidth().getValue().longValue();
            Long unrsv = 0L;
            for (UnreservedBandwidth unResBw : attributes.getUnreservedBandwidth()) {
                if (unResBw.getClassType().intValue() == cos) {
                    unrsv = unResBw.getBandwidth().getValue().longValue();
                    break;
                }
            }
            if (unrsv < bandwidth || attributes.getMaxLinkBandwidth().getValue().longValue() < bandwidth || attributes.getMaxResvLinkBandwidth().getValue().longValue() < bandwidth) {
                LOG.debug("Bandwidth constraint is not met");
                return true;
            }
        }
    }
    /* Check that Edge belongs to admin group */
    if (constraints.getAdminGroup() != null && !constraints.getAdminGroup().equals(attributes.getAdminGroup())) {
        LOG.debug("Not in the requested admin-group");
        return true;
    }
    /*
         * OK. All is fine. We can consider this Edge valid, so not to be prune
         */
    LOG.trace("Edge {} is valid for Constrained Path Computation", edge);
    return false;
}
Also used : UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth) EdgeAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributes)

Example 2 with Edge

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.

the class ConstrainedShortestPathFirst method computeP2pPath.

@Override
public ConstrainedPath computeP2pPath(final VertexKey src, final VertexKey dst, final PathConstraints cts) {
    LOG.info("Start CSPF Path Computation from {} to {} with constraints {}", src, dst, cts);
    /* Initialize algorithm */
    this.constraints = cts;
    ConstrainedPathBuilder cpathBuilder = initializePathComputation(src, dst);
    if (cpathBuilder.getStatus() == ComputationStatus.Failed) {
        return cpathBuilder.build();
    }
    cpathBuilder.setBandwidth(cts.getBandwidth()).setClassType(cts.getClassType());
    visitedVertices.clear();
    /* Process all Connected Vertex until priority queue becomes empty. Connected Vertices are added into the
         * priority queue when processing the next Connected Vertex: see relaxMC() method */
    int currentCost = Integer.MAX_VALUE;
    while (priorityQueue.size() != 0) {
        CspfPath currentPath = priorityQueue.poll();
        visitedVertices.put(currentPath.getVertexKey(), currentPath);
        LOG.debug("Got path to Vertex {} from Priority Queue", currentPath.getVertex());
        List<ConnectedEdge> edges = currentPath.getVertex().getOutputConnectedEdges();
        for (ConnectedEdge edge : edges) {
            /* Skip Connected Edges that must be prune i.e. Edges that not satisfy the given constraints,
                 * in particular the Bandwidth, TE Metric and Delay. */
            if (pruneEdge(edge, currentPath)) {
                LOG.trace("  Prune Edge {}", edge);
                continue;
            }
            if (relaxMultiConstraints(edge, currentPath) && pathDestination.getCost() < currentCost) {
                currentCost = pathDestination.getCost();
                cpathBuilder.setPathDescription(getPathDescription(pathDestination.getPath())).setMetric(Uint32.valueOf(pathDestination.getCost())).setStatus(ComputationStatus.Active);
                LOG.debug("  Found a valid path up to destination {}", cpathBuilder.getPathDescription());
            }
        }
    }
    /* The priority queue is empty => all the possible (vertex, path) elements have been explored
         * The "ConstrainedPathBuilder" object contains the optimal path if it exists
         * Otherwise an empty path with status failed is returned
         */
    if (cpathBuilder.getStatus() == ComputationStatus.InProgress || cpathBuilder.getPathDescription().size() == 0) {
        cpathBuilder.setStatus(ComputationStatus.Failed);
    } else {
        cpathBuilder.setStatus(ComputationStatus.Completed);
    }
    return cpathBuilder.build();
}
Also used : ConstrainedPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder) ConnectedEdge(org.opendaylight.graph.ConnectedEdge)

Example 3 with Edge

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.

the class Samcra method computeP2pPath.

/* Samcra Algo:
     *
     * To limit the modification outside the Samcra method the same set of parameters as
     * the CSPF method is used (related to pseudo code, the path length is computed inside
     * the method based on the individual constraint parameters).
     *
     * On contrast to a simple CSPF algo, with Samcra a connected vertex might be associated to several
     * metric vectors from which different path lengths are computed. However a connected vertex is only
     * present once in the priority queue, associated to the minimal path weight, which is used as key
     * to address the priority queue.
     *
     * For a given metric the path weight is an integer value computed as the entire part of
     * the quantity:
     *      100 * (vector_path_metric/target_metric)
     * The path weight correspond to the maximum length computed from either the delay or TE metric.
     *
     * To maintain the priority queue behavior unchanged, a "SamcraPath" classes is created to manage
     * the set of possible paths associated to a given vertex (see above).
     *
     */
@Override
public ConstrainedPath computeP2pPath(final VertexKey src, final VertexKey dst, final PathConstraints cts) {
    ConstrainedPathBuilder cpathBuilder;
    List<ConnectedEdge> edges;
    CspfPath currentPath;
    LOG.info("Start SAMCRA Path Computation from {} to {} with constraints {}", src, dst, cts);
    /* Initialize SAMCRA variables */
    this.constraints = cts;
    cpathBuilder = initializePathComputation(src, dst);
    if (cpathBuilder.getStatus() == ComputationStatus.Failed) {
        return cpathBuilder.build();
    }
    cpathBuilder.setBandwidth(cts.getBandwidth()).setClassType(cts.getClassType());
    samcraPaths.clear();
    samcraPaths.put(pathSource.getVertexKey(), new SamcraPath(pathSource.getVertex()));
    samcraPaths.put(pathDestination.getVertexKey(), new SamcraPath(pathDestination.getVertex()));
    /* Exploration of the priority queue:
         * Each connected vertex is represented only once in the priority queue associated to the path
         * with the minimal length (other path are stored in the SamcraPath object).
         * The top of the queue, i.e. the element with the minimal key( path weight), is processed at each loop
         */
    while (priorityQueue.size() != 0) {
        currentPath = priorityQueue.poll();
        LOG.debug(" - Process path up to Vertex {} from Priority Queue", currentPath.getVertex());
        /* Prepare Samcra Path from current CSP Path except for the source */
        if (!currentPath.equals(pathSource)) {
            SamcraPath currentSamcraPath = samcraPaths.get(currentPath.getVertexKey());
            CspfPath currentCspfPath = currentSamcraPath.getCurrentPath();
            float queuePathLength = currentCspfPath.getPathLength();
            LOG.trace(" - Priority Queue output SamcraPaths {} CurrentPath {} with PathLength {}", currentSamcraPath.currentPath, currentCspfPath, queuePathLength);
        }
        edges = currentPath.getVertex().getOutputConnectedEdges();
        float currentPathLength = 1.0F;
        for (ConnectedEdge edge : edges) {
            /* Connected Vertex's edges processing:
                 * Prune the connected edges that do not satisfy the constraints (Bandwidth, TE Metric, Delay, Loss)
                 * For each remaining edge process the path to the remote vertex using the "relaxSamcra" procedure
                 *
                 * If the return path length is positive, the destination is reached and the
                 * obtained route satisfies the requested constraints.
                 * The path length is checked to record only the optimal route (i.e. the route with
                 * the minimal path length) info obtained from the destination vertex
                 */
            if (pruneEdge(edge, currentPath)) {
                LOG.trace(" - Prune Edge {}", edge);
                continue;
            }
            float pathLength = relaxSamcra(edge, currentPath, pathSource);
            /* Check if we found a valid and better path */
            if (pathLength > 0F && pathLength <= currentPathLength) {
                final SamcraPath finalPath = samcraPaths.get(pathDestination.getVertexKey());
                cpathBuilder.setPathDescription(getPathDescription(finalPath.getCurrentPath().getPath())).setMetric(Uint32.valueOf(finalPath.getCurrentPath().getCost())).setDelay(new Delay(Uint32.valueOf(finalPath.getCurrentPath().getDelay()))).setStatus(ComputationStatus.Active);
                LOG.debug(" - Path to destination found and registered {}", cpathBuilder.getPathDescription());
                currentPathLength = pathLength;
            }
        }
        /* The connected vertex that has been removed from the priority queue may have to be re-inserted with
             * the minimal length non-dominated path associated to the connected vertex if it exists (to be done
             * except for the source). Otherwise, the current path associated to the connected vertex is reset to
             * null to allow the connected vertex addition to the priority queue later on with a new path
             * (refer to "relaxSamcra" for addition of a connected vertex to the priority queue).
             */
        float previousLength = 1.0F;
        CspfPath selectedPath = null;
        if (!currentPath.equals(pathSource)) {
            LOG.debug(" - Processing current path {} up to {} from Priority Queue", currentPath, currentPath.getVertex());
            SamcraPath currentSamcraPath = samcraPaths.get(currentPath.getVertexKey());
            currentSamcraPath.decrementPathCount();
            /*
                 * The list of paths associated to the connected vertex is retrieved
                 * The path used to represent the connected vertex in the Priority Queue is marked from "selected"
                 * to "processed". The list of paths is analyzed to check if other "active" path(s) exist(s).
                 * If it is the case the shortest length is used to re-inject the connected vertex in the Priority Queue
                 */
            for (CspfPath testedPath : currentSamcraPath.getPathList()) {
                LOG.debug(" - Testing path {} with status {} ", testedPath, testedPath.getPathStatus());
                if (testedPath.getPathStatus() == CspfPath.SELECTED) {
                    testedPath.setPathStatus(CspfPath.PROCESSED);
                } else if (testedPath.getPathStatus() == CspfPath.ACTIVE && testedPath.getPathLength() < previousLength) {
                    selectedPath = testedPath;
                    previousLength = testedPath.getPathLength();
                }
            }
            /* If a path is found it is marked as "selected", used as "current path" for the connected vertex
                 * and added to the priority queue
                 */
            if (selectedPath != null) {
                selectedPath.setPathStatus(CspfPath.SELECTED);
                currentSamcraPath.setCurrentPath(selectedPath);
                priorityQueue.add(selectedPath);
                LOG.debug(" - Add path {} to Priority Queue. New path count {} ", selectedPath, currentSamcraPath.getPathCount());
            } else {
                currentSamcraPath.setCurrentPath(null);
            }
        }
    }
    /* The priority queue is empty => all the possible (vertex, path) elements have been explored
         * The "ConstrainedPathBuilder" object contains the optimal path if it exists
         * Otherwise an empty path with status failed is returned
         */
    if (cpathBuilder.getStatus() == ComputationStatus.InProgress || cpathBuilder.getPathDescription().size() == 0) {
        cpathBuilder.setStatus(ComputationStatus.Failed);
    } else {
        cpathBuilder.setStatus(ComputationStatus.Completed);
    }
    return cpathBuilder.build();
}
Also used : ConstrainedPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder) ConnectedEdge(org.opendaylight.graph.ConnectedEdge) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)

Example 4 with Edge

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createEdge.

/**
 * Create new Connected Edge in the Connected Graph.
 *
 * @param value       The complete Linkstate route information
 * @param linkCase    The Link part of the Linkstate route
 * @param attributes  The Link attributes
 */
private void createEdge(final LinkstateRoute value, final LinkCase linkCase, final Attributes attributes) {
    checkArgument(checkLinkState(linkCase), "Missing mandatory information in link {}", linkCase);
    final LinkAttributes la = getLinkAttributes(attributes);
    if (la == null) {
        LOG.warn("Missing attributes in link {} route {}, skipping it", linkCase, value);
        return;
    }
    /* Get Source and Destination Vertex from the graph */
    Uint64 srcId = getVertexId(linkCase.getLocalNodeDescriptors().getCRouterIdentifier());
    Uint64 dstId = getVertexId(linkCase.getRemoteNodeDescriptors().getCRouterIdentifier());
    if (srcId == Uint64.ZERO || dstId == Uint64.ZERO) {
        LOG.warn("Unable to get the Source or Destination Vertex Identifier from link {}, skipping it", linkCase);
        return;
    }
    /* Get Source and Destination Key for the corresponding Edge */
    Uint64 edgeId = getEdgeId(linkCase);
    if (edgeId == Uint64.ZERO) {
        LOG.warn("Unable to get the Edge Identifier from link {}, skipping it", linkCase);
        return;
    }
    /* Add associated Edge */
    Edge edge = new EdgeBuilder().setEdgeId(edgeId).setLocalVertexId(srcId).setRemoteVertexId(dstId).setName(srcId + " - " + dstId).setEdgeAttributes(createEdgeAttributes(la, linkCase.getLinkDescriptors())).build();
    /*
         * Add corresponding Prefix for the Local Address. Remote address will be added with the remote Edge */
    final var localAddress = edge.getEdgeAttributes().getLocalAddress();
    PrefixBuilder prefBuilder = new PrefixBuilder().setVertexId(srcId);
    if (localAddress.getIpv4Address() != null) {
        prefBuilder.setPrefix(new IpPrefix(IetfInetUtil.INSTANCE.ipv4PrefixFor(localAddress.getIpv4Address())));
    }
    if (localAddress.getIpv6Address() != null) {
        prefBuilder.setPrefix(new IpPrefix(IetfInetUtil.INSTANCE.ipv6PrefixFor(localAddress.getIpv6Address())));
    }
    Prefix prefix = prefBuilder.build();
    /* Add the Edge in the Connected Graph */
    LOG.info("Add Edge {} and associated Prefix {} in TED[{}]", edge.getName(), prefix.getPrefix(), cgraph);
    cgraph.addEdge(edge);
    cgraph.addPrefix(prefix);
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) Prefix(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Edge(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge) EdgeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.EdgeBuilder) Uint64(org.opendaylight.yangtools.yang.common.Uint64) PrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)

Example 5 with Edge

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge in project bgpcep by opendaylight.

the class LinkstateGraphBuilder method createEdgeAttributes.

/**
 * Create Edge Attributes from Link attributes.
 *
 * @param la         Linkstate Attributes
 * @param linkDesc   Linkstate Descriptors
 *
 * @return EdgeAttributes
 */
private static EdgeAttributes createEdgeAttributes(final LinkAttributes la, final LinkDescriptors linkDesc) {
    EdgeAttributesBuilder builder = new EdgeAttributesBuilder();
    if (linkDesc.getIpv4InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv4InterfaceAddress()));
    }
    if (linkDesc.getIpv6InterfaceAddress() != null) {
        builder.setLocalAddress(new IpAddress(linkDesc.getIpv6InterfaceAddress()));
    }
    if (linkDesc.getIpv4NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv4NeighborAddress()));
    }
    if (linkDesc.getIpv6NeighborAddress() != null) {
        builder.setRemoteAddress(new IpAddress(linkDesc.getIpv6NeighborAddress()));
    }
    if (linkDesc.getLinkLocalIdentifier() != null) {
        builder.setLocalIdentifier(linkDesc.getLinkLocalIdentifier());
    }
    if (linkDesc.getLinkRemoteIdentifier() != null) {
        builder.setRemoteIdentifier(linkDesc.getLinkRemoteIdentifier());
    }
    if (la.getMetric() != null) {
        builder.setMetric(la.getMetric().getValue());
    }
    if (la.getTeMetric() != null) {
        builder.setTeMetric(la.getTeMetric().getValue());
    }
    if (la.getMaxLinkBandwidth() != null) {
        builder.setMaxLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxLinkBandwidth()));
    }
    if (la.getMaxReservableBandwidth() != null) {
        builder.setMaxResvLinkBandwidth(bandwithToDecimalBandwidth(la.getMaxReservableBandwidth()));
    }
    if (la.getUnreservedBandwidth() != null) {
        int upperBound = Math.min(la.getUnreservedBandwidth().size(), MAX_PRIORITY);
        final List<UnreservedBandwidth> unRsvBw = new ArrayList<>(upperBound);
        for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.UnreservedBandwidth bandwidth : la.nonnullUnreservedBandwidth().values()) {
            unRsvBw.add(new UnreservedBandwidthBuilder().setBandwidth(bandwithToDecimalBandwidth(bandwidth.getBandwidth())).withKey(new UnreservedBandwidthKey(bandwidth.getPriority())).build());
        }
        builder.setUnreservedBandwidth(unRsvBw);
    }
    if (la.getAdminGroup() != null) {
        builder.setAdminGroup(la.getAdminGroup().getValue());
    }
    if (la.getLinkDelay() != null) {
        builder.setDelay(new Delay(la.getLinkDelay().getValue()));
    }
    if (la.getLinkMinMaxDelay() != null && la.getLinkMinMaxDelay() != null) {
        MinMaxDelay mmDelay = new MinMaxDelayBuilder().setMaxDelay(new Delay(la.getLinkMinMaxDelay().getMaxDelay().getValue())).setMinDelay(new Delay(la.getLinkMinMaxDelay().getMinDelay().getValue())).build();
        builder.setMinMaxDelay(mmDelay);
    }
    if (la.getDelayVariation() != null) {
        builder.setJitter(new Delay(la.getDelayVariation().getValue()));
    }
    if (la.getLinkLoss() != null) {
        builder.setLoss(new Loss(la.getLinkLoss().getValue()));
    }
    if (la.getAvailableBandwidth() != null) {
        builder.setAvailableBandwidth(bandwithToDecimalBandwidth(la.getAvailableBandwidth()));
    }
    if (la.getResidualBandwidth() != null) {
        builder.setResidualBandwidth(bandwithToDecimalBandwidth(la.getResidualBandwidth()));
    }
    if (la.getUtilizedBandwidth() != null) {
        builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
    }
    if (la.getSharedRiskLinkGroups() != null) {
        List<Uint32> srlgs = new ArrayList<>();
        for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
            srlgs.add(srlg.getValue());
        }
        builder.setSrlgs(srlgs);
    }
    for (SrAdjIds adj : la.nonnullSrAdjIds()) {
        if (adj.getSidLabelIndex() instanceof LocalLabelCase) {
            boolean backup = false;
            if (adj.getFlags() instanceof OspfAdjFlags) {
                backup = ((OspfAdjFlags) adj.getFlags()).getBackup();
            }
            if (adj.getFlags() instanceof IsisAdjFlags) {
                backup = ((IsisAdjFlags) adj.getFlags()).getBackup();
            }
            if (!backup) {
                builder.setAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            } else {
                builder.setBackupAdjSid(((LocalLabelCase) adj.getSidLabelIndex()).getLocalLabel().getValue());
            }
        }
    }
    return builder.build();
}
Also used : EdgeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.EdgeAttributesBuilder) OspfAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags) ArrayList(java.util.ArrayList) Delay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrAdjIds(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) Uint32(org.opendaylight.yangtools.yang.common.Uint32) UnreservedBandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth) UnreservedBandwidthKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthKey) MinMaxDelayBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelayBuilder) Loss(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss) MinMaxDelay(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.MinMaxDelay) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId) UnreservedBandwidthBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidthBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) IsisAdjFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)

Aggregations

ConnectedEdge (org.opendaylight.graph.ConnectedEdge)6 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)3 ConstrainedPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder)3 ArrayList (java.util.ArrayList)2 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)2 Delay (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Delay)2 UnreservedBandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.edge.attributes.UnreservedBandwidth)2 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)2 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)2 ConnectedVertex (org.opendaylight.graph.ConnectedVertex)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)1 SrAdjIds (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrAdjIds)1 LinkDescriptors (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.link._case.LinkDescriptors)1 LinkAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes)1 IsisAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlags)1 OspfAdjFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.ospf.adj.flags._case.OspfAdjFlags)1 LocalLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase)1 Loss (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.Loss)1