From 2bf2e52f7001e81608c8219f35a1bf4f637aa5f1 Mon Sep 17 00:00:00 2001 From: Jan Medved Date: Sat, 21 Nov 2015 19:24:24 -0800 Subject: [PATCH 1/1] Changed the artifact id from 'benchmark-features' to 'features-benchmark' Added 'odl-mdsal-features' feature definition that contains all benchmark artifacts (api, ds, ntf and rpc) Added rpcbenchmark Fixed tabs and white space at the end-of-lines Fixed more white spaces Change-Id: I1789ae09c3f316facef38e484310f6c3a4098dd7 Signed-off-by: Jan Medved --- benchmark/pom.xml | 1 + benchmark/rpcbenchmark/pom.xml | 39 +++++ .../src/main/config/default-config.xml | 30 ++++ .../src/main/config/maven-metadata-local.xml | 20 +++ .../impl/rev141210/RpcbenchmarkModule.java | 33 ++++ .../rev141210/RpcbenchmarkModuleFactory.java | 20 +++ .../impl/GlobalBindingRTCClient.java | 96 +++++++++++ .../impl/GlobalBindingRTCServer.java | 57 +++++++ .../java/rpcbenchmark/impl/RTCClient.java | 16 ++ .../impl/RoutedBindingRTClient.java | 105 ++++++++++++ .../impl/RpcbenchmarkProvider.java | 159 ++++++++++++++++++ .../src/main/yang/rpcbenchmark-impl.yang | 35 ++++ features/benchmark/pom.xml | 14 +- .../benchmark/src/main/features/features.xml | 11 ++ 14 files changed, 635 insertions(+), 1 deletion(-) create mode 100644 benchmark/rpcbenchmark/pom.xml create mode 100644 benchmark/rpcbenchmark/src/main/config/default-config.xml create mode 100644 benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml create mode 100644 benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java create mode 100644 benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.java create mode 100644 benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java create mode 100644 benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCServer.java create mode 100644 benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java create mode 100644 benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java create mode 100644 benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java create mode 100644 benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang diff --git a/benchmark/pom.xml b/benchmark/pom.xml index 227a741f83..b6d9c8fff5 100644 --- a/benchmark/pom.xml +++ b/benchmark/pom.xml @@ -25,6 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL api dsbenchmark ntfbenchmark + rpcbenchmark artifacts diff --git a/benchmark/rpcbenchmark/pom.xml b/benchmark/rpcbenchmark/pom.xml new file mode 100644 index 0000000000..e0fee07cf0 --- /dev/null +++ b/benchmark/rpcbenchmark/pom.xml @@ -0,0 +1,39 @@ + + + + + + org.opendaylight.controller + config-parent + 0.4.0-SNAPSHOT + + + + 4.0.0 + org.opendaylight.controller + rpcbenchmark + 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/rpcbenchmark/src/main/config/default-config.xml b/benchmark/rpcbenchmark/src/main/config/default-config.xml new file mode 100644 index 0000000000..3ce1e64757 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/config/default-config.xml @@ -0,0 +1,30 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:rpcbenchmark:impl?module=rpcbenchmark-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:rpcbenchmark + rpcbenchmark-default + + binding:binding-broker-osgi-registry + binding-osgi-broker + + + + + + diff --git a/benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml b/benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml new file mode 100644 index 0000000000..22a3e024f2 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml @@ -0,0 +1,20 @@ + + + org.opendaylight.controller + rpcbenchmark + 1.1.0-SNAPSHOT + + + true + + 20151122054906 + + + config + xml + 1.1.0-SNAPSHOT + 20151122054906 + + + + diff --git a/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java b/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java new file mode 100644 index 0000000000..01b39ad766 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.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.rpcbenchmark.impl.rev141210; + +import rpcbenchmark.impl.RpcbenchmarkProvider; + +public class RpcbenchmarkModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.impl.rev141210.AbstractRpcbenchmarkModule { + public RpcbenchmarkModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public RpcbenchmarkModule(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.rpcbenchmark.impl.rev141210.RpcbenchmarkModule 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() { + RpcbenchmarkProvider provider = new RpcbenchmarkProvider(); + getBrokerDependency().registerProvider(provider); + return provider; + } + +} diff --git a/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.java b/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.java new file mode 100644 index 0000000000..d8b69734b8 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.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: rpcbenchmark yang module local name: rpcbenchmark +* 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.rpcbenchmark.impl.rev141210; +public class RpcbenchmarkModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.impl.rev141210.AbstractRpcbenchmarkModuleFactory { + +} diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java new file mode 100644 index 0000000000..ea426ba990 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java @@ -0,0 +1,96 @@ +/* + * 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 rpcbenchmark.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.atomic.AtomicLong; + +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInputBuilder; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchOutput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.Payload; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.PayloadBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class GlobalBindingRTCClient implements RTCClient { + + private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRTCClient.class); + private final RpcbenchPayloadService service; + private final AtomicLong rpcOk = new AtomicLong(0); + private final AtomicLong rpcError = new AtomicLong(0); + private final GlobalRpcBenchInput inVal; + private final int inSize; + + public long getRpcOk() { + return rpcOk.get(); + } + + public long getRpcError() { + return rpcError.get(); + } + + public GlobalBindingRTCClient(RpcConsumerRegistry registry, int inSize) { + if (registry != null) { + this.service = registry.getRpcService(RpcbenchPayloadService.class); + } else { + this.service = null; + } + + this.inSize = inSize; + List listVals = new ArrayList<>(); + for (int i = 0; i < inSize; i++) { + listVals.add(new PayloadBuilder().setId(i).build()); + } + inVal = new GlobalRpcBenchInputBuilder().setPayload(listVals).build(); + } + + public void runTest(int iterations) { + int rpcOk = 0; + int rpcError = 0; + + for (int i = 0; i < iterations; i++) { + Future> output = service.globalRpcBench(inVal); + try { + RpcResult rpcResult = output.get(); + + if (rpcResult.isSuccessful()) { + List retVal = rpcResult.getResult().getPayload(); + if (retVal.size() == inSize) { + rpcOk++; + } + else { + rpcError++; + } + } + } catch (InterruptedException e) { + rpcError++; + LOG.error("Execution failed: ", e); + } catch (ExecutionException e) { + rpcError++; + LOG.error("Execution failed: ", e); + } + } + + this.rpcOk.addAndGet(rpcOk); + this.rpcError.addAndGet(rpcError); + } + + @Override + public void close() { + // TODO Auto-generated method stub + + } + +} diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCServer.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCServer.java new file mode 100644 index 0000000000..0eaf10dbee --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCServer.java @@ -0,0 +1,57 @@ +/* + * 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 rpcbenchmark.impl; + +import java.util.concurrent.Future; + +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchInput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchOutput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.GlobalRpcBenchOutputBuilder; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutputBuilder; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.Futures; + +public class GlobalBindingRTCServer implements RpcbenchPayloadService { + + private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRTCServer.class); + private int numRpcs = 0; + + public GlobalBindingRTCServer() { + LOG.info("GlobalBindingRTCServer created."); + } + + @Override + public Future> globalRpcBench( + GlobalRpcBenchInput input) { + GlobalRpcBenchOutput output = new GlobalRpcBenchOutputBuilder(input).build(); + RpcResult result = RpcResultBuilder.success(output).build(); + numRpcs++; + return Futures.immediateFuture(result); + } + + @Override + public Future> routedRpcBench( + RoutedRpcBenchInput input) { + RoutedRpcBenchOutput output = new RoutedRpcBenchOutputBuilder(input).build(); + RpcResult result = RpcResultBuilder.success(output).build(); + numRpcs++; + return Futures.immediateFuture(result); + } + + public int getNumRpcs() { + return numRpcs; + } +} diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java new file mode 100644 index 0000000000..5565e037c0 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java @@ -0,0 +1,16 @@ +/* + * 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 rpcbenchmark.impl; + +public interface RTCClient { + long getRpcOk(); + long getRpcError(); + void runTest(int iterations); + void close(); +} diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java new file mode 100644 index 0000000000..c0e362bd4d --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java @@ -0,0 +1,105 @@ +/* + * 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 rpcbenchmark.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicLong; + +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchInputBuilder; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RoutedRpcBenchOutput; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.Payload; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.payload.PayloadBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RoutedBindingRTClient implements RTCClient { + private static final Logger LOG = LoggerFactory.getLogger(GlobalBindingRTCClient.class); + private final RpcbenchPayloadService service; + private final AtomicLong rpcOk = new AtomicLong(0); + private final AtomicLong rpcError = new AtomicLong(0); + private final List inVal; + private final int inSize; + + public long getRpcOk() { + return rpcOk.get(); + } + + public long getRpcError() { + return rpcError.get(); + } + + public RoutedBindingRTClient(RpcConsumerRegistry registry, int inSize, List> routeIid) { + if (registry != null) { + this.service = registry.getRpcService(RpcbenchPayloadService.class); + } else { + this.service = null; + } + this.inSize = inSize; + this.inVal = new ArrayList<>(); + + List listVals = new ArrayList<>(); + for (int i = 0; i < inSize; i++) { + listVals.add(new PayloadBuilder().setId(i).build()); + } + + for (InstanceIdentifier iid : routeIid) { + inVal.add(new RoutedRpcBenchInputBuilder().setNode(iid).setPayload(listVals).build()); + } + + } + + public void runTest(int iterations) { + int rpcOk = 0; + int rpcError = 0; + + int rpcServerCnt = inVal.size(); + for (int i = 0; i < iterations; i++) { + RoutedRpcBenchInput input = inVal.get(ThreadLocalRandom.current().nextInt(rpcServerCnt)); + Future> output = service.routedRpcBench(input); + try { + RpcResult rpcResult = output.get(); + + if (rpcResult.isSuccessful()) { + List retVal = rpcResult.getResult().getPayload(); + if (retVal.size() == inSize) { + rpcOk++; + } + else { + rpcError++; + } + } + } catch (InterruptedException e) { + rpcError++; + LOG.error("Execution failed: ", e); + } catch (ExecutionException e) { + rpcError++; + LOG.error("Execution failed: ", e); + } + } + + this.rpcOk.addAndGet(rpcOk); + this.rpcError.addAndGet(rpcError); + } + + @Override + public void close() { + // TODO Auto-generated method stub + + } + +} diff --git a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java new file mode 100644 index 0000000000..e06e3c02f8 --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java @@ -0,0 +1,159 @@ +/* + * 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 rpcbenchmark.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicReference; + +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.NodeContext; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchPayloadService; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.RpcbenchRpcRoutes; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRoute; +import org.opendaylight.yang.gen.v1.rpcbench.payload.rev150702.rpcbench.rpc.routes.RpcRouteKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.RpcbenchmarkService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.StartTestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.StartTestOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.StartTestOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutput.ExecStatus; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.rev150702.TestStatusOutputBuilder; +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 RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable, RpcbenchmarkService { + + private static final Logger LOG = LoggerFactory.getLogger(RpcbenchmarkProvider.class); + private static final GlobalBindingRTCServer gServer = new GlobalBindingRTCServer(); + private static final int testTimeout = 5; + private final AtomicReference execStatus = new AtomicReference(ExecStatus.Idle ); + private RpcConsumerRegistry consumerRegistry; + private RpcProviderRegistry providerRegistry; + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("RpcbenchmarkProvider Session Initiated"); + consumerRegistry = session.getSALService(RpcConsumerRegistry.class); + providerRegistry = session.getSALService(RpcProviderRegistry.class); + + // Register the benchmark Global RPC + session.addRpcImplementation(RpcbenchPayloadService.class, gServer); + // Register RPC Benchmark's control REST API + session.addRpcImplementation(RpcbenchmarkService.class, this); + } + + @Override + public void close() throws Exception { + LOG.info("RpcbenchmarkProvider Closed"); + } + + @Override + public Future> startTest(final StartTestInput input) { + LOG.info("startTest {}", input); + + final RTCClient client; + final List> rpcRegs = new ArrayList<>(); + + switch (input.getOperation()) { + case ROUTEDRTC: + List> routeIid = new ArrayList<>(); + for (int i = 0; i < input.getNumServers().intValue(); i++) { + GlobalBindingRTCServer server = new GlobalBindingRTCServer(); + RoutedRpcRegistration routedReg = + providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server); + + KeyedInstanceIdentifier iid = + InstanceIdentifier + .create(RpcbenchRpcRoutes.class) + .child(RpcRoute.class, new RpcRouteKey(Integer.toString(i))); + routeIid.add(iid); + routedReg.registerPath(NodeContext.class, iid); + rpcRegs.add(routedReg); + } + + client = new RoutedBindingRTClient(consumerRegistry, input.getPayloadSize().intValue(), routeIid); + break; + + case GLOBALRTC: + client = new GlobalBindingRTCClient(consumerRegistry, input.getPayloadSize().intValue()); + break; + + default: + LOG.error("Unsupported server/client type {}", input.getOperation()); + throw new IllegalArgumentException("Unsupported server/client type" + input.getOperation()); + } + + try { + ExecutorService executor = Executors.newFixedThreadPool(input.getNumClients().intValue()); + + final Runnable testRun = new Runnable() { + @Override + public void run() { + client.runTest(input.getIterations().intValue()); + } + }; + + LOG.info("Test Started"); + long startTime = System.nanoTime(); + + for (int i = 0; i < input.getNumClients().intValue(); i++ ) { + executor.submit(testRun); + } + + executor.shutdown(); + try { + executor.awaitTermination(testTimeout, TimeUnit.MINUTES); + } catch (InterruptedException e) { + LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout); + } + + long endTime = System.nanoTime(); + LOG.info("Test Done"); + + long elapsedTime = endTime - startTime; + + StartTestOutput output = new StartTestOutputBuilder() + .setRate((long)0) + .setGlobalRtcClientError((long)client.getRpcError()) + .setGlobalRtcClientOk((long)client.getRpcOk()) + .setExecTime(TimeUnit.NANOSECONDS.toMillis(elapsedTime)) + .setRate(((client.getRpcOk() + client.getRpcError()) * 1000000000) / elapsedTime) + .build(); + return RpcResultBuilder.success(output).buildFuture(); + } finally { + for (RoutedRpcRegistration routedRpcRegistration : rpcRegs) { + routedRpcRegistration.close(); + } + } + } + + @Override + public Future> testStatus() { + LOG.info("testStatus"); + TestStatusOutput output = new TestStatusOutputBuilder() + .setGlobalServerCnt((long)gServer.getNumRpcs()) + .setExecStatus(execStatus.get()) + .build(); + return RpcResultBuilder.success(output).buildFuture(); + } + +} diff --git a/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang b/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang new file mode 100644 index 0000000000..b28de5163d --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang @@ -0,0 +1,35 @@ +module rpcbenchmark-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:rpcbenchmark:impl"; + prefix "rpcbenchmark-impl"; + + import config { prefix config; revision-date 2013-04-05; } + import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;} + + description + "Service definition for rpcbenchmark project"; + + revision "2014-12-10" { + description + "Initial revision"; + } + + identity rpcbenchmark { + base config:module-type; + config:java-name-prefix Rpcbenchmark; + } + + augment "/config:modules/config:module/config:configuration" { + case rpcbenchmark { + when "/config:modules/config:module/config:type = 'rpcbenchmark'"; + container broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-broker-osgi-registry; + } + } + } + } + } +} diff --git a/features/benchmark/pom.xml b/features/benchmark/pom.xml index cd75de9d59..b56a6aaac6 100644 --- a/features/benchmark/pom.xml +++ b/features/benchmark/pom.xml @@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL org.opendaylight.controller - benchmark-features + features-mdsal-benchmark 1.1.0-SNAPSHOT ${project.artifactId} 4.0.0 @@ -86,6 +86,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL xml config + + ${project.groupId} + rpcbenchmark + ${project.version} + + + ${project.groupId} + rpcbenchmark + ${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 fcc4e2a39a..c2626f5669 100644 --- a/features/benchmark/src/main/features/features.xml +++ b/features/benchmark/src/main/features/features.xml @@ -30,4 +30,15 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}} mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}/xml/config + + odl-mdsal-broker + odl-benchmark-api + mvn:org.opendaylight.controller/benchmark-api/{{VERSION}} + mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}} + mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}} + mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}} + mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}/xml/config + mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}/xml/config + mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}}/xml/config + -- 2.36.6