Search in sources :

Example 1 with Ipv4Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route in project bgpcep by opendaylight.

the class AppPeerBenchmark method processRoutes.

private long processRoutes(final Ipv4Prefix ipv4Prefix, final long count, final long batch, final Attributes attributes) {
    WriteTransaction wt = this.txChain.newWriteOnlyTransaction();
    String address = getAdddressFromPrefix(ipv4Prefix);
    final Stopwatch stopwatch = Stopwatch.createStarted();
    for (int i = 1; i <= count; i++) {
        final Ipv4RouteKey routeKey = new Ipv4RouteKey(NON_PATH_ID, createPrefix(address));
        final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIId = this.routesIId.child(Ipv4Route.class, routeKey);
        if (attributes != null) {
            final Ipv4RouteBuilder ipv4RouteBuilder = new Ipv4RouteBuilder();
            ipv4RouteBuilder.setPrefix(routeKey.getPrefix());
            ipv4RouteBuilder.setKey(routeKey);
            ipv4RouteBuilder.setAttributes(attributes);
            final Ipv4Route ipv4Route = ipv4RouteBuilder.build();
            wt.put(LogicalDatastoreType.CONFIGURATION, routeIId, ipv4Route);
        } else {
            wt.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
        }
        if (i % batch == 0) {
            wt.submit();
            wt = this.txChain.newWriteOnlyTransaction();
        }
        address = increasePrefix(address);
    }
    wt.submit();
    return stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) Ipv4RouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4RouteBuilder) Stopwatch(com.google.common.base.Stopwatch) Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4RouteKey) Ipv4Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4Route)

Example 2 with Ipv4Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route in project bgpcep by opendaylight.

the class IPv4RIBSupportTest method testPutRoutes.

@Test
public void testPutRoutes() {
    this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
    final Ipv4Route route = (Ipv4Route) this.insertedRoutes.get(0).getValue();
    assertEquals(ROUTE, route);
}
Also used : Ipv4Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route) AbstractRIBSupportTest(org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest) Test(org.junit.Test)

Example 3 with Ipv4Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route in project bgpcep by opendaylight.

the class AppPeerBenchmark method processRoutes.

private long processRoutes(final Ipv4Prefix ipv4Prefix, final Uint32 count, final Uint32 batch, final Attributes attributes) {
    WriteTransaction wt = this.txChain.newWriteOnlyTransaction();
    String address = getAdddressFromPrefix(ipv4Prefix);
    final long countLong = count.longValue();
    final long batchLong = batch.longValue();
    final Stopwatch stopwatch = Stopwatch.createStarted();
    for (int i = 1; i <= countLong; i++) {
        final Ipv4RouteKey routeKey = new Ipv4RouteKey(NON_PATH_ID, createKey(address));
        final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIId = this.routesIId.child(Ipv4Route.class, routeKey);
        if (attributes != null) {
            final Ipv4RouteBuilder ipv4RouteBuilder = new Ipv4RouteBuilder();
            ipv4RouteBuilder.setRouteKey(routeKey.getRouteKey());
            ipv4RouteBuilder.setPrefix(new Ipv4Prefix(routeKey.getRouteKey()));
            ipv4RouteBuilder.withKey(routeKey);
            ipv4RouteBuilder.setAttributes(attributes);
            final Ipv4Route ipv4Route = ipv4RouteBuilder.build();
            wt.put(LogicalDatastoreType.CONFIGURATION, routeIId, ipv4Route);
        } else {
            wt.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
        }
        if (i % batchLong == 0) {
            wt.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());
            wt = this.txChain.newWriteOnlyTransaction();
        }
        address = increasePrefix(address);
    }
    wt.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Route batch stored.");
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Failed to store route batch.", throwable);
        }
    }, MoreExecutors.directExecutor());
    return stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
}
Also used : WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Stopwatch(com.google.common.base.Stopwatch) Ipv4RouteBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteBuilder) Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Ipv4Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route)

Example 4 with Ipv4Route

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route in project bgpcep by opendaylight.

the class AbstractAddPathTest method checkLocRib.

private void checkLocRib(final int expectedRoutesOnDS) throws Exception {
    // FIXME: remove this sleep
    Thread.sleep(100);
    readDataOperational(getDataBroker(), BGP_IID, bgpRib -> {
        final Ipv4RoutesCase routes = (Ipv4RoutesCase) bgpRib.getRib().values().iterator().next().getLocRib().nonnullTables().values().iterator().next().getRoutes();
        final int size;
        if (routes != null) {
            final Ipv4Routes routesCase = routes.getIpv4Routes();
            if (routesCase != null) {
                final Map<Ipv4RouteKey, Ipv4Route> routeList = routesCase.getIpv4Route();
                size = routeList == null ? 0 : routeList.size();
            } else {
                size = 0;
            }
        } else {
            size = 0;
        }
        assertEquals(expectedRoutesOnDS, size);
        return bgpRib;
    });
}
Also used : Ipv4RouteKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey) Ipv4RoutesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase) Ipv4Routes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.Ipv4Routes) Ipv4Route(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route)

Aggregations

Ipv4Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4Route)3 Stopwatch (com.google.common.base.Stopwatch)2 Ipv4RouteKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteKey)2 Test (org.junit.Test)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)1 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)1 AbstractRIBSupportTest (org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 Ipv4Route (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4Route)1 Ipv4RouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4RouteBuilder)1 Ipv4RouteKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.ipv4.routes.ipv4.routes.Ipv4RouteKey)1 Ipv4RoutesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.bgp.rib.rib.loc.rib.tables.routes.Ipv4RoutesCase)1 Ipv4Routes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.Ipv4Routes)1 Ipv4RouteBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteBuilder)1