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=d6100e3fdc499c2bd53eb9eb45c414c70e8517d1;hb=06aa5ce746e29a3760688b2ef2817f50bec5ea7a;hp=98a296260628d0e4b303217af344390a3ec43cc6;hpb=f9c1698f289be1cc34eaf1fffd887ffc632a9d65;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..d6100e3fdc 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() { @@ -701,8 +703,10 @@ public class OFStatisticsManager implements IOFStatisticsManager, ByteBuffer data = ByteBuffer.allocate(length); stat.writeTo(data); data.rewind(); - log.trace("getV6ReplyStatistics: Buffer BYTES ARE {}", - HexString.toHexString(data.array())); + if (log.isTraceEnabled()) { + log.trace("getV6ReplyStatistics: Buffer BYTES ARE {}", + HexString.toHexString(data.array())); + } int vendor = data.getInt(); // first 4 bytes is vendor id. if (vendor != V6StatsRequest.NICIRA_VENDOR_ID) { @@ -876,6 +880,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 +1007,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) { + } + } + } }