role assertion failure is returned to DeviceProvider
Change-Id: Ic5189327c85fa37b3bbfa07d0e285cabae363712
Showing
13 changed files
with
82 additions
and
3 deletions
... | @@ -233,6 +233,8 @@ public class DeviceManager | ... | @@ -233,6 +233,8 @@ public class DeviceManager |
233 | @Override | 233 | @Override |
234 | public void unableToAssertRole(DeviceId deviceId, MastershipRole role) { | 234 | public void unableToAssertRole(DeviceId deviceId, MastershipRole role) { |
235 | // FIXME: implement response to this notification | 235 | // FIXME: implement response to this notification |
236 | + log.warn("Falied to assert role [{}] onto Device {}", | ||
237 | + role, deviceId); | ||
236 | } | 238 | } |
237 | } | 239 | } |
238 | 240 | ... | ... |
... | @@ -11,7 +11,6 @@ import org.onlab.onos.net.DefaultDevice; | ... | @@ -11,7 +11,6 @@ import org.onlab.onos.net.DefaultDevice; |
11 | import org.onlab.onos.net.DefaultPort; | 11 | import org.onlab.onos.net.DefaultPort; |
12 | import org.onlab.onos.net.Device; | 12 | import org.onlab.onos.net.Device; |
13 | import org.onlab.onos.net.DeviceId; | 13 | import org.onlab.onos.net.DeviceId; |
14 | -import org.onlab.onos.net.MastershipRole; | ||
15 | import org.onlab.onos.net.Port; | 14 | import org.onlab.onos.net.Port; |
16 | import org.onlab.onos.net.PortNumber; | 15 | import org.onlab.onos.net.PortNumber; |
17 | import org.onlab.onos.net.device.DeviceDescription; | 16 | import org.onlab.onos.net.device.DeviceDescription; |
... | @@ -54,7 +53,6 @@ public class SimpleDeviceStore | ... | @@ -54,7 +53,6 @@ public class SimpleDeviceStore |
54 | public static final String DEVICE_NOT_FOUND = "Device with ID %s not found"; | 53 | public static final String DEVICE_NOT_FOUND = "Device with ID %s not found"; |
55 | 54 | ||
56 | private final Map<DeviceId, DefaultDevice> devices = new ConcurrentHashMap<>(); | 55 | private final Map<DeviceId, DefaultDevice> devices = new ConcurrentHashMap<>(); |
57 | - private final Map<DeviceId, MastershipRole> roles = new ConcurrentHashMap<>(); | ||
58 | private final Set<DeviceId> availableDevices = new HashSet<>(); | 56 | private final Set<DeviceId> availableDevices = new HashSet<>(); |
59 | private final Map<DeviceId, Map<PortNumber, Port>> devicePorts = new HashMap<>(); | 57 | private final Map<DeviceId, Map<PortNumber, Port>> devicePorts = new HashMap<>(); |
60 | 58 | ||
... | @@ -257,7 +255,6 @@ public class SimpleDeviceStore | ... | @@ -257,7 +255,6 @@ public class SimpleDeviceStore |
257 | @Override | 255 | @Override |
258 | public DeviceEvent removeDevice(DeviceId deviceId) { | 256 | public DeviceEvent removeDevice(DeviceId deviceId) { |
259 | synchronized (this) { | 257 | synchronized (this) { |
260 | - roles.remove(deviceId); | ||
261 | Device device = devices.remove(deviceId); | 258 | Device device = devices.remove(deviceId); |
262 | return device == null ? null : | 259 | return device == null ? null : |
263 | new DeviceEvent(DEVICE_REMOVED, device, null); | 260 | new DeviceEvent(DEVICE_REMOVED, device, null); | ... | ... |
... | @@ -105,4 +105,11 @@ public interface OpenFlowSwitch { | ... | @@ -105,4 +105,11 @@ public interface OpenFlowSwitch { |
105 | */ | 105 | */ |
106 | public void disconnectSwitch(); | 106 | public void disconnectSwitch(); |
107 | 107 | ||
108 | + /** | ||
109 | + * Notifies the controller that role assertion has failed. | ||
110 | + * | ||
111 | + * @param role the failed role | ||
112 | + */ | ||
113 | + void returnRoleAssertFailure(RoleState role); | ||
114 | + | ||
108 | } | 115 | } | ... | ... |
... | @@ -25,4 +25,12 @@ public interface OpenFlowSwitchListener { | ... | @@ -25,4 +25,12 @@ public interface OpenFlowSwitchListener { |
25 | * @param status the new state of the port. | 25 | * @param status the new state of the port. |
26 | */ | 26 | */ |
27 | public void portChanged(Dpid dpid, OFPortStatus status); | 27 | public void portChanged(Dpid dpid, OFPortStatus status); |
28 | + | ||
29 | + /** | ||
30 | + * Notify that a role imposed on a switch failed to take hold. | ||
31 | + * | ||
32 | + * @param dpid the switch that failed role assertion | ||
33 | + * @param role the role imposed by the controller | ||
34 | + */ | ||
35 | + public void roleAssertFailed(Dpid dpid, RoleState role); | ||
28 | } | 36 | } | ... | ... |
... | @@ -213,6 +213,11 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { | ... | @@ -213,6 +213,11 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { |
213 | } | 213 | } |
214 | 214 | ||
215 | @Override | 215 | @Override |
216 | + public void returnRoleAssertFailure(RoleState role) { | ||
217 | + this.agent.returnRoleAssertFailed(dpid, role); | ||
218 | + } | ||
219 | + | ||
220 | + @Override | ||
216 | public abstract void startDriverHandshake(); | 221 | public abstract void startDriverHandshake(); |
217 | 222 | ||
218 | @Override | 223 | @Override | ... | ... |
... | @@ -2,6 +2,7 @@ package org.onlab.onos.openflow.controller.driver; | ... | @@ -2,6 +2,7 @@ package org.onlab.onos.openflow.controller.driver; |
2 | 2 | ||
3 | import org.onlab.onos.openflow.controller.Dpid; | 3 | import org.onlab.onos.openflow.controller.Dpid; |
4 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; | 4 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
5 | +import org.onlab.onos.openflow.controller.RoleState; | ||
5 | import org.projectfloodlight.openflow.protocol.OFMessage; | 6 | import org.projectfloodlight.openflow.protocol.OFMessage; |
6 | 7 | ||
7 | /** | 8 | /** |
... | @@ -74,4 +75,12 @@ public interface OpenFlowAgent { | ... | @@ -74,4 +75,12 @@ public interface OpenFlowAgent { |
74 | * @param m the message to process | 75 | * @param m the message to process |
75 | */ | 76 | */ |
76 | public void processMessage(Dpid dpid, OFMessage m); | 77 | public void processMessage(Dpid dpid, OFMessage m); |
78 | + | ||
79 | + /** | ||
80 | + * Notifies the controller that role assertion has failed. | ||
81 | + * | ||
82 | + * @param dpid the switch that failed role assertion | ||
83 | + * @param role the failed role | ||
84 | + */ | ||
85 | + public void returnRoleAssertFailed(Dpid dpid, RoleState role); | ||
77 | } | 86 | } | ... | ... |
... | @@ -313,6 +313,13 @@ public class OpenFlowControllerImpl implements OpenFlowController { | ... | @@ -313,6 +313,13 @@ public class OpenFlowControllerImpl implements OpenFlowController { |
313 | public void processMessage(Dpid dpid, OFMessage m) { | 313 | public void processMessage(Dpid dpid, OFMessage m) { |
314 | processPacket(dpid, m); | 314 | processPacket(dpid, m); |
315 | } | 315 | } |
316 | + | ||
317 | + @Override | ||
318 | + public void returnRoleAssertFailed(Dpid dpid, RoleState role) { | ||
319 | + for (OpenFlowSwitchListener l : ofSwitchListener) { | ||
320 | + l.roleAssertFailed(dpid, role); | ||
321 | + } | ||
322 | + } | ||
316 | } | 323 | } |
317 | 324 | ||
318 | private final class OFMessageHandler implements Runnable { | 325 | private final class OFMessageHandler implements Runnable { | ... | ... |
... | @@ -232,6 +232,8 @@ class RoleManager implements RoleHandler { | ... | @@ -232,6 +232,8 @@ class RoleManager implements RoleHandler { |
232 | } else { | 232 | } else { |
233 | return RoleRecvStatus.OTHER_EXPECTATION; | 233 | return RoleRecvStatus.OTHER_EXPECTATION; |
234 | } | 234 | } |
235 | + } else { | ||
236 | + sw.returnRoleAssertFailure(pendingRole); | ||
235 | } | 237 | } |
236 | 238 | ||
237 | // if xids match but role's don't, perhaps its a query (OF1.3) | 239 | // if xids match but role's don't, perhaps its a query (OF1.3) | ... | ... |
... | @@ -142,6 +142,26 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -142,6 +142,26 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
142 | providerService.portStatusChanged(deviceId(uri(dpid)), portDescription); | 142 | providerService.portStatusChanged(deviceId(uri(dpid)), portDescription); |
143 | } | 143 | } |
144 | 144 | ||
145 | + @Override | ||
146 | + public void roleAssertFailed(Dpid dpid, RoleState role) { | ||
147 | + MastershipRole failed; | ||
148 | + switch (role) { | ||
149 | + case MASTER: | ||
150 | + failed = MastershipRole.MASTER; | ||
151 | + break; | ||
152 | + case EQUAL: | ||
153 | + failed = MastershipRole.STANDBY; | ||
154 | + break; | ||
155 | + case SLAVE: | ||
156 | + failed = MastershipRole.NONE; | ||
157 | + break; | ||
158 | + default: | ||
159 | + LOG.warn("unknown role {}", role); | ||
160 | + return; | ||
161 | + } | ||
162 | + providerService.unableToAssertRole(deviceId(uri(dpid)), failed); | ||
163 | + } | ||
164 | + | ||
145 | /** | 165 | /** |
146 | * Builds a list of port descriptions for a given list of ports. | 166 | * Builds a list of port descriptions for a given list of ports. |
147 | * | 167 | * |
... | @@ -169,6 +189,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -169,6 +189,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
169 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); | 189 | !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
170 | return new DefaultPortDescription(portNo, enabled); | 190 | return new DefaultPortDescription(portNo, enabled); |
171 | } | 191 | } |
192 | + | ||
172 | } | 193 | } |
173 | 194 | ||
174 | } | 195 | } | ... | ... |
... | @@ -344,6 +344,10 @@ public class OpenFlowDeviceProviderTest { | ... | @@ -344,6 +344,10 @@ public class OpenFlowDeviceProviderTest { |
344 | public void disconnectSwitch() { | 344 | public void disconnectSwitch() { |
345 | } | 345 | } |
346 | 346 | ||
347 | + @Override | ||
348 | + public void returnRoleAssertFailure(RoleState role) { | ||
349 | + } | ||
350 | + | ||
347 | } | 351 | } |
348 | 352 | ||
349 | } | 353 | } | ... | ... |
providers/openflow/flow/src/main/java/org/onlab/onos/provider/of/flow/impl/OpenFlowRuleProvider.java
... | @@ -23,6 +23,7 @@ import org.onlab.onos.openflow.controller.OpenFlowController; | ... | @@ -23,6 +23,7 @@ import org.onlab.onos.openflow.controller.OpenFlowController; |
23 | import org.onlab.onos.openflow.controller.OpenFlowEventListener; | 23 | import org.onlab.onos.openflow.controller.OpenFlowEventListener; |
24 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; | 24 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
25 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; | 25 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; |
26 | +import org.onlab.onos.openflow.controller.RoleState; | ||
26 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; | 27 | import org.projectfloodlight.openflow.protocol.OFFlowRemoved; |
27 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; | 28 | import org.projectfloodlight.openflow.protocol.OFFlowStatsEntry; |
28 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; | 29 | import org.projectfloodlight.openflow.protocol.OFFlowStatsReply; |
... | @@ -162,6 +163,12 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr | ... | @@ -162,6 +163,12 @@ public class OpenFlowRuleProvider extends AbstractProvider implements FlowRulePr |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
166 | + @Override | ||
167 | + public void roleAssertFailed(Dpid dpid, RoleState role) { | ||
168 | + // TODO Auto-generated method stub | ||
169 | + | ||
170 | + } | ||
171 | + | ||
165 | private synchronized void pushFlowMetrics(Dpid dpid, OFStatsReply stats) { | 172 | private synchronized void pushFlowMetrics(Dpid dpid, OFStatsReply stats) { |
166 | if (stats.getStatsType() != OFStatsType.FLOW) { | 173 | if (stats.getStatsType() != OFStatsType.FLOW) { |
167 | return; | 174 | return; | ... | ... |
providers/openflow/link/src/main/java/org/onlab/onos/provider/of/link/impl/OpenFlowLinkProvider.java
... | @@ -22,6 +22,7 @@ import org.onlab.onos.openflow.controller.OpenFlowPacketContext; | ... | @@ -22,6 +22,7 @@ import org.onlab.onos.openflow.controller.OpenFlowPacketContext; |
22 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; | 22 | import org.onlab.onos.openflow.controller.OpenFlowSwitch; |
23 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; | 23 | import org.onlab.onos.openflow.controller.OpenFlowSwitchListener; |
24 | import org.onlab.onos.openflow.controller.PacketListener; | 24 | import org.onlab.onos.openflow.controller.PacketListener; |
25 | +import org.onlab.onos.openflow.controller.RoleState; | ||
25 | import org.projectfloodlight.openflow.protocol.OFPortConfig; | 26 | import org.projectfloodlight.openflow.protocol.OFPortConfig; |
26 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 27 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
27 | import org.projectfloodlight.openflow.protocol.OFPortState; | 28 | import org.projectfloodlight.openflow.protocol.OFPortState; |
... | @@ -135,6 +136,11 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid | ... | @@ -135,6 +136,11 @@ public class OpenFlowLinkProvider extends AbstractProvider implements LinkProvid |
135 | 136 | ||
136 | } | 137 | } |
137 | 138 | ||
139 | + @Override | ||
140 | + public void roleAssertFailed(Dpid dpid, RoleState role) { | ||
141 | + // TODO Auto-generated method stub | ||
142 | + } | ||
143 | + | ||
138 | } | 144 | } |
139 | 145 | ||
140 | } | 146 | } | ... | ... |
... | @@ -394,6 +394,10 @@ public class OpenFlowPacketProviderTest { | ... | @@ -394,6 +394,10 @@ public class OpenFlowPacketProviderTest { |
394 | public void disconnectSwitch() { | 394 | public void disconnectSwitch() { |
395 | } | 395 | } |
396 | 396 | ||
397 | + @Override | ||
398 | + public void returnRoleAssertFailure(RoleState role) { | ||
399 | + } | ||
400 | + | ||
397 | } | 401 | } |
398 | 402 | ||
399 | } | 403 | } | ... | ... |
-
Please register or login to post a comment