use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project bgpcep by opendaylight.
the class ConnectedGraphImpl method addEdge.
@Override
public ConnectedEdge addEdge(final Edge edge) {
checkArgument(edge != null, "Provided Edge is a null object");
ConnectedEdgeImpl cedge = updateConnectedEdge(edge.getEdgeId().longValue());
Edge old = cedge.getEdge();
if (old == null) {
ConnectedVertexImpl source = null;
ConnectedVertexImpl destination = null;
if (edge.getLocalVertexId() != null) {
source = updateConnectedVertex(edge.getLocalVertexId().longValue());
}
if (edge.getRemoteVertexId() != null) {
destination = updateConnectedVertex(edge.getRemoteVertexId().longValue());
}
connectVertices(source, destination, cedge);
}
this.connectedGraphServer.addEdge(this.graph, edge, old);
cedge.setEdge(edge);
return cedge;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project bgpcep by opendaylight.
the class PCEPUnreachDestinationSerializer method serializeObject.
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
Preconditions.checkArgument(object instanceof UnreachDestinationObj, "Wrong instance of PCEPObject. Passed %s. Needed UnreachDestinationObj.", object.getClass());
final UnreachDestinationObj uPObj = (UnreachDestinationObj) object;
final Destination destination = uPObj.getDestination();
final Boolean processing = object.getProcessingRule();
final Boolean ignore = object.getIgnore();
if (destination instanceof Ipv6DestinationCase) {
final Ipv6DestinationCase ipv6 = (Ipv6DestinationCase) destination;
PCEPIpv6UnreachDestinationParser.serializeObject(processing, ignore, ipv6, buffer);
} else if (destination instanceof Ipv4DestinationCase) {
final Ipv4DestinationCase ipv4 = (Ipv4DestinationCase) destination;
PCEPIpv4UnreachDestinationParser.serializeObject(processing, ignore, ipv4, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project bgpcep by opendaylight.
the class PathComputationImpl method getDestinationVertexKey.
private VertexKey getDestinationVertexKey(final EndpointsObj endPoints) {
IpAddress address = null;
if (endPoints.getAddressFamily() instanceof Ipv4Case) {
address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getDestinationIpv4Address());
}
if (endPoints.getAddressFamily() instanceof Ipv6Case) {
address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getDestinationIpv6Address());
}
if (address == null) {
return null;
}
ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
LOG.debug("Compute path to Destination {}", vertex != null ? vertex : "Unknown");
return vertex != null ? vertex.getVertex().key() : null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project bgpcep by opendaylight.
the class PathComputationImpl method computeEro.
@Override
public Ero computeEro(final EndpointsObj endpoints, final Bandwidth bandwidth, final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
VertexKey source = getSourceVertexKey(endpoints);
VertexKey destination = getDestinationVertexKey(endpoints);
if (source == null) {
return null;
}
if (destination == null) {
return null;
}
/* Create new Constraints Object from the request */
PathConstraints cts = getConstraints(endpoints, bandwidth, classType, metrics, segmentRouting);
/* Determine Path Computation Algorithm according to parameters */
AlgorithmType algoType;
if (cts.getTeMetric() == null && cts.getDelay() == null && cts.getBandwidth() == null) {
algoType = AlgorithmType.Spf;
} else if (cts.getDelay() == null) {
algoType = AlgorithmType.Cspf;
} else {
algoType = AlgorithmType.Samcra;
}
PathComputationAlgorithm algo = algoProvider.getPathComputationAlgorithm(tedGraph, algoType);
if (algo == null) {
return null;
}
/*
* Request Path Computation for given source, destination and
* constraints
*/
final ConstrainedPath cpath = algo.computeP2pPath(source, destination, cts);
LOG.info("Computed ERO: {}", cpath.getPathDescription());
/* Check if we got a valid Path and return appropriate ERO */
if (cpath.getStatus() == ComputationStatus.Completed) {
return MessagesUtil.getEro(cpath.getPathDescription());
} else {
return null;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.Destination in project bgpcep by opendaylight.
the class NodeChangedListener method remove.
private void remove(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier, final ReportedLsp value) throws ExecutionException, InterruptedException {
final InstanceIdentifier<Link> li = linkForLsp(linkIdForLsp(identifier, value));
final Optional<Link> ol = trans.read(LogicalDatastoreType.OPERATIONAL, li).get();
if (!ol.isPresent()) {
return;
}
final Link l = ol.get();
LOG.debug("Removing link {} (was {})", li, l);
trans.delete(LogicalDatastoreType.OPERATIONAL, li);
LOG.debug("Searching for orphan links/nodes");
final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).get();
Preconditions.checkState(ot.isPresent());
final Topology topology = ot.get();
final NodeId srcNode = l.getSource().getSourceNode();
final NodeId dstNode = l.getDestination().getDestNode();
final TpId srcTp = l.getSource().getSourceTp();
final TpId dstTp = l.getDestination().getDestTp();
boolean orphSrcNode = true;
boolean orphDstNode = true;
boolean orphDstTp = true;
boolean orphSrcTp = true;
for (final Link lw : topology.nonnullLink().values()) {
LOG.trace("Checking link {}", lw);
final NodeId sn = lw.getSource().getSourceNode();
final NodeId dn = lw.getDestination().getDestNode();
final TpId st = lw.getSource().getSourceTp();
final TpId dt = lw.getDestination().getDestTp();
// Source node checks
if (srcNode.equals(sn)) {
if (orphSrcNode) {
LOG.debug("Node {} held by source of link {}", srcNode, lw);
orphSrcNode = false;
}
if (orphSrcTp && srcTp.equals(st)) {
LOG.debug("TP {} held by source of link {}", srcTp, lw);
orphSrcTp = false;
}
}
if (srcNode.equals(dn)) {
if (orphSrcNode) {
LOG.debug("Node {} held by destination of link {}", srcNode, lw);
orphSrcNode = false;
}
if (orphSrcTp && srcTp.equals(dt)) {
LOG.debug("TP {} held by destination of link {}", srcTp, lw);
orphSrcTp = false;
}
}
// Destination node checks
if (dstNode.equals(sn)) {
if (orphDstNode) {
LOG.debug("Node {} held by source of link {}", dstNode, lw);
orphDstNode = false;
}
if (orphDstTp && dstTp.equals(st)) {
LOG.debug("TP {} held by source of link {}", dstTp, lw);
orphDstTp = false;
}
}
if (dstNode.equals(dn)) {
if (orphDstNode) {
LOG.debug("Node {} held by destination of link {}", dstNode, lw);
orphDstNode = false;
}
if (orphDstTp && dstTp.equals(dt)) {
LOG.debug("TP {} held by destination of link {}", dstTp, lw);
orphDstTp = false;
}
}
}
if (orphSrcNode && !orphSrcTp) {
LOG.warn("Orphan source node {} but not TP {}, retaining the node", srcNode, srcTp);
orphSrcNode = false;
}
if (orphDstNode && !orphDstTp) {
LOG.warn("Orphan destination node {} but not TP {}, retaining the node", dstNode, dstTp);
orphDstNode = false;
}
if (orphSrcNode) {
LOG.debug("Removing orphan node {}", srcNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(srcNode));
} else if (orphSrcTp) {
LOG.debug("Removing orphan TP {} on node {}", srcTp, srcNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(srcNode, srcTp));
}
if (orphDstNode) {
LOG.debug("Removing orphan node {}", dstNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, nodeIdentifier(dstNode));
} else if (orphDstTp) {
LOG.debug("Removing orphan TP {} on node {}", dstTp, dstNode);
trans.delete(LogicalDatastoreType.OPERATIONAL, tpIdentifier(dstNode, dstTp));
}
}
Aggregations