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 bd10dabbefe4a48a47d7494b04f3ada3eb1767eb..6d1c7bc0cce8ae7700c372bd2dc600fe8a8bb259 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 28ff58f61874c1810dc8fd6225890a2dd78d7f8d..8378e8b3c8b8c8e7bbc1c20938149c440c0626c0 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 84bb61f9adcce6a2f1bd7378d185975d507ef272..50eb0d4e8bbafab7c1723a6ba5a6234a862ef395 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 cc4fc045cea38c83cc137b26041938b58847a12c..2641fead359e8873646e7184b98c50342298fc72 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 91c53ccf919eb2d15dcf81d56e4b63ef558021e2..0cf0195ca41acccd8f4fc79bbcc9d36a48b4edc3 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 d0385252effd353a546029edcbf038aa7e59f0ee..181ff23f0b0804e8f71764134ea2e10fa90007aa 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 fb4d02887114252be3e30b345e7c97b20ff63040..5455162e2f3cdf9bfb98f9a4feece0464a3716a7 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 0a7ec6d22040246af278acc87dbf617e85da675b..efedbfc1dbe1fd4e93868344d79137b74e764bf7 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 81017f42bd6754b563ec03dde60df5f0b1e31c7f..5135a9260236cec6c8e1c1f8f7541b3e77594d73 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 2d0bf63f56e3294488a421b2f7b3eac3669694a3..65393febd05cc5534302ade77aff04cbc10730cc 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 ffc0eeeadeecefc6352b9d5a1e1a70555b42fd17..edb1fe6fd58f7ecd566906d6cd5122ba8f5e94db 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 5dc6618e9c131933a25351a0a794dc6c2e3938a8..e658580c5ff2517171c89b840bd8ba73075b852f 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 b086910f1ccc84764dc4c5c9387fd009b4317d88..b1bc0701965235a7cb3a92184a954ed224239a2a 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 e92c1f7891eb80a729c1199d814e2e0db055d387..485eb158074c53702ea876416b8b224b75698f06 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 cad1d359ea83079a54e4a46845dae1c29075c2a4..d126b2774ae35bdb240a7ce850f3ff51f707b3c6 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 1e63c4b75d4d49a06df88e3d9a6d04d4a64d0a2b..1b16329d524b7210bec5a948599c0d8f95b1389b 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 cb5925f68a4ac9e2c6bcf130aa59d334487d5890..c11f676dafd1cf9412236ea836340d53d9df601a 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 808c2c0970205ea3902afcff60ef1019369bc935..86661321a14e8408b2deb1a5568de79595934c7b 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>