- 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 6a7d68c8d066efd7b8e86bc71fd551ff7f36603e..33789ee2d28e75cde71be02b36084cff12aceb27 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 24e63df30a8fe429f81560d3845d1f1d4fa11a2e..df03a0438410c4056603e686b330809a59364af1 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 e7c11a6eeab16c9c6c918612c6782aabefdd570b..6b328961fc40d4936314a5880fb7f1c1139b84fe 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 23b40a3e304e3aba9704a03445e7b34bc98a5dae..0c30c80f0df48fe4a5ca35fee756cdd7f698a464 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 9bccbd1d68f450dc60889b1c35f21742da690d1e..9b7d1e3bc20a07b2dc97760c08b41257dcfce4a6 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 98a296260628d0e4b303217af344390a3ec43cc6..9dc8b3b6aa77f352a80ee58c5e358de0d331f46f 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 424af8d4f445e2e7b214e7533b2141c211dde2d7..af502a2177d12c89101ca5b2363f90a9eeabe4da 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 3dda38ef56f11d720b5c4587669cb8341ec0ffab..29094d34f954c606f23a6c87ca35ca65c0d1b088 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 2df60530989a081739e84fe7f89303963cc464c8..3c58ecbfcdc04ee4e7bca4b6a375fd956b3d45a4 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 41b91e19195043e7e07275e3926e1c8fff670357..ccfb3388494452088203732a2b322654b7d5fe2a 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 420f9bb00c44936a3cee5eaf380e2e9ace9fefe2..5822731f26babd33bea1ea18d108fcf5be0a6f4c 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 124c34ab3e48ec424ab2b8bfb705b623275f43bb..42c9ab7475ef09f4e3289124f56a5a591df9f037 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 1b67e529df85f774e7815d46a237bfb96edced05..0d6410662aa6dc4f6bf1997fc131685e199f7c91 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 73bbc4a29b41c7d5c8ff4d1b33e72f42da77a8e2..de4f0d5347eb5b7954e8f9e5c2d84748f562ee84 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 fafbd4b3dca37fe291a80cda2dda54ed84d23163..d5b499c42b9737cfac8783eb8ec4943180d75aad 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)