use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class ConnectedGraphServer method initOperationalGraphModel.
/**
* Initialize GraphModel tree at Data Store top-level.
*/
private synchronized void initOperationalGraphModel() {
requireNonNull(this.chain, "A valid transaction chain must be provided.");
final WriteTransaction trans = this.chain.newWriteOnlyTransaction();
LOG.info("Create Graph Model at top level in Operational DataStore: {}", GRAPH_TOPOLOGY_IDENTIFIER);
trans.put(LogicalDatastoreType.OPERATIONAL, GRAPH_TOPOLOGY_IDENTIFIER, new GraphTopologyBuilder().build());
trans.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Transaction {} committed successfully", trans.getIdentifier());
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failed to initialize GraphModel {} (transaction {}) by listener {}", GRAPH_TOPOLOGY_IDENTIFIER, trans.getIdentifier(), ConnectedGraphServer.this, throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class GraphListener method onDataTreeChanged.
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Graph>> changes) {
for (DataTreeModification<Graph> change : changes) {
DataObjectModification<Graph> root = change.getRootNode();
GraphKey key = change.getRootPath().getRootIdentifier().firstKeyOf(Graph.class);
switch(root.getModificationType()) {
case DELETE:
graphProvider.deleteGraph(key);
break;
case SUBTREE_MODIFIED:
/* getModificationType() returns SUBTREE_MODIFIED only when Data Object is already present in the
* Data Store, thus, only for deletion. Thus, to insert children, we must used parseSubTree()
* method (See above). This method is called only when the graph already exists.
*/
case WRITE:
/* First look if the Graph was not already configured */
ConnectedGraph cgraph = this.graphProvider.getConnectedGraph(key);
if (cgraph == null) {
graphProvider.addGraph(root.getDataAfter());
} else {
/* Graph exist, process Children */
parseSubTree(cgraph, root.getModifiedChildren());
}
break;
default:
break;
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class ProgrammingServiceImpl method realCancelInstruction.
private synchronized RpcResult<CancelInstructionOutput> realCancelInstruction(final CancelInstructionInput input) {
final InstructionImpl instruction = this.insns.get(input.getId());
if (instruction == null) {
LOG.debug("Instruction {} not present in the graph", input.getId());
final CancelInstructionOutput out = new CancelInstructionOutputBuilder().setFailure(UnknownInstruction.class).build();
return SuccessfulRpcResult.create(out);
}
return SuccessfulRpcResult.create(new CancelInstructionOutputBuilder().setFailure(instruction.tryCancel(null)).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph in project bgpcep by opendaylight.
the class ProgrammingServiceImpl method realCleanInstructions.
private synchronized RpcResult<CleanInstructionsOutput> realCleanInstructions(final CleanInstructionsInput input) {
final List<InstructionId> failed = new ArrayList<>();
for (final InstructionId id : input.getId()) {
// Find the instruction
final InstructionImpl instruction = this.insns.get(id);
if (instruction == null) {
LOG.debug("Instruction {} not present in the graph", input.getId());
failed.add(id);
continue;
}
// Check its status
switch(instruction.getStatus()) {
case Cancelled:
case Failed:
case Successful:
break;
case Executing:
case Queued:
case Scheduled:
case Unknown:
LOG.debug("Instruction {} cannot be cleaned because of it's in state {}", id, instruction.getStatus());
failed.add(id);
continue;
default:
break;
}
// The instruction is in a terminal state, we need to just unlink
// it from its dependencies and dependents
instruction.clean();
this.insns.remove(id);
LOG.debug("Instruction {} cleaned successfully", id);
}
final CleanInstructionsOutputBuilder ob = new CleanInstructionsOutputBuilder();
ob.setUnflushed(failed);
return SuccessfulRpcResult.create(ob.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph 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