Ayaka Koshibe

implement DeviceProvider triggerProbe() to call after mastership change

Change-Id: I65002296189e6a499ef353255a016b013eb24020
...@@ -20,6 +20,12 @@ public interface OpenFlowSwitchListener { ...@@ -20,6 +20,12 @@ public interface OpenFlowSwitchListener {
20 public void switchRemoved(Dpid dpid); 20 public void switchRemoved(Dpid dpid);
21 21
22 /** 22 /**
23 + * Notify that the switch has changed in some way.
24 + * @param dpid the switch that changed
25 + */
26 + public void switchChanged(Dpid dpid);
27 +
28 + /**
23 * Notify that a port has changed. 29 * Notify that a port has changed.
24 * @param dpid the switch on which the change happened. 30 * @param dpid the switch on which the change happened.
25 * @param status the new state of the port. 31 * @param status the new state of the port.
......
...@@ -565,6 +565,9 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -565,6 +565,9 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
565 @Override 565 @Override
566 void processOFStatisticsReply(OFChannelHandler h, 566 void processOFStatisticsReply(OFChannelHandler h,
567 OFStatsReply m) { 567 OFStatsReply m) {
568 + if (m.getStatsType().equals(OFStatsType.PORT_DESC)) {
569 + h.sw.setPortDescReply((OFPortDescStatsReply) m);
570 + }
568 h.dispatchMessage(m); 571 h.dispatchMessage(m);
569 } 572 }
570 573
...@@ -610,7 +613,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -610,7 +613,7 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
610 613
611 @Override 614 @Override
612 void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m) { 615 void processOFFeaturesReply(OFChannelHandler h, OFFeaturesReply m) {
613 - // TODO verify this leads to right behavior. 616 + h.sw.setFeaturesReply(m);
614 h.dispatchMessage(m); 617 h.dispatchMessage(m);
615 } 618 }
616 619
......
...@@ -27,6 +27,8 @@ import org.onlab.onos.openflow.controller.driver.OpenFlowAgent; ...@@ -27,6 +27,8 @@ import org.onlab.onos.openflow.controller.driver.OpenFlowAgent;
27 import org.projectfloodlight.openflow.protocol.OFMessage; 27 import org.projectfloodlight.openflow.protocol.OFMessage;
28 import org.projectfloodlight.openflow.protocol.OFPacketIn; 28 import org.projectfloodlight.openflow.protocol.OFPacketIn;
29 import org.projectfloodlight.openflow.protocol.OFPortStatus; 29 import org.projectfloodlight.openflow.protocol.OFPortStatus;
30 +import org.projectfloodlight.openflow.protocol.OFStatsReply;
31 +import org.projectfloodlight.openflow.protocol.OFStatsType;
30 import org.slf4j.Logger; 32 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory; 33 import org.slf4j.LoggerFactory;
32 34
...@@ -142,11 +144,15 @@ public class OpenFlowControllerImpl implements OpenFlowController { ...@@ -142,11 +144,15 @@ public class OpenFlowControllerImpl implements OpenFlowController {
142 public void processPacket(Dpid dpid, OFMessage msg) { 144 public void processPacket(Dpid dpid, OFMessage msg) {
143 switch (msg.getType()) { 145 switch (msg.getType()) {
144 case PORT_STATUS: 146 case PORT_STATUS:
145 - case FEATURES_REPLY:
146 for (OpenFlowSwitchListener l : ofSwitchListener) { 147 for (OpenFlowSwitchListener l : ofSwitchListener) {
147 l.portChanged(dpid, (OFPortStatus) msg); 148 l.portChanged(dpid, (OFPortStatus) msg);
148 } 149 }
149 break; 150 break;
151 + case FEATURES_REPLY:
152 + for (OpenFlowSwitchListener l : ofSwitchListener) {
153 + l.switchChanged(dpid);
154 + }
155 + break;
150 case PACKET_IN: 156 case PACKET_IN:
151 OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext 157 OpenFlowPacketContext pktCtx = DefaultOpenFlowPacketContext
152 .packetContextFromPacketIn(this.getSwitch(dpid), 158 .packetContextFromPacketIn(this.getSwitch(dpid),
...@@ -155,9 +161,15 @@ public class OpenFlowControllerImpl implements OpenFlowController { ...@@ -155,9 +161,15 @@ public class OpenFlowControllerImpl implements OpenFlowController {
155 p.handlePacket(pktCtx); 161 p.handlePacket(pktCtx);
156 } 162 }
157 break; 163 break;
164 + case STATS_REPLY:
165 + OFStatsReply reply = (OFStatsReply) msg;
166 + if (reply.getStatsType().equals(OFStatsType.PORT_DESC)) {
167 + for (OpenFlowSwitchListener l : ofSwitchListener) {
168 + l.switchChanged(dpid);
169 + }
170 + }
158 case FLOW_REMOVED: 171 case FLOW_REMOVED:
159 case ERROR: 172 case ERROR:
160 - case STATS_REPLY:
161 case BARRIER_REPLY: 173 case BARRIER_REPLY:
162 executor.submit(new OFMessageHandler(dpid, msg)); 174 executor.submit(new OFMessageHandler(dpid, msg));
163 break; 175 break;
......
...@@ -165,6 +165,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -165,6 +165,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
165 providerService.deviceDisconnected(deviceId(uri(dpid))); 165 providerService.deviceDisconnected(deviceId(uri(dpid)));
166 } 166 }
167 167
168 +
169 + @Override
170 + public void switchChanged(Dpid dpid) {
171 + if (providerService == null) {
172 + return;
173 + }
174 + DeviceId did = deviceId(uri(dpid));
175 + OpenFlowSwitch sw = controller.getSwitch(dpid);
176 + providerService.updatePorts(did, buildPortDescriptions(sw.getPorts()));
177 + }
178 +
168 @Override 179 @Override
169 public void portChanged(Dpid dpid, OFPortStatus status) { 180 public void portChanged(Dpid dpid, OFPortStatus status) {
170 PortDescription portDescription = buildPortDescription(status.getDesc()); 181 PortDescription portDescription = buildPortDescription(status.getDesc());
......
...@@ -233,6 +233,10 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -233,6 +233,10 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
233 } 233 }
234 234
235 @Override 235 @Override
236 + public void switchChanged(Dpid dpid) {
237 + }
238 +
239 + @Override
236 public void portChanged(Dpid dpid, OFPortStatus status) { 240 public void portChanged(Dpid dpid, OFPortStatus status) {
237 //TODO: Decide whether to evict flows internal store. 241 //TODO: Decide whether to evict flows internal store.
238 } 242 }
...@@ -313,6 +317,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr ...@@ -313,6 +317,7 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr
313 } 317 }
314 return false; 318 return false;
315 } 319 }
320 +
316 } 321 }
317 322
318 private class InstallationFuture implements Future<CompletedBatchOperation> { 323 private class InstallationFuture implements Future<CompletedBatchOperation> {
......
...@@ -118,6 +118,12 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid ...@@ -118,6 +118,12 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid
118 DeviceId.deviceId("of:" + Long.toHexString(dpid.value()))); 118 DeviceId.deviceId("of:" + Long.toHexString(dpid.value())));
119 } 119 }
120 120
121 +
122 + @Override
123 + public void switchChanged(Dpid dpid) {
124 + //might not need to do anything since DeviceManager is notified
125 + }
126 +
121 @Override 127 @Override
122 public void portChanged(Dpid dpid, OFPortStatus status) { 128 public void portChanged(Dpid dpid, OFPortStatus status) {
123 LinkDiscovery ld = discoverers.get(dpid); 129 LinkDiscovery ld = discoverers.get(dpid);
......