Fix deprecation warnings and checkstyle in benchmarks 14/71214/13
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Apr 2018 13:49:28 +0000 (15:49 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 6 Aug 2018 08:24:41 +0000 (10:24 +0200)
This fixes up warnings/checkstyle and flips the enforcement switch.

Change-Id: I22754c767ef643d703286a30252cf57006062ade
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 files changed:
benchmark/dsbenchmark/pom.xml
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/BaListBuilder.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DatastoreAbstractWriter.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DomListBuilder.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/simpletx/SimpletxDomWrite.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainBaWrite.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomDelete.java
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/txchain/TxchainDomWrite.java
benchmark/ntfbenchmark/pom.xml
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/AbstractNtfbenchProducer.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchBlockingProducer.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchNonblockingProducer.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchTestListener.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchWTCListener.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java
benchmark/rpcbenchmark/pom.xml

index bd10dab..6d1c7bc 100644 (file)
@@ -54,37 +54,43 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   </dependencies>
 
   <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
+    </plugins>
+
     <pluginManagement>
-        <plugins>
-            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
-            <plugin>
-                <groupId>org.eclipse.m2e</groupId>
-                <artifactId>lifecycle-mapping</artifactId>
-                <version>1.0.0</version>
-                <configuration>
-                    <lifecycleMappingMetadata>
-                        <pluginExecutions>
-                            <pluginExecution>
-                                <pluginExecutionFilter>
-                                    <groupId>org.jacoco</groupId>
-                                    <artifactId>
-                                        jacoco-maven-plugin
-                                    </artifactId>
-                                    <versionRange>
-                                        [0.7.2.201409121644,)
-                                    </versionRange>
-                                    <goals>
-                                        <goal>prepare-agent</goal>
-                                    </goals>
-                                </pluginExecutionFilter>
-                                <action>
-                                    <ignore></ignore>
-                                </action>
-                            </pluginExecution>
-                        </pluginExecutions>
-                    </lifecycleMappingMetadata>
-                </configuration>
-            </plugin>
+      <plugins>
+        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+        <plugin>
+          <groupId>org.eclipse.m2e</groupId>
+          <artifactId>lifecycle-mapping</artifactId>
+          <version>1.0.0</version>
+          <configuration>
+            <lifecycleMappingMetadata>
+              <pluginExecutions>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <versionRange>[0.7.2.201409121644,)</versionRange>
+                    <goals>
+                      <goal>prepare-agent</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore/>
+                  </action>
+                </pluginExecution>
+              </pluginExecutions>
+            </lifecycleMappingMetadata>
+          </configuration>
+        </plugin>
         </plugins>
     </pluginManagement>
   </build>
index 28ff58f..8378e8b 100644 (file)
@@ -5,7 +5,6 @@
  * 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.dsbenchmark;
 
 import java.util.ArrayList;
@@ -18,27 +17,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchm
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerListKey;
 
 public final class BaListBuilder {
+    private BaListBuilder() {
+
+    }
+
     public static List<OuterList> buildOuterList(final int outerElements, final int innerElements) {
         List<OuterList> outerList = new ArrayList<>(outerElements);
         for (int j = 0; j < outerElements; j++) {
             outerList.add(new OuterListBuilder()
-                                .setId( j )
+                                .setId(j)
                                 .setInnerList(buildInnerList(j, innerElements))
-                                .withKey(new OuterListKey( j ))
+                                .withKey(new OuterListKey(j))
                                 .build());
         }
         return outerList;
     }
 
-    private static List<InnerList> buildInnerList( final int index, final int elements ) {
-        List<InnerList> innerList = new ArrayList<>( elements );
+    private static List<InnerList> buildInnerList(final int index, final int elements) {
+        List<InnerList> innerList = new ArrayList<>(elements);
 
         final String itemStr = "Item-" + String.valueOf(index) + "-";
         for (int i = 0; i < elements; i++) {
             innerList.add(new InnerListBuilder()
-                                .withKey( new InnerListKey( i ) )
+                                .withKey(new InnerListKey(i))
                                 .setName(i)
-                                .setValue( itemStr + String.valueOf( i ) )
+                                .setValue(itemStr + String.valueOf(i))
                                 .build());
         }
         return innerList;
index 84bb61f..50eb0d4 100644 (file)
@@ -24,13 +24,11 @@ public abstract class DatastoreAbstractWriter {
     protected final StartTestInput.DataStore dataStore;
     protected final Random rn = new Random();
 
-
     protected int txOk = 0;
     protected int txError = 0;
 
-
     public DatastoreAbstractWriter(final StartTestInput.Operation oper,
-                                   final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
+            final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
         this.outerListElem = outerListElem;
         this.innerListElem = innerListElem;
         this.writesPerTx = writesPerTx;
index cc4fc04..2641fea 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.dsbenchmark;
 
 import java.util.ArrayList;
 import java.util.List;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.outer.list.InnerList;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -28,6 +27,10 @@ public final class DomListBuilder {
     // Outer List Qname identifier for yang model's 'id'
     private static final org.opendaylight.yangtools.yang.common.QName OL_ID = QName.create(OuterList.QNAME, "id");
 
+    private DomListBuilder() {
+
+    }
+
     public static List<MapEntryNode> buildOuterList(final int outerElements, final int innerElements) {
         List<MapEntryNode> outerList = new ArrayList<>(outerElements);
         for (int j = 0; j < outerElements; j++) {
@@ -40,7 +43,7 @@ public final class DomListBuilder {
         return outerList;
     }
 
-    private static MapNode buildInnerList(final int index, final int elements ) {
+    private static MapNode buildInnerList(final int index, final int elements) {
         CollectionNodeBuilder<MapEntryNode, MapNode> innerList = ImmutableNodes.mapNodeBuilder(InnerList.QNAME);
 
         final String itemStr = "Item-" + String.valueOf(index) + "-";
index 91c53cc..0cf0195 100644 (file)
@@ -73,6 +73,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
         this.simpleTxDataBroker = simpleTxDataBroker;
     }
 
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void init() {
         listenerProvider.setDataBroker(simpleTxDataBroker);
 
@@ -100,6 +101,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public ListenableFuture<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
         LOG.info("Starting the data store benchmark test, input: {}", input);
 
@@ -120,14 +122,14 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
         // Create listeners on OPERATIONAL and CONFIG test data subtrees
         listenerProvider.createAndRegisterListeners(input.getListeners().intValue());
 
-        long startTime, endTime, listCreateTime, execTime;
 
-        startTime = System.nanoTime();
+        long startTime = System.nanoTime();
         dsWriter.createList();
-        endTime = System.nanoTime();
-        listCreateTime = (endTime - startTime) / 1000;
+        long endTime = System.nanoTime();
+        final long listCreateTime = (endTime - startTime) / 1000;
 
         // Run the test and measure the execution time
+        long execTime;
         try {
             startTime = System.nanoTime();
             dsWriter.executeList();
index d038525..181ff23 100644 (file)
@@ -31,7 +31,7 @@ public class SimpletxDomWrite extends DatastoreAbstractWriter {
     private List<MapEntryNode> list;
 
     public SimpletxDomWrite(final DOMDataBroker domDataBroker, final StartTestInput.Operation oper,
-                                    final int outerListElem, final int innerListElem, final long putsPerTx, final DataStore dataStore ) {
+            final int outerListElem, final int innerListElem, final long putsPerTx, final DataStore dataStore) {
         super(oper, outerListElem, innerListElem, putsPerTx, dataStore);
         this.domDataBroker = domDataBroker;
         LOG.debug("Created SimpletxDomWrite");
index fb4d028..5455162 100644 (file)
@@ -80,8 +80,8 @@ public class TxchainBaDelete extends DatastoreAbstractWriter implements Transact
                     }
 
                     @Override
-                    public void onFailure(final Throwable t) {
-                        LOG.error("Transaction failed, {}", t);
+                    public void onFailure(final Throwable cause) {
+                        LOG.error("Transaction failed", cause);
                         txError++;
                     }
                 }, MoreExecutors.directExecutor());
index 0a7ec6d..efedbfc 100644 (file)
@@ -36,7 +36,7 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti
     private List<OuterList> list;
 
     public TxchainBaWrite(final DataBroker bindingDataBroker, final Operation oper,
-                          final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
+            final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
         super(oper, outerListElem, innerListElem, writesPerTx, dataStore);
         this.bindingDataBroker = bindingDataBroker;
         LOG.debug("Created TxchainBaWrite");
@@ -77,8 +77,8 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti
                     }
 
                     @Override
-                    public void onFailure(final Throwable t) {
-                        LOG.error("Transaction failed, {}", t);
+                    public void onFailure(final Throwable cause) {
+                        LOG.error("Transaction failed", cause);
                         txError++;
                     }
                 }, MoreExecutors.directExecutor());
@@ -118,4 +118,4 @@ public class TxchainBaWrite extends DatastoreAbstractWriter implements Transacti
         LOG.debug("DatastoreBaAbstractWrite closed successfully, chain {}", chain);
     }
 
-}
\ No newline at end of file
+}
index 81017f4..5135a92 100644 (file)
@@ -83,8 +83,8 @@ public class TxchainDomDelete extends DatastoreAbstractWriter implements Transac
                     }
 
                     @Override
-                    public void onFailure(final Throwable t) {
-                        LOG.error("Transaction failed, {}", t);
+                    public void onFailure(final Throwable cause) {
+                        LOG.error("Transaction failed", cause);
                         txError++;
                     }
                 }, MoreExecutors.directExecutor());
index 2d0bf63..65393fe 100644 (file)
@@ -36,8 +36,8 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
     private final DOMDataBroker domDataBroker;
     private List<MapEntryNode> list;
 
-    public TxchainDomWrite(final DOMDataBroker domDataBroker, final StartTestInput.Operation oper, final int outerListElem,
-            final int innerListElem, final long writesPerTx, final DataStore dataStore) {
+    public TxchainDomWrite(final DOMDataBroker domDataBroker, final StartTestInput.Operation oper,
+            final int outerListElem, final int innerListElem, final long writesPerTx, final DataStore dataStore) {
         super(oper, outerListElem, innerListElem, writesPerTx, dataStore);
         this.domDataBroker = domDataBroker;
         LOG.debug("Created TxchainDomWrite");
@@ -81,8 +81,8 @@ public class TxchainDomWrite extends DatastoreAbstractWriter implements Transact
                     }
 
                     @Override
-                    public void onFailure(final Throwable t) {
-                        LOG.error("Transaction failed, {}", t);
+                    public void onFailure(final Throwable cause) {
+                        LOG.error("Transaction failed", cause);
                         txError++;
                     }
                 }, MoreExecutors.directExecutor());
index ffc0eee..edb1fe6 100644 (file)
@@ -53,4 +53,15 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationseverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>
index 5dc6618..e658580 100644 (file)
@@ -21,7 +21,12 @@ public abstract class AbstractNtfbenchProducer implements Runnable {
     protected final int iterations;
     protected final Ntfbench ntf;
 
+    protected int ntfOk = 0;
+    protected int ntfError = 0;
+
     /**
+     * Return number of successful notifications.
+     *
      * @return the ntfOk
      */
     public int getNtfOk() {
@@ -29,15 +34,14 @@ public abstract class AbstractNtfbenchProducer implements Runnable {
     }
 
     /**
+     * Return number of unsuccessful notifications.
+     *
      * @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;
index b086910..b1bc070 100644 (file)
@@ -18,6 +18,7 @@ public class NtfbenchBlockingProducer extends AbstractNtfbenchProducer {
     }
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void run() {
         int ntfOk = 0;
         int ntfError = 0;
index e92c1f7..485eb15 100644 (file)
@@ -25,6 +25,7 @@ public class NtfbenchNonblockingProducer extends AbstractNtfbenchProducer {
 
 
     @Override
+    @SuppressWarnings("checkstyle:illegalCatch")
     public void run() {
         int ntfOk = 0;
         int ntfError = 0;
index cad1d35..d126b27 100644 (file)
@@ -5,16 +5,13 @@
  * 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.util.concurrent.Futures;
 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;
@@ -38,5 +35,4 @@ public class NtfbenchTestListener implements NtfbenchPayloadListener {
     public Future<?> getAllDone() {
         return Futures.immediateFuture(null);
     }
-
 }
index 1e63c4b..1b16329 100644 (file)
@@ -5,12 +5,10 @@
  * 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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench.payload.rev150709.Ntfbench;
 
 public class NtfbenchWTCListener extends NtfbenchTestListener {
     private final int expectedCount;
@@ -30,6 +28,7 @@ public class NtfbenchWTCListener extends NtfbenchTestListener {
         }
     }
 
+    @Override
     public SettableFuture<?> getAllDone() {
         return allDone;
     }
index cb5925f..c11f676 100644 (file)
@@ -30,11 +30,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService {
-
     private static final Logger LOG = LoggerFactory.getLogger(NtfbenchmarkProvider.class);
+    private static final int TEST_TIMEOUT = 5;
+
     private final NotificationService listenService;
     private final NotificationPublishService publishService;
-    private static final int testTimeout = 5;
 
     public NtfbenchmarkProvider(final NotificationService listenServiceDependency,
             final NotificationPublishService publishServiceDependency) {
@@ -87,12 +87,12 @@ public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService
             }
             executor.shutdown();
             try {
-                executor.awaitTermination(testTimeout, TimeUnit.MINUTES);
+                executor.awaitTermination(TEST_TIMEOUT, TimeUnit.MINUTES);
                 for (ListenerRegistration<NtfbenchTestListener> 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);
+                LOG.error("Out of time: test did not finish within the {} min deadline ", TEST_TIMEOUT);
             }
 
             final long producerEndTime = System.nanoTime();
index 808c2c0..8666132 100644 (file)
@@ -53,4 +53,15 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationseverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
 </project>

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.