From b98dc95becad0e77cef5920b0041029b62119abe Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Fri, 29 Jun 2018 07:35:35 +0200 Subject: jvpp-benchmark: improve exception handling Fixes several issues found by Sonar. Change-Id: I7ab017f9d89221e8eff4b2438b7669df608b5587 Signed-off-by: Marek Gradzki --- .../io/fd/hc2vpp/it/jvpp/benchmark/acl/AclUpdateBenchmark.java | 2 +- .../hc2vpp/it/jvpp/benchmark/classify/ClassifyTableBenchmark.java | 5 +++-- .../java/io/fd/hc2vpp/it/jvpp/benchmark/util/JVppBenchmark.java | 8 ++------ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/acl/AclUpdateBenchmark.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/acl/AclUpdateBenchmark.java index 4042f8a73..ac3032ccd 100644 --- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/acl/AclUpdateBenchmark.java +++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/acl/AclUpdateBenchmark.java @@ -65,7 +65,7 @@ public class AclUpdateBenchmark extends JVppBenchmark { * Initializes loopback interface, creates ACL and assigns it to loop0. */ @Override - protected void iterationSetup() throws Exception { + protected void iterationSetup() throws ExecutionException, InterruptedException { aclProvider = new AclProviderImpl(aclSetSize, aclSize); // Init loop0 interface diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/classify/ClassifyTableBenchmark.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/classify/ClassifyTableBenchmark.java index ba234e44d..fba7110d1 100644 --- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/classify/ClassifyTableBenchmark.java +++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/classify/ClassifyTableBenchmark.java @@ -22,6 +22,7 @@ import io.fd.vpp.jvpp.core.JVppCoreImpl; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade; import java.io.IOException; +import java.util.concurrent.ExecutionException; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Param; import org.slf4j.Logger; @@ -37,13 +38,13 @@ public class ClassifyTableBenchmark extends JVppBenchmark { private ClassifyTableProvider classifyTableProvider; @Benchmark - public ClassifyAddDelTableReply testCreate() throws Exception { + public ClassifyAddDelTableReply testCreate() throws ExecutionException, InterruptedException { // Caller may want to process reply, so return it to prevent JVM from dead code elimination return jvppCore.classifyAddDelTable(classifyTableProvider.next()).toCompletableFuture().get(); } @Override - protected void iterationSetup() throws Exception { + protected void iterationSetup() { classifyTableProvider = new ClassifyTableProviderImpl(tableSetSize); } diff --git a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/util/JVppBenchmark.java b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/util/JVppBenchmark.java index 9f422747e..761ee98d0 100644 --- a/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/util/JVppBenchmark.java +++ b/it/jvpp-benchmark/src/main/java/io/fd/hc2vpp/it/jvpp/benchmark/util/JVppBenchmark.java @@ -19,10 +19,6 @@ package io.fd.hc2vpp.it.jvpp.benchmark.util; import com.google.common.io.CharStreams; import io.fd.vpp.jvpp.JVppRegistry; import io.fd.vpp.jvpp.JVppRegistryImpl; -import io.fd.vpp.jvpp.acl.JVppAclImpl; -import io.fd.vpp.jvpp.acl.future.FutureJVppAclFacade; -import io.fd.vpp.jvpp.core.JVppCoreImpl; -import io.fd.vpp.jvpp.core.future.FutureJVppCoreFacade; import io.fd.vpp.jvpp.dto.JVppReply; import java.io.IOException; import java.io.InputStreamReader; @@ -81,14 +77,14 @@ public abstract class JVppBenchmark { // NOOP } - private void startVpp() throws Exception { + private void startVpp() throws IOException, InterruptedException { LOG.info("Starting VPP ..."); final String[] cmd = {"/bin/sh", "-c", "sudo service vpp start"}; exec(cmd); LOG.info("VPP started successfully"); } - private void stopVpp() throws Exception { + private void stopVpp() throws IOException, InterruptedException { LOG.info("Stopping VPP ..."); final String[] cmd = {"/bin/sh", "-c", "sudo service vpp stop"}; exec(cmd); -- cgit 1.2.3-korg