Search in sources :

Example 26 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class GracefulRestartUtilTest method getLlGracefulCapabilityTest.

@Test
public void getLlGracefulCapabilityTest() {
    final Set<BgpPeerUtil.LlGracefulRestartDTO> llGracefulRestartDTOs = new HashSet<>();
    llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV4_KEY, STALE_TIME, true));
    llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV6_KEY, STALE_TIME, false));
    CParameters capability = GracefulRestartUtil.getLlGracefulCapability(llGracefulRestartDTOs);
    final CParameters1 params = capability.augmentation(CParameters1.class);
    assertNotNull(params);
    final LlGracefulRestartCapability llGracefulCapability = params.getLlGracefulRestartCapability();
    assertNotNull(llGracefulCapability);
    final var tables = llGracefulCapability.getTables();
    assertNotNull(tables);
    assertEquals(2, tables.size());
    assertEquals(STALE_TIME, tables.values().iterator().next().getLongLivedStaleTime().getValue().intValue());
    tables.values().forEach(table -> {
        assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
    });
}
Also used : BgpPeerUtil(org.opendaylight.protocol.bgp.rib.impl.BgpPeerUtil) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class GracefulRestartUtilTest method getGracefulCapabilityTest.

@Test
public void getGracefulCapabilityTest() {
    final Map<TablesKey, Boolean> gracefulMap = new HashMap<>();
    gracefulMap.put(IPV4_KEY, true);
    gracefulMap.put(IPV6_KEY, false);
    CParameters capability = GracefulRestartUtil.getGracefulCapability(gracefulMap, RESTART_TIME, RESTARTING);
    final CParameters1 params = capability.augmentation(CParameters1.class);
    assertNotNull(params);
    final GracefulRestartCapability gracefulCapability = params.getGracefulRestartCapability();
    assertNotNull(gracefulCapability);
    assertTrue(gracefulCapability.getRestartFlags().getRestartState());
    assertEquals(RESTART_TIME, gracefulCapability.getRestartTime().intValue());
    final var tables = gracefulCapability.getTables();
    assertNotNull(tables);
    assertEquals(2, tables.size());
    tables.values().forEach(table -> {
        assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
    });
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) HashMap(java.util.HashMap) CParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters) GracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability) LlGracefulRestartCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1) Test(org.junit.Test)

Example 28 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class AbstractTopologyBuilder method registerDataChangeListener.

/**
 * Register to data tree change listener.
 */
private synchronized void registerDataChangeListener() {
    Preconditions.checkState(this.listenerRegistration == null, "Topology Listener on topology %s has been registered before.", this.getInstanceIdentifier());
    final InstanceIdentifier<Tables> tablesId = this.locRibReference.getInstanceIdentifier().child(LocRib.class).child(Tables.class, new TablesKey(this.afi, this.safi));
    final DataTreeIdentifier<T> id = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getRouteWildcard(tablesId));
    this.listenerRegistration = this.dataProvider.registerDataTreeChangeListener(id, this);
    LOG.debug("Registered listener {} on topology {}. Timestamp={}", this, this.getInstanceIdentifier(), this.listenerScheduledRestartTime);
}
Also used : LocRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib.rib.LocRib) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables)

Example 29 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class BgpPeer method getBgpParameters.

private static List<BgpParameters> getBgpParameters(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
    final List<BgpParameters> tlvs = new ArrayList<>();
    final List<OptionalCapabilities> caps = new ArrayList<>();
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
    caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
    final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false);
    final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
    if (!addPathCapability.isEmpty()) {
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
    }
    final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
    for (final BgpTableType tableType : tableTypes) {
        if (!rib.getLocalTables().contains(tableType)) {
            LOG.info("RIB instance does not list {} " + "in its local tables. Incoming data will be dropped.", tableType);
        }
        caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
    }
    tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
    return tlvs;
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilitiesBuilder) MultiprotocolCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapabilityBuilder) AfiSafi(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi) ArrayList(java.util.ArrayList) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) BgpParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParametersBuilder) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities) As4BytesCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1Builder) AddressFamilies(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.add.path.capability.AddressFamilies) AddPathCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.AddPathCapabilityBuilder)

Example 30 with Tables

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.

the class LocRibWriter method updateNodes.

@SuppressWarnings("unchecked")
private void updateNodes(final DataObjectModification<Tables> table, final UnsignedInteger peerUuid, final WriteTransaction tx, final Map<RouteUpdateKey, RouteEntry> routes) {
    final DataObjectModification<Attributes> attUpdate = table.getModifiedChildContainer(Attributes.class);
    if (attUpdate != null && attUpdate.getDataAfter() != null) {
        final Attributes newAttValue = attUpdate.getDataAfter();
        LOG.trace("Uptodate found for {}", newAttValue);
        tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.child(Attributes.class), newAttValue);
    }
    final DataObjectModification routesChangesContainer = table.getModifiedChildContainer(this.ribSupport.routesContainerClass());
    if (routesChangesContainer == null) {
        return;
    }
    updateRoutesEntries(routesChangesContainer.getModifiedChildren(), peerUuid, routes);
}
Also used : DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) Attributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.tables.Attributes)

Aggregations

Test (org.junit.Test)12 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)10 ArrayList (java.util.ArrayList)9 Table (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)9 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)9 FlowKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey)7 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)6 ByteBuf (io.netty.buffer.ByteBuf)6 Map (java.util.Map)6 ExecutionException (java.util.concurrent.ExecutionException)6 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)6 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 HashMap (java.util.HashMap)5 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)5 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)5 BigInteger (java.math.BigInteger)4 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)4 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)4