Class StatisticsCounters
- java.lang.Object
-
- org.opendaylight.openflowjava.statistics.StatisticsCounters
-
- All Implemented Interfaces:
StatisticsHandler
public final class StatisticsCounters extends Object implements StatisticsHandler
Singleton class to hold and process counters.- Author:
- madamjak
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_LOG_REPORT_PERIOD
Default delay between two writings into log (milliseconds).static int
MINIMAL_LOG_REPORT_PERIOD
Minimal delay between two writings into log (milliseconds).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Counter
getCounter(CounterEventTypes counterEventKey)
Get counter by CounterEventType.protected Map<CounterEventTypes,Counter>
getCountersMap()
Returns the countersMap.protected CounterEventTypes[]
getEnabledCounters()
Returns the enabled counters.static StatisticsCounters
getInstance()
Get instance of statistics counters, first created object does not start counting and log reporting.int
getLogReportPeriod()
Returns the current delay between two writings into logs.void
incrementCounter(CounterEventTypes counterEventKey)
Increment value of given counter.boolean
isCounterEnabled(CounterEventTypes counterEventKey)
Determines if the given counter is enabled.boolean
isRunCounting()
Give an information if counting is running.boolean
isRunLogReport()
Give an information if log reporter is running (statistics are write into logs).String
printStatistics()
Returns statistics.void
resetCounters()
Resets all counters.void
startCounting(boolean reportToLogs, int logReportDelay)
Start counting (counters are set to 0 before counting starts).void
startLogReport(int logReportDelay)
Prints statistics with given delay between logs.void
stopCounting()
Stop counting, values in counters are untouched, log reporter is stopped.void
stopLogReport()
Stops logging, counting continues.
-
-
-
Field Detail
-
DEFAULT_LOG_REPORT_PERIOD
public static final int DEFAULT_LOG_REPORT_PERIOD
Default delay between two writings into log (milliseconds).- See Also:
- Constant Field Values
-
MINIMAL_LOG_REPORT_PERIOD
public static final int MINIMAL_LOG_REPORT_PERIOD
Minimal delay between two writings into log (milliseconds).- See Also:
- Constant Field Values
-
-
Method Detail
-
getInstance
public static StatisticsCounters getInstance()
Get instance of statistics counters, first created object does not start counting and log reporting.- Returns:
- an instance
-
startCounting
public void startCounting(boolean reportToLogs, int logReportDelay)
Start counting (counters are set to 0 before counting starts).- Parameters:
reportToLogs
- - true = statistic counters will periodically loglogReportDelay
- - delay between two logs (in milliseconds)
-
stopCounting
public void stopCounting()
Stop counting, values in counters are untouched, log reporter is stopped.
-
isRunCounting
public boolean isRunCounting()
Give an information if counting is running.- Returns:
- true, if counting is running, otherwise false
-
startLogReport
public void startLogReport(int logReportDelay)
Prints statistics with given delay between logs.- Parameters:
logReportDelay
- - delay between two logs (in milliseconds)- Throws:
IllegalArgumentException
- if logReportDelay is less than 0
-
stopLogReport
public void stopLogReport()
Stops logging, counting continues.
-
isRunLogReport
public boolean isRunLogReport()
Give an information if log reporter is running (statistics are write into logs).- Returns:
- true if log reporter writes statistics into log, otherwise false
-
getLogReportPeriod
public int getLogReportPeriod()
Returns the current delay between two writings into logs.
-
getEnabledCounters
protected CounterEventTypes[] getEnabledCounters()
Returns the enabled counters.
-
getCountersMap
protected Map<CounterEventTypes,Counter> getCountersMap()
Returns the countersMap.
-
isCounterEnabled
public boolean isCounterEnabled(CounterEventTypes counterEventKey)
Determines if the given counter is enabled.- Parameters:
counterEventKey
- the counter key- Returns:
- true if counter has been Enabled, otherwise false
-
getCounter
public Counter getCounter(CounterEventTypes counterEventKey)
Get counter by CounterEventType.- Parameters:
counterEventKey
- key to identify counter (can not be null)- Returns:
- Counter object or null if counter has not been enabled
- Throws:
IllegalArgumentException
- if counterEventKey is null
-
incrementCounter
public void incrementCounter(CounterEventTypes counterEventKey)
Increment value of given counter.- Parameters:
counterEventKey
- key to identify counter
-
resetCounters
public void resetCounters()
Description copied from interface:StatisticsHandler
Resets all counters.- Specified by:
resetCounters
in interfaceStatisticsHandler
-
printStatistics
public String printStatistics()
Description copied from interface:StatisticsHandler
Returns statistics.- Specified by:
printStatistics
in interfaceStatisticsHandler
-
-