- Add flow and port stats polling intervals in config.ini 78/278/1
authorJason Ye <yisye@cisco.com>
Wed, 1 May 2013 22:43:12 +0000 (15:43 -0700)
committerJason Ye <yisye@cisco.com>
Wed, 1 May 2013 22:43:12 +0000 (15:43 -0700)
- Add DESC stats polling interval in CONFIG.ini and thru OSGI cmd
- When the switch port is changed to admin down or the link is changed to down state, the switch sends port_status msg with OFPPR_MODIFY type. The existing logic is to map OFPPR_MODIFY to UpdateType.CHANGED. But we should exam the Config state and Link state fields within the port_status packet. If they are "down", we should fire an UpdateType.REMOVED event instead and remove both edges associated with the port.

Signed-off-by: Jason Ye <yisye@cisco.com>
15 files changed:
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryShimExternalListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/IInventoryShimInternalListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/ITopologyServiceShimListener.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/Activator.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/TopologyServiceShim.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/discovery/IDiscoveryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IListenInventoryUpdates.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginInInventoryService.java
opendaylight/sal/api/src/main/java/org/opendaylight/controller/sal/inventory/IPluginOutInventoryService.java
opendaylight/switchmanager/api/src/main/java/org/opendaylight/controller/switchmanager/ISwitchManagerAware.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/ITopologyManager.java
opendaylight/topologymanager/src/main/java/org/opendaylight/controller/topologymanager/TopologyUserLinkConfig.java

index 6a7d68c..33789ee 100644 (file)
@@ -50,6 +50,12 @@ org.eclipse.gemini.web.tomcat.config.path=configuration/tomcat-server.xml
 # of.messageResponseTimer=2000
 # The switch liveness timeout value (default 60500 msec)
 # of.switchLivenessTimeout=60500
+# The flow statistics polling interval in second (default 10 sec)
+# of.flowStatsPollInterval=10
+# The port statistics polling interval in second (default 5 sec)
+# of.portStatsPollInterval=5
+# The description statistics polling interval in second (default 60 sec)
+# of.descStatsPollInterval=60
 # The maximum number of asynchronous messages can be sent before sending a Barrier Request (default 100)
 # of.barrierMessagePriorCount=100
 # The interval which determines how often the discovery packets should be sent (default 300 sec)
index 24e63df..df03a04 100644 (file)
 package org.opendaylight.controller.protocol_plugin.openflow;
 
 /**
- * Wrapper of Interface class that provides inventory updates locally in the
- * protocol plugin
- *
- *
+ * Wrapper of Interface that provides inventory updates locally in the protocol
+ * plugin.
  */
 public interface IInventoryShimExternalListener extends
         IInventoryShimInternalListener {
index e7c11a6..6b32896 100644 (file)
@@ -17,10 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * Interface class that provides inventory updates to inventory listeners
- * within the protocol plugin
- *
- *
+ * The Interface provides inventory updates to inventory listeners within the
+ * protocol plugin
  */
 public interface IInventoryShimInternalListener {
     /**
index 23b40a3..0c30c80 100644 (file)
@@ -16,9 +16,7 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * Interface class that provides Edge updates to the topology listeners
- *
- *
+ * The Interface provides Edge updates to the topology listeners
  */
 public interface ITopologyServiceShimListener {
     /**
index 9bccbd1..9b7d1e3 100644 (file)
@@ -358,8 +358,9 @@ public class Activator extends ComponentActivatorAbstractBase {
         if (imp.equals(TopologyServiceShim.class)) {
             c.setInterface(new String[] { IDiscoveryService.class.getName(),
                     IContainerListener.class.getName(),
-                    IRefreshInternalProvider.class.getName() }, null);
-            c.add(createServiceDependency()
+                    IRefreshInternalProvider.class.getName(),
+                    IInventoryShimExternalListener.class.getName() }, null);
+          c.add(createServiceDependency()
                     .setService(ITopologyServiceShimListener.class)
                     .setCallbacks("setTopologyServiceShimListener",
                             "unsetTopologyServiceShimListener")
index 98a2962..9dc8b3b 100644 (file)
@@ -175,6 +175,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         txRates = new HashMap<Long, Map<Short, TxRates>>(initialSize);
         descriptionListeners = new HashSet<IStatisticsListener>();
 
+        configStatsPollIntervals();
+        
         // Initialize managed timers
         statisticsTimer = new Timer();
         statisticsTimerTask = new TimerTask() {
@@ -876,6 +878,8 @@ public class OFStatisticsManager implements IOFStatisticsManager,
         help.append("---OF Statistics Manager utilities---\n");
         help.append("\t ofdumpstatsmgr         - "
                 + "Print Internal Stats Mgr db\n");
+        help.append("\t ofstatsmgrintervals <fP> <pP> <dP>(in seconds) - "
+                + "Set/Show flow/port/dedscription stats poll intervals\n");
         return help.toString();
     }
 
@@ -1001,33 +1005,76 @@ public class OFStatisticsManager implements IOFStatisticsManager,
     public void _ofstatsmgrintervals(CommandInterpreter ci) {
         String flowStatsInterv = ci.nextArgument();
         String portStatsInterv = ci.nextArgument();
+        String descStatsInterv = ci.nextArgument();
 
-        if (flowStatsInterv == null || portStatsInterv == null) {
-
-            ci.println("Usage: ostatsmgrintervals <fP> <pP> (in seconds)");
+        if (flowStatsInterv == null || portStatsInterv == null
+                || descStatsInterv == null) {
+            ci.println("Usage: ostatsmgrintervals <fP> <pP> <dP>(in seconds)");
             ci.println("Current Values: fP=" + statisticsTickNumber + "s pP="
-                    + portTickNumber + "s");
+                    + portTickNumber + "s dP=" + descriptionTickNumber + "s");
             return;
         }
-        Short fP, pP;
+        Short fP, pP, dP;
         try {
             fP = Short.parseShort(flowStatsInterv);
             pP = Short.parseShort(portStatsInterv);
+            dP = Short.parseShort(descStatsInterv);
         } catch (Exception e) {
             ci.println("Invalid format values: " + e.getMessage());
             return;
         }
 
-        if (pP <= 1 || fP <= 1) {
-            ci.println("Invalid values. fP and pP have to be greater than 1.");
+        if (pP <= 1 || fP <= 1 || dP <= 1) {
+            ci.println("Invalid values. fP, pP, dP have to be greater than 1.");
             return;
         }
 
         statisticsTickNumber = fP;
         portTickNumber = pP;
+        descriptionTickNumber = dP;
 
         ci.println("New Values: fP=" + statisticsTickNumber + "s pP="
-                + portTickNumber + "s");
+                + portTickNumber + "s dP=" + descriptionTickNumber + "s");
     }
 
+    /**
+     * This method retrieves user configurations from config.ini and updates
+     * statisticsTickNumber/portTickNumber/descriptionTickNumber accordingly.
+     */
+    private void configStatsPollIntervals() {
+        String fsStr = System.getProperty("of.flowStatsPollInterval");
+        String psStr = System.getProperty("of.portStatsPollInterval");
+        String dsStr = System.getProperty("of.descStatsPollInterval");
+        Short fs, ps, ds;
+
+        if (fsStr != null) {
+            try {
+                fs = Short.parseShort(fsStr);
+                if (fs > 0) {
+                    statisticsTickNumber = fs;
+                }
+            } catch (Exception e) {
+            }
+        }
+
+        if (psStr != null) {
+            try {
+                ps = Short.parseShort(psStr);
+                if (ps > 0) {
+                    portTickNumber = ps;
+                }
+            } catch (Exception e) {
+            }
+        }
+
+        if (dsStr != null) {
+            try {
+                ds = Short.parseShort(dsStr);
+                if (ds > 0) {
+                    descriptionTickNumber = ds;
+                }
+            } catch (Exception e) {
+            }
+        }
+    }
 }
index 424af8d..af502a2 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.controller.protocol_plugin.openflow.IInventoryShimExternalListener;
 import org.opendaylight.controller.protocol_plugin.openflow.IOFStatisticsManager;
 import org.opendaylight.controller.protocol_plugin.openflow.IRefreshInternalProvider;
 import org.opendaylight.controller.protocol_plugin.openflow.ITopologyServiceShimListener;
@@ -33,12 +34,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.opendaylight.controller.sal.core.Bandwidth;
+import org.opendaylight.controller.sal.core.Config;
 import org.opendaylight.controller.sal.core.ContainerFlow;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.IContainerListener;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
+import org.opendaylight.controller.sal.core.State;
 import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.discovery.IDiscoveryService;
 import org.opendaylight.controller.sal.utils.GlobalConstants;
@@ -49,7 +52,8 @@ import org.opendaylight.controller.sal.utils.GlobalConstants;
  * container configurations.
  */
 public class TopologyServiceShim implements IDiscoveryService,
-        IContainerListener, CommandProvider, IRefreshInternalProvider {
+               IContainerListener, CommandProvider, IRefreshInternalProvider,
+               IInventoryShimExternalListener {
     protected static final Logger logger = LoggerFactory
             .getLogger(TopologyServiceShim.class);
     private ConcurrentMap<String, ITopologyServiceShimListener> topologyServiceShimListeners = new ConcurrentHashMap<String, ITopologyServiceShimListener>();
@@ -645,4 +649,56 @@ public class TopologyServiceShim implements IDiscoveryService,
         logger.debug("Sent {} updates", i);
     }
 
+    @Override
+    public void updateNode(Node node, UpdateType type, Set<Property> props) {
+    }
+
+    @Override
+    public void updateNodeConnector(NodeConnector nodeConnector,
+            UpdateType type, Set<Property> props) {
+        List<String> containers = new ArrayList<String>();
+        List<String> conList = this.containerMap.get(nodeConnector);
+
+        containers.add(GlobalConstants.DEFAULT.toString());
+        if (conList != null) {
+            containers.addAll(conList);
+        }
+        
+        switch (type) {
+        case ADDED:
+            break;
+        case CHANGED:
+            if (props == null) {
+                break;
+            }
+
+            boolean rmEdge = false;
+            for (Property prop : props) {
+                if (((prop instanceof Config) && (((Config) prop).getValue() != Config.ADMIN_UP))
+                        || ((prop instanceof State) && (((State) prop)
+                                .getValue() != State.EDGE_UP))) {
+                    /*
+                     * If port admin down or link down, remove the edges
+                     * associated with the port
+                     */
+                    rmEdge = true;
+                    break;
+                }
+            }
+
+            if (rmEdge) {
+                for (String cName : containers) {
+                    removeNodeConnector(cName, nodeConnector);
+                }
+            }
+            break;
+        case REMOVED:
+            for (String cName : containers) {
+                removeNodeConnector(cName, nodeConnector);
+            }
+            break;
+        default:
+            break;
+        }
+    }
 }
index 3dda38e..29094d3 100644 (file)
@@ -16,8 +16,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class provides the methods to notify the listener when an edge
- * is added/deleted/changed
+ * The interface provides the methods to notify the listener when an edge is
+ * added/deleted/changed.
  */
 public interface IDiscoveryService {
     /**
index 2df6053..3c58ecb 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 
 /**
- * Interface class that describes methods invoked from application toward SAL to
- * solicit existing inventory data
+ * The Interface describes methods invoked from application toward SAL to
+ * solicit existing inventory data.
  */
 public interface IInventoryService {
     /**
index 41b91e1..ccfb338 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class provides the methods to notify the upper applications
- * in regards to any inventory changes.
+ * The interface provides the methods to notify the upper applications in
+ * regards to any inventory changes.
  */
 public interface IListenInventoryUpdates {
     /**
index 420f9bb..5822731 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.Property;
 
 /**
- * The interface class that describes methods invoked from SAL toward the protocol
- * plugin to solicit existing inventory data.
+ * The Interface describes methods invoked from SAL toward the protocol plugin
+ * to solicit existing inventory data.
  */
 public interface IPluginInInventoryService {
     /**
index 124c34a..42c9ab7 100644 (file)
@@ -17,8 +17,8 @@ import org.opendaylight.controller.sal.core.Property;
 import org.opendaylight.controller.sal.core.UpdateType;
 
 /**
- * The interface class describes Inventory update methods to be implemented by
- * protocol plugin
+ * The Interface describes Inventory update methods to be implemented by
+ * protocol plugin.
  */
 public interface IPluginOutInventoryService {
     /**
index 1b67e52..0d64106 100644 (file)
@@ -14,8 +14,8 @@ import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.switchmanager.Subnet;
 
 /**
- * The interface class provides methods to notify listeners about subnet and
- * mode changes.
+ * The interface provides methods to notify listeners about subnet and mode
+ * changes.
  */
 public interface ISwitchManagerAware {
     /**
index 73bbc4a..de4f0d5 100644 (file)
@@ -22,8 +22,7 @@ import org.opendaylight.controller.sal.core.UpdateType;
 import org.opendaylight.controller.sal.utils.Status;
 
 /**
- * Interface class that provides methods to interact with
- * network topology database
+ * The Interface provides methods to interact with network topology database.
  */
 public interface ITopologyManager {
     /**
index fafbd4b..d5b499c 100644 (file)
@@ -27,7 +27,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Interface class that provides methods to manipulate user configured link
+ * The Interface provides methods to manipulate user configured link.
  */
 @XmlRootElement
 @XmlAccessorType(XmlAccessType.NONE)