public abstract class OFController extends java.lang.Object implements IOFHandler, java.lang.Comparable<IOFHandler>
Modifier and Type | Class and Description |
---|---|
private class |
OFController.QI
Queue Item
|
private class |
OFController.QP
Queue Item Processor, which is a thread that pulls QI object
from the queue that is associated with the thread.
|
IOFHandler.Role
Modifier and Type | Field and Description |
---|---|
private java.util.Set<OFModule> |
modules
set of all modules.
|
private OFController.QP[] |
processors
Queue Item Processors
|
private IOFHandler.Role |
role
role of this controller.
|
private IOFProtocolServer |
server
Protocol Server object, which is currently
TcpServer . |
private java.util.concurrent.ConcurrentHashMap<java.lang.Long,IOFSwitch> |
switches
index to all switches.
|
private java.util.Timer |
timer
Timer for scheduling asynchronous jobs.
|
Constructor and Description |
---|
OFController(int num_of_queue,
java.lang.String role)
OFController constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addModule(OFModule module)
This method is automatically called by
OFModule.init(IOFHandler) . |
int |
compareTo(IOFHandler o) |
java.lang.String |
getConcatenatedModuleNames()
get a String representation of all module names
linked with ','.
|
OFModel[] |
getModels()
This method returns all the
OFModel object
which are associated with this controller. |
java.lang.String[] |
getModuleNames()
get an array that holds all the module names associated with this controller.
|
java.util.Collection<OFModule> |
getModules()
get all the
OFModule objects associated with this controller. |
IOFHandler.Role |
getRole()
get the role of this controller.
|
IOFSwitch |
getSwitch(long id)
return a specific switch with a given identifier
|
java.util.Collection<IOFSwitch> |
getSwitches()
return the set of all switches
|
java.util.Set<java.lang.Long> |
getSwitchIdentifiers()
return the set of all switch identifiers
|
boolean |
handleConnectedEvent(Connection conn)
This callback is called when a new connection to a new switch is made.
|
boolean |
handleDisconnectEvent(Connection conn)
This callback is called when a connection to a switch is lost.
|
boolean |
handleEchoRequest(Connection conn,
MessageContext context,
org.openflow.protocol.OFEchoRequest m)
handle Echo Request message.
|
abstract boolean |
handleGeneric(Connection conn,
MessageContext context,
org.openflow.protocol.OFMessage m)
handle the other messages.
|
boolean |
handleHello(Connection conn,
MessageContext context,
org.openflow.protocol.OFHello m)
handle Hello message.
|
abstract boolean |
handlePacketIn(Connection conn,
MessageContext context,
org.openflow.protocol.OFPacketIn m)
handle Packet-in Message.
|
boolean |
handleReadEvent(Connection conn,
java.util.List<org.openflow.protocol.OFMessage> msgs)
This is a method that cannot be overridden.
|
abstract void |
init()
Every controller implementation that inherits OFController should implement this function
to handle all the chores related to the controller initialization.
|
boolean |
isMyFlow(Connection conn,
java.util.List<org.openflow.protocol.OFMessage> msgs)
This function returns true if a given messages is assigned to this controller.
|
boolean |
isMySwitch(Connection conn)
This function returns true if a given switch is assigned to this controller.
|
void |
registerProtocolServer(IOFProtocolServer server)
Register a protocol server that actually handles the underlying bearer protocol.
|
void |
removeSelf()
This method is called by
OFController.QP.run() when a controller fails
to remove itself from the protocol server, which prevents this controller
from receiving other Openflow messages from the protocol server. |
void |
scheduleTask(IOFTask task,
long after)
Schedule a task to be executed after 'after'.
|
void |
shutdown()
Shutdown this OF Controller instance including all the Queue Processors
|
void |
start()
Start all Queue Processors.
|
private java.util.Timer timer
private java.util.concurrent.ConcurrentHashMap<java.lang.Long,IOFSwitch> switches
private java.util.Set<OFModule> modules
private IOFHandler.Role role
private OFController.QP[] processors
private IOFProtocolServer server
TcpServer
.public OFController(int num_of_queue, java.lang.String role)
num_of_queue
- number of Queue Item Processorspublic abstract void init()
public IOFHandler.Role getRole()
getRole
in interface IOFHandler
public void registerProtocolServer(IOFProtocolServer server)
registerProtocolServer
in interface IOFHandler
public void removeSelf()
OFController.QP.run()
when a controller fails
to remove itself from the protocol server, which prevents this controller
from receiving other Openflow messages from the protocol server.public void shutdown()
public void start()
public void scheduleTask(IOFTask task, long after)
scheduleTask
in interface IOFHandler
task
- time
- millisecond since Epochafter
- re-schedule this task after 'after' milliseconds. If zero is given,
the task will start immediately, and never be repeated.public final boolean handleConnectedEvent(Connection conn)
handleConnectedEvent
in interface IOFHandler
public abstract boolean handlePacketIn(Connection conn, MessageContext context, org.openflow.protocol.OFPacketIn m)
conn
- underlying connectioncontext
- m
- Packet-in message.public boolean handleHello(Connection conn, MessageContext context, org.openflow.protocol.OFHello m)
conn
- underlying connectioncontext
- m
- Hello message.public final boolean handleEchoRequest(Connection conn, MessageContext context, org.openflow.protocol.OFEchoRequest m)
conn
- underlying connectioncontext
- m
- Echo Request message.public abstract boolean handleGeneric(Connection conn, MessageContext context, org.openflow.protocol.OFMessage m)
conn
- underlying connectioncontext
- m
- message which is not packet-in, hello, or echo request message.public final boolean handleReadEvent(Connection conn, java.util.List<org.openflow.protocol.OFMessage> msgs)
handleReadEvent
in interface IOFHandler
public final java.util.Set<java.lang.Long> getSwitchIdentifiers()
getSwitchIdentifiers
in interface IOFHandler
public final java.util.Collection<IOFSwitch> getSwitches()
getSwitches
in interface IOFHandler
public final IOFSwitch getSwitch(long id)
getSwitch
in interface IOFHandler
public final boolean handleDisconnectEvent(Connection conn)
handleDisconnectEvent
in interface IOFHandler
public boolean isMySwitch(Connection conn)
isMySwitch
in interface IOFHandler
public boolean isMyFlow(Connection conn, java.util.List<org.openflow.protocol.OFMessage> msgs)
isMyFlow
in interface IOFHandler
public final void addModule(OFModule module)
OFModule.init(IOFHandler)
.
This method is for adding a module as a part of this controller object.addModule
in interface IOFHandler
public final int compareTo(IOFHandler o)
compareTo
in interface java.lang.Comparable<IOFHandler>
public final OFModel[] getModels()
OFModel
object
which are associated with this controller.
As an OFModel
object is normally associated with
a OFModule
object, this method calls OFModule.getModels()
method
of each OFModule
object in modules
.getModels
in interface IOFHandler
public final java.lang.String getConcatenatedModuleNames()
getConcatenatedModuleNames
in interface IOFHandler
public final java.util.Collection<OFModule> getModules()
OFModule
objects associated with this controller.getModules
in interface IOFHandler
public final java.lang.String[] getModuleNames()
getModuleNames
in interface IOFHandler