fix logging issues in statistics 73/69273/2
authorFaseela K <faseela.k@ericsson.com>
Thu, 8 Mar 2018 14:29:57 +0000 (19:59 +0530)
committerStephen Kitt <skitt@redhat.com>
Thu, 8 Mar 2018 15:23:35 +0000 (15:23 +0000)
Change-Id: Id5c2f0d980f3fa50d2da791d60e7c6e9c915258c
Signed-off-by: Faseela K <faseela.k@ericsson.com>
statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/CounterRetriever.java
statistics/impl/src/main/java/org/opendaylight/netvirt/statistics/StatisticsImpl.java

index fd74fdc23e82c90491081db2d2207dd21b7fe9aa..8cc3b65f043e426e96d556b801bcff327f8083a4 100644 (file)
@@ -45,7 +45,9 @@ import org.slf4j.LoggerFactory;
 
 @Singleton
 public class CounterRetriever {
-    protected static final Logger LOG = LoggerFactory.getLogger(CounterRetriever.class);
+
+    private static final Logger LOG = LoggerFactory.getLogger(CounterRetriever.class);
+
     private final OpendaylightDirectStatisticsService odlDirectStatsService;
     private final long nodeResultTimeout;
     private final Counters counters = new Counters();
index e26c3ef428884686a69dc15b6c6856dd9065f43b..6a8798101633148d1423fc02d94a30410a32c82b 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -25,6 +26,7 @@ import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import javax.annotation.Nonnull;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
@@ -134,7 +136,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
                         .buildFuture();
             }
         } catch (RuntimeException e) {
-            LOG.warn("failed to get counter result for node " + dpId, e);
+            LOG.warn("failed to get counter result for node {}", dpId, e);
             return RpcResultBuilder.<GetNodeCountersOutput>failed()
                     .withError(ErrorType.APPLICATION, "failed to get node counters for node: " + dpId).buildFuture();
         }
@@ -160,7 +162,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
                         .buildFuture();
             }
         } catch (Exception e) {
-            LOG.warn("failed to get counter result for node " + dpId, e);
+            LOG.warn("failed to get counter result for node {}", dpId, e);
             return RpcResultBuilder.<GetNodeAggregatedCountersOutput>failed()
                     .withError(ErrorType.APPLICATION, "failed to get node aggregated counters for node " + dpId)
                     .buildFuture();
@@ -200,7 +202,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
                         .withError(ErrorType.APPLICATION, "failed to get port counters").buildFuture();
             }
         } catch (RuntimeException e) {
-            LOG.warn("failed to get counter result for port " + portId, e);
+            LOG.warn("failed to get counter result for port {}", portId, e);
         }
 
         GetNodeConnectorCountersOutputBuilder gpcob = new GetNodeConnectorCountersOutputBuilder();
@@ -785,6 +787,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
         }
     }
 
+    @SuppressFBWarnings("SLF4J_FORMAT_SHOULD_BE_CONST")
     private void logElementCounterRequests(List<ElementCountersRequest> ecrList) {
         for (ElementCountersRequest counterRequest : ecrList) {
             LOG.debug(counterRequest.toString());
@@ -972,7 +975,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
             Future<RpcResult<Void>> result = idManagerService.releaseId(idInput);
             RpcResult<Void> rpcResult = result.get();
             if (!rpcResult.isSuccessful()) {
-                LOG.warn("RPC Call to release Id {} with Key {} returned with Errors {}", idKey, rpcResult.getErrors());
+                LOG.warn("RPC Call to release Id with Key {} returned with Errors {}", idKey, rpcResult.getErrors());
             }
         } catch (InterruptedException | ExecutionException e) {
             LOG.warn("Exception when releasing Id for key {}", idKey, e);
@@ -1065,7 +1068,7 @@ public class StatisticsImpl implements StatisticsService, ICountersInterfaceChan
         ingress_counters_service_unbind, //
         egress_counters_service_unbind, //
         ;
-        private OccurenceCounter counter;
+        private final OccurenceCounter counter;
 
         StatisticsPluginImplCounters() {
             counter = new OccurenceCounter(getClass().getEnclosingClass().getSimpleName(), name(), "");