Reference Guide

Table Of Contents
MessageListenerTo receive events about OpenFlow messages received by the controller
from connected datapaths.
SequencedPacketListenerTo participate in the processing of Packet-In messages
FlowListenerTo receive events about flow.
DataPathListener will be used to monitor connections and thus translate connected devices to
reachable devices. Even though just DataPathListener will be shown here, using the other listeners
is a matter of creating a variation of what is shown.
The following listings illustrate an extract of the implementation of SwitchManager and
SwitchComponent consuming the ControllerService to monitor datapath connections.
SwitchManager.java Subscribing a DataPathListener to the ControllerService:
package com.hp.hm.impl;
import com.hp.of.ctl.ControllerService;
import com.hp.of.ctl.DataPathEvent;
import com.hp.of.ctl.DataPathListener;
import com.hp.of.ctl.OpenflowEventType;
import com.hp.of.ctl.QueueEvent;
import com.hp.of.lib.dt.DataPathInfo;
...
public class SwitchManager implements SwitchService {
...
private DataPathListener dataPathListener;
public SwitchManager(SystemInformationService systemInformationService) {
...
dataPathListener = new DataPathListenerImpl();
}
...
@Override
public List<Switch> find(SwitchFilter filter,
SortSpecification<SwitchSortKey> sortSpecification) {
// In a real application a database may be used: filter would be
// mapped to predicates and sortSpecification to sorting clauses.
List<Switch> switches = new ArrayList<Switch>(devices.values());
// At this point just the MAC Address filter is used so a temporal
// implementation is also used (NOTE: This is not a proper way of
// implementing filtering).
// -----
if (filter != null && filter.getMacAddressCondition() != null) {
List<Switch> toDelete = new ArrayList<Switch>();
MacAddress filterMacAddress = filter.getMacAddressCondition()
.getValue();
222