@Override public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(portDescriptions, PORT_DESC_LIST_NULL); checkValidity(); if (!mastershipService.isLocalMaster(deviceId)) { // Never been a master for this device // any update will be ignored. log.trace("Ignoring {} port updates on standby node. {}", deviceId, portDescriptions); return; } PortDescriptionsConfig portConfig = networkConfigService.getConfig(deviceId, PortDescriptionsConfig.class); if (portConfig != null) { // Updating the ports if configuration exists (on new lists as // the passed one might be immutable) portDescriptions = Lists.newArrayList(portDescriptions); portDescriptions.addAll(portConfig.portDescriptions()); } portDescriptions = portDescriptions.stream() .map(e -> applyAllPortOps(deviceId, e)) .collect(Collectors.toList()); List<DeviceEvent> events = store.updatePorts(this.provider().id(), deviceId, portDescriptions); if (events != null) { for (DeviceEvent event : events) { post(event); } } }
@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 deviceDisconnected(DeviceId deviceId) { checkNotNull(deviceId, DEVICE_ID_NULL); checkValidity(); deviceLocalStatus.put(deviceId, new LocalStatus(false, Instant.now())); log.info("Device {} disconnected from this node", deviceId);
checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(deviceDescription, DEVICE_DESCRIPTION_NULL); checkValidity();
checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(portDescription, PORT_DESCRIPTION_NULL); checkValidity();
@Override public void deletePort(DeviceId deviceId, PortDescription basePortDescription) { checkNotNull(deviceId, DEVICE_ID_NULL); checkNotNull(basePortDescription, PORT_DESCRIPTION_NULL); checkValidity(); if (!mastershipService.isLocalMaster(deviceId)) { // Never been a master for this device // any update will be ignored. log.trace("Ignoring {} port update on standby node. {}", deviceId, basePortDescription); return; } Device device = getDevice(deviceId); if (device == null) { log.trace("Device not found: {}", deviceId); } PortDescription newPortDescription = DefaultPortDescription.builder(basePortDescription) .isRemoved(true) .build(); final DeviceEvent event = store.updatePortStatus(this.provider().id(), deviceId, newPortDescription); if (event != null) { log.info("Device {} port {} status changed", deviceId, event.port().number()); post(event); } }