Search in sources :

Example 26 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class GracefulRestartUtilTest method getGracefulBgpParametersTest.

@Test
public void getGracefulBgpParametersTest() {
    final OptionalCapabilities cap1 = new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build();
    final OptionalCapabilities cap2 = new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build();
    final List<OptionalCapabilities> fixedCaps = new ArrayList<>();
    fixedCaps.add(cap1);
    fixedCaps.add(cap2);
    final Set<TablesKey> gracefulTables = new HashSet<>();
    gracefulTables.add(IPV4_KEY);
    gracefulTables.add(IPV6_KEY);
    final Set<TablesKey> preservedTables = new HashSet<>();
    preservedTables.add(IPV4_KEY);
    final Map<TablesKey, Boolean> gracefulMap = new HashMap<>();
    gracefulMap.put(IPV4_KEY, true);
    gracefulMap.put(IPV6_KEY, false);
    final OptionalCapabilities expectedGracefulCapability = new OptionalCapabilitiesBuilder().setCParameters(GracefulRestartUtil.getGracefulCapability(gracefulMap, RESTART_TIME, RESTARTING)).build();
    final Set<BgpPeerUtil.LlGracefulRestartDTO> llGracefulDTOs = Collections.singleton(new BgpPeerUtil.LlGracefulRestartDTO(IPV4_KEY, STALE_TIME, true));
    final OptionalCapabilities expectedLlGracefulCapability = new OptionalCapabilitiesBuilder().setCParameters(GracefulRestartUtil.getLlGracefulCapability(llGracefulDTOs)).build();
    final BgpParameters parameters = GracefulRestartUtil.getGracefulBgpParameters(fixedCaps, gracefulTables, preservedTables, RESTART_TIME, RESTARTING, llGracefulDTOs);
    final List<OptionalCapabilities> capabilities = parameters.getOptionalCapabilities();
    assertTrue(capabilities != null);
    assertEquals(4, capabilities.size());
    assertTrue(capabilities.contains(cap1));
    assertTrue(capabilities.contains(cap2));
    assertTrue(capabilities.contains(expectedGracefulCapability));
    assertTrue(capabilities.contains(expectedLlGracefulCapability));
}
Also used : OptionalCapabilitiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder) BgpPeerUtil(org.opendaylight.protocol.bgp.rib.impl.BgpPeerUtil) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters) OptionalCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 27 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class SimpleRIBExtensionProviderContext method registerRIBSupport.

@Override
public <T extends RIBSupport<?, ?>> RIBSupportRegistration<T> registerRIBSupport(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final T support) {
    final TablesKey key = new TablesKey(afi, safi);
    final RIBSupport<?, ?> prev = this.supports.putIfAbsent(key, support);
    checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
    this.domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
    return new AbstractRIBSupportRegistration<>(support) {

        @Override
        protected void removeRegistration() {
            // FIXME: clean up registrations, too
            SimpleRIBExtensionProviderContext.this.supports.remove(key);
        }
    };
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)

Example 28 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class LinkstateTopologyBuilderTest method setUp.

@Before
@Override
public void setUp() {
    super.setUp();
    this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
    this.linkstateTopoBuilder.start();
    this.tablePathIID = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class)).build();
    this.linkstateNodeRouteKey = getLinkstateRouteKey("node-route");
    this.linkstatePrefixRouteKey = getLinkstateRouteKey("prefix-route");
    this.linkstateLinkRouteKey = getLinkstateRouteKey("link-route");
    this.linkstateNodeRouteIID = createLinkstateRouteIID(this.linkstateNodeRouteKey);
    this.linkstatePrefixRouteIID = createLinkstateRouteIID(this.linkstatePrefixRouteKey);
    this.linkstateLinkRouteIID = createLinkstateRouteIID(this.linkstateLinkRouteKey);
}
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) LinkstateSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateSubsequentAddressFamily) LinkstateAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.LinkstateAddressFamily) Before(org.junit.Before)

Example 29 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey 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 30 with TablesKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey in project bgpcep by opendaylight.

the class BmpRibInWriter method addRoutes.

private synchronized void addRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes attributes) {
    final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
    final TableContext ctx = this.tables.get(key);
    if (ctx == null) {
        LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
        return;
    }
    final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
    ctx.writeRoutes(tx, nlri, attributes);
    LOG.trace("Write routes {}", nlri);
    tx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Successful commit");
        }

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed commit", trw);
        }
    }, MoreExecutors.directExecutor());
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Aggregations

TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)40 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)15 RIBSupport (org.opendaylight.protocol.bgp.rib.spi.RIBSupport)11 KeyedInstanceIdentifier (org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 Before (org.junit.Before)8 Test (org.junit.Test)8 PathSelectionMode (org.opendaylight.protocol.bgp.mode.api.PathSelectionMode)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)8 ArrayList (java.util.ArrayList)7 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)7 Peer (org.opendaylight.protocol.bgp.rib.spi.Peer)6 Identifier (org.opendaylight.yangtools.yang.binding.Identifier)6 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)5 RibId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.RibId)5 ChannelFuture (io.netty.channel.ChannelFuture)4 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 BGPRouteEntryExportParametersImpl (org.opendaylight.protocol.bgp.mode.impl.BGPRouteEntryExportParametersImpl)4 BGPRouteEntryExportParameters (org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters)4