Search in sources :

Example 1 with CleanInstructionsOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsOutputBuilder 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)

Aggregations

ArrayList (java.util.ArrayList)1 CleanInstructionsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsOutputBuilder)1 DuplicateInstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.DuplicateInstructionId)1 InstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId)1