Search in sources :

Example 61 with Order

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project bgpcep by opendaylight.

the class GracefulRestartTest method verifySendEORafterRestartTest.

/**
 * After graceful restart is performed from peer side we have to re-advertise routes followed by
 * End-of-RIB marker.
 *
 * @throws Exception on reading Rib failure
 */
@Test
public void verifySendEORafterRestartTest() throws Exception {
    final SimpleSessionListener listener2 = new SimpleSessionListener();
    configurePeer(this.tableRegistry, PEER2, this.ribImpl, this.parameters, PeerRole.Ebgp, this.serverRegistry, afiSafiAdvertised, gracefulAfiSafiAdvertised);
    final BGPSessionImpl session2 = createPeerSession(PEER2, this.parameters, listener2);
    final List<Ipv4Prefix> ipv4Prefixes = Arrays.asList(new Ipv4Prefix(PREFIX1));
    final List<Ipv4Prefix> ipv4Prefixes2 = Arrays.asList(new Ipv4Prefix(PREFIX2));
    final List<Ipv6Prefix> ipv6Prefixes = Collections.singletonList(new Ipv6Prefix(PREFIX3));
    insertRoutes(ipv4Prefixes, ipv6Prefixes);
    insertRoutes(ipv4Prefixes2, PEER2, null, null, session2, BgpOrigin.Egp);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(1);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 3);
    // verify sending of Ipv4 EOT, Ipv6 EOT and Ipv4 update with route
    checkReceivedMessages(this.listener, 3);
    assertTrue(this.listener.getListMsg().get(0) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(0)));
    assertTrue(this.listener.getListMsg().get(1) instanceof Update);
    assertTrue(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(1)));
    assertTrue(this.listener.getListMsg().get(2) instanceof Update);
    assertFalse(BgpPeerUtil.isEndOfRib((Update) this.listener.getListMsg().get(2)));
    this.session.close();
    checkIdleState(this.peer);
    checkLocRibIpv4Routes(2);
    checkLocRibIpv6Routes(0);
    // verify nothing new was sent
    checkReceivedMessages(this.listener, 3);
    this.session = createPeerSession(PEER1, createParameter(false, true, Collections.singletonMap(TABLES_KEY, true)), this.listener);
    checkUpState(listener);
    checkUpState(this.peer);
    org.opendaylight.protocol.util.CheckUtil.checkReceivedMessages(this.listener, 6);
    // verify sending of Ipv4 update with route, Ipv4 EOT and Ipv6 EOT; order can vary based on ODTC order
    final List<Notification> subList = this.listener.getListMsg().subList(3, 6);
    int eotCount = 0;
    int routeUpdateCount = 0;
    for (Notification message : subList) {
        if (BgpPeerUtil.isEndOfRib((Update) message)) {
            eotCount++;
        } else {
            routeUpdateCount++;
        }
    }
    assertEquals(2, eotCount);
    assertEquals(1, routeUpdateCount);
}
Also used : Update(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Notification(org.opendaylight.yangtools.yang.binding.Notification) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix) Test(org.junit.Test)

Example 62 with Order

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order in project bgpcep by opendaylight.

the class OrderTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    checkArgument(tlv instanceof Order, "OrderTlv is mandatory.");
    final Order otlv = (Order) tlv;
    final ByteBuf body = Unpooled.buffer();
    ByteBufUtils.writeOrZero(body, otlv.getDelete());
    ByteBufUtils.writeOrZero(body, otlv.getSetup());
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : Order(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.Order) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ArrayList (java.util.ArrayList)25 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)19 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder)17 VisibleForTesting (com.google.common.annotations.VisibleForTesting)7 Test (org.junit.Test)6 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)5 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 Batch (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch)4 BatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder)4 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 HashMap (java.util.HashMap)3 List (java.util.List)3 ExecutionException (java.util.concurrent.ExecutionException)3 Inject (javax.inject.Inject)3 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)3 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)3 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)3