net.floodlightcontroller.debugcounter
Class NullDebugCounter

java.lang.Object
  extended by net.floodlightcontroller.debugcounter.NullDebugCounter
All Implemented Interfaces:
IFloodlightModule, IFloodlightService, IDebugCounterService

public class NullDebugCounter
extends java.lang.Object
implements IFloodlightModule, IDebugCounterService


Nested Class Summary
 class NullDebugCounter.NullCounterImpl
           
 
Nested classes/interfaces inherited from interface net.floodlightcontroller.debugcounter.IDebugCounterService
IDebugCounterService.CounterException, IDebugCounterService.CounterType, IDebugCounterService.MaxCountersRegistered, IDebugCounterService.MaxHierarchyRegistered, IDebugCounterService.MissingHierarchicalLevel
 
Field Summary
 
Fields inherited from interface net.floodlightcontroller.debugcounter.IDebugCounterService
CTR_MDATA_ERROR, CTR_MDATA_WARN, MAX_COUNTERS, MAX_HIERARCHY
 
Constructor Summary
NullDebugCounter()
           
 
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.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
          Get a list of Modules that this module depends on.
 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
 java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleServices()
          Return the list of interfaces that this module implements.
 java.util.Map<java.lang.Class<? extends IFloodlightService>,IFloodlightService> getServiceImpls()
          Instantiate (as needed) and return objects that implement each of the services exported by this module.
 void init(FloodlightModuleContext context)
          This is a hook for each module to do its internal initialization, e.g., call setService(context.getService("Service")) All module dependencies are resolved when this is called, but not every module is initialized.
 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.
 void startUp(FloodlightModuleContext context)
          This is a hook for each module to do its external initializations, e.g., register for callbacks or query for state in other modules It is expected that this function will not block and that modules that want non-event driven CPU will spawn their own threads.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullDebugCounter

public NullDebugCounter()
Method Detail

getModuleServices

public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleServices()
Description copied from interface: IFloodlightModule
Return the list of interfaces that this module implements. All interfaces must inherit IFloodlightService

Specified by:
getModuleServices in interface IFloodlightModule
Returns:

getServiceImpls

public java.util.Map<java.lang.Class<? extends IFloodlightService>,IFloodlightService> getServiceImpls()
Description copied from interface: IFloodlightModule
Instantiate (as needed) and return objects that implement each of the services exported by this module. The map returned maps the implemented service to the object. The object could be the same object or different objects for different exported services.

Specified by:
getServiceImpls in interface IFloodlightModule
Returns:
The map from service interface class to service implementation

getModuleDependencies

public java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
Description copied from interface: IFloodlightModule
Get a list of Modules that this module depends on. The module system will ensure that each these dependencies is resolved before the subsequent calls to init().

Specified by:
getModuleDependencies in interface IFloodlightModule
Returns:
The Collection of IFloodlightServices that this module depends on.

init

public void init(FloodlightModuleContext context)
          throws FloodlightModuleException
Description copied from interface: IFloodlightModule
This is a hook for each module to do its internal initialization, e.g., call setService(context.getService("Service")) All module dependencies are resolved when this is called, but not every module is initialized.

Specified by:
init in interface IFloodlightModule
Throws:
FloodlightModuleException

startUp

public void startUp(FloodlightModuleContext context)
Description copied from interface: IFloodlightModule
This is a hook for each module to do its external initializations, e.g., register for callbacks or query for state in other modules It is expected that this function will not block and that modules that want non-event driven CPU will spawn their own threads.

Specified by:
startUp in interface IFloodlightModule

flushCounters

public void flushCounters()
Description copied from interface: IDebugCounterService
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.

Specified by:
flushCounters in interface IDebugCounterService

resetAllCounters

public void resetAllCounters()
Description copied from interface: IDebugCounterService
Resets the values of all counters in the system.

Specified by:
resetAllCounters in interface IDebugCounterService

resetAllModuleCounters

public void resetAllModuleCounters(java.lang.String moduleName)
Description copied from interface: IDebugCounterService
Resets the values of all counters belonging to a module with the given 'moduleName'.

Specified by:
resetAllModuleCounters in interface IDebugCounterService

resetCounterHierarchy

public void resetCounterHierarchy(java.lang.String moduleName,
                                  java.lang.String counterHierarchy)
Description copied from interface: IDebugCounterService
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.

Specified by:
resetCounterHierarchy in interface IDebugCounterService

enableCtrOnDemand

public void enableCtrOnDemand(java.lang.String moduleName,
                              java.lang.String counterHierarchy)
Description copied from interface: IDebugCounterService
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.

Specified by:
enableCtrOnDemand in interface IDebugCounterService

disableCtrOnDemand

public void disableCtrOnDemand(java.lang.String moduleName,
                               java.lang.String counterHierarchy)
Description copied from interface: IDebugCounterService
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.

Specified by:
disableCtrOnDemand in interface IDebugCounterService

getCounterHierarchy

public java.util.List<DebugCounter.DebugCounterInfo> getCounterHierarchy(java.lang.String moduleName,
                                                                         java.lang.String counterHierarchy)
Description copied from interface: IDebugCounterService
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.

Specified by:
getCounterHierarchy in interface IDebugCounterService
Returns:
A list of DebugCounterInfo or an empty list if the counter could not be found

getAllCounterValues

public java.util.List<DebugCounter.DebugCounterInfo> getAllCounterValues()
Description copied from interface: IDebugCounterService
Get counter values and associated information for all counters in the system

Specified by:
getAllCounterValues in interface IDebugCounterService
Returns:
the list of values/info or an empty list

getModuleCounterValues

public java.util.List<DebugCounter.DebugCounterInfo> getModuleCounterValues(java.lang.String moduleName)
Description copied from interface: IDebugCounterService
Get counter values and associated information for all counters associated with a module.

Specified by:
getModuleCounterValues in interface IDebugCounterService
Returns:
the list of values/info or an empty list

containsModuleCounterHierarchy

public boolean containsModuleCounterHierarchy(java.lang.String moduleName,
                                              java.lang.String counterHierarchy)
Description copied from interface: IDebugCounterService
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.

Specified by:
containsModuleCounterHierarchy in interface IDebugCounterService
Returns:
false if moduleCounterHierarchy is not a registered counter

containsModuleName

public boolean containsModuleName(java.lang.String moduleName)
Description copied from interface: IDebugCounterService
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.

Specified by:
containsModuleName in interface IDebugCounterService
Returns:
false if moduleName is not a registered counter

registerCounter

public IDebugCounter registerCounter(java.lang.String moduleName,
                                     java.lang.String counterHierarchy,
                                     java.lang.String counterDescription,
                                     IDebugCounterService.CounterType counterType,
                                     java.lang.String... metaData)
                              throws IDebugCounterService.MaxCountersRegistered
Description copied from interface: IDebugCounterService
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.

Specified by:
registerCounter in interface IDebugCounterService
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

getModuleList

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

Specified by:
getModuleList in interface IDebugCounterService

getModuleCounterList

public java.util.List<java.lang.String> getModuleCounterList(java.lang.String moduleName)
Description copied from interface: IDebugCounterService
Returns a list of all counters registered for a specific moduleName or a empty list

Specified by:
getModuleCounterList in interface IDebugCounterService