SONAR TD - Remove unused fields, fix naming 92/43992/1
authorTomas Slusny <tomas.slusny@pantheon.sk>
Tue, 2 Aug 2016 11:11:11 +0000 (13:11 +0200)
committerShuva Jyoti Kar <shuva.jyoti.kar@ericsson.com>
Mon, 15 Aug 2016 14:42:18 +0000 (14:42 +0000)
- Added private constructor to EventsTimeCounter
- Removed unused fields
- Fixed naming of constants

Change-Id: I4321e2b75af71abb3473eef5e5cc6b92e36c76c4
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.sk>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/EventsTimeCounter.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/ofpspecific/SessionStatistics.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/AllFlowsInTableService.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/statistics/services/OpendaylightFlowStatisticsServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/translator/PacketReceivedTranslator.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/BarrierUtil.java

index 9deaddbddb1134515b287b12adb7b455a71bb8f7..357c0ab69475bd2cbcd5673c8a1761048e263f28 100644 (file)
@@ -20,7 +20,11 @@ import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.Event
  */
 public final class EventsTimeCounter {
 
-    private static Map<String, Map<String, EventTimeCounter>> devicesEvents = new HashMap<>();
+    private static final Map<String, Map<String, EventTimeCounter>> DEVICES_EVENTS = new HashMap<>();
+
+    private EventsTimeCounter() {
+        // Hiding implicit constructor
+    }
 
     public static void markStart(final EventIdentifier eventIdentifier) {
         Map<String, EventTimeCounter> deviceEvents = getOrCreateCountersForDevice(eventIdentifier.getDeviceId());
@@ -44,10 +48,10 @@ public final class EventsTimeCounter {
     }
 
     private static Map<String, EventTimeCounter> getOrCreateCountersForDevice(final String deviceId) {
-        Map<String, EventTimeCounter> lookup = devicesEvents.get(deviceId);
+        Map<String, EventTimeCounter> lookup = DEVICES_EVENTS.get(deviceId);
         if (null == lookup) {
-            lookup = new HashMap<String, EventTimeCounter>();
-            devicesEvents.put(deviceId, lookup);
+            lookup = new HashMap<>();
+            DEVICES_EVENTS.put(deviceId, lookup);
         }
 
         return lookup;
@@ -55,7 +59,7 @@ public final class EventsTimeCounter {
 
     public static List<String> provideTimes() {
         List<String> dump = new ArrayList<>();
-        for (Map.Entry<String, Map<String, EventTimeCounter>> deviceEntry : devicesEvents.entrySet()) {
+        for (Map.Entry<String, Map<String, EventTimeCounter>> deviceEntry : DEVICES_EVENTS.entrySet()) {
             Map<String, EventTimeCounter> eventsMap = deviceEntry.getValue();
             dump.add("================================================");
             dump.add(String.format("DEVICE : %s", deviceEntry.getKey()));
@@ -76,7 +80,7 @@ public final class EventsTimeCounter {
     }
 
     public static void resetAllCounters() {
-        devicesEvents = new HashMap<>();
+        DEVICES_EVENTS.clear();
     }
 
 
index b243ec480263b2410749a399ff2f4449c5d085ce..7ae6d0c957a87f0d443094d487eb440d5d5fa9bd 100644 (file)
@@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicLongFieldUpdater;
  */
 public class SessionStatistics {
 
-    private static final Map<String, Map<ConnectionStatus, EventCounter>> sessionEvents = new HashMap<>();
+    private static final Map<String, Map<ConnectionStatus, EventCounter>> SESSION_EVENTS = new HashMap<>();
 
     public static void countEvent(final String sessionId, final ConnectionStatus connectionStatus) {
         Map<ConnectionStatus, EventCounter> sessionsConnectionEvents = getConnectionEvents(sessionId);
@@ -38,10 +38,10 @@ public class SessionStatistics {
     }
 
     private static Map<ConnectionStatus, EventCounter> getConnectionEvents(final String sessionId) {
-        Map<ConnectionStatus, EventCounter> sessionConnectionEvents = sessionEvents.get(sessionId);
+        Map<ConnectionStatus, EventCounter> sessionConnectionEvents = SESSION_EVENTS.get(sessionId);
         if (null == sessionConnectionEvents) {
             sessionConnectionEvents = new HashMap<>();
-            sessionEvents.put(sessionId, sessionConnectionEvents);
+            SESSION_EVENTS.put(sessionId, sessionConnectionEvents);
         }
         return sessionConnectionEvents;
     }
@@ -49,7 +49,7 @@ public class SessionStatistics {
 
     public static List<String> provideStatistics() {
         List<String> dump = new ArrayList<>();
-        for (Map.Entry<String, Map<ConnectionStatus, EventCounter>> sessionEntries : sessionEvents.entrySet()) {
+        for (Map.Entry<String, Map<ConnectionStatus, EventCounter>> sessionEntries : SESSION_EVENTS.entrySet()) {
             Map<ConnectionStatus, EventCounter> sessionEvents = sessionEntries.getValue();
             dump.add(String.format("SESSION : %s", sessionEntries.getKey()));
             for (Map.Entry<ConnectionStatus, EventCounter> sessionEvent : sessionEvents.entrySet()) {
@@ -65,7 +65,7 @@ public class SessionStatistics {
     }
 
     private static final class EventCounter {
-        private final AtomicLongFieldUpdater<EventCounter> UPDATER = AtomicLongFieldUpdater.newUpdater(EventCounter.class, "count");
+        private final AtomicLongFieldUpdater<EventCounter> updater = AtomicLongFieldUpdater.newUpdater(EventCounter.class, "count");
         private volatile long count;
 
         public long getCount() {
@@ -73,12 +73,12 @@ public class SessionStatistics {
         }
 
         public void increment() {
-            count = UPDATER.incrementAndGet(this);
+            count = updater.incrementAndGet(this);
         }
     }
 
     public static void resetAllCounters() {
-        sessionEvents.clear();
+        SESSION_EVENTS.clear();
     }
 
 }
index d7a4af5da35782cbb5dfb4c6c5dcf9b38b5cc39a..2f1783bee64bade314d1c573500f9a3cf2f6680f 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.openflowplugin.impl.statistics.services;
 
-import com.google.common.base.Function;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 import org.opendaylight.openflowplugin.api.OFConstants;
@@ -30,13 +29,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 
 public class AllFlowsInTableService extends AbstractCompatibleStatService<GetAllFlowStatisticsFromFlowTableInput,
         GetAllFlowStatisticsFromFlowTableOutput, FlowsStatisticsUpdate> {
 
     private final ConvertorExecutor convertorExecutor;
-    private Function<? super RpcResult<List<MultipartReply>>, FlowsStatisticsUpdate> transformer;
 
     public AllFlowsInTableService(final RequestContextStack requestContextStack, final DeviceContext deviceContext, AtomicLong compatibilityXidSeed, ConvertorExecutor convertorExecutor) {
         super(requestContextStack, deviceContext, compatibilityXidSeed);
index 3ab8c8b21af044805919b78706c1ffe4a54fbefe..4d9a2b3ce16a452923cb6c7e0eca7d29b77265bc 100644 (file)
@@ -37,16 +37,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * @author joe
  */
 public class OpendaylightFlowStatisticsServiceImpl implements OpendaylightFlowStatisticsService, Delegator<OpendaylightFlowStatisticsService> {
 
-    private static final Logger LOG = LoggerFactory.getLogger(OpendaylightFlowStatisticsServiceImpl.class);
-
     private final Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> matchingConvertor =
             new Function<RpcResult<List<MultipartReply>>, RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>>() {
                 @Override
index f37474da379e7a25ec342c6dd0f0f6dcc87d4c6a..a3423ac69a8ef3ec26e452cfa98dee142d287cc6 100644 (file)
@@ -46,8 +46,6 @@ public class PacketReceivedTranslator implements MessageTranslator<PacketInMessa
         BigInteger datapathId = deviceInfo.getDatapathId();
 
         // TODO: connection cookie from connection distinguisher
-        // packetReceivedBuilder.setConnectionCookie(new ConnectionCookie(input.getCookie().longValue()));
-
         packetReceivedBuilder.setPayload(input.getData());
 
         // get the Cookie if it exists
index 209ff92c1bb7061b5b6ac401f14524ea4f2ed362..18460aa6df5de3191053bc7ccbe9e432cee78750 100644 (file)
@@ -21,16 +21,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
 import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * provides barrier message chaining and factory methods
  */
 public final class BarrierUtil {
 
-    private static final Logger LOG = LoggerFactory.getLogger(BarrierUtil.class);
-
 
     private BarrierUtil() {
         throw new IllegalStateException("This class should not be instantiated.");