Reference Guide

Table Of Contents
}
}
Notification on Region and Role changes
Applications can express interest in region change notifications using the addListener(...) API in
RegionService and providing an implementation of the RegionListener. A sample listener
implementation is illustrated in the following listing:
Region Listener Example:
import com.hp.sdn.adm.region.RegionListener;
import com.hp.sdn.region.Region;
...
public class RegionListenerImpl implements RegionListener {
...
@Override
public void added(Region region) {
log.debug(“Master of new region: {}”, region.master());
}
@Override
public void removed(Region region) {
log.debug(“Master of removed region: {}”, region.master());
}
}
Similarly applications can express interest in role change notifications using the addListener(...) API
in RoleService and providing an implementation of the RoleListener. A sample listener
implementation is illustrated in the following listing:
Role Listener Example:
import com.hp.sdn.adm.role.RoleEvent;
import com.hp.sdn.adm.role.RoleListener;
...
public class RoleListenerImpl implements RoleListener {
...
@Override
public void rolesAsserted(RoleEvent roleEvent) {
log.debug(“Previous master: {}”, roleEvent.oldMaster());
log.debug(“New master: {}”, roleEvent.newMaster());
log.debug(“Affected datapaths: {}”, roleEvent.datapaths());
}
}
OpenFlow
OpenFlow messages are sent and received between the controller and the switches (datapaths) it
manages. These messages are byte streams, the structure of which is documented in the OpenFlow
Protocol Specification documents published by the Open Networking Foundation (ONF) [28].
26