Changed the artifact id from 'benchmark-features' to 'features-benchmark' 46/30046/4
authorJan Medved <jmedved@cisco.com>
Sun, 22 Nov 2015 03:24:24 +0000 (19:24 -0800)
committerJan Medved <jmedved@cisco.com>
Sun, 22 Nov 2015 06:56:14 +0000 (22:56 -0800)
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 <jmedved@cisco.com>
14 files changed:
benchmark/pom.xml
benchmark/rpcbenchmark/pom.xml [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/config/default-config.xml [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/config/maven-metadata-local.xml [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModule.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/rpcbenchmark/impl/rev141210/RpcbenchmarkModuleFactory.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCClient.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/GlobalBindingRTCServer.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RTCClient.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RoutedBindingRTClient.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java [new file with mode: 0644]
benchmark/rpcbenchmark/src/main/yang/rpcbenchmark-impl.yang [new file with mode: 0644]
features/benchmark/pom.xml
features/benchmark/src/main/features/features.xml

index 227a741f835d8c6ece4a8f62b1954de2e93e9a33..b6d9c8fff5503a7fe4a43a7b91d77eebed7709b1 100644 (file)
@@ -25,6 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>api</module>
     <module>dsbenchmark</module>
     <module>ntfbenchmark</module>
+    <module>rpcbenchmark</module>
     <module>artifacts</module>
   </modules>
 </project>
diff --git a/benchmark/rpcbenchmark/pom.xml b/benchmark/rpcbenchmark/pom.xml
new file mode 100644 (file)
index 0000000..e0fee07
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+Copyright (c) 2014 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">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.4.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>rpcbenchmark</artifactId>
+  <version>1.1.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>benchmark-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-core-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-data-impl</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>
diff --git a/benchmark/rpcbenchmark/src/main/config/default-config.xml b/benchmark/rpcbenchmark/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..3ce1e64
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+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
+-->
+<snapshot>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:rpcbenchmark:impl?module=rpcbenchmark-impl&amp;revision=2014-12-10</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:rpcbenchmark:impl">prefix:rpcbenchmark</type>
+          <name>rpcbenchmark-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
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 (file)
index 0000000..22a3e02
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata modelVersion="1.1.0">
+  <groupId>org.opendaylight.controller</groupId>
+  <artifactId>rpcbenchmark</artifactId>
+  <version>1.1.0-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <localCopy>true</localCopy>
+    </snapshot>
+    <lastUpdated>20151122054906</lastUpdated>
+    <snapshotVersions>
+      <snapshotVersion>
+        <classifier>config</classifier>
+        <extension>xml</extension>
+        <value>1.1.0-SNAPSHOT</value>
+        <updated>20151122054906</updated>
+      </snapshotVersion>
+    </snapshotVersions>
+  </versioning>
+</metadata>
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 (file)
index 0000000..01b39ad
--- /dev/null
@@ -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 (file)
index 0000000..d8b6973
--- /dev/null
@@ -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 (file)
index 0000000..ea426ba
--- /dev/null
@@ -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<Payload> 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<RpcResult<GlobalRpcBenchOutput>> output = service.globalRpcBench(inVal);
+            try {
+                RpcResult<GlobalRpcBenchOutput> rpcResult = output.get();
+
+                if (rpcResult.isSuccessful()) {
+                    List<Payload> 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 (file)
index 0000000..0eaf10d
--- /dev/null
@@ -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<RpcResult<GlobalRpcBenchOutput>> globalRpcBench(
+            GlobalRpcBenchInput input) {
+        GlobalRpcBenchOutput output = new GlobalRpcBenchOutputBuilder(input).build();
+        RpcResult<GlobalRpcBenchOutput> result = RpcResultBuilder.success(output).build();
+        numRpcs++;
+        return Futures.immediateFuture(result);
+    }
+
+    @Override
+    public Future<RpcResult<RoutedRpcBenchOutput>> routedRpcBench(
+            RoutedRpcBenchInput input) {
+        RoutedRpcBenchOutput output = new RoutedRpcBenchOutputBuilder(input).build();
+        RpcResult<RoutedRpcBenchOutput> 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 (file)
index 0000000..5565e03
--- /dev/null
@@ -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 (file)
index 0000000..c0e362b
--- /dev/null
@@ -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<RoutedRpcBenchInput> inVal;
+    private final int inSize;
+
+    public long getRpcOk() {
+        return rpcOk.get();
+    }
+
+    public long getRpcError() {
+        return rpcError.get();
+    }
+
+    public RoutedBindingRTClient(RpcConsumerRegistry registry, int inSize, List<InstanceIdentifier<?>> routeIid) {
+        if (registry != null) {
+            this.service = registry.getRpcService(RpcbenchPayloadService.class);
+        } else {
+            this.service = null;
+        }
+        this.inSize = inSize;
+        this.inVal = new ArrayList<>();
+
+        List<Payload> 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<RpcResult<RoutedRpcBenchOutput>> output = service.routedRpcBench(input);
+            try {
+                RpcResult<RoutedRpcBenchOutput> rpcResult = output.get();
+
+                if (rpcResult.isSuccessful()) {
+                    List<Payload> 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 (file)
index 0000000..e06e3c0
--- /dev/null
@@ -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> execStatus = new AtomicReference<ExecStatus>(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<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
+        LOG.info("startTest {}", input);
+
+        final RTCClient client;
+        final List<RoutedRpcRegistration<?>> rpcRegs = new ArrayList<>();
+
+        switch (input.getOperation()) {
+        case ROUTEDRTC:
+            List<InstanceIdentifier<?>> routeIid = new ArrayList<>();
+            for (int i = 0; i < input.getNumServers().intValue(); i++) {
+                GlobalBindingRTCServer server = new GlobalBindingRTCServer();
+                RoutedRpcRegistration<RpcbenchPayloadService> routedReg =
+                        providerRegistry.addRoutedRpcImplementation(RpcbenchPayloadService.class, server);
+
+                KeyedInstanceIdentifier<RpcRoute, RpcRouteKey> 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<RpcResult<TestStatusOutput>> 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 (file)
index 0000000..b28de51
--- /dev/null
@@ -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;
+                    }
+                }
+            }
+        }
+    }
+}
index cd75de9d59e26819a0a2db38c041c8035169d63b..b56a6aaac60b7d625c5febe3b8b0a195a6731fbb 100644 (file)
@@ -13,7 +13,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <relativePath/>
   </parent>
   <groupId>org.opendaylight.controller</groupId>
-  <artifactId>benchmark-features</artifactId>
+  <artifactId>features-mdsal-benchmark</artifactId>
   <version>1.1.0-SNAPSHOT</version>
   <name>${project.artifactId}</name>
   <modelVersion>4.0.0</modelVersion>
@@ -86,6 +86,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <type>xml</type>
       <classifier>config</classifier>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>rpcbenchmark</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>rpcbenchmark</artifactId>
+      <version>${project.version}</version>
+      <type>xml</type>
+      <classifier>config</classifier>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>benchmark-api</artifactId>
index fcc4e2a39a6acccb9b0141b8c60aa4b1e6913b15..c2626f5669911d3d0de9220b9dce4b9967fe967a 100644 (file)
@@ -30,4 +30,15 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}</bundle>
     <configfile finalname="ntfbenchmark-impl-default-config.xml">mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}/xml/config</configfile>
   </feature>
+  <feature name='odl-mdsal-benchmark' version='${project.version}' description='OpenDaylight :: dsbenchmark :: '>
+    <feature version='${controller.mdsal.version}'>odl-mdsal-broker</feature>
+    <feature version='${project.version}'>odl-benchmark-api</feature>
+    <bundle>mvn:org.opendaylight.controller/benchmark-api/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}</bundle>
+    <bundle>mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}}</bundle>
+    <configfile finalname="dsbenchmark-impl-default-config.xml">mvn:org.opendaylight.controller/dsbenchmark/{{VERSION}}/xml/config</configfile>
+    <configfile finalname="ntfbenchmark-impl-default-config.xml">mvn:org.opendaylight.controller/ntfbenchmark/{{VERSION}}/xml/config</configfile>
+    <configfile finalname="rpcbenchmark-impl-default-config.xml">mvn:org.opendaylight.controller/rpcbenchmark/{{VERSION}}/xml/config</configfile>
+  </feature>
 </features>