Post "Clustering optimization" updates
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / statistics / SinglePurposeMultipartReplyTranslator.java
index 327f559560c5d36ab76135ddd5f89bfa3ba255f4..ad111387be91dcc2e326b044ec456ff8557af0bd 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.openflowplugin.impl.statistics;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.FlowStatsResponseConvertor;
@@ -112,16 +111,16 @@ public class SinglePurposeMultipartReplyTranslator {
     private static MeterStatsResponseConvertor meterStatsConvertor = new MeterStatsResponseConvertor();
 
 
-    public List<DataObject> translate(DeviceContext deviceContext, OfHeader msg) {
+    public List<DataObject> translate(final DeviceContext deviceContext, final OfHeader msg) {
 
-        List<DataObject> listDataObject = new CopyOnWriteArrayList<DataObject>();
+        List<DataObject> listDataObject = new ArrayList<>();
 
         OpenflowVersion ofVersion = OpenflowVersion.get(deviceContext.getPrimaryConnectionContext().getFeatures().getVersion());
 
         final FeaturesReply features = deviceContext.getPrimaryConnectionContext().getFeatures();
         if (msg instanceof MultipartReplyMessage) {
             MultipartReplyMessage mpReply = (MultipartReplyMessage) msg;
-            NodeId node = this.nodeIdFromDatapathId(features.getDatapathId());
+            NodeId node = SinglePurposeMultipartReplyTranslator.nodeIdFromDatapathId(features.getDatapathId());
             switch (mpReply.getType()) {
                 case OFPMPFLOW: {
                     FlowsStatisticsUpdateBuilder message = new FlowsStatisticsUpdateBuilder();
@@ -182,10 +181,12 @@ public class SinglePurposeMultipartReplyTranslator {
                         statsBuilder.setPackets(packetsBuilder.build());
 
                         DurationBuilder durationBuilder = new DurationBuilder();
-                        if (portStats.getDurationSec() != null)
+                        if (portStats.getDurationSec() != null) {
                             durationBuilder.setSecond(new Counter32(portStats.getDurationSec()));
-                        if (portStats.getDurationNsec() != null)
+                        }
+                        if (portStats.getDurationNsec() != null) {
                             durationBuilder.setNanosecond(new Counter32(portStats.getDurationNsec()));
+                        }
                         statsBuilder.setDuration(durationBuilder.build());
                         statsBuilder.setCollisionCount(portStats.getCollisions());
                         statsBuilder.setKey(new NodeConnectorStatisticsAndPortNumberMapKey(statsBuilder.getNodeConnectorId()));
@@ -426,27 +427,23 @@ public class SinglePurposeMultipartReplyTranslator {
         return listDataObject;
     }
 
-    private NodeId nodeIdFromDatapathId(BigInteger datapathId) {
+    private static NodeId nodeIdFromDatapathId(final BigInteger datapathId) {
         String current = datapathId.toString();
         return new NodeId("openflow:" + current);
     }
 
-    private TransactionId generateTransactionId(Long xid) {
+    private static TransactionId generateTransactionId(final Long xid) {
         BigInteger bigIntXid = BigInteger.valueOf(xid);
         return new TransactionId(bigIntXid);
-
     }
 
     /*
      * Method returns the bitmap of actions supported by each group.
-     * TODO: My recommendation would be, its good to have a respective model of
-     * 'type bits', which will generate a class where all these flags will eventually
-     * be stored as boolean. It will be convenient for application to check the
-     * supported action, rather then doing bitmap operation.
+     *
      * @param actionsSupported
      * @return
      */
-    private List<Long> getGroupActionsSupportBitmap(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType> actionsSupported) {
+    static List<Long> getGroupActionsSupportBitmap(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType> actionsSupported) {
         List<Long> supportActionByGroups = new ArrayList<Long>();
         for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
             long supportActionBitmap = 0;