X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FOFStatisticsManager.java;h=9dc8b3b6aa77f352a80ee58c5e358de0d331f46f;hb=a3a28e8138fa25170b01e6b51a44490f002f6e91;hp=98a296260628d0e4b303217af344390a3ec43cc6;hpb=650881665d632280824523b05a2ab699e6932bfb;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java index 98a2962606..9dc8b3b6aa 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/OFStatisticsManager.java @@ -175,6 +175,8 @@ public class OFStatisticsManager implements IOFStatisticsManager, txRates = new HashMap>(initialSize); descriptionListeners = new HashSet(); + 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 (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 (in seconds)"); + if (flowStatsInterv == null || portStatsInterv == null + || descStatsInterv == null) { + ci.println("Usage: ostatsmgrintervals (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) { + } + } + } }