Search in sources :

Example 1 with IOFMessageListener

use of net.floodlightcontroller.core.IOFMessageListener in project open-kilda by telstra.

the class MockFloodlightProvider method logListeners.

private void logListeners() {
    for (Map.Entry<OFType, ListenerDispatcher<OFType, IOFMessageListener>> entry : listeners.entrySet()) {
        OFType type = entry.getKey();
        ListenerDispatcher<OFType, IOFMessageListener> ldd = entry.getValue();
        StringBuffer sb = new StringBuffer();
        sb.append("OFListeners for ");
        sb.append(type);
        sb.append(": ");
        for (IOFMessageListener l : ldd.getOrderedListeners()) {
            sb.append(l.getName());
            sb.append(",");
        }
        log.debug(sb.toString());
    }
}
Also used : OFType(org.projectfloodlight.openflow.protocol.OFType) IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ListenerDispatcher(net.floodlightcontroller.core.util.ListenerDispatcher)

Example 2 with IOFMessageListener

use of net.floodlightcontroller.core.IOFMessageListener in project open-kilda by telstra.

the class MockFloodlightProvider method dispatchMessage.

public void dispatchMessage(IOFSwitch sw, OFMessage msg, FloodlightContext bc) {
    List<IOFMessageListener> theListeners = listeners.get(msg.getType()).getOrderedListeners();
    if (theListeners != null) {
        Command result = Command.CONTINUE;
        Iterator<IOFMessageListener> it = theListeners.iterator();
        if (OFType.PACKET_IN.equals(msg.getType())) {
            OFPacketIn pi = (OFPacketIn) msg;
            Ethernet eth = new Ethernet();
            eth.deserialize(pi.getData(), 0, pi.getData().length);
            IFloodlightProviderService.bcStore.put(bc, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, eth);
        }
        while (it.hasNext() && !Command.STOP.equals(result)) {
            result = it.next().receive(sw, msg, bc);
        }
    }
    // paag
    for (IControllerCompletionListener listener : completionListeners) listener.onMessageConsumed(sw, msg, bc);
}
Also used : IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) Command(net.floodlightcontroller.core.IListener.Command) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) IControllerCompletionListener(net.floodlightcontroller.core.IControllerCompletionListener)

Example 3 with IOFMessageListener

use of net.floodlightcontroller.core.IOFMessageListener in project open-kilda by telstra.

the class MockFloodlightProvider method handleOutgoingMessage.

@Override
public void handleOutgoingMessage(IOFSwitch sw, OFMessage m) {
    FloodlightContext bc = new FloodlightContext();
    List<IOFMessageListener> msgListeners = null;
    if (listeners.containsKey(m.getType())) {
        msgListeners = listeners.get(m.getType()).getOrderedListeners();
    }
    if (msgListeners != null) {
        for (IOFMessageListener listener : msgListeners) {
            if (Command.STOP.equals(listener.receive(sw, m, bc))) {
                break;
            }
        }
    }
}
Also used : IOFMessageListener(net.floodlightcontroller.core.IOFMessageListener) FloodlightContext(net.floodlightcontroller.core.FloodlightContext)

Aggregations

IOFMessageListener (net.floodlightcontroller.core.IOFMessageListener)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)1 IControllerCompletionListener (net.floodlightcontroller.core.IControllerCompletionListener)1 Command (net.floodlightcontroller.core.IListener.Command)1 ListenerDispatcher (net.floodlightcontroller.core.util.ListenerDispatcher)1 Ethernet (net.floodlightcontroller.packet.Ethernet)1 OFPacketIn (org.projectfloodlight.openflow.protocol.OFPacketIn)1 OFType (org.projectfloodlight.openflow.protocol.OFType)1