NETVIRT-1141: Remote ACL count missing in acl stats data 04/68804/7
authorNishchya Gupta <nishchyag@altencalsoftlabs.com>
Tue, 27 Feb 2018 09:02:24 +0000 (14:32 +0530)
committerNishchya Gupta <nishchyag@altencalsoftlabs.com>
Tue, 13 Mar 2018 10:47:26 +0000 (16:17 +0530)
While displaying the stats for acl it is not considering remote acl
drop in the count.
Providing implementation to consider that also.

Jira Id:https://jira.opendaylight.org/browse/NETVIRT-1141

Change-Id: I72fa8ad261ada769a65ae7e992e670523ed99b83
Signed-off-by: Nishchya Gupta <nishchyag@altencalsoftlabs.com>
aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/stats/AclLiveStatisticsHelper.java

index bfb59539b9c6f08811bb3983d501539d8277e7cc..df09d25b89e0cd005ac64c8f6a8f6beefac33f40 100644 (file)
@@ -173,14 +173,36 @@ public final class AclLiveStatisticsHelper {
         PacketsBuilder portIngressPacketsBuilder = new PacketsBuilder();
 
         for (FlowAndStatisticsMapList flowStats : flowAndStatisticsMapList) {
+            BigInteger portEgressBytesBuilderDropCount = BigInteger.valueOf(0);
+            BigInteger portEgressPacketsBuilderDropCount = BigInteger.valueOf(0);
+            BigInteger portIngressBytesBuilderDropCount = BigInteger.valueOf(0);
+            BigInteger portIngressPacketsBuilderDropCount = BigInteger.valueOf(0);
+
             switch (flowStats.getTableId()) {
                 case NwConstants.INGRESS_ACL_FILTER_CUM_DISPATCHER_TABLE:
                     if (flowStats.getPriority().equals(AclConstants.CT_STATE_TRACKED_INVALID_PRIORITY)) {
                         portEgressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                         portEgressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                     } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
-                        portEgressBytesBuilder.setDropCount(flowStats.getByteCount().getValue());
-                        portEgressPacketsBuilder.setDropCount(flowStats.getPacketCount().getValue());
+                        if (portEgressBytesBuilder.getDropCount() != null) {
+                            portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount()
+                                    .add(flowStats.getByteCount().getValue());
+                            portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount()
+                                    .add(flowStats.getPacketCount().getValue());
+                        } else {
+                            portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
+                            portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
+                        }
+                    } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
+                        if (portEgressBytesBuilder.getDropCount() != null) {
+                            portEgressBytesBuilderDropCount = portEgressBytesBuilder.getDropCount()
+                                    .add(flowStats.getByteCount().getValue());
+                            portEgressPacketsBuilderDropCount = portEgressPacketsBuilder.getDropCount()
+                                    .add(flowStats.getPacketCount().getValue());
+                        } else {
+                            portEgressBytesBuilderDropCount = flowStats.getByteCount().getValue();
+                            portEgressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
+                        }
                     }
                     // TODO: Update stats for other drops
                     break;
@@ -190,8 +212,25 @@ public final class AclLiveStatisticsHelper {
                         portIngressBytesBuilder.setInvalidDropCount(flowStats.getByteCount().getValue());
                         portIngressPacketsBuilder.setInvalidDropCount(flowStats.getPacketCount().getValue());
                     } else if (flowStats.getPriority().equals(AclConstants.ACL_PORT_SPECIFIC_DROP_PRIORITY)) {
-                        portIngressBytesBuilder.setDropCount(flowStats.getByteCount().getValue());
-                        portIngressPacketsBuilder.setDropCount(flowStats.getPacketCount().getValue());
+                        if (portIngressBytesBuilder.getDropCount() != null) {
+                            portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount()
+                                    .add(flowStats.getByteCount().getValue());
+                            portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount()
+                                    .add(flowStats.getPacketCount().getValue());
+                        } else {
+                            portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
+                            portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
+                        }
+                    } else if (flowStats.getPriority().equals(AclConstants.ACE_LAST_REMOTE_ACL_PRIORITY)) {
+                        if (portIngressBytesBuilder.getDropCount() != null) {
+                            portIngressBytesBuilderDropCount = portIngressBytesBuilder.getDropCount()
+                                    .add(flowStats.getByteCount().getValue());
+                            portIngressPacketsBuilderDropCount = portIngressPacketsBuilder.getDropCount()
+                                    .add(flowStats.getPacketCount().getValue());
+                        } else {
+                            portIngressBytesBuilderDropCount = flowStats.getByteCount().getValue();
+                            portIngressPacketsBuilderDropCount = flowStats.getPacketCount().getValue();
+                        }
                     }
                     // TODO: Update stats for other drops
                     break;
@@ -200,6 +239,10 @@ public final class AclLiveStatisticsHelper {
                     LOG.warn("Invalid table ID filtered for Acl flow stats: {}", flowStats);
                     break;
             }
+            portEgressBytesBuilder.setDropCount(portEgressBytesBuilderDropCount);
+            portEgressPacketsBuilder.setDropCount(portEgressPacketsBuilderDropCount);
+            portIngressBytesBuilder.setDropCount(portIngressBytesBuilderDropCount);
+            portIngressPacketsBuilder.setDropCount(portIngressPacketsBuilderDropCount);
         }
 
         List<AclDropStats> lstAclDropStats = new ArrayList<>();