net.floodlightcontroller.flowcache
Class FlowReconcileManager

java.lang.Object
  extended by net.floodlightcontroller.flowcache.FlowReconcileManager
All Implemented Interfaces:
IFloodlightModule, IFloodlightService, IFlowReconcileService

public class FlowReconcileManager
extends java.lang.Object
implements IFloodlightModule, IFlowReconcileService


Field Summary
protected  ICounterStoreService counterStore
           
protected  IDebugCounterService debugCounters
           
protected static java.lang.String EnableConfigKey
          Config to enable or disable flowReconcile
protected static int FLOW_RECONCILE_DELAY_MILLISEC
          start flow reconcile in 10ms after a new reconcile request is received.
protected  boolean flowReconcileEnabled
           
protected  ListenerDispatcher<OFType,IFlowReconcileListener> flowReconcileListeners
          The list of flow reconcile listeners that have registered to get flow reconcile callbacks.
protected  SingletonTask flowReconcileTask
          Asynchronous task to feed the flowReconcile pipeline
 java.util.concurrent.atomic.AtomicInteger flowReconcileThreadRunCount
           
protected  SimpleCounter lastPacketInCounter
           
protected  java.util.Date lastReconcileTime
           
protected static int MAX_SYSTEM_LOAD_PER_SECOND
           
protected static int MIN_FLOW_RECONCILE_PER_SECOND
          a minimum flow reconcile rate so that it won't stave
static java.lang.String PACKAGE
           
protected  IThreadPoolService threadPool
          Reference to dependent modules
 
Constructor Summary
FlowReconcileManager()
           
 
Method Summary
 void addFlowReconcileListener(IFlowReconcileListener listener)
          Add a flow reconcile listener
 void clearFlowReconcileListeners()
          Remove all flow reconcile listeners
protected  boolean doReconcile()
          Feed the flows into the flow reconciliation pipeline.
protected  int getCurrentCapacity()
          Compute the maximum number of flows to be reconciled.
 java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleDependencies()
          Get a list of Modules that this module depends on.
 java.util.Collection<java.lang.Class<? extends IFloodlightService>> getModuleServices()
          Return the list of interfaces that this module implements.
protected  int getPktInRate(ICounter newCnt, java.util.Date currentTime)
           
 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.
 void reconcileFlow(OFMatchReconcile ofmRcIn, PriorityPendingQueue.EventPriority priority)
          Add to-be-reconciled flow to the queue.
 void removeFlowReconcileListener(IFlowReconcileListener listener)
          Remove a flow reconcile listener
 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.
protected  void updateFlush()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadPool

protected IThreadPoolService threadPool
Reference to dependent modules


counterStore

protected ICounterStoreService counterStore

debugCounters

protected IDebugCounterService debugCounters

flowReconcileListeners

protected ListenerDispatcher<OFType,IFlowReconcileListener> flowReconcileListeners
The list of flow reconcile listeners that have registered to get flow reconcile callbacks. Such callbacks are invoked, for example, when a switch with existing flow-mods joins this controller and those flows need to be reconciled with the current configuration of the controller.


flowReconcileTask

protected SingletonTask flowReconcileTask
Asynchronous task to feed the flowReconcile pipeline


lastPacketInCounter

protected SimpleCounter lastPacketInCounter

MAX_SYSTEM_LOAD_PER_SECOND

protected static final int MAX_SYSTEM_LOAD_PER_SECOND
See Also:
Constant Field Values

MIN_FLOW_RECONCILE_PER_SECOND

protected static final int MIN_FLOW_RECONCILE_PER_SECOND
a minimum flow reconcile rate so that it won't stave

See Also:
Constant Field Values

FLOW_RECONCILE_DELAY_MILLISEC

protected static final int FLOW_RECONCILE_DELAY_MILLISEC
start flow reconcile in 10ms after a new reconcile request is received. The max delay is 1 second.

See Also:
Constant Field Values

lastReconcileTime

protected java.util.Date lastReconcileTime

EnableConfigKey

protected static final java.lang.String EnableConfigKey
Config to enable or disable flowReconcile

See Also:
Constant Field Values

PACKAGE

public static final java.lang.String PACKAGE

flowReconcileEnabled

protected boolean flowReconcileEnabled

flowReconcileThreadRunCount

public java.util.concurrent.atomic.AtomicInteger flowReconcileThreadRunCount
Constructor Detail

FlowReconcileManager

public FlowReconcileManager()
Method Detail

addFlowReconcileListener

public void addFlowReconcileListener(IFlowReconcileListener listener)
Description copied from interface: IFlowReconcileService
Add a flow reconcile listener

Specified by:
addFlowReconcileListener in interface IFlowReconcileService
Parameters:
listener - The module that can reconcile flows

removeFlowReconcileListener

public void removeFlowReconcileListener(IFlowReconcileListener listener)
Description copied from interface: IFlowReconcileService
Remove a flow reconcile listener

Specified by:
removeFlowReconcileListener in interface IFlowReconcileService
Parameters:
listener - The module that no longer reconcile flows

clearFlowReconcileListeners

public void clearFlowReconcileListeners()
Description copied from interface: IFlowReconcileService
Remove all flow reconcile listeners

Specified by:
clearFlowReconcileListeners in interface IFlowReconcileService

reconcileFlow

public void reconcileFlow(OFMatchReconcile ofmRcIn,
                          PriorityPendingQueue.EventPriority priority)
Add to-be-reconciled flow to the queue.

Specified by:
reconcileFlow in interface IFlowReconcileService
Parameters:
ofmRcIn - the ofm rc in

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
Specified by:
init in interface IFlowReconcileService
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
Specified by:
startUp in interface IFlowReconcileService

updateFlush

protected void updateFlush()

doReconcile

protected boolean doReconcile()
Feed the flows into the flow reconciliation pipeline.

Returns:
true if more flows to be reconciled false if no more flows to be reconciled.

getCurrentCapacity

protected int getCurrentCapacity()
Compute the maximum number of flows to be reconciled. It computes the packetIn increment from the counter values in the counter store; Then computes the rate based on the elapsed time from the last query; Then compute the max flow reconcile rate by subtracting the packetIn rate from the hard-coded max system rate. If the system rate is reached or less than MIN_FLOW_RECONCILE_PER_SECOND, set the maximum flow reconcile rate to the MIN_FLOW_RECONCILE_PER_SECOND to prevent starvation. Then convert the rate to an absolute number for the FLOW_RECONCILE_PERIOD.

Returns:

getPktInRate

protected int getPktInRate(ICounter newCnt,
                           java.util.Date currentTime)