Bug 5030: BGP Application Peer beanchmark app 09/36009/1
authorMilos Fabian <milfabia@cisco.com>
Wed, 9 Mar 2016 17:53:32 +0000 (18:53 +0100)
committerMilos Fabian <milfabia@cisco.com>
Wed, 9 Mar 2016 17:57:44 +0000 (18:57 +0100)
Created benchmark ODL application for performance
testing of BGP application peer.
The application offers two types of RPC operations:
*add-prefix - for injection of IPv4 prefix routes
*delete-prefix - for IPv4 prefix routes removal

Change-Id: Ia3e3e930b01d59e0ab21dcf777801716e6f13769
Signed-off-by: Milos Fabian <milfabia@cisco.com>
artifacts/pom.xml
bgp/benchmark-app/pom.xml [new file with mode: 0644]
bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModule.java [new file with mode: 0644]
bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModuleFactory.java [new file with mode: 0644]
bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java [new file with mode: 0644]
bgp/benchmark-app/src/main/resources/initial/bgp-app-peer-benchmark.xml [new file with mode: 0644]
bgp/benchmark-app/src/main/yang/odl-bgp-app-peer-benchmark.yang [new file with mode: 0644]
bgp/benchmark-app/src/main/yang/odl-bgp-benchmark-cfg.yang [new file with mode: 0644]
bgp/pom.xml
features/bgp/pom.xml
features/bgp/src/main/features/features.xml

index ca784f88cb38387f7e8dee7c9490f36449a0a0b8..889de4521b04dcb9fa9a5b846d09e3e91cc6be69 100644 (file)
                 <type>xml</type>
                 <classifier>openconfig-config</classifier>
             </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>bgp-benchmark-app</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>bgp-benchmark-app</artifactId>
+                <version>${project.version}</version>
+                <type>xml</type>
+                <classifier>app-peer-benchmark-config</classifier>
+            </dependency>
 
             <dependency>
                 <groupId>${project.groupId}</groupId>
diff --git a/bgp/benchmark-app/pom.xml b/bgp/benchmark-app/pom.xml
new file mode 100644 (file)
index 0000000..e0a5f3a
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
+        <tag>HEAD</tag>
+    </scm>
+    <parent>
+        <groupId>org.opendaylight.bgpcep</groupId>
+        <artifactId>bgp-parent</artifactId>
+        <version>0.5.1-SNAPSHOT</version>
+    </parent>
+    <packaging>bundle</packaging>
+    <artifactId>bgp-benchmark-app</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>concepts</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-inet-types</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-rib-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-parser-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-concepts</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-inet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+         </dependency>
+         <dependency>
+             <groupId>org.opendaylight.controller</groupId>
+             <artifactId>sal-binding-api</artifactId>
+         </dependency>
+         <dependency>
+             <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-config</artifactId>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>attach-artifacts</id>
+                        <goals>
+                            <goal>attach-artifact</goal>
+                        </goals>
+                        <phase>package</phase>
+                        <configuration>
+                            <artifacts>
+                                <artifact>
+                                    <file>src/main/resources/initial/bgp-app-peer-benchmark.xml</file>
+                                    <type>xml</type>
+                                    <classifier>app-peer-benchmark-config</classifier>
+                                </artifact>
+                            </artifacts>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModule.java b/bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModule.java
new file mode 100644 (file)
index 0000000..3852059
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.odl_bgp_benchmark_cfg;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.protocol.bgp.benchmark.app.AppPeerBenchmark;
+
+public class AppPeerBenchmarkModule extends AbstractAppPeerBenchmarkModule {
+    public AppPeerBenchmarkModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public AppPeerBenchmarkModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver, final AppPeerBenchmarkModule oldModule, final java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new AppPeerBenchmark(getBindingDataBrokerDependency(), getRpcRegistryDependency(), getAppRibId());
+    }
+
+}
diff --git a/bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModuleFactory.java b/bgp/benchmark-app/src/main/java/org/opendaylight/controller/config/yang/odl_bgp_benchmark_cfg/AppPeerBenchmarkModuleFactory.java
new file mode 100644 (file)
index 0000000..e4d5d40
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.yang.odl_bgp_benchmark_cfg;
+
+public class AppPeerBenchmarkModuleFactory extends org.opendaylight.controller.config.yang.odl_bgp_benchmark_cfg.AbstractAppPeerBenchmarkModuleFactory {
+
+}
diff --git a/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java b/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java
new file mode 100644 (file)
index 0000000..f580b3d
--- /dev/null
@@ -0,0 +1,236 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.bgp.benchmark.app;
+
+import com.google.common.base.Stopwatch;
+import com.google.common.net.InetAddresses;
+import java.util.Collections;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.application.rib.tables.routes.Ipv4RoutesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4Routes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4RoutesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4RouteKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.AttributesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.AsPathBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.LocalPref;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.LocalPrefBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.MultiExitDisc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.MultiExitDiscBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.Origin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.OriginBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.ApplicationRib;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.ApplicationRibBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.ApplicationRibId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.ApplicationRibKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv4NextHopCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.ipv4.next.hop._case.Ipv4NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.AddPrefixInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.AddPrefixOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.AddPrefixOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.DeletePrefixInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.DeletePrefixOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.DeletePrefixOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.OdlBgpAppPeerBenchmarkService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.output.Result;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev160309.output.ResultBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AppPeerBenchmark implements OdlBgpAppPeerBenchmarkService, TransactionChainListener, AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AppPeerBenchmark.class);
+
+    private static final AsPath AS_PATH = new AsPathBuilder().build();
+    private static final Origin ORIGIN = new OriginBuilder().setValue(BgpOrigin.Igp).build();
+    private static final MultiExitDisc MED = new MultiExitDiscBuilder().setMed(0L).build();
+    private static final LocalPref LOC_PREF = new LocalPrefBuilder().setPref(100L).build();
+
+    private static final String SLASH = "/";
+    private static final String PREFIX = SLASH + "32";
+
+    private final BindingTransactionChain txChain;
+    private final RpcRegistration<OdlBgpAppPeerBenchmarkService> rpcRegistration;
+    private final InstanceIdentifier<ApplicationRib> iid;
+    private final InstanceIdentifier<Ipv4Routes> routesIId;
+
+    public AppPeerBenchmark(final DataBroker bindingDataBroker, final RpcProviderRegistry rpcProviderRegistry,
+            final String appRibId) {
+        this.txChain = bindingDataBroker.createTransactionChain(this);
+        this.iid = initTable(appRibId);
+        final InstanceIdentifier tablesIId = this.iid
+                .child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
+        this.routesIId = tablesIId.child(Ipv4Routes.class);
+        this.rpcRegistration = rpcProviderRegistry.addRpcImplementation(OdlBgpAppPeerBenchmarkService.class, this);
+        LOG.info("BGP Application Peer Benchmark Application started.");
+    }
+
+    @Override
+    public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction,
+            final Throwable cause) {
+        LOG.error("Broken chain {} in DatastoreBaAbstractWrite, transaction {}, cause {}", chain,
+                transaction.getIdentifier(), cause);
+    }
+
+    @Override
+    public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
+        LOG.debug("DatastoreBaAbstractWrite closed successfully, chain {}", chain);
+    }
+
+    private InstanceIdentifier<ApplicationRib> initTable(final String appRibId) {
+        final Tables tables = new TablesBuilder()
+                .setAfi(Ipv4AddressFamily.class)
+                .setSafi(UnicastSubsequentAddressFamily.class)
+                .setRoutes(
+                        new Ipv4RoutesCaseBuilder().setIpv4Routes(
+                                new Ipv4RoutesBuilder().setIpv4Route(Collections.<Ipv4Route> emptyList()).build())
+                                .build()).build();
+
+        final ApplicationRib appRib = new ApplicationRibBuilder()
+                .setId(new ApplicationRibId(new ApplicationRibId(appRibId)))
+                .setTables(Collections.singletonList(tables)).build();
+
+        final InstanceIdentifier<ApplicationRib> iid = KeyedInstanceIdentifier.builder(ApplicationRib.class,
+                new ApplicationRibKey(new ApplicationRibId(appRibId))).build();
+        final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
+        wTx.put(LogicalDatastoreType.CONFIGURATION, iid, appRib);
+        wTx.submit();
+        return iid;
+    }
+
+    @Override
+    public Future<RpcResult<AddPrefixOutput>> addPrefix(final AddPrefixInput input) {
+        final long duration = addRoute(input.getPrefix(), input.getNexthop(), input.getCount(), input.getBatchsize());
+        final long rate = countRate(duration, input.getCount());
+
+        final AddPrefixOutputBuilder outputbuilder = new AddPrefixOutputBuilder();
+        outputbuilder.setResult(createResult(input.getCount(), duration, rate));
+        final AddPrefixOutput output = outputbuilder.build();
+        return RpcResultBuilder.success(output).buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<DeletePrefixOutput>> deletePrefix(final DeletePrefixInput input) {
+        final long duration = deleteRoute(input.getPrefix(), input.getCount(), input.getBatchsize());
+        final long rate = countRate(duration, input.getCount());
+
+        final DeletePrefixOutputBuilder outputbuilder = new DeletePrefixOutputBuilder();
+        outputbuilder.setResult(createResult(input.getCount(), duration, rate));
+        final DeletePrefixOutput output = outputbuilder.build();
+        return RpcResultBuilder.success(output).buildFuture();
+    }
+
+    @Override
+    public void close() {
+        this.rpcRegistration.close();
+        final WriteTransaction dTx = this.txChain.newWriteOnlyTransaction();
+        dTx.delete(LogicalDatastoreType.CONFIGURATION, this.iid);
+        try {
+            dTx.submit().checkedGet();
+        } catch (final TransactionCommitFailedException e) {
+            LOG.warn("Failed to clean-up BGP Application RIB.");
+        }
+        this.txChain.close();
+        LOG.info("BGP Application Peer Benchmark Application closed.");
+    }
+
+    private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4Address ipv4Address, final long count, final long batch) {
+        final AttributesBuilder attributesBuilder = new AttributesBuilder();
+        attributesBuilder.setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(
+                new Ipv4NextHopBuilder().setGlobal(new Ipv4Address(ipv4Address)).build()).build());
+        attributesBuilder.setMultiExitDisc(MED);
+        attributesBuilder.setLocalPref(LOC_PREF);
+        attributesBuilder.setOrigin(ORIGIN);
+        attributesBuilder.setAsPath(AS_PATH);
+        final Attributes attributes = attributesBuilder.build();
+        return processRoutes(ipv4Prefix, count, batch, attributes);
+    }
+
+    private long deleteRoute(final Ipv4Prefix ipv4Prefix, final long count, final long batch) {
+        return processRoutes(ipv4Prefix, count, batch, null);
+    }
+
+    private long processRoutes(final Ipv4Prefix ipv4Prefix, final long count, final long batch, final Attributes attributes) {
+        WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
+        String address = getAdddressFromPrefix(ipv4Prefix);
+        final Stopwatch stopwatch = Stopwatch.createStarted();
+        for (int i = 1; i <= count; i++) {
+            final Ipv4RouteKey routeKey = new Ipv4RouteKey(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();
+                wTx.put(LogicalDatastoreType.CONFIGURATION, routeIId,
+                        ipv4Route);
+            } else {
+                wTx.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
+            }
+            if (i % batch == 0) {
+                wTx.submit();
+                wTx = this.txChain.newWriteOnlyTransaction();
+            }
+            address = increasePrefix(address);
+        }
+        wTx.submit();
+        return stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
+    }
+
+    private static long countRate(final long durationMillis, final long count) {
+        final long durationSec = TimeUnit.MILLISECONDS.toSeconds(durationMillis);
+        if (durationSec != 0) {
+            return count / durationSec;
+        }
+        return count;
+    }
+
+    private static String increasePrefix(final String prefix) {
+        return InetAddresses.increment(InetAddresses.forString(prefix)).getHostAddress();
+    }
+
+    private static Result createResult(final long count, final long duration, final long rate) {
+        return new ResultBuilder().setCount(count).setDuration(duration).setRate(rate).build();
+    }
+
+    private static String getAdddressFromPrefix(final Ipv4Prefix prefix) {
+        return prefix.getValue().split(SLASH)[0];
+    }
+
+    private static Ipv4Prefix createPrefix(final String address) {
+        return new Ipv4Prefix(address + PREFIX);
+    }
+}
\ No newline at end of file
diff --git a/bgp/benchmark-app/src/main/resources/initial/bgp-app-peer-benchmark.xml b/bgp/benchmark-app/src/main/resources/initial/bgp-app-peer-benchmark.xml
new file mode 100644 (file)
index 0000000..3eb8bc5
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2016 Cisco System and others. All rights reserved.
+
+This program and the accompanying materials are made available under the
+terms of the Eclipse Public License v1.0 which accompanies this distribution,
+and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:odl-bgp-benchmark-cfg?module=odl-bgp-benchmark-cfg&amp;revision=2016-03-09</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <configuration>
+
+    <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+      <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <module>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:odl-bgp-benchmark-cfg">prefix:app-peer-benchmark</type>
+          <name>bgp-app-peer-benchmark</name>
+          <rpc-registry>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+            <name>binding-rpc-broker</name>
+          </rpc-registry>
+          <binding-data-broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+            <name>pingpong-binding-data-broker</name>
+          </binding-data-broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
\ No newline at end of file
diff --git a/bgp/benchmark-app/src/main/yang/odl-bgp-app-peer-benchmark.yang b/bgp/benchmark-app/src/main/yang/odl-bgp-app-peer-benchmark.yang
new file mode 100644 (file)
index 0000000..91c382d
--- /dev/null
@@ -0,0 +1,97 @@
+// Contents of "odl-bgp-benchmark"
+module odl-bgp-app-peer-benchmark {
+    namespace "urn:opendaylight:params:xml:ns:yang:odl-bgp-app-peer-benchmark";
+    prefix "bgp-app-peer-bm";
+
+    import ietf-inet-types { prefix inet; revision-date 2010-09-24; }
+
+    organization "Cisco Systems, Inc.";
+    contact "Milos Fabian <milfabia@cisco.com>";
+
+    description
+        "This module contains Yang Data Models for BGP Application Peer
+        Benchmark application.
+
+        Copyright (c)2016 Cisco Systems, Inc. All rights reserved.
+
+        This program and the accompanying materials are made available
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
+
+    revision 2016-03-09 {
+        description "Initial revision";
+    }
+
+    grouping input {
+        leaf prefix {
+            mandatory true;
+            type inet:ipv4-prefix;
+            description
+                "IPv4 prefix";
+        }
+        leaf count {
+            mandatory true;
+            type uint32;
+            description
+                "loop count";
+        }
+        leaf batchsize {
+            mandatory true;
+            type uint32;
+            description
+                "batchsize";
+        }
+    }
+
+    grouping output {
+        container result {
+            leaf count {
+                mandatory true;
+                type uint32;
+            }
+            leaf duration {
+                mandatory true;
+                type uint32;
+                units seconds;
+            }
+            leaf rate {
+                mandatory true;
+                type uint32;
+                units "per-second";
+            }
+        }
+    }
+
+    rpc add-prefix {
+        description
+                "Add prefix into RIB";
+        input {
+            uses input;
+            leaf nexthop {
+                mandatory true;
+                type inet:ipv4-address;
+                description
+                    "nexthop";
+            }
+        }
+
+        output {
+            uses output;
+        }
+    }
+
+    rpc delete-prefix {
+        description
+            "Delete prefix into RIB";
+
+        input {
+            uses input;
+        }
+
+        output {
+            uses output;
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/bgp/benchmark-app/src/main/yang/odl-bgp-benchmark-cfg.yang b/bgp/benchmark-app/src/main/yang/odl-bgp-benchmark-cfg.yang
new file mode 100644 (file)
index 0000000..ae945d8
--- /dev/null
@@ -0,0 +1,61 @@
+// Contents of "odl-bgp-benchmark-cfg"
+module odl-bgp-benchmark-cfg {
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:odl-bgp-benchmark-cfg";
+    prefix "bgp-bm-cfg";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+    organization "Cisco Systems, Inc.";
+    contact "Milos Fabian <milfabia@cisco.com>";
+
+    description
+        "This module contains Configuration Yang Data Model for BGP Benchmark application.
+
+        Copyright (c)2016 Cisco Systems, Inc. All rights reserved.
+
+        This program and the accompanying materials are made available
+        under the terms of the Eclipse Public License v1.0 which
+        accompanies this distribution, and is available at
+        http://www.eclipse.org/legal/epl-v10.html";
+
+    revision 2016-03-09 {
+        description "Initial revision";
+    }
+
+    identity app-peer-benchmark {
+        base config:module-type;
+        config:java-name-prefix AppPeerBenchmark;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case app-peer-benchmark {
+            when "/config:modules/config:module/config:type = 'app-peer-benchmark'";
+
+            container rpc-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-rpc-registry;
+                    }
+                }
+            }
+
+            container binding-data-broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-async-data-broker;
+                    }
+                }
+            }
+
+            leaf app-rib-id {
+                type string;
+                default "example-app-rib";
+            }
+
+        }
+    }
+
+}
\ No newline at end of file
index 9d130e5671f4abb89e73b47fa0ee2d5b023e9fe2..1f196efc547ef78e9c643dce46e2fe93c86a4263 100644 (file)
@@ -54,5 +54,6 @@
         <module>openconfig-api</module>
         <module>openconfig-spi</module>
         <module>openconfig-impl</module>
-  </modules>
+        <module>benchmark-app</module>
+    </modules>
 </project>
index 54c7be0804f8f65b1f7724dae930ea6eae42de1b..c73acd378cc9a2dafa15c6261ba56957f78ca8bc 100644 (file)
           <groupId>${project.groupId}</groupId>
           <artifactId>bgp-openconfig-spi</artifactId>
       </dependency>
+      <dependency>
+          <groupId>${project.groupId}</groupId>
+          <artifactId>bgp-benchmark-app</artifactId>
+      </dependency>
       <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>concepts</artifactId>
           <type>xml</type>
           <classifier>openconfig-config</classifier>
       </dependency>
+      <dependency>
+          <groupId>${project.groupId}</groupId>
+          <artifactId>bgp-benchmark-app</artifactId>
+          <type>xml</type>
+          <classifier>app-peer-benchmark-config</classifier>
+      </dependency>
       <dependency>
           <groupId>${project.groupId}</groupId>
           <artifactId>data-change-counter-controller-config</artifactId>
index 49ee224ea071ead0cf49aff336dd400a32d07ff6..2379e10c9c2b6096e4cc36f17bb37e2fe3cd2c6a 100644 (file)
         <feature version='${protocol-framework.version}'>odl-protocol-framework</feature>
         <bundle>mvn:org.opendaylight.bgpcep/bgp-topology-provider/{{VERSION}}</bundle>
     </feature>
+
+    <feature name='odl-bgpcep-bgp-benchmark' version='${project.version}'>
+        <feature version='${project.version}'>odl-bgpcep-bgp-inet</feature>
+        <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
+        <bundle>mvn:org.opendaylight.bgpcep/bgp-benchmark-app/{{VERSION}}</bundle>
+        <configfile finalname="etc/opendaylight/karaf/bgp-app-peer-benchmark.xml">mvn:org.opendaylight.bgpcep/bgp-benchmark-app/{{VERSION}}/xml/app-peer-benchmark-config</configfile>
+    </feature>
 </features>