Ayaka Koshibe

implement DeviceProvider triggerProbe() to call after mastership change

Change-Id: I65002296189e6a499ef353255a016b013eb24020
......@@ -20,6 +20,12 @@ public interface OpenFlowSwitchListener {
public void switchRemoved(Dpid dpid);
/**
* Notify that the switch has changed in some way.
* @param dpid the switch that changed
*/
public void switchChanged(Dpid dpid);
/**
* Notify that a port has changed.
* @param dpid the switch on which the change happened.
* @param status the new state of the port.
......
......@@ -565,6 +565,9 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
@Override
void processOFStatisticsReply(OFChannelHandler h,
OFStatsReply m) {
if (m.getStatsType().equals(OFStatsType.PORT_DESC)) {
h.sw.setPortDescReply((OFPortDescStatsReply) m);
}
h.dispatchMessage(m);
}
......@@ -610,7 +613,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
@Override
void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m) {
// TODO verify this leads to right behavior.
h.sw.setFeaturesReply(m);
h.dispatchMessage(m);
}
......
......@@ -27,6 +27,8 @@ import org.onlab.onos.openflow.controller.driver.OpenFlowAgent;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.protocol.OFPacketIn;
import org.projectfloodlight.openflow.protocol.OFPortStatus;
import org.projectfloodlight.openflow.protocol.OFStatsReply;
import org.projectfloodlight.openflow.protocol.OFStatsType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -142,11 +144,15 @@ public class OpenFlowControllerImpl implements OpenFlowController {
public void processPacket(Dpid dpid, OFMessage msg) {
switch (msg.getType()) {
case PORT_STATUS:
case FEATURES_REPLY:
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.portChanged(dpid, (OFPortStatus) msg);
}
break;
case FEATURES_REPLY:
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.switchChanged(dpid);
}
break;
case PACKET_IN:
OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext
.packetContextFromPacketIn(this.getSwitch(dpid),
......@@ -155,9 +161,15 @@ public class OpenFlowControllerImpl implements OpenFlowController {
p.handlePacket(pktCtx);
}
break;
case STATS_REPLY:
OFStatsReply reply = (OFStatsReply) msg;
if (reply.getStatsType().equals(OFStatsType.PORT_DESC)) {
for (OpenFlowSwitchListener l : ofSwitchListener) {
l.switchChanged(dpid);
}
}
case FLOW_REMOVED:
case ERROR:
case STATS_REPLY:
case BARRIER_REPLY:
executor.submit(new OFMessageHandler(dpid, msg));
break;
......
......@@ -165,6 +165,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
providerService.deviceDisconnected(deviceId(uri(dpid)));
}
@Override
public void switchChanged(Dpid dpid) {
if (providerService == null) {
return;
}
DeviceId did = deviceId(uri(dpid));
OpenFlowSwitch sw = controller.getSwitch(dpid);
providerService.updatePorts(did, buildPortDescriptions(sw.getPorts()));
}
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
PortDescription portDescription = buildPortDescription(status.getDesc());
......
......@@ -233,6 +233,10 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
}
@Override
public void switchChanged(Dpid dpid) {
}
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
//TODO: Decide whether to evict flows internal store.
}
......@@ -313,6 +317,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
}
return false;
}
}
private class InstallationFuture implements Future<CompletedBatchOperation> {
......
......@@ -118,6 +118,12 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
DeviceId.deviceId("of:" + Long.toHexString(dpid.value())));
}
@Override
public void switchChanged(Dpid dpid) {
//might not need to do anything since DeviceManager is notified
}
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
LinkDiscovery ld = discoverers.get(dpid);
......