Showing
7 changed files
with
30 additions
and
26 deletions
... | @@ -48,6 +48,7 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { | ... | @@ -48,6 +48,7 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { |
48 | DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, | 48 | DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId, |
49 | DeviceDescription deviceDescription); | 49 | DeviceDescription deviceDescription); |
50 | 50 | ||
51 | + // TODO: We may need to enforce that ancillary cannot interfere this state | ||
51 | /** | 52 | /** |
52 | * Removes the specified infrastructure device. | 53 | * Removes the specified infrastructure device. |
53 | * | 54 | * |
... | @@ -60,22 +61,24 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { | ... | @@ -60,22 +61,24 @@ public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> { |
60 | * Updates the ports of the specified infrastructure device using the given | 61 | * Updates the ports of the specified infrastructure device using the given |
61 | * list of port descriptions. The list is assumed to be comprehensive. | 62 | * list of port descriptions. The list is assumed to be comprehensive. |
62 | * | 63 | * |
64 | + * @param providerId provider identifier | ||
63 | * @param deviceId device identifier | 65 | * @param deviceId device identifier |
64 | * @param portDescriptions list of port descriptions | 66 | * @param portDescriptions list of port descriptions |
65 | * @return ready to send events describing what occurred; empty list if no change | 67 | * @return ready to send events describing what occurred; empty list if no change |
66 | */ | 68 | */ |
67 | - List<DeviceEvent> updatePorts(DeviceId deviceId, | 69 | + List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
68 | List<PortDescription> portDescriptions); | 70 | List<PortDescription> portDescriptions); |
69 | 71 | ||
70 | /** | 72 | /** |
71 | * Updates the port status of the specified infrastructure device using the | 73 | * Updates the port status of the specified infrastructure device using the |
72 | * given port description. | 74 | * given port description. |
73 | * | 75 | * |
76 | + * @param providerId provider identifier | ||
74 | * @param deviceId device identifier | 77 | * @param deviceId device identifier |
75 | * @param portDescription port description | 78 | * @param portDescription port description |
76 | * @return ready to send event describing what occurred; null if no change | 79 | * @return ready to send event describing what occurred; null if no change |
77 | */ | 80 | */ |
78 | - DeviceEvent updatePortStatus(DeviceId deviceId, | 81 | + DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
79 | PortDescription portDescription); | 82 | PortDescription portDescription); |
80 | 83 | ||
81 | /** | 84 | /** | ... | ... |
... | @@ -228,8 +228,9 @@ public class DeviceManager | ... | @@ -228,8 +228,9 @@ public class DeviceManager |
228 | checkNotNull(portDescriptions, | 228 | checkNotNull(portDescriptions, |
229 | "Port descriptions list cannot be null"); | 229 | "Port descriptions list cannot be null"); |
230 | checkValidity(); | 230 | checkValidity(); |
231 | - List<DeviceEvent> events = store.updatePorts(deviceId, | 231 | + this.provider().id(); |
232 | - portDescriptions); | 232 | + List<DeviceEvent> events = store.updatePorts(this.provider().id(), |
233 | + deviceId, portDescriptions); | ||
233 | for (DeviceEvent event : events) { | 234 | for (DeviceEvent event : events) { |
234 | post(event); | 235 | post(event); |
235 | } | 236 | } |
... | @@ -241,8 +242,8 @@ public class DeviceManager | ... | @@ -241,8 +242,8 @@ public class DeviceManager |
241 | checkNotNull(deviceId, DEVICE_ID_NULL); | 242 | checkNotNull(deviceId, DEVICE_ID_NULL); |
242 | checkNotNull(portDescription, PORT_DESCRIPTION_NULL); | 243 | checkNotNull(portDescription, PORT_DESCRIPTION_NULL); |
243 | checkValidity(); | 244 | checkValidity(); |
244 | - DeviceEvent event = store.updatePortStatus(deviceId, | 245 | + DeviceEvent event = store.updatePortStatus(this.provider().id(), |
245 | - portDescription); | 246 | + deviceId, portDescription); |
246 | if (event != null) { | 247 | if (event != null) { |
247 | log.info("Device {} port {} status changed", deviceId, event | 248 | log.info("Device {} port {} status changed", deviceId, event |
248 | .port().number()); | 249 | .port().number()); | ... | ... |
... | @@ -192,7 +192,7 @@ public class OnosDistributedDeviceStore | ... | @@ -192,7 +192,7 @@ public class OnosDistributedDeviceStore |
192 | } | 192 | } |
193 | 193 | ||
194 | @Override | 194 | @Override |
195 | - public List<DeviceEvent> updatePorts(DeviceId deviceId, | 195 | + public List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
196 | List<PortDescription> portDescriptions) { | 196 | List<PortDescription> portDescriptions) { |
197 | List<DeviceEvent> events = new ArrayList<>(); | 197 | List<DeviceEvent> events = new ArrayList<>(); |
198 | synchronized (this) { | 198 | synchronized (this) { |
... | @@ -296,7 +296,7 @@ public class OnosDistributedDeviceStore | ... | @@ -296,7 +296,7 @@ public class OnosDistributedDeviceStore |
296 | } | 296 | } |
297 | 297 | ||
298 | @Override | 298 | @Override |
299 | - public DeviceEvent updatePortStatus(DeviceId deviceId, | 299 | + public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
300 | PortDescription portDescription) { | 300 | PortDescription portDescription) { |
301 | VersionedValue<Device> device = devices.get(deviceId); | 301 | VersionedValue<Device> device = devices.get(deviceId); |
302 | checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); | 302 | checkArgument(device != null, DEVICE_NOT_FOUND, deviceId); | ... | ... |
... | @@ -221,7 +221,7 @@ public class DistributedDeviceStore | ... | @@ -221,7 +221,7 @@ public class DistributedDeviceStore |
221 | } | 221 | } |
222 | 222 | ||
223 | @Override | 223 | @Override |
224 | - public List<DeviceEvent> updatePorts(DeviceId deviceId, | 224 | + public List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
225 | List<PortDescription> portDescriptions) { | 225 | List<PortDescription> portDescriptions) { |
226 | List<DeviceEvent> events = new ArrayList<>(); | 226 | List<DeviceEvent> events = new ArrayList<>(); |
227 | synchronized (this) { | 227 | synchronized (this) { |
... | @@ -319,7 +319,7 @@ public class DistributedDeviceStore | ... | @@ -319,7 +319,7 @@ public class DistributedDeviceStore |
319 | } | 319 | } |
320 | 320 | ||
321 | @Override | 321 | @Override |
322 | - public DeviceEvent updatePortStatus(DeviceId deviceId, | 322 | + public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
323 | PortDescription portDescription) { | 323 | PortDescription portDescription) { |
324 | synchronized (this) { | 324 | synchronized (this) { |
325 | Device device = devices.getUnchecked(deviceId).orNull(); | 325 | Device device = devices.getUnchecked(deviceId).orNull(); | ... | ... |
... | @@ -201,7 +201,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -201,7 +201,7 @@ public class DistributedDeviceStoreTest { |
201 | new DefaultPortDescription(P2, true) | 201 | new DefaultPortDescription(P2, true) |
202 | ); | 202 | ); |
203 | 203 | ||
204 | - List<DeviceEvent> events = deviceStore.updatePorts(DID1, pds); | 204 | + List<DeviceEvent> events = deviceStore.updatePorts(PID, DID1, pds); |
205 | 205 | ||
206 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); | 206 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
207 | for (DeviceEvent event : events) { | 207 | for (DeviceEvent event : events) { |
... | @@ -220,7 +220,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -220,7 +220,7 @@ public class DistributedDeviceStoreTest { |
220 | new DefaultPortDescription(P3, true) | 220 | new DefaultPortDescription(P3, true) |
221 | ); | 221 | ); |
222 | 222 | ||
223 | - events = deviceStore.updatePorts(DID1, pds2); | 223 | + events = deviceStore.updatePorts(PID, DID1, pds2); |
224 | assertFalse("event should be triggered", events.isEmpty()); | 224 | assertFalse("event should be triggered", events.isEmpty()); |
225 | for (DeviceEvent event : events) { | 225 | for (DeviceEvent event : events) { |
226 | PortNumber num = event.port().number(); | 226 | PortNumber num = event.port().number(); |
... | @@ -243,7 +243,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -243,7 +243,7 @@ public class DistributedDeviceStoreTest { |
243 | new DefaultPortDescription(P1, false), | 243 | new DefaultPortDescription(P1, false), |
244 | new DefaultPortDescription(P2, true) | 244 | new DefaultPortDescription(P2, true) |
245 | ); | 245 | ); |
246 | - events = deviceStore.updatePorts(DID1, pds3); | 246 | + events = deviceStore.updatePorts(PID, DID1, pds3); |
247 | assertFalse("event should be triggered", events.isEmpty()); | 247 | assertFalse("event should be triggered", events.isEmpty()); |
248 | for (DeviceEvent event : events) { | 248 | for (DeviceEvent event : events) { |
249 | PortNumber num = event.port().number(); | 249 | PortNumber num = event.port().number(); |
... | @@ -268,9 +268,9 @@ public class DistributedDeviceStoreTest { | ... | @@ -268,9 +268,9 @@ public class DistributedDeviceStoreTest { |
268 | List<PortDescription> pds = Arrays.<PortDescription>asList( | 268 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
269 | new DefaultPortDescription(P1, true) | 269 | new DefaultPortDescription(P1, true) |
270 | ); | 270 | ); |
271 | - deviceStore.updatePorts(DID1, pds); | 271 | + deviceStore.updatePorts(PID, DID1, pds); |
272 | 272 | ||
273 | - DeviceEvent event = deviceStore.updatePortStatus(DID1, | 273 | + DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, |
274 | new DefaultPortDescription(P1, false)); | 274 | new DefaultPortDescription(P1, false)); |
275 | assertEquals(PORT_UPDATED, event.type()); | 275 | assertEquals(PORT_UPDATED, event.type()); |
276 | assertDevice(DID1, SW1, event.subject()); | 276 | assertDevice(DID1, SW1, event.subject()); |
... | @@ -286,7 +286,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -286,7 +286,7 @@ public class DistributedDeviceStoreTest { |
286 | new DefaultPortDescription(P1, true), | 286 | new DefaultPortDescription(P1, true), |
287 | new DefaultPortDescription(P2, true) | 287 | new DefaultPortDescription(P2, true) |
288 | ); | 288 | ); |
289 | - deviceStore.updatePorts(DID1, pds); | 289 | + deviceStore.updatePorts(PID, DID1, pds); |
290 | 290 | ||
291 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); | 291 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
292 | List<Port> ports = deviceStore.getPorts(DID1); | 292 | List<Port> ports = deviceStore.getPorts(DID1); |
... | @@ -309,7 +309,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -309,7 +309,7 @@ public class DistributedDeviceStoreTest { |
309 | new DefaultPortDescription(P1, true), | 309 | new DefaultPortDescription(P1, true), |
310 | new DefaultPortDescription(P2, false) | 310 | new DefaultPortDescription(P2, false) |
311 | ); | 311 | ); |
312 | - deviceStore.updatePorts(DID1, pds); | 312 | + deviceStore.updatePorts(PID, DID1, pds); |
313 | 313 | ||
314 | Port port1 = deviceStore.getPort(DID1, P1); | 314 | Port port1 = deviceStore.getPort(DID1, P1); |
315 | assertEquals(P1, port1.number()); | 315 | assertEquals(P1, port1.number()); | ... | ... |
... | @@ -143,7 +143,7 @@ public class SimpleDeviceStore | ... | @@ -143,7 +143,7 @@ public class SimpleDeviceStore |
143 | } | 143 | } |
144 | 144 | ||
145 | @Override | 145 | @Override |
146 | - public List<DeviceEvent> updatePorts(DeviceId deviceId, | 146 | + public List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId, |
147 | List<PortDescription> portDescriptions) { | 147 | List<PortDescription> portDescriptions) { |
148 | List<DeviceEvent> events = new ArrayList<>(); | 148 | List<DeviceEvent> events = new ArrayList<>(); |
149 | synchronized (this) { | 149 | synchronized (this) { |
... | @@ -221,7 +221,7 @@ public class SimpleDeviceStore | ... | @@ -221,7 +221,7 @@ public class SimpleDeviceStore |
221 | } | 221 | } |
222 | 222 | ||
223 | @Override | 223 | @Override |
224 | - public DeviceEvent updatePortStatus(DeviceId deviceId, | 224 | + public DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId, |
225 | PortDescription portDescription) { | 225 | PortDescription portDescription) { |
226 | synchronized (this) { | 226 | synchronized (this) { |
227 | Device device = devices.get(deviceId); | 227 | Device device = devices.get(deviceId); | ... | ... |
... | @@ -182,7 +182,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -182,7 +182,7 @@ public class SimpleDeviceStoreTest { |
182 | new DefaultPortDescription(P2, true) | 182 | new DefaultPortDescription(P2, true) |
183 | ); | 183 | ); |
184 | 184 | ||
185 | - List<DeviceEvent> events = deviceStore.updatePorts(DID1, pds); | 185 | + List<DeviceEvent> events = deviceStore.updatePorts(PID, DID1, pds); |
186 | 186 | ||
187 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); | 187 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
188 | for (DeviceEvent event : events) { | 188 | for (DeviceEvent event : events) { |
... | @@ -201,7 +201,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -201,7 +201,7 @@ public class SimpleDeviceStoreTest { |
201 | new DefaultPortDescription(P3, true) | 201 | new DefaultPortDescription(P3, true) |
202 | ); | 202 | ); |
203 | 203 | ||
204 | - events = deviceStore.updatePorts(DID1, pds2); | 204 | + events = deviceStore.updatePorts(PID, DID1, pds2); |
205 | assertFalse("event should be triggered", events.isEmpty()); | 205 | assertFalse("event should be triggered", events.isEmpty()); |
206 | for (DeviceEvent event : events) { | 206 | for (DeviceEvent event : events) { |
207 | PortNumber num = event.port().number(); | 207 | PortNumber num = event.port().number(); |
... | @@ -224,7 +224,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -224,7 +224,7 @@ public class SimpleDeviceStoreTest { |
224 | new DefaultPortDescription(P1, false), | 224 | new DefaultPortDescription(P1, false), |
225 | new DefaultPortDescription(P2, true) | 225 | new DefaultPortDescription(P2, true) |
226 | ); | 226 | ); |
227 | - events = deviceStore.updatePorts(DID1, pds3); | 227 | + events = deviceStore.updatePorts(PID, DID1, pds3); |
228 | assertFalse("event should be triggered", events.isEmpty()); | 228 | assertFalse("event should be triggered", events.isEmpty()); |
229 | for (DeviceEvent event : events) { | 229 | for (DeviceEvent event : events) { |
230 | PortNumber num = event.port().number(); | 230 | PortNumber num = event.port().number(); |
... | @@ -249,9 +249,9 @@ public class SimpleDeviceStoreTest { | ... | @@ -249,9 +249,9 @@ public class SimpleDeviceStoreTest { |
249 | List<PortDescription> pds = Arrays.<PortDescription>asList( | 249 | List<PortDescription> pds = Arrays.<PortDescription>asList( |
250 | new DefaultPortDescription(P1, true) | 250 | new DefaultPortDescription(P1, true) |
251 | ); | 251 | ); |
252 | - deviceStore.updatePorts(DID1, pds); | 252 | + deviceStore.updatePorts(PID, DID1, pds); |
253 | 253 | ||
254 | - DeviceEvent event = deviceStore.updatePortStatus(DID1, | 254 | + DeviceEvent event = deviceStore.updatePortStatus(PID, DID1, |
255 | new DefaultPortDescription(P1, false)); | 255 | new DefaultPortDescription(P1, false)); |
256 | assertEquals(PORT_UPDATED, event.type()); | 256 | assertEquals(PORT_UPDATED, event.type()); |
257 | assertDevice(DID1, SW1, event.subject()); | 257 | assertDevice(DID1, SW1, event.subject()); |
... | @@ -267,7 +267,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -267,7 +267,7 @@ public class SimpleDeviceStoreTest { |
267 | new DefaultPortDescription(P1, true), | 267 | new DefaultPortDescription(P1, true), |
268 | new DefaultPortDescription(P2, true) | 268 | new DefaultPortDescription(P2, true) |
269 | ); | 269 | ); |
270 | - deviceStore.updatePorts(DID1, pds); | 270 | + deviceStore.updatePorts(PID, DID1, pds); |
271 | 271 | ||
272 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); | 272 | Set<PortNumber> expectedPorts = Sets.newHashSet(P1, P2); |
273 | List<Port> ports = deviceStore.getPorts(DID1); | 273 | List<Port> ports = deviceStore.getPorts(DID1); |
... | @@ -290,7 +290,7 @@ public class SimpleDeviceStoreTest { | ... | @@ -290,7 +290,7 @@ public class SimpleDeviceStoreTest { |
290 | new DefaultPortDescription(P1, true), | 290 | new DefaultPortDescription(P1, true), |
291 | new DefaultPortDescription(P2, false) | 291 | new DefaultPortDescription(P2, false) |
292 | ); | 292 | ); |
293 | - deviceStore.updatePorts(DID1, pds); | 293 | + deviceStore.updatePorts(PID, DID1, pds); |
294 | 294 | ||
295 | Port port1 = deviceStore.getPort(DID1, P1); | 295 | Port port1 = deviceStore.getPort(DID1, P1); |
296 | assertEquals(P1, port1.number()); | 296 | assertEquals(P1, port1.number()); | ... | ... |
-
Please register or login to post a comment