use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteBuilder 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.ipv4.routes.ipv4.routes.Ipv4RouteBuilder 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);
}
Aggregations