use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.
the class ConnectedGraphImpl method addVertex.
@Override
public ConnectedVertex addVertex(final Vertex vertex) {
checkArgument(vertex != null, "Provided Vertex is a null object");
ConnectedVertexImpl cvertex = updateConnectedVertex(vertex.getVertexId().longValue());
Vertex old = cvertex.getVertex();
this.connectedGraphServer.addVertex(this.graph, vertex, old);
cvertex.setVertex(vertex);
return cvertex;
}
use of org.opendaylight.graph.ConnectedVertex 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.graph.ConnectedVertex in project bgpcep by opendaylight.
the class PathComputationImpl method getSourceVertexKey.
private VertexKey getSourceVertexKey(final EndpointsObj endPoints) {
IpAddress address = null;
if (endPoints.getAddressFamily() instanceof Ipv4Case) {
address = new IpAddress(((Ipv4Case) endPoints.getAddressFamily()).getIpv4().getSourceIpv4Address());
}
if (endPoints.getAddressFamily() instanceof Ipv6Case) {
address = new IpAddress(((Ipv6Case) endPoints.getAddressFamily()).getIpv6().getSourceIpv6Address());
}
if (address == null) {
return null;
}
ConnectedVertex vertex = tedGraph.getConnectedVertex(address);
LOG.debug("Compute path from Source {}", vertex != null ? vertex : "Unknown");
return vertex != null ? vertex.getVertex().key() : null;
}
use of org.opendaylight.graph.ConnectedVertex in project bgpcep by opendaylight.
the class AbstractPathComputation method initializePathComputation.
/**
* Initialize the various parameters for Path Computation, in particular the
* Source and Destination CspfPath.
*
* @param src
* Source Vertex Identifier in the Connected Graph
* @param dst
* Destination Vertex Identifier in the Connected Graph
*
* @return Constrained Path Builder with status set to 'OnGoing' if
* initialization success, 'Failed' otherwise
*/
protected ConstrainedPathBuilder initializePathComputation(final VertexKey src, final VertexKey dst) {
ConstrainedPathBuilder cpathBuilder = new ConstrainedPathBuilder().setStatus(ComputationStatus.InProgress);
/* Check that source and destination vertexKey are not identical */
if (src.equals(dst)) {
LOG.warn("Source and Destination are equal: Abort!");
cpathBuilder.setStatus(ComputationStatus.Failed);
return cpathBuilder;
}
/*
* Get the Connected Vertex from the Graph to initialize the source of
* the Cspf Path
*/
ConnectedVertex vertex = graph.getConnectedVertex(src.getVertexId().longValue());
if (vertex == null) {
LOG.warn("Found no source for Vertex Key {}", src);
cpathBuilder.setStatus(ComputationStatus.Failed);
return cpathBuilder;
}
LOG.debug("Create Path Source with Vertex {}", vertex);
pathSource = new CspfPath(vertex).setCost(0).setDelay(0);
cpathBuilder.setSource(vertex.getVertex().getVertexId());
/*
* Get the Connected Vertex from the Graph to initialize the destination
* of the Cspf Path
*/
vertex = graph.getConnectedVertex(dst.getVertexId().longValue());
if (vertex == null) {
LOG.warn("Found no destination for Vertex Key {}", src);
cpathBuilder.setStatus(ComputationStatus.Failed);
return cpathBuilder;
}
LOG.debug("Create Path Destination with Vertex {}", vertex);
pathDestination = new CspfPath(vertex);
cpathBuilder.setDestination(vertex.getVertex().getVertexId());
/* Initialize the Priority Queue, HashMap */
priorityQueue.clear();
priorityQueue.add(pathSource);
processedPath.clear();
processedPath.put(pathSource.getVertexKey(), pathSource);
processedPath.put(pathDestination.getVertexKey(), pathDestination);
return cpathBuilder;
}
Aggregations