net.floodlightcontroller.debugcounter
Interface IDebugCounterService

All Superinterfaces:
IFloodlightService
All Known Implementing Classes:
DebugCounter, NullDebugCounter

public interface IDebugCounterService
extends IFloodlightService


Nested Class Summary
static class IDebugCounterService.CounterException
           
static class IDebugCounterService.CounterType
          Different counter types.
static class IDebugCounterService.MaxCountersRegistered
          Exception thrown when MAX_COUNTERS have been registered
static class IDebugCounterService.MaxHierarchyRegistered
          Exception thrown when MAX_HIERARCHY has been reached
static class IDebugCounterService.MissingHierarchicalLevel
          Exception thrown when attempting to register a hierarchical counter where higher levels of the hierarchy have not been pre-registered
 
Field Summary
static java.lang.String CTR_MDATA_ERROR
           
static java.lang.String CTR_MDATA_WARN
          Debug Counter Qualifiers
static int MAX_COUNTERS
          A limit on the maximum number of counters that can be created
static int MAX_HIERARCHY
          maximum levels of hierarchy Example of moduleName/counterHierarchy: switch/00:00:00:00:01:02:03:04/pktin/drops where moduleName ==> "switch" and counterHierarchy of 3 ==> "00:00:00:00:01:02:03:04/pktin/drops"
 
Method Summary
 boolean containsModuleCounterHierarchy(java.lang.String moduleName, java.lang.String counterHierarchy)
          Convenience method to figure out if the the given 'counterHierarchy' corresponds to a registered counterHierarchy for 'moduleName'.
 boolean containsModuleName(java.lang.String moduleName)
          Convenience method to figure out if the the given 'moduleName' corresponds to a registered moduleName or not.
 void disableCtrOnDemand(java.lang.String moduleName, java.lang.String counterHierarchy)
          This method applies only to CounterType.COUNT_ON_DEMAND.
 void enableCtrOnDemand(java.lang.String moduleName, java.lang.String counterHierarchy)
          This method applies only to CounterType.COUNT_ON_DEMAND.
 void flushCounters()
          Flush all thread-local counter values (from the current thread) to the global counter store.
 java.util.List<DebugCounter.DebugCounterInfo> getAllCounterValues()
          Get counter values and associated information for all counters in the system
 java.util.List<DebugCounter.DebugCounterInfo> getCounterHierarchy(java.lang.String moduleName, java.lang.String counterHierarchy)
          Get counter value and associated information for the specified counterHierarchy.
 java.util.List<java.lang.String> getModuleCounterList(java.lang.String moduleName)
          Returns a list of all counters registered for a specific moduleName or a empty list
 java.util.List<DebugCounter.DebugCounterInfo> getModuleCounterValues(java.lang.String moduleName)
          Get counter values and associated information for all counters associated with a module.
 java.util.List<java.lang.String> getModuleList()
          Returns a list of moduleNames registered for debug counters or an empty list if no counters have been registered in the system
 IDebugCounter registerCounter(java.lang.String moduleName, java.lang.String counterHierarchy, java.lang.String counterDescription, IDebugCounterService.CounterType counterType, java.lang.String... metaData)
          All modules that wish to have the DebugCounterService count for them, must register their counters by making this call (typically from that module's 'startUp' method).
 void resetAllCounters()
          Resets the values of all counters in the system.
 void resetAllModuleCounters(java.lang.String moduleName)
          Resets the values of all counters belonging to a module with the given 'moduleName'.
 void resetCounterHierarchy(java.lang.String moduleName, java.lang.String counterHierarchy)
          Resets the value of counters in the hierarchy to zero.
 

Field Detail

CTR_MDATA_WARN

static final java.lang.String CTR_MDATA_WARN
Debug Counter Qualifiers

See Also:
Constant Field Values

CTR_MDATA_ERROR

static final java.lang.String CTR_MDATA_ERROR
See Also:
Constant Field Values

MAX_COUNTERS

static final int MAX_COUNTERS
A limit on the maximum number of counters that can be created

See Also:
Constant Field Values

MAX_HIERARCHY

static final int MAX_HIERARCHY
maximum levels of hierarchy Example of moduleName/counterHierarchy: switch/00:00:00:00:01:02:03:04/pktin/drops where moduleName ==> "switch" and counterHierarchy of 3 ==> "00:00:00:00:01:02:03:04/pktin/drops"

See Also:
Constant Field Values
Method Detail

registerCounter

IDebugCounter registerCounter(java.lang.String moduleName,
                              java.lang.String counterHierarchy,
                              java.lang.String counterDescription,
                              IDebugCounterService.CounterType counterType,
                              java.lang.String... metaData)
                              throws IDebugCounterService.MaxCountersRegistered,
                                     IDebugCounterService.MaxHierarchyRegistered,
                                     IDebugCounterService.MissingHierarchicalLevel
All modules that wish to have the DebugCounterService count for them, must register their counters by making this call (typically from that module's 'startUp' method). The counter can then be updated, displayed, reset etc. using the registered moduleName and counterHierarchy.

Parameters:
moduleName - the name of the module which is registering the counter eg. linkdiscovery or controller or switch
counterHierarchy - the hierarchical counter name specifying all the hierarchical levels that come above it. For example: to register a drop counter for packet-ins from a switch, the counterHierarchy can be "00:00:00:00:01:02:03:04/pktin/drops" It is necessary that counters in hierarchical levels above have already been pre-registered - in this example: "00:00:00:00:01:02:03:04/pktin" and "00:00:00:00:01:02:03:04"
counterDescription - a descriptive string that gives more information of what the counter is measuring. For example, "Measures the number of incoming packets seen by this module".
counterType - One of CounterType. On-demand counter types need to be explicitly enabled/disabled using other methods in this API -- i.e. registering them is not enough to start counting.
metaData - variable arguments that qualify a counter eg. warn, error etc.
Returns:
IDebugCounter with update methods that can be used to update a counter.
Throws:
IDebugCounterService.MaxCountersRegistered
IDebugCounterService.MaxHierarchyRegistered
IDebugCounterService.MissingHierarchicalLevel

flushCounters

void flushCounters()
Flush all thread-local counter values (from the current thread) to the global counter store. This method is not intended for use by any module. It's typical usage is from floodlight core and it is meant to flush those counters that are updated in the packet-processing pipeline, typically with the 'updateCounterNoFlush" methods in IDebugCounter.


resetCounterHierarchy

void resetCounterHierarchy(java.lang.String moduleName,
                           java.lang.String counterHierarchy)
Resets the value of counters in the hierarchy to zero. Note that the reset applies to the level of counter hierarchy specified AND ALL LEVELS BELOW it in the hierarchy. For example: If a hierarchy exists like "00:00:00:00:01:02:03:04/pktin/drops" specifying a reset hierarchy: "00:00:00:00:01:02:03:04" will reset all counters for the switch dpid specified; while specifying a reset hierarchy: ""00:00:00:00:01:02:03:04/pktin" will reset the pktin counter and all levels below it (like drops) for the switch dpid specified.


resetAllCounters

void resetAllCounters()
Resets the values of all counters in the system.


resetAllModuleCounters

void resetAllModuleCounters(java.lang.String moduleName)
Resets the values of all counters belonging to a module with the given 'moduleName'.


enableCtrOnDemand

void enableCtrOnDemand(java.lang.String moduleName,
                       java.lang.String counterHierarchy)
This method applies only to CounterType.COUNT_ON_DEMAND. It is used to enable counting on the counter. Note that this step is necessary to start counting for these counter types - merely registering the counter is not enough (as is the case for CounterType.ALWAYS_COUNT). Newly enabled counters start from an initial value of zero. Enabling a counter in a counterHierarchy enables only THAT counter. It does not enable any other part of the counterHierarchy. For example, if a hierarchy exists like "00:00:00:00:01:02:03:04/pktin/drops", where the 'pktin' and 'drops' counters are CounterType.COUNT_ON_DEMAND, then enabling the 'pktin' counter by specifying the counterHierarchy as "00:00:00:00:01:02:03:04/pktin" does NOT enable the 'drops' counter.


disableCtrOnDemand

void disableCtrOnDemand(java.lang.String moduleName,
                        java.lang.String counterHierarchy)
This method applies only to CounterType.COUNT_ON_DEMAND. It is used to enable counting on the counter. Note that disabling a counter results in a loss of the counter value. When re-enabled the counter will restart from zero. Disabling a counter in a counterHierarchy disables only THAT counter. It does not disable any other part of the counterHierarchy. For example, if a hierarchy exists like "00:00:00:00:01:02:03:04/pktin/drops", where the 'pktin' and 'drops' counters are CounterType.COUNT_ON_DEMAND, then disabling the 'pktin' counter by specifying the counterHierarchy as "00:00:00:00:01:02:03:04/pktin" does NOT disable the 'drops' counter.


getCounterHierarchy

java.util.List<DebugCounter.DebugCounterInfo> getCounterHierarchy(java.lang.String moduleName,
                                                                  java.lang.String counterHierarchy)
Get counter value and associated information for the specified counterHierarchy. Note that information on the level of counter hierarchy specified AND ALL LEVELS BELOW it in the hierarchy will be returned. For example, if a hierarchy exists like "00:00:00:00:01:02:03:04/pktin/drops", then specifying a counterHierarchy of "00:00:00:00:01:02:03:04/pktin" in the get call will return information on the 'pktin' as well as the 'drops' counters for the switch dpid specified.

Returns:
A list of DebugCounterInfo or an empty list if the counter could not be found

getAllCounterValues

java.util.List<DebugCounter.DebugCounterInfo> getAllCounterValues()
Get counter values and associated information for all counters in the system

Returns:
the list of values/info or an empty list

getModuleCounterValues

java.util.List<DebugCounter.DebugCounterInfo> getModuleCounterValues(java.lang.String moduleName)
Get counter values and associated information for all counters associated with a module.

Parameters:
moduleName -
Returns:
the list of values/info or an empty list

containsModuleCounterHierarchy

boolean containsModuleCounterHierarchy(java.lang.String moduleName,
                                       java.lang.String counterHierarchy)
Convenience method to figure out if the the given 'counterHierarchy' corresponds to a registered counterHierarchy for 'moduleName'. Note that the counter may or may not be enabled for counting, but if it is registered the method will return true.

Parameters:
param -
Returns:
false if moduleCounterHierarchy is not a registered counter

containsModuleName

boolean containsModuleName(java.lang.String moduleName)
Convenience method to figure out if the the given 'moduleName' corresponds to a registered moduleName or not. Note that the module may or may not have a counter enabled for counting, but if it is registered the method will return true.

Parameters:
param -
Returns:
false if moduleName is not a registered counter

getModuleList

java.util.List<java.lang.String> getModuleList()
Returns a list of moduleNames registered for debug counters or an empty list if no counters have been registered in the system


getModuleCounterList

java.util.List<java.lang.String> getModuleCounterList(java.lang.String moduleName)
Returns a list of all counters registered for a specific moduleName or a empty list