Search in sources :

Example 6 with InstructionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId in project bgpcep by opendaylight.

the class ProgrammingServiceImpl method collectDependencies.

private List<InstructionImpl> collectDependencies(final SubmitInstructionInput input) throws SchedulerException {
    final List<InstructionImpl> dependencies = new ArrayList<>();
    for (final InstructionId pid : input.getPreconditions()) {
        final InstructionImpl instruction = this.insns.get(pid);
        if (instruction == null) {
            LOG.info("Instruction {} depends on {}, which is not a known instruction", input.getId(), pid);
            throw new SchedulerException("Unknown dependency ID specified", new FailureBuilder().setType(UnknownPreconditionId.class).build());
        }
        dependencies.add(instruction);
    }
    return dependencies;
}
Also used : FailureBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.failure._case.FailureBuilder) SchedulerException(org.opendaylight.bgpcep.programming.spi.SchedulerException) 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 7 with InstructionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId in project bgpcep by opendaylight.

the class MockedNotificationServiceWrapper method assertInstructionStatusChangedNotification.

void assertInstructionStatusChangedNotification(final int idx, final InstructionId id, final InstructionStatus status) {
    assertTrue(InstructionStatusChanged.class.isAssignableFrom(this.publishedNotifications.get(idx).getClass()));
    final InstructionStatusChanged firstNotification = (InstructionStatusChanged) this.publishedNotifications.get(idx);
    assertInstructionStatusChangedNotification(id, status, firstNotification);
}
Also used : InstructionStatusChanged(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionStatusChanged)

Example 8 with InstructionId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId in project bgpcep by opendaylight.

the class ProgrammingServiceImplTest method getMockedSubmitInstructionInput.

private static SubmitInstructionInput getMockedSubmitInstructionInput(final String id, final Optional<Nanotime> deadline, final String... dependencyIds) {
    final SubmitInstructionInput mockedSubmitInstruction = mock(SubmitInstructionInput.class);
    doReturn(PcepUpdateTunnelInput.class).when(mockedSubmitInstruction).getImplementedInterface();
    final List<InstructionId> dependencies = Lists.newArrayList();
    for (final String dependencyId : dependencyIds) {
        dependencies.add(new InstructionId(dependencyId));
    }
    doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
    doReturn(new InstructionId(id)).when(mockedSubmitInstruction).getId();
    doReturn(deadline.isPresent() ? deadline.get() : new Nanotime(BigInteger.valueOf(Long.MAX_VALUE))).when(mockedSubmitInstruction).getDeadline();
    return mockedSubmitInstruction;
}
Also used : InstructionId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SubmitInstructionInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput) Nanotime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime)

Aggregations

InstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionId)7 ArrayList (java.util.ArrayList)4 DuplicateInstructionId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.DuplicateInstructionId)3 SchedulerException (org.opendaylight.bgpcep.programming.spi.SchedulerException)2 Nanotime (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.Nanotime)2 DetailsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction.status.changed.DetailsBuilder)2 FailureBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.submit.instruction.output.result.failure._case.FailureBuilder)2 Timeout (io.netty.util.Timeout)1 BigInteger (java.math.BigInteger)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Instruction (org.opendaylight.bgpcep.programming.spi.Instruction)1 CancelInstructionInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CancelInstructionInputBuilder)1 CleanInstructionsOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.CleanInstructionsOutputBuilder)1 InstructionStatusChanged (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.InstructionStatusChanged)1 SubmitInstructionInput (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.SubmitInstructionInput)1 UnknownInstruction (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.UnknownInstruction)1