First use of the infrautils counters in netvirt. 74/42574/8
authoryair <yair.zinger@hpe.com>
Tue, 26 Jul 2016 14:07:30 +0000 (17:07 +0300)
committeryair <yair.zinger@hpe.com>
Sun, 31 Jul 2016 07:33:20 +0000 (10:33 +0300)
Added install and remove flows counters for Dhcp and SNAT default flows.

Change-Id: I2b4b6692675b4f22af600cb3edea6bf660462af6
Signed-off-by: yair <yair.zinger@hpe.com>
vpnservice/commons/config-parent/pom.xml
vpnservice/dhcpservice/dhcpservice-impl/pom.xml
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpManager.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceCounters.java [new file with mode: 0644]
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceUtils.java
vpnservice/features/pom.xml
vpnservice/features/src/main/features/features.xml
vpnservice/natservice/natservice-impl/pom.xml
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatServiceCounters.java [new file with mode: 0644]
vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/SNATDefaultRouteProgrammer.java

index 7978dc1d0459b20f5982f4b2b6a626b0fdef80c7..70a9084efc63163d9f510c056e0275d98895ebb7 100644 (file)
@@ -35,6 +35,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <karaf.shell.console.version>3.0.3</karaf.shell.console.version>
     <neutron.version>0.7.0-SNAPSHOT</neutron.version>
     <genius.version>0.1.0-SNAPSHOT</genius.version>
+    <infrautils.version>1.0.0-SNAPSHOT</infrautils.version>
   </properties>
 
   <dependencyManagement>
index 19146c3571f7dfbbde322f94fd472cc44d2ba7ea..737ab00250cad9887aa2634c4135d001923eee01 100644 (file)
@@ -79,6 +79,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>hwvtepsouthbound-api</artifactId>
       <version>${vpns.ovsdb.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.infrautils</groupId>
+      <artifactId>counters-api</artifactId>
+      <version>${infrautils.version}</version>
+    </dependency>
    </dependencies>
 
   <!--
index 76d78f6e6b9df0eef1a6a9fe8764fa4a87301878..967db1864091d53d7966bab82571e4a7b00e1e62 100644 (file)
@@ -28,12 +28,12 @@ import org.opendaylight.netvirt.dhcpservice.api.DHCPMConstants;
 import org.opendaylight.netvirt.neutronvpn.interfaces.INeutronVpnManager;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceBindings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceTypeFlowBased;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.StypeOpenflowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.ServicesInfoKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeIngress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServicesKey;
@@ -156,6 +156,7 @@ public class DhcpManager implements AutoCloseable {
         FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, DHCPMConstants.DHCP_TABLE, "DHCPTableMissFlow",
                 0, "DHCP Table Miss Flow", 0, 0,
                 DHCPMConstants.COOKIE_DHCP_BASE, matches, instructions);
+        DhcpServiceCounters.install_dhcp_table_miss_flow.inc();
         mdsalUtil.installFlow(flowEntity);
         setupTableMissForHandlingExternalTunnel(dpId);
     }
@@ -168,6 +169,7 @@ public class DhcpManager implements AutoCloseable {
         FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.DHCP_TABLE_EXTERNAL_TUNNEL, "DHCPTableMissFlowForExternalTunnel",
                 0, "DHCP Table Miss Flow For External Tunnel", 0, 0,
                 DHCPMConstants.COOKIE_DHCP_BASE, matches, instructions);
+        DhcpServiceCounters.install_dhcp_table_miss_flow_for_external_table.inc();
         mdsalUtil.installFlow(flowEntity);
     }
 
diff --git a/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceCounters.java b/vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceCounters.java
new file mode 100644 (file)
index 0000000..fc6eaab
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Hewlett-Packard Enterprise and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netvirt.dhcpservice;
+
+import org.opendaylight.infrautils.counters.api.OccurenceCounter;
+
+public enum DhcpServiceCounters {
+    install_dhcp_drop_flow, //
+    install_dhcp_flow, //
+    install_dhcp_table_miss_flow, //
+    install_dhcp_table_miss_flow_for_external_table, //
+    remove_dhcp_drop_flow, //
+    remove_dhcp_flow;
+
+    private OccurenceCounter counter;
+
+    private DhcpServiceCounters() {
+        counter = new OccurenceCounter(getClass().getEnclosingClass().getSimpleName(), name(), name());
+    }
+
+    public void inc() {
+        counter.inc();
+    }
+}
index ac3c99ab3681e54c2799a661470229decf35bce9..c5350041eaaad1fc7015020a1dd00d5ff93e3865 100644 (file)
@@ -15,7 +15,6 @@ import java.util.List;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.netvirt.dhcpservice.api.DHCPMConstants;
 import org.opendaylight.genius.mdsalutil.ActionInfo;
 import org.opendaylight.genius.mdsalutil.ActionType;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
@@ -27,6 +26,7 @@ import org.opendaylight.genius.mdsalutil.MatchInfo;
 import org.opendaylight.genius.mdsalutil.NwConstants;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.genius.mdsalutil.packet.IPProtocols;
+import org.opendaylight.netvirt.dhcpservice.api.DHCPMConstants;
 import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
@@ -36,6 +36,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVxlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
@@ -43,10 +47,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesListKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -93,12 +93,14 @@ public class DhcpServiceUtils {
                     DHCPMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0,
                     DHCPMConstants.COOKIE_DHCP_BASE, matches, null);
             logger.trace("Removing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
+            DhcpServiceCounters.remove_dhcp_flow.inc();
             mdsalUtil.removeFlow(flowEntity);
         } else {
             FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
                     getDhcpFlowRef(dpId, tableId, vmMacAddress),DHCPMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0,
                     DHCPMConstants.COOKIE_DHCP_BASE, matches, instructions);
             logger.trace("Installing DHCP Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
+            DhcpServiceCounters.install_dhcp_flow.inc();
             mdsalUtil.installFlow(flowEntity);
         }
     }
@@ -128,12 +130,14 @@ public class DhcpServiceUtils {
                     DHCPMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0,
                     DHCPMConstants.COOKIE_DHCP_BASE, matches, null);
             logger.trace("Removing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
+            DhcpServiceCounters.remove_dhcp_drop_flow.inc();
             mdsalUtil.removeFlow(flowEntity);
         } else {
             FlowEntity flowEntity = MDSALUtil.buildFlowEntity(dpId, tableId,
                     getDhcpFlowRef(dpId, tableId, vmMacAddress),DHCPMConstants.DEFAULT_DHCP_FLOW_PRIORITY, "DHCP", 0, 0,
                     DHCPMConstants.COOKIE_DHCP_BASE, matches, instructions);
             logger.trace("Installing DHCP Drop Flow DpId {}, vmMacAddress {}", dpId, vmMacAddress);
+            DhcpServiceCounters.install_dhcp_drop_flow.inc();
             mdsalUtil.installFlow(flowEntity);
         }
     }
index 88667594b60163e309e51e27b748366cf2c903de..acbc29bbcc0be1ca5f71f93736be2c12ae412cc0 100644 (file)
@@ -31,6 +31,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <liblldp.version>0.11.0-SNAPSHOT</liblldp.version>
     <neutron.version>0.7.0-SNAPSHOT</neutron.version>
     <genius.version>0.1.0-SNAPSHOT</genius.version>
+    <infrautils.version>1.0.0-SNAPSHOT</infrautils.version>
     <arputil.version>${genius.version}</arputil.version>
     <mdsalutil.version>${genius.version}</mdsalutil.version>
     <vpnmanager.version>${vpnservices.version}</vpnmanager.version>
@@ -366,6 +367,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <artifactId>statemanager-impl</artifactId>
       <version>${vpnservices.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.infrautils</groupId>
+      <artifactId>infrautils-features</artifactId>
+      <version>${infrautils.version}</version>
+      <classifier>features</classifier>
+      <type>xml</type>
+    </dependency>
   </dependencies>
 
   <!--
index 54fe31a233d9a046d46fc5f03b59b371b065a91b..0a08fe063664d67be210f93a52bf0d190eda71bd 100644 (file)
@@ -20,6 +20,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <repository>mvn:org.opendaylight.neutron/features-neutron/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.ovsdb/hwvtepsouthbound-features/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.genius/genius-features/{{VERSION}}/xml/features</repository>
+  <repository>mvn:org.opendaylight.infrautils/infrautils-features/{{VERSION}}/xml/features</repository>
 
   <feature name='odl-netvirt-api' version='${project.version}' description='OpenDaylight :: NetVirt :: api'>
     <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
@@ -29,6 +30,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version="${ovsdb.version}">odl-ovsdb-southbound-api</feature>
     <feature version='${ovsdb.version}'>odl-ovsdb-hwvtepsouthbound-api</feature>
     <feature version='${genius.version}'>odl-genius-api</feature>
+    <feature version='${infrautils.version}'>odl-infrautils-counters</feature>
     <bundle>mvn:org.opendaylight.controller/liblldp/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.neutron/model/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netvirt/model-bgp/{{VERSION}}</bundle>
index 928cc8aed24585557a58bcfa39f70f6013dfa7bf..b44b29f4cdb59d5339a402f9a51befd120bdef23 100644 (file)
@@ -102,6 +102,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <version>${powermock.version}</version>
         <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.infrautils</groupId>
+      <artifactId>counters-api</artifactId>
+      <version>${infrautils.version}</version>
+    </dependency>
     </dependencies>
 
     <!--
diff --git a/vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatServiceCounters.java b/vpnservice/natservice/natservice-impl/src/main/java/org/opendaylight/netvirt/natservice/internal/NatServiceCounters.java
new file mode 100644 (file)
index 0000000..16fb346
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Hewlett-Packard Enterprise and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netvirt.natservice.internal;
+
+import org.opendaylight.infrautils.counters.api.OccurenceCounter;
+
+public enum NatServiceCounters {
+    install_default_nat_flow, //
+    remove_default_nat_flow;
+
+    private OccurenceCounter counter;
+
+    private NatServiceCounters() {
+        counter = new OccurenceCounter(getClass().getEnclosingClass().getSimpleName(), name(), name());
+    }
+
+    public void inc() {
+        counter.inc();
+    }
+}
index b7db14fb84530567a89f266535d48048f5f16978..8b9b2b3dcc0942b4e90e95864aa1cc271655497e 100644 (file)
@@ -120,6 +120,7 @@ public class SNATDefaultRouteProgrammer {
             LOG.error("Flow entity received is NULL. Cannot proceed with installation of Default NAT flow");
             return;
         }
+        NatServiceCounters.install_default_nat_flow.inc();
         mdsalManager.installFlow(flowEntity);
     }
 
@@ -129,6 +130,7 @@ public class SNATDefaultRouteProgrammer {
             LOG.error("Flow entity received is NULL. Cannot proceed with installation of Default NAT flow");
             return;
         }
+        NatServiceCounters.install_default_nat_flow.inc();
         mdsalManager.installFlow(flowEntity);
     }
 
@@ -138,6 +140,7 @@ public class SNATDefaultRouteProgrammer {
             LOG.error("Flow entity received is NULL. Cannot proceed with installation of Default NAT flow");
             return;
         }
+        NatServiceCounters.remove_default_nat_flow.inc();
         mdsalManager.removeFlow(flowEntity);
     }
 
@@ -147,7 +150,7 @@ public class SNATDefaultRouteProgrammer {
             LOG.error("Flow entity received is NULL. Cannot proceed with installation of Default NAT flow");
             return;
         }
+        NatServiceCounters.remove_default_nat_flow.inc();
         mdsalManager.removeFlow(flowEntity);
     }
-
 }