@Test public final void testMarkOffline() { putDevice(DID1, SW1); assertTrue(deviceStore.isAvailable(DID1)); Capture<InternalDeviceEvent> message = new Capture<>(); Capture<MessageSubject> subject = new Capture<>(); Capture<Function<InternalDeviceEvent, byte[]>> encoder = new Capture<>(); resetCommunicatorExpectingSingleBroadcast(message, subject, encoder); DeviceEvent event = deviceStore.markOffline(DID1); assertEquals(DEVICE_AVAILABILITY_CHANGED, event.type()); assertDevice(DID1, SW1, event.subject()); assertFalse(deviceStore.isAvailable(DID1)); verify(clusterCommunicator); assertTrue(message.hasCaptured()); resetCommunicatorExpectingNoBroadcast(message, subject, encoder); DeviceEvent event2 = deviceStore.markOffline(DID1); assertNull("No change, no event", event2); verify(clusterCommunicator); assertFalse(message.hasCaptured()); }
@Override public DeviceEvent markOffline(DeviceId deviceId) { final Timestamp timestamp = deviceClockService.getTimestamp(deviceId); final DeviceEvent event = markOfflineInternal(deviceId, timestamp); if (event != null) { log.debug("Notifying peers of a device offline topology event for deviceId: {} {}", deviceId, timestamp); notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); } return event; }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public DeviceEvent markOffline(DeviceId deviceId) { final Timestamp timestamp = deviceClockService.getTimestamp(deviceId); final DeviceEvent event = markOfflineInternal(deviceId, timestamp); if (event != null) { log.debug("Notifying peers of a device offline topology event for deviceId: {} {}", deviceId, timestamp); notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); } return event; } }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public DeviceEvent markOffline(DeviceId deviceId) { final Timestamp timestamp = deviceClockService.getTimestamp(deviceId); final DeviceEvent event = markOfflineInternal(deviceId, timestamp); if (event != null) { log.debug("Notifying peers of a device offline topology event for deviceId: {} {}", deviceId, timestamp); notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); } return event; }  }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public DeviceEvent markOffline(DeviceId deviceId) { final Timestamp timestamp = deviceClockService.getTimestamp(deviceId); final DeviceEvent event = markOfflineInternal(deviceId, timestamp); if (event != null) { log.debug("Notifying peers of a device offline topology event for deviceId: {} {}", deviceId, timestamp); notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); } return event; }  @Activate void activate(); @Deactivate void deactivate(); @Override int getDeviceCount(); @Override Iterable<Device> getDevices(); @Override Iterable<Device> getAvailableDevices(); @Override Device getDevice(DeviceId deviceId); @Override synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
                                                         DeviceId deviceId,
                                                         DeviceDescription deviceDescription); @Override DeviceEvent markOffline(DeviceId deviceId); @Override synchronized List<DeviceEvent> updatePorts(ProviderId providerId,
                                                      DeviceId deviceId,
                                                      List<PortDescription> portDescriptions); @Override synchronized DeviceEvent updatePortStatus(ProviderId providerId,
                                                     DeviceId deviceId,
                                                     PortDescription portDescription); @Override List<Port> getPorts(DeviceId deviceId); @Override DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
                                            Collection<PortStatistics> newStatsCollection); PortStatistics calcDeltaStats(DeviceId deviceId, PortStatistics prvStats, PortStatistics newStats); @Override List<PortStatistics> getPortStatistics(DeviceId deviceId); @Override List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); @Override Port getPort(DeviceId deviceId, PortNumber portNumber); @Override boolean isAvailable(DeviceId deviceId); @Override synchronized DeviceEvent removeDevice(DeviceId deviceId); }
GossipDeviceStore extends AbstractStore<DeviceEvent, DeviceStoreDelegate> implements DeviceStore { @Override public DeviceEvent markOffline(DeviceId deviceId) { final Timestamp timestamp = deviceClockService.getTimestamp(deviceId); final DeviceEvent event = markOfflineInternal(deviceId, timestamp); if (event != null) { log.debug("Notifying peers of a device offline topology event for deviceId: {} {}", deviceId, timestamp); notifyPeers(new InternalDeviceOfflineEvent(deviceId, timestamp)); } return event; }  @Activate void activate(); @Deactivate void deactivate(); @Override int getDeviceCount(); @Override Iterable<Device> getDevices(); @Override Iterable<Device> getAvailableDevices(); @Override Device getDevice(DeviceId deviceId); @Override synchronized DeviceEvent createOrUpdateDevice(ProviderId providerId,
                                                         DeviceId deviceId,
                                                         DeviceDescription deviceDescription); @Override DeviceEvent markOffline(DeviceId deviceId); @Override synchronized List<DeviceEvent> updatePorts(ProviderId providerId,
                                                      DeviceId deviceId,
                                                      List<PortDescription> portDescriptions); @Override synchronized DeviceEvent updatePortStatus(ProviderId providerId,
                                                     DeviceId deviceId,
                                                     PortDescription portDescription); @Override List<Port> getPorts(DeviceId deviceId); @Override DeviceEvent updatePortStatistics(ProviderId providerId, DeviceId deviceId,
                                            Collection<PortStatistics> newStatsCollection); PortStatistics calcDeltaStats(DeviceId deviceId, PortStatistics prvStats, PortStatistics newStats); @Override List<PortStatistics> getPortStatistics(DeviceId deviceId); @Override List<PortStatistics> getPortDeltaStatistics(DeviceId deviceId); @Override Port getPort(DeviceId deviceId, PortNumber portNumber); @Override boolean isAvailable(DeviceId deviceId); @Override synchronized DeviceEvent removeDevice(DeviceId deviceId);  }