Disable DHCP relay counters

The use of strong consistent counter creates a huge performance overhead.
The semaphore also prevent parallel processing of DHCP packets.
Moving forward, we should replace this with local counter, CRDT, or other less expensive counters.

Change-Id: I4023ae2b6867a3f3ab3675717ce6e9c396580b19
diff --git a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
index a5a9eb5..1aa7931 100644
--- a/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
+++ b/apps/dhcprelay/app/src/main/java/org/onosproject/dhcprelay/Dhcp6HandlerImpl.java
@@ -65,7 +65,6 @@
 import org.onosproject.dhcprelay.store.DhcpRelayStore;
 import org.onosproject.dhcprelay.store.DhcpRecord;
 import org.onosproject.dhcprelay.store.DhcpFpmPrefixStore;
-import org.onosproject.dhcprelay.store.DhcpRelayCounters;
 import org.onosproject.dhcprelay.store.DhcpRelayCountersStore;
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
@@ -722,12 +721,12 @@
                 leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress());
             } else {
                 log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created.");
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
                 return;
             }
         } else {
             log.warn("CLIENTID option NOT found. Don't create DhcpRelay Record.");
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
             return;
         }
 
@@ -762,7 +761,7 @@
             IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId);
             if (nextHopIp == null) {
                 log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId);
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
                 return;
             }
 
@@ -832,6 +831,7 @@
             record.updateLastSeen();
         }
         dhcpRelayStore.updateDhcpRecord(leafHostId, record);
+        /*
         // TODO Use AtomicInteger for the counters
         try {
             recordSemaphore.acquire();
@@ -844,6 +844,7 @@
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
         }
+        */
     }
 
     /**
@@ -872,12 +873,12 @@
                 leafClientMac = MacAddress.valueOf(clientIdOption.getDuid().getLinkLayerAddress());
             } else {
                 log.warn("Link-Layer Address not supported in CLIENTID option. No DhcpRelay Record created.");
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_FAIL);
                 return;
             }
         } else {
             log.warn("CLIENTID option NOT found. No DhcpRelay Record created.");
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENTID_FAIL);
             return;
         }
         HostId leafHostId = HostId.hostId(leafClientMac, vlanId);
@@ -925,7 +926,7 @@
             IpAddress nextHopIp = getFirstIpByHost(directConnFlag, srcMac, vlanId);
             if (nextHopIp == null) {
                 log.warn("Can't find link-local IP address of gateway mac {} vlanId {}", srcMac, vlanId);
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_LINKLOCAL_GW);
                 return;
             }
 
@@ -991,6 +992,7 @@
         record.setDirectlyConnected(directConnFlag);
         record.updateLastSeen();
         dhcpRelayStore.updateDhcpRecord(leafHostId, record);
+        /*
         // TODO Use AtomicInteger for the counters
         try {
             recordSemaphore.acquire();
@@ -1003,6 +1005,7 @@
         } catch (InterruptedException e) {
             Thread.currentThread().interrupt();
         }
+        */
     }
 
     private List<InternalPacket> processDhcp6ForwardOnly(PacketContext context,
@@ -1135,7 +1138,7 @@
             log.warn("Missing DHCP relay agent interface Ipv6 addr config for "
                       + "packet from client on port: {}. Aborting packet processing",
                       clientInterfaces.iterator().next().connectPoint());
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
             return Lists.newArrayList();
         }
 
@@ -1216,12 +1219,12 @@
         if (foundServerInfo == null) {
             log.warn("Cannot find server info for {} server, inPort {}",
                       directConnFlag ? "direct" : "indirect", inPort);
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_INFO);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_INFO);
             return null;
         } else {
             if (Dhcp6HandlerUtil.isServerIpEmpty(foundServerInfo)) {
                 log.warn("Cannot find server info's ipaddress");
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_IP6ADDR);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_SERVER_IP6ADDR);
                 return null;
             }
         }
@@ -1233,7 +1236,7 @@
                 .orElse(null);
         if (interfaceIdOption == null) {
             log.warn("Interface Id option is not present, abort packet...");
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.OPTION_MISSING_FAIL);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.OPTION_MISSING_FAIL);
             return null;
         }
 
@@ -1246,7 +1249,7 @@
                 .findFirst().orElse(null);
         if (clientInterface == null) {
             log.warn("Cannot get client interface for from packet, abort... vlan {}", vlanIdInUse.toString());
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_MATCHING_INTF);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_MATCHING_INTF);
             return null;
         }
         etherReply.setVlanID(vlanIdInUse.toShort());
@@ -1254,7 +1257,7 @@
         MacAddress relayAgentMac = clientInterface.mac();
         if (relayAgentMac == null) {
             log.warn("Can not get client interface mac, abort packet..");
-            dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
+            //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
             return null;
         }
         etherReply.setSourceMACAddress(relayAgentMac);
@@ -1272,7 +1275,7 @@
             clientMac = clients.iterator().next().mac();
             if (clientMac == null) {
                 log.warn("No client mac address found, abort packet...");
-                dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
+                //dhcpRelayCountersStore.incrementCounter(gCount, DhcpRelayCounters.NO_CLIENT_INTF_MAC);
                 return null;
             }
             log.trace("Client mac address found from getHostByIp");