From 46939989aefff4b3f7cfec5c95abc8cae9c79c47 Mon Sep 17 00:00:00 2001 From: Jan Medved Date: Thu, 12 Nov 2015 21:47:38 -0800 Subject: [PATCH] Added notification benchmark (ntfbenchmark) and rpc benchmark models Rplaced tabls with spaces Change-Id: Ic81947d69ddc6286a9ed3be3600f77d46088b6b0 Signed-off-by: Jan Medved --- benchmark/api/pom.xml | 7 + .../api/src/main/yang/ntfbench-payload.yang | 24 +++ benchmark/api/src/main/yang/ntfbenchmark.yang | 128 +++++++++++++++ .../api/src/main/yang/rpcbench-payload.yang | 64 ++++++++ benchmark/api/src/main/yang/rpcbenchmark.yang | 112 +++++++++++++ benchmark/dsbenchmark/pom.xml | 35 +++++ benchmark/ntfbenchmark/pom.xml | 39 +++++ .../src/main/config/default-config.xml | 38 +++++ .../src/main/config/maven-metadata-local.xml | 20 +++ .../impl/AbstractNtfbenchProducer.java | 53 +++++++ .../impl/NtfbenchBlockingProducer.java | 37 +++++ .../impl/NtfbenchNonblockingProducer.java | 59 +++++++ .../impl/NtfbenchTestListener.java | 42 +++++ .../impl/NtfbenchWTCListener.java | 36 +++++ .../impl/NtfbenchmarkProvider.java | 148 ++++++++++++++++++ .../impl/rev141210/NtfbenchmarkModule.java | 33 ++++ .../rev141210/NtfbenchmarkModuleFactory.java | 20 +++ .../src/main/yang/ntfbenchmark-impl.yang | 53 +++++++ benchmark/pom.xml | 1 + features/benchmark/pom.xml | 12 ++ .../benchmark/src/main/features/features.xml | 6 + 21 files changed, 967 insertions(+) create mode 100644 benchmark/api/src/main/yang/ntfbench-payload.yang create mode 100644 benchmark/api/src/main/yang/ntfbenchmark.yang create mode 100644 benchmark/api/src/main/yang/rpcbench-payload.yang create mode 100644 benchmark/api/src/main/yang/rpcbenchmark.yang create mode 100644 benchmark/ntfbenchmark/pom.xml create mode 100644 benchmark/ntfbenchmark/src/main/config/default-config.xml create mode 100644 benchmark/ntfbenchmark/src/main/config/maven-metadata-local.xml create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/AbstractNtfbenchProducer.java create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchBlockingProducer.java create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchTestListener.java create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchWTCListener.java create mode 100644 benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java create mode 100644 benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModule.java create mode 100644 benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModuleFactory.java create mode 100644 benchmark/ntfbenchmark/src/main/yang/ntfbenchmark-impl.yang diff --git a/benchmark/api/pom.xml b/benchmark/api/pom.xml index 1bd6f14206..5861d2c12c 100644 --- a/benchmark/api/pom.xml +++ b/benchmark/api/pom.xml @@ -20,4 +20,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html 1.1.0-SNAPSHOT bundle + + + org.opendaylight.mdsal.model + yang-ext + + + diff --git a/benchmark/api/src/main/yang/ntfbench-payload.yang b/benchmark/api/src/main/yang/ntfbench-payload.yang new file mode 100644 index 0000000000..307c063412 --- /dev/null +++ b/benchmark/api/src/main/yang/ntfbench-payload.yang @@ -0,0 +1,24 @@ +module ntfbench-payload { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:ntfbench-payload"; + prefix "ntfbenchmark"; + + revision "2015-07-09" { + description "Initial revision of ntfbenchmark model"; + } + + grouping payload { + list payload { + description + "The payload for the notification"; + key id; + leaf id { + type int32; + } + } + } + + notification ntfbench { + uses payload; + } +} diff --git a/benchmark/api/src/main/yang/ntfbenchmark.yang b/benchmark/api/src/main/yang/ntfbenchmark.yang new file mode 100644 index 0000000000..c1619b6ec5 --- /dev/null +++ b/benchmark/api/src/main/yang/ntfbenchmark.yang @@ -0,0 +1,128 @@ +module ntfbenchmark { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:ntfbenchmark"; + prefix "ntfbenchmark"; + + revision "2015-01-05" { + description "Initial revision of ntfbenchmark model"; + } + + rpc test-status { + description + "Get test status"; + output { + leaf execStatus { + type enumeration { + enum "idle" { + value 1; + } + enum "executing" { + value 2; + } + } + } + leaf ntf-cnt { + type uint32; + default 0; + description + "The number of times the notification benchmark test was invoked"; + } + } + } + + rpc start-test { + description + "Start a new RPC Benchmark test"; + + input { + leaf producer-type { + mandatory true; + type enumeration { + enum "BLOCKING" { + value 1; + description + "The producer waits for a free slot in RPC Broker's ring buffer"; + } + enum "DROPPING" { + value 2; + description + "The producer drops a notification if there is no free slot in RPC Broker's ring buffer"; + } + } + description + "RPC type and client type to use in the test"; + } + leaf producers { + type uint32; + default 1; + description + "Number of notification producers (test client threads) to start"; + } + leaf listeners { + type uint32; + default 1; + description + "Number of notification listener instances"; + } + + leaf payload-size { + type uint32; + default 1; + description + "Notification payload size: number of elements in the list of integers that is the notification payload"; + } + leaf iterations { + type uint32; + default 1; + description + "Number of notifications to generate in each client thread"; + } + + } + + output { + leaf listener-ok { + type uint32; + default 0; + description + "Number of successfully creceived notifications by all listeners"; + } + leaf producer-ok { + type uint32; + default 0; + description + "Number of successfully generated notifications in all producer clients"; + } + leaf producer-error { + type uint32; + default 0; + description + "Number of errors encoutered during notification generation at all producers"; + } + leaf producer-elapsed-time { + type uint32; + default 0; + description + "The time it took for all producers to finish (i.e. to send their notifications), in milliseconds"; + } + leaf listener-elapsed-time { + type uint32; + default 0; + description + "The time it took for all listeners to finish (i.e. to receive their notifications), in milliseconds"; + } + leaf producer-rate { + type uint32; + default 0; + description + "RPC rate (Number of RPCs/sec)"; + } + leaf listener-rate { + type uint32; + default 0; + description + "RPC rate (Number of RPCs/sec)"; + } + } + } +} diff --git a/benchmark/api/src/main/yang/rpcbench-payload.yang b/benchmark/api/src/main/yang/rpcbench-payload.yang new file mode 100644 index 0000000000..a054908da0 --- /dev/null +++ b/benchmark/api/src/main/yang/rpcbench-payload.yang @@ -0,0 +1,64 @@ +module rpcbench-payload { + yang-version 1; + namespace "rpcbench-payload"; + prefix "rpcb"; + + import yang-ext { prefix ext; revision-date "2013-07-09"; } + + revision "2015-07-02" { + description "Initial revision of rpcbenchmark model"; + } + + identity node-context { + description "Identity used to mark node context for Routed RPCs (determines the type of routing)"; + } + + grouping payload { + list payload { + description + "The input and output payload for the RPC Benchmark's Global RPC Server (a list of integers)"; + key id; + leaf id { + type int32; + } + } + } + + rpc global-rpc-bench { + description + "Interface to the RPC Benchmark's Global RPC Server. In each RPC call, the input is copied on the output"; + input { + uses payload; + } + output { + uses payload; + } + } + + rpc routed-rpc-bench { + description + "Interface to RPC Benchmark's Routed RPC Servers. In each RPC call, the input is copied on the output"; + input { + leaf node { + ext:context-reference "node-context"; + type "instance-identifier"; + } + uses payload; + } + output { + uses payload; + } + } + + container rpcbench-rpc-routes { + list rpc-route { + description + "Routed RPC server context instances (i.e. instances to which RPC calls are routed)"; + key id; + ext:context-instance "node-context"; + leaf id { + type string; + } + } + } +} diff --git a/benchmark/api/src/main/yang/rpcbenchmark.yang b/benchmark/api/src/main/yang/rpcbenchmark.yang new file mode 100644 index 0000000000..7ec13578bf --- /dev/null +++ b/benchmark/api/src/main/yang/rpcbenchmark.yang @@ -0,0 +1,112 @@ +module rpcbenchmark { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:rpcbenchmark"; + prefix "rpcbenchmark"; + + revision "2015-07-02" { + description "Initial revision of rpcbenchmark model"; + } + + rpc test-status { + description + "Get test status"; + output { + leaf execStatus { + type enumeration { + enum "idle" { + value 1; + } + enum "executing" { + value 2; + } + } + } + leaf global-server-cnt { + type uint32; + default 0; + description + "The number of times the Global RPC server was invoked"; + + } + } + } + + rpc start-test { + description + "Start a new RPC Benchmark test run"; + + input { + leaf operation { + mandatory true; + type enumeration { + enum "GLOBAL-RTC" { + value 1; + description + "Use Global RPC service and run-to-completion client"; + } + enum "ROUTED-RTC" { + value 2; + description + "Use routed RPC service and run-to-completion client. RPC server instances are + dynamically created when the test starts and deleted when the test finishes"; + } + } + description + "RPC type and client type to use in the test"; + } + leaf num-clients { + type uint32; + default 1; + description + "Number of clients (test client threads) to start"; + } + leaf num-servers { + type uint32; + default 1; + description + "Number of RPC server instances. Only valid for routed RPCs."; + } + + leaf payload-size { + type uint32; + default 1; + description + "Input/Output payload size: number of elements in the list of integers that is the input and output RPC payload"; + } + leaf iterations { + type uint32; + default 1; + description + "Number of calls to the specified RPC server that is to be made by each client"; + } + + } + + output { + leaf global-rtc-client-ok { + type uint32; + default 0; + description + "Number of successful calls to the Global RPC Server for all test threads"; + } + leaf global-rtc-client-error { + type uint32; + default 0; + description + "Number of failed calls to the Global RPC server from all test threads"; + } + leaf exec-time { + type uint32; + default 0; + description + "Test execution time, in milliseconds"; + } + leaf rate { + type uint32; + default 0; + description + "RPC rate (Number of RPCs/sec)"; + } + } + } +} diff --git a/benchmark/dsbenchmark/pom.xml b/benchmark/dsbenchmark/pom.xml index d70adcf078..ec05561c52 100644 --- a/benchmark/dsbenchmark/pom.xml +++ b/benchmark/dsbenchmark/pom.xml @@ -36,4 +36,39 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.jacoco + + jacoco-maven-plugin + + + [0.7.2.201409121644,) + + + prepare-agent + + + + + + + + + + + + + diff --git a/benchmark/ntfbenchmark/pom.xml b/benchmark/ntfbenchmark/pom.xml new file mode 100644 index 0000000000..836d080dfd --- /dev/null +++ b/benchmark/ntfbenchmark/pom.xml @@ -0,0 +1,39 @@ + + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.controller + ntfbenchmark + 1.1.0-SNAPSHOT + bundle + + + org.opendaylight.controller + benchmark-api + ${project.version} + + + org.opendaylight.controller + sal-core-api + + + org.opendaylight.yangtools + yang-data-impl + + + + diff --git a/benchmark/ntfbenchmark/src/main/config/default-config.xml b/benchmark/ntfbenchmark/src/main/config/default-config.xml new file mode 100644 index 0000000000..9853304339 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/config/default-config.xml @@ -0,0 +1,38 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:ntfbenchmark:impl?module=ntfbenchmark-impl&revision=2014-12-10 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 + + + + + + + prefix:ntfbenchmark + ntfbenchmark-default + + binding:binding-broker-osgi-registry + binding-osgi-broker + + + binding:binding-new-notification-publish-service + binding-notification-publish-adapter + + + binding:binding-new-notification-service + binding-notification-adapter + + + + + + diff --git a/benchmark/ntfbenchmark/src/main/config/maven-metadata-local.xml b/benchmark/ntfbenchmark/src/main/config/maven-metadata-local.xml new file mode 100644 index 0000000000..cf4dd85199 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/config/maven-metadata-local.xml @@ -0,0 +1,20 @@ + + + org.opendaylight.controller + ntfbenchmark + 1.1.0-SNAPSHOT + + + true + + 20151113053911 + + + config + xml + 1.1.0-SNAPSHOT + 20151113053911 + + + + diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/AbstractNtfbenchProducer.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/AbstractNtfbenchProducer.java new file mode 100644 index 0000000000..5dc6618e9c --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/AbstractNtfbenchProducer.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015 Cisco Systems 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 ntfbenchmark.impl; + +import java.util.ArrayList; +import java.util.List; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.Ntfbench; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.NtfbenchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.payload.Payload; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.payload.PayloadBuilder; + +public abstract class AbstractNtfbenchProducer implements Runnable { + protected final NotificationPublishService publishService; + protected final int iterations; + protected final Ntfbench ntf; + + /** + * @return the ntfOk + */ + public int getNtfOk() { + return ntfOk; + } + + /** + * @return the ntfError + */ + public int getNtfError() { + return ntfError; + } + + protected int ntfOk = 0; + protected int ntfError = 0; + + public AbstractNtfbenchProducer(final NotificationPublishService publishService, final int iterations, + final int payloadSize) { + this.publishService = publishService; + this.iterations = iterations; + + final List listVals = new ArrayList<>(); + for (int i = 0; i < payloadSize; i++) { + listVals.add(new PayloadBuilder().setId(i).build()); + } + + ntf = new NtfbenchBuilder().setPayload(listVals).build(); + } +} diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchBlockingProducer.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchBlockingProducer.java new file mode 100644 index 0000000000..b086910f1c --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchBlockingProducer.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2015 Cisco Systems 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 ntfbenchmark.impl; + +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; + +public class NtfbenchBlockingProducer extends AbstractNtfbenchProducer { + + public NtfbenchBlockingProducer(final NotificationPublishService publishService, final int iterations, + final int payloadSize) { + super(publishService, iterations, payloadSize); + } + + @Override + public void run() { + int ntfOk = 0; + int ntfError = 0; + + for (int i = 0; i < this.iterations; i++) { + try { + this.publishService.putNotification(this.ntf); + ntfOk++; + } catch (final Exception e) { + ntfError++; + } + } + + this.ntfOk = ntfOk; + this.ntfError = ntfError; + } +} diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java new file mode 100644 index 0000000000..f4db3693c4 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2015 Cisco Systems 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 ntfbenchmark.impl; + +import com.google.common.base.Throwables; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; +import java.util.concurrent.ExecutionException; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; + +public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer { + + private final SettableFuture lastDeliveryFuture = SettableFuture.create(); + + + public NtfbenchNonblockingProducer(final NotificationPublishService publishService, final int iterations, + final int payloadSize) { + super(publishService, iterations, payloadSize); + } + + + @Override + public void run() { + int ntfOk = 0; + int ntfError = 0; + ListenableFuture lastOkFuture = null; + for (int i = 0; i < this.iterations; i++) { + try { + final ListenableFuture result = this.publishService.offerNotification(this.ntf); + if (NotificationPublishService.REJECTED == result) { + ntfError++; + } else { + ntfOk++; + lastOkFuture = result; + } + } catch (final Exception e) { + ntfError++; + } + } + + this.ntfOk = ntfOk; + this.ntfError = ntfError; + // We wait for last notification to be delivered to listeners. + if (lastOkFuture != null) { + try { + lastOkFuture.get(); + } catch (InterruptedException | ExecutionException e) { + throw Throwables.propagate(e); + } + } + } + +} diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchTestListener.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchTestListener.java new file mode 100644 index 0000000000..e2c876dba4 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchTestListener.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015 Cisco Systems 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 ntfbenchmark.impl; + +import java.util.concurrent.Future; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.Ntfbench; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.NtfbenchPayloadListener; + +import com.google.common.util.concurrent.Futures; + +public class NtfbenchTestListener implements NtfbenchPayloadListener { + + private final int expectedSize; + private int received = 0; + + public NtfbenchTestListener(final int expectedSize) { + this.expectedSize = expectedSize; + } + + @Override + public void onNtfbench(final Ntfbench notification) { + if (expectedSize == notification.getPayload().size()) { + received++; + } + }; + + public int getReceived() { + return received; + } + + public Future getAllDone() { + return Futures.immediateFuture(null); + } + +} diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchWTCListener.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchWTCListener.java new file mode 100644 index 0000000000..a9d44bffb0 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchWTCListener.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015 Cisco Systems 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 ntfbenchmark.impl; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.Ntfbench; + +import com.google.common.util.concurrent.SettableFuture; + +public class NtfbenchWTCListener extends NtfbenchTestListener { + private final int expectedCount; + private final SettableFuture allDone = SettableFuture.create(); + + public NtfbenchWTCListener(int expectedSize, int expectedCount) { + super(expectedSize); + this.expectedCount = expectedCount; + } + + @Override + public void onNtfbench(Ntfbench notification) { + // TODO Auto-generated method stub + super.onNtfbench(notification); + if (expectedCount == getReceived()) { + allDone.set(null); + } + } + + public SettableFuture getAllDone() { + return allDone; + } +} diff --git a/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java new file mode 100644 index 0000000000..35bea7808f --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2015 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 ntfbenchmark.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; + +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.NtfbenchmarkService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestInput.ProducerType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.StartTestOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.rev150105.TestStatusOutput; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NtfbenchmarkProvider implements BindingAwareProvider, AutoCloseable, NtfbenchmarkService { + + private static final Logger LOG = LoggerFactory.getLogger(NtfbenchmarkProvider.class); + private NotificationService listenService; + private NotificationPublishService publishService; + private static final int testTimeout = 5; + + public NtfbenchmarkProvider(NotificationService listenServiceDependency, + NotificationPublishService publishServiceDependency) { + LOG.info("NtfbenchmarkProvider Constructor"); + listenService = listenServiceDependency; + publishService = publishServiceDependency; + } + + @Override + public void onSessionInitiated(final ProviderContext session) { + LOG.info("NtfbenchmarkProvider Session Initiated"); + session.addRpcImplementation(NtfbenchmarkService.class, this); + } + + @Override + public void close() throws Exception { + LOG.info("NtfbenchmarkProvider Closed"); + } + + @Override + public Future> startTest(final StartTestInput input) { + final int producerCount = input.getProducers().intValue(); + final int listenerCount = input.getListeners().intValue(); + final int iterations = input.getIterations().intValue(); + final int payloadSize = input.getIterations().intValue(); + + final List producers = new ArrayList<>(producerCount); + final List> listeners = new ArrayList<>(listenerCount); + for (int i = 0; i < producerCount; i++) { + producers.add(new NtfbenchBlockingProducer(publishService, iterations, payloadSize)); + } + int expectedCntPerListener = producerCount * iterations; + + for (int i = 0; i < listenerCount; i++) { + final NtfbenchTestListener listener; + if (input.getProducerType() == ProducerType.BLOCKING) { + listener = new NtfbenchWTCListener(payloadSize, expectedCntPerListener); + } else { + listener = new NtfbenchTestListener(payloadSize); + } + listeners.add(listenService.registerNotificationListener(listener)); + } + + try { + final ExecutorService executor = Executors.newFixedThreadPool(input.getProducers().intValue()); + + LOG.info("Test Started"); + final long startTime = System.nanoTime(); + + for (int i = 0; i < input.getProducers().intValue(); i++) { + executor.submit(producers.get(i)); + } + executor.shutdown(); + try { + executor.awaitTermination(testTimeout, TimeUnit.MINUTES); + for (ListenerRegistration listenerRegistration : listeners) { + listenerRegistration.getInstance().getAllDone().get(); + } + } catch (final InterruptedException | ExecutionException e) { + LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout); + } + + final long producerEndTime = System.nanoTime(); + final long producerElapsedTime = producerEndTime - startTime; + + long allListeners = 0; + long allProducersOk = 0; + long allProducersError = 0; + + for (final ListenerRegistration listenerRegistration : listeners) { + allListeners += listenerRegistration.getInstance().getReceived(); + } + + final long listenerEndTime = System.nanoTime(); + final long listenerElapsedTime = producerEndTime - startTime; + + LOG.info("Test Done"); + + for (final AbstractNtfbenchProducer abstractNtfbenchProducer : producers) { + allProducersOk += abstractNtfbenchProducer.getNtfOk(); + allProducersError += abstractNtfbenchProducer.getNtfError(); + } + + final StartTestOutput output = + new StartTestOutputBuilder() + .setProducerElapsedTime(producerElapsedTime / 1000000) + .setListenerElapsedTime(listenerElapsedTime / 1000000) + .setListenerOk(allListeners) + .setProducerOk(allProducersOk) + .setProducerError(allProducersError) + .setProducerRate(((allProducersOk + allProducersError) * 1000000000) / producerElapsedTime) + .setListenerRate((allListeners * 1000000000) / listenerElapsedTime) + .build(); + return RpcResultBuilder.success(output).buildFuture(); + } finally { + for (final ListenerRegistration listenerRegistration : listeners) { + listenerRegistration.close(); + } + } + } + + @Override + public Future> testStatus() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModule.java b/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModule.java new file mode 100644 index 0000000000..0b20fe5e63 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModule.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.impl.rev141210; + +import ntfbenchmark.impl.NtfbenchmarkProvider; + +public class NtfbenchmarkModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.impl.rev141210.AbstractNtfbenchmarkModule { + public NtfbenchmarkModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public NtfbenchmarkModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.impl.rev141210.NtfbenchmarkModule oldModule, 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() { + NtfbenchmarkProvider provider = new NtfbenchmarkProvider(getListenServiceDependency(), getPublishServiceDependency()); + getBrokerDependency().registerProvider(provider); + return provider; + } + +} diff --git a/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModuleFactory.java b/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModuleFactory.java new file mode 100644 index 0000000000..43d7a2e04a --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/ntfbenchmark/impl/rev141210/NtfbenchmarkModuleFactory.java @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2015 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 + */ +/* +* Generated file +* +* Generated from: yang module name: ntfbenchmark yang module local name: ntfbenchmark +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Fri Jan 02 13:49:24 CST 2015 +* +* Do not modify this file unless it is present under src/main directory +*/ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.impl.rev141210; +public class NtfbenchmarkModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbenchmark.impl.rev141210.AbstractNtfbenchmarkModuleFactory { + +} diff --git a/benchmark/ntfbenchmark/src/main/yang/ntfbenchmark-impl.yang b/benchmark/ntfbenchmark/src/main/yang/ntfbenchmark-impl.yang new file mode 100644 index 0000000000..b12e10f437 --- /dev/null +++ b/benchmark/ntfbenchmark/src/main/yang/ntfbenchmark-impl.yang @@ -0,0 +1,53 @@ +module ntfbenchmark-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:ntfbenchmark:impl"; + prefix "ntfbenchmark-impl"; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} + import opendaylight-sal-binding-broker-impl {prefix binding-impl; revision-date 2013-10-28;} + + description + "Service definition for ntfbenchmark project"; + + revision "2014-12-10" { + description + "Initial revision"; + } + + identity ntfbenchmark { + base config:module-type; + config:java-name-prefix Ntfbenchmark; + } + + augment "/config:modules/config:module/config:configuration" { + case ntfbenchmark { + when "/config:modules/config:module/config:type = 'ntfbenchmark'"; + container broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-broker-osgi-registry; + } + } + } + container publish-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity binding-impl:binding-new-notification-publish-service; + } + } + } + container listen-service { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity binding-impl:binding-new-notification-service; + } + } + } + + } + } +} diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 53d14c1bc0..227a741f83 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -24,6 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL api dsbenchmark + ntfbenchmark artifacts diff --git a/features/benchmark/pom.xml b/features/benchmark/pom.xml index ed99085c7e..cd75de9d59 100644 --- a/features/benchmark/pom.xml +++ b/features/benchmark/pom.xml @@ -74,6 +74,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL xml config + + ${project.groupId} + ntfbenchmark + ${project.version} + + + ${project.groupId} + ntfbenchmark + ${project.version} + xml + config + ${project.groupId} benchmark-api diff --git a/features/benchmark/src/main/features/features.xml b/features/benchmark/src/main/features/features.xml index 55e60e57bc..fcc4e2a39a 100644 --- a/features/benchmark/src/main/features/features.xml +++ b/features/benchmark/src/main/features/features.xml @@ -24,4 +24,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}} mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}/xml/config + + odl-mdsal-broker + odl-benchmark-api + mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}} + mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}/xml/config + -- 2.36.6