From 86809c51abd9644f5c0478c2c4caf964279adc7f Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 7 Jun 2017 10:54:33 -0400 Subject: [PATCH] Convert rpcbenchmark to blueprint Change-Id: I1af664396721a899d51d12fe132853d642d98a7e Signed-off-by: Tom Pantelis --- benchmark/rpcbenchmark/pom.xml | 25 +++++++++-- .../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/RpcbenchmarkProvider.java | 43 ++++++++----------- .../opendaylight/blueprint/rpcbenchmark.xml | 25 +++++++++++ .../src/main/yang/rpcbenchmark-impl.yang | 35 --------------- .../features-mdsal-benchmark/pom.xml | 7 --- .../src/main/features/features.xml | 1 - .../benchmark/odl-mdsal-benchmark/pom.xml | 8 ---- .../src/main/feature/feature.xml | 15 ------- 12 files changed, 64 insertions(+), 198 deletions(-) delete mode 100644 benchmark/rpcbenchmark/src/main/config/default-config.xml delete mode 100644 benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml delete mode 100644 benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java delete 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/resources/org/opendaylight/blueprint/rpcbenchmark.xml delete mode 100644 benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang delete mode 100644 features/benchmark/odl-mdsal-benchmark/src/main/feature/feature.xml diff --git a/benchmark/rpcbenchmark/pom.xml b/benchmark/rpcbenchmark/pom.xml index 6b016bdf32..e4d398b13b 100644 --- a/benchmark/rpcbenchmark/pom.xml +++ b/benchmark/rpcbenchmark/pom.xml @@ -9,10 +9,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - org.opendaylight.controller - config-parent - 0.7.0-SNAPSHOT - ../../opendaylight/config/config-parent/pom.xml + org.opendaylight.mdsal + binding-parent + 0.11.0-SNAPSHOT + 4.0.0 @@ -20,12 +20,29 @@ and is available at http://www.eclipse.org/legal/epl-v10.html rpcbenchmark 1.4.0-SNAPSHOT bundle + + + + + org.opendaylight.controller + mdsal-artifacts + 1.6.0-SNAPSHOT + pom + import + + + + org.opendaylight.controller benchmark-api ${project.version} + + org.opendaylight.controller + sal-binding-api + org.opendaylight.controller sal-core-api diff --git a/benchmark/rpcbenchmark/src/main/config/default-config.xml b/benchmark/rpcbenchmark/src/main/config/default-config.xml deleted file mode 100644 index 3ce1e64757..0000000000 --- a/benchmark/rpcbenchmark/src/main/config/default-config.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - 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 deleted file mode 100644 index 22a3e024f2..0000000000 --- a/benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - 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 deleted file mode 100644 index 6475d0c1aa..0000000000 --- a/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public RpcbenchmarkModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rpcbenchmark.impl.rev141210.RpcbenchmarkModule 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() { - 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 deleted file mode 100644 index d8b69734b8..0000000000 --- a/benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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/RpcbenchmarkProvider.java b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java index 503bd170a5..7f8be49c3b 100644 --- a/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java +++ b/benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java @@ -15,11 +15,7 @@ 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; @@ -40,30 +36,27 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable, RpcbenchmarkService { +public class RpcbenchmarkProvider implements 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 GlobalBindingRTCServer globalServer; private final AtomicReference execStatus = new AtomicReference<>(ExecStatus.Idle); - private RpcConsumerRegistry consumerRegistry; - private RpcProviderRegistry providerRegistry; + private final RpcProviderRegistry providerRegistry; - @Override - public void onSessionInitiated(final ProviderContext session) { - LOG.debug("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); + public RpcbenchmarkProvider(final RpcProviderRegistry providerRegistry, final GlobalBindingRTCServer globalServer) { + this.providerRegistry = providerRegistry; + this.globalServer = globalServer; + } + + public void init() { + LOG.info("RpcbenchmarkProvider initiated"); } @Override - public void close() throws Exception { - LOG.debug("RpcbenchmarkProvider Closed"); + public void close() { + LOG.info("RpcbenchmarkProvider closed"); } @Override @@ -90,11 +83,11 @@ public class RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable rpcRegs.add(routedReg); } - client = new RoutedBindingRTClient(consumerRegistry, input.getPayloadSize().intValue(), routeIid); + client = new RoutedBindingRTClient(providerRegistry, input.getPayloadSize().intValue(), routeIid); break; case GLOBALRTC: - client = new GlobalBindingRTCClient(consumerRegistry, input.getPayloadSize().intValue()); + client = new GlobalBindingRTCClient(providerRegistry, input.getPayloadSize().intValue()); break; default: @@ -118,7 +111,7 @@ public class RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable try { executor.awaitTermination(testTimeout, TimeUnit.MINUTES); } catch (final InterruptedException e) { - LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout); + LOG.error("Out of time: test did not finish within the {} min deadline ", testTimeout); } long endTime = System.nanoTime(); @@ -131,7 +124,7 @@ public class RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable .setGlobalRtcClientError(client.getRpcError()) .setGlobalRtcClientOk(client.getRpcOk()) .setExecTime(TimeUnit.NANOSECONDS.toMillis(elapsedTime)) - .setRate(((client.getRpcOk() + client.getRpcError()) * 1000000000) / elapsedTime) + .setRate((client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime) .build(); return RpcResultBuilder.success(output).buildFuture(); } finally { @@ -145,7 +138,7 @@ public class RpcbenchmarkProvider implements BindingAwareProvider, AutoCloseable public Future> testStatus() { LOG.info("testStatus"); TestStatusOutput output = new TestStatusOutputBuilder() - .setGlobalServerCnt((long)gServer.getNumRpcs()) + .setGlobalServerCnt((long)globalServer.getNumRpcs()) .setExecStatus(execStatus.get()) .build(); return RpcResultBuilder.success(output).buildFuture(); diff --git a/benchmark/rpcbenchmark/src/main/resources/org/opendaylight/blueprint/rpcbenchmark.xml b/benchmark/rpcbenchmark/src/main/resources/org/opendaylight/blueprint/rpcbenchmark.xml new file mode 100644 index 0000000000..96611d36ba --- /dev/null +++ b/benchmark/rpcbenchmark/src/main/resources/org/opendaylight/blueprint/rpcbenchmark.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang b/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang deleted file mode 100644 index b28de5163d..0000000000 --- a/benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang +++ /dev/null @@ -1,35 +0,0 @@ -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/features-mdsal-benchmark/pom.xml b/features/benchmark/features-mdsal-benchmark/pom.xml index 72e9812fcd..6001a90793 100644 --- a/features/benchmark/features-mdsal-benchmark/pom.xml +++ b/features/benchmark/features-mdsal-benchmark/pom.xml @@ -73,13 +73,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL rpcbenchmark ${project.version} - - ${project.groupId} - rpcbenchmark - ${project.version} - xml - config - ${project.groupId} benchmark-api diff --git a/features/benchmark/features-mdsal-benchmark/src/main/features/features.xml b/features/benchmark/features-mdsal-benchmark/src/main/features/features.xml index b1a1a1889a..7e2b451fcb 100644 --- a/features/benchmark/features-mdsal-benchmark/src/main/features/features.xml +++ b/features/benchmark/features-mdsal-benchmark/src/main/features/features.xml @@ -32,6 +32,5 @@ and is available at http://www.eclipse.org/legal/epl-v10.html odl-dsbenchmark odl-ntfbenchmark mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}} - mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}}/xml/config diff --git a/features/benchmark/odl-mdsal-benchmark/pom.xml b/features/benchmark/odl-mdsal-benchmark/pom.xml index ec732703e8..dc5be791e4 100644 --- a/features/benchmark/odl-mdsal-benchmark/pom.xml +++ b/features/benchmark/odl-mdsal-benchmark/pom.xml @@ -60,13 +60,5 @@ rpcbenchmark ${project.version} - - - ${project.groupId} - rpcbenchmark - ${project.version} - xml - config - diff --git a/features/benchmark/odl-mdsal-benchmark/src/main/feature/feature.xml b/features/benchmark/odl-mdsal-benchmark/src/main/feature/feature.xml deleted file mode 100644 index f5f1e0a9c2..0000000000 --- a/features/benchmark/odl-mdsal-benchmark/src/main/feature/feature.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - mvn:org.opendaylight.controller/rpcbenchmark/${project.version}/xml/config - - - -- 2.36.6