Search in sources :

Example 1 with DetailsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder in project bgpcep by opendaylight.

the class InstructionImpl method cancelInstrunction.

private synchronized void cancelInstrunction() {
    final List<InstructionId> ids = new ArrayList<>();
    for (final InstructionImpl instruction : this.dependencies) {
        if (instruction.getStatus() != InstructionStatus.Successful) {
            ids.add(instruction.getId());
        }
    }
    cancel(new DetailsBuilder().setUnmetDependencies(ids).build());
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) ArrayList(java.util.ArrayList) DetailsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)

Example 2 with DetailsBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder in project bgpcep by opendaylight.

the class InstructionImpl method checkDependencies.

private Boolean checkDependencies() {
    boolean ready = true;
    final List<InstructionId> unmet = new ArrayList<>();
    for (final InstructionImpl instruction : this.dependencies) {
        switch(instruction.getStatus()) {
            case Cancelled:
            case Failed:
            case Unknown:
                unmet.add(instruction.getId());
                break;
            case Executing:
            case Queued:
            case Scheduled:
                ready = false;
                break;
            case Successful:
                // No-op
                break;
            default:
                break;
        }
    }
    if (!unmet.isEmpty()) {
        LOG.warn("Instruction {} was Queued, while some dependencies were resolved unsuccessfully, cancelling it", this.id);
        cancel(new DetailsBuilder().setUnmetDependencies(unmet).build());
        return false;
    }
    return ready;
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) ArrayList(java.util.ArrayList) DetailsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)

Aggregations

ArrayList (java.util.ArrayList)2 InstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId)2 DetailsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)2