Search in sources :

Example 1 with Stateful1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 in project bgpcep by opendaylight.

the class PCCMockCommon method checkResyncSession.

static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp, final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion, final TestingSessionListener pceSessionListener) throws Exception {
    assertNotNull(pceSessionListener.getSession());
    assertTrue(pceSessionListener.isUp());
    final List<Message> messages;
    checkReceivedMessages(pceSessionListener, expectedTotalMessages);
    if (startAtNumberLsp.isPresent()) {
        messages = pceSessionListener.messages().subList(startAtNumberLsp.get(), startAtNumberLsp.get() + expectedNumberOfLsp);
    } else {
        messages = pceSessionListener.messages();
    }
    checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
    assertEquals(expectedNumberOfLsp, messages.size());
    final PCEPSession session = pceSessionListener.getSession();
    checkSession(session, DEAD_TIMER, KEEP_ALIVE);
    assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
    final BigInteger pceDBVersion = session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue();
    assertEquals(startingDBVersion, pceDBVersion);
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Message(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message) BigInteger(java.math.BigInteger)

Example 2 with Stateful1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 in project bgpcep by opendaylight.

the class PCCMockCommon method checkSession.

static void checkSession(final PCEPSession session, final int expectedDeadTimer, final int expectedKeepAlive) {
    assertNotNull(session);
    assertEquals(expectedDeadTimer, session.getPeerPref().getDeadtimer().shortValue());
    assertEquals(expectedKeepAlive, session.getPeerPref().getKeepalive().shortValue());
    final Stateful1 stateful = session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class);
    assertTrue(stateful.isInitiation());
}
Also used : Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)

Example 3 with Stateful1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 in project bgpcep by opendaylight.

the class PCEPStatefulPeerProposalTest method setUp.

@SuppressWarnings("unchecked")
@Before
public void setUp() throws InterruptedException, ExecutionException {
    MockitoAnnotations.initMocks(this);
    this.tlvsBuilder = new TlvsBuilder().addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder().addAugmentation(Stateful1.class, new Stateful1Builder().build()).build()).build());
    doReturn(this.rt).when(this.dataBroker).newReadOnlyTransaction();
    doNothing().when(this.rt).close();
    doReturn(this.listenableFutureMock).when(this.rt).read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
    doReturn(true).when(this.listenableFutureMock).isDone();
    doAnswer(invocation -> {
        final Runnable runnable = (Runnable) invocation.getArguments()[0];
        runnable.run();
        return null;
    }).when(this.listenableFutureMock).addListener(any(Runnable.class), any(Executor.class));
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder) Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1) Executor(java.util.concurrent.Executor) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1) Before(org.junit.Before)

Example 4 with Stateful1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testOpenObjectWithTLV.

@Test
public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
    try (SyncOptimizationsActivator a = new SyncOptimizationsActivator()) {
        a.start(this.ctx);
        final SyncOptimizationsOpenObjectParser parser = new SyncOptimizationsOpenObjectParser(this.ctx.getTlvHandlerRegistry(), this.ctx.getVendorInformationTlvRegistry());
        final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
        final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
        builder.setProcessingRule(false);
        builder.setIgnore(false);
        builder.setVersion(new ProtocolVersion((short) 1));
        builder.setKeepalive((short) 30);
        builder.setDeadTimer((short) 120);
        builder.setSessionId((short) 1);
        final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(Stateful1.class, new Stateful1Builder().build()).build();
        final Tlvs1Builder statBuilder = new Tlvs1Builder();
        statBuilder.setStateful(tlv1);
        final Tlvs3Builder syncOptBuilder = new Tlvs3Builder();
        syncOptBuilder.setLspDbVersion(new LspDbVersionBuilder().setLspDbVersionValue(new BigInteger(DB_VERSION)).build());
        syncOptBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build());
        builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(Tlvs1.class, statBuilder.build()).addAugmentation(Tlvs3.class, syncOptBuilder.build()).build());
        assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
        final ByteBuf buf = Unpooled.buffer();
        parser.serializeObject(builder.build(), buf);
        assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    }
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) SyncOptimizationsActivator(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) LspDbVersionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersionBuilder) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) ByteBuf(io.netty.buffer.ByteBuf) ProtocolVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder) Tlvs1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder) SyncOptimizationsOpenObjectParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser) Stateful1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1) SpeakerEntityIdBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityIdBuilder) Tlvs1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 5 with Stateful1

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1 in project bgpcep by opendaylight.

the class CInitiated00StatefulCapabilityTlvParser method parseFlags.

@Override
protected void parseFlags(final StatefulBuilder sb, final ByteBuf buffer) {
    final BitArray flags = BitArray.valueOf(buffer, FLAGS_F_LENGTH);
    sb.setLspUpdateCapability(flags.get(U_FLAG_OFFSET));
    if (flags.get(I_FLAG_OFFSET)) {
        sb.addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(Boolean.TRUE).build());
    }
}
Also used : BitArray(org.opendaylight.protocol.util.BitArray) Stateful1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1Builder)

Aggregations

BitArray (org.opendaylight.protocol.util.BitArray)4 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1)4 StatefulBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder)3 ByteBuf (io.netty.buffer.ByteBuf)2 BigInteger (java.math.BigInteger)2 Test (org.junit.Test)2 PCEPSession (org.opendaylight.protocol.pcep.PCEPSession)2 Stateful1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1)2 Stateful1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder)2 Stateful1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Stateful1Builder)2 Tlvs1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1)2 Tlvs1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1Builder)2 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)2 Executor (java.util.concurrent.Executor)1 Before (org.junit.Before)1 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)1 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)1 SyncOptimizationsActivator (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsActivator)1 SyncOptimizationsCapabilityTlvParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser)1 SyncOptimizationsOpenObjectParser (org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsOpenObjectParser)1