Search in sources :

Example 6 with Graph

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());
}
Also used : ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) GraphTopologyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.GraphTopologyBuilder) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 7 with Graph

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;
        }
    }
}
Also used : ConnectedGraph(org.opendaylight.graph.ConnectedGraph) Graph(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph) ConnectedGraph(org.opendaylight.graph.ConnectedGraph) GraphKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.GraphKey)

Example 8 with Graph

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());
}
Also used : CancelInstructionOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionOutputBuilder) UnknownInstruction(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.UnknownInstruction) CancelInstructionOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionOutput)

Example 9 with Graph

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());
}
Also used : CleanInstructionsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsOutputBuilder) InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) DuplicateInstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.DuplicateInstructionId) ArrayList(java.util.ArrayList)

Example 10 with Graph

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;
}
Also used : ConstrainedPathBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPathBuilder) ConnectedVertex(org.opendaylight.graph.ConnectedVertex)

Aggregations

Uint64 (org.opendaylight.yangtools.yang.common.Uint64)4 ConnectedGraph (org.opendaylight.graph.ConnectedGraph)3 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)3 Prefix (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Prefix)3 PathComputationAlgorithm (org.opendaylight.algo.PathComputationAlgorithm)2 ConnectedVertex (org.opendaylight.graph.ConnectedVertex)2 Graph (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.Graph)2 Edge (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Edge)2 PrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.PrefixBuilder)2 Vertex (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.Vertex)2 VertexKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev191125.graph.topology.graph.VertexKey)2 ConstrainedPath (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev200120.ConstrainedPath)2 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)2 ArrayList (java.util.ArrayList)1 ConnectedEdge (org.opendaylight.graph.ConnectedEdge)1 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)1 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)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