@Override public void roleChanged(DeviceId deviceId, MastershipRole newRole) { providerService.receivedRoleReply(deviceId, newRole, newRole); }
@Override public boolean isRelevant(DeviceEvent event) { return event.type().equals(DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED) && deviceService.isAvailable(event.subject().id()); }
@Override public void event(DeviceEvent event) { DeviceEvent.Type type = event.type(); DeviceId deviceId = event.subject().id(); if (type == PORT_STATS_UPDATED) { // Update port load updateDeviceData(deviceId); } else if (type == DEVICE_REMOVED || (type == DEVICE_AVAILABILITY_CHANGED && !deviceService.isAvailable(deviceId))) { // Clean-up all port loads pruneDeviceData(deviceId); } } }
private void handleEvent(DeviceEvent event) { Device device = event.subject(); boolean isRelevant = mastershipService.isLocalMaster(device.id()) && deviceService.isAvailable(device.id()); if (isRelevant) { pollDeviceFlowEntries(device); } } }
private Device getDevice(DeviceId deviceId) throws PiTranslationException { final Device device = deviceService.getDevice(deviceId); if (device == null) { throw new PiTranslationException("Unable to get device " + deviceId); } return device; }
private AsyncDeviceFetcher(DeviceService deviceService) { this.deviceService = deviceService; deviceService.addListener(listener); }
/** * Shuts down. */ public void shutdown() { deviceService.removeListener(listener); devices.clear(); }
private void removeDevice(DeviceId did) { providerService.deviceDisconnected(did); }
private long getEgressValue(PortStatistics stats, MetricType metricType) { return metricType == MetricType.BYTES ? stats.bytesSent() : stats.packetsSent(); }
private long getIngressValue(PortStatistics stats, MetricType metricType) { return metricType == MetricType.BYTES ? stats.bytesReceived() : stats.packetsReceived(); }
@Override public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) { checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(portStatistics, "Port statistics list cannot be null"); checkValidity(); DeviceEvent event = store.updatePortStatistics(this.provider().id(), deviceId, portStatistics); post(event); } }
@Override public void removeLinks(DeviceId deviceId) { if (deviceService.getRole(deviceId) != MastershipRole.MASTER) { return; } removeLinks(getDeviceLinks(deviceId), false); }
@Override public int getDeviceCount() { checkPermission(DEVICE_READ); return store.getDeviceCount(); }
@Override public Iterable<Device> getAvailableDevices() { checkPermission(DEVICE_READ); return store.getAvailableDevices(); }
private void handleEvent(DeviceEvent event) { Device device = event.subject(); boolean isRelevant = mastershipService.isLocalMaster(device.id()) && deviceService.isAvailable(device.id()); if (isRelevant) { pollDeviceGroups(device.id()); } } }
@Override public void event(DeviceEvent event) { DeviceEvent.Type type = event.type(); if (type == DEVICE_ADDED || type == DEVICE_REMOVED || type == DEVICE_AVAILABILITY_CHANGED) { processEvent(event); } } }
private void handleEvent(DeviceEvent event) { Device device = event.subject(); boolean isRelevant = mastershipService.isLocalMaster(device.id()) && deviceService.isAvailable(device.id()); if (isRelevant) { pollDeviceMeters(device.id()); } } }
@Override public void event(DeviceEvent event) { if (event.type() == PORT_STATS_UPDATED) { return; } processDeviceEvent(event); } }