/** * {@inheritDoc} */ @Override public void switchActivated(final DatapathId switchId) { final IOFSwitch sw = switchService.getSwitch(switchId); Message message = buildSwitchMessage(sw, SwitchState.ACTIVATED); kafkaProducer.postMessage(TOPO_EVENT_TOPIC, message); ImmutablePair<Long, Boolean> metersDeleted; metersDeleted = switchManager.deleteMeter(switchId, ALL_VAL); if (!metersDeleted.getRight()) { logger.error("Could not delete meters from switch={} xid={}", switchId, metersDeleted.getLeft()); } boolean defaultRulesInstalled = switchManager.installDefaultRules(switchId); if (!defaultRulesInstalled) { logger.error("Could not install default rules on switch={}", switchId); } if (sw.getEnabledPortNumbers() != null) { for (OFPort p : sw.getEnabledPortNumbers()) { kafkaProducer.postMessage(TOPO_EVENT_TOPIC, buildPortMessage(sw.getId(), p, PortChangeType.UP)); } } }
/** * We don't react the port changed notifications here. we listen for * OFPortStatus messages directly. Might consider using this notifier * instead */ @Override public void switchPortChanged(DatapathId switchId, OFPortDesc port, PortChangeType type) { switch (type) { case UP: processNewPort(switchId, port.getPortNo()); break; case DELETE: case DOWN: handlePortDown(switchId, port.getPortNo()); break; case OTHER_UPDATE: case ADD: // This is something other than port add or delete. // Topology does not worry about this. // If for some reason the port features change, which // we may have to react. break; } }
public SwitchUpdate(DatapathId swId, SwitchUpdateType switchUpdateType, OFPortDesc port, PortChangeType changeType) { if (switchUpdateType == SwitchUpdateType.PORTCHANGED) { if (port == null) { throw new NullPointerException("Port must not be null " + "for PORTCHANGED updates"); } if (changeType == null) { throw new NullPointerException("ChangeType must not be " + "null for PORTCHANGED updates"); } } else { if (port != null || changeType != null) { throw new IllegalArgumentException("port and changeType " + "must be null for " + switchUpdateType + " updates"); } } this.swId = swId; this.switchUpdateType = switchUpdateType; this.port = port; this.changeType = changeType; }
@Override public synchronized void notifyPortChanged(IOFSwitchBackend sw, OFPortDesc port, PortChangeType changeType) { Preconditions.checkNotNull(sw, "switch must not be null"); Preconditions.checkNotNull(port, "port must not be null"); Preconditions.checkNotNull(changeType, "changeType must not be null"); if (role != OFControllerRole.ROLE_MASTER) { counters.invalidPortsChanged.increment(); return; } if (!this.switches.containsKey(sw.getId())) { counters.invalidPortsChanged.increment(); return; } if(sw.getStatus().isVisible()) { // no need to count here. SwitchUpdate.dispatch will count // the portchanged SwitchUpdate update = new SwitchUpdate(sw.getId(), SwitchUpdateType.PORTCHANGED, port, changeType); addUpdateToQueue(update); } }
private static org.openkilda.messaging.info.event.PortChangeType toJsonType(PortChangeType type) { switch (type) { case ADD: return org.openkilda.messaging.info.event.PortChangeType.ADD; case OTHER_UPDATE: return org.openkilda.messaging.info.event.PortChangeType.OTHER_UPDATE; case DELETE: return org.openkilda.messaging.info.event.PortChangeType.DELETE; case UP: return org.openkilda.messaging.info.event.PortChangeType.UP; default: return org.openkilda.messaging.info.event.PortChangeType.DOWN; } }
@Override public void switchPortChanged(DatapathId switchId, OFPortDesc port, PortChangeType type) { String msg = String.format("Switch %s port %s changed: %s", switchId, port.getName(), type.toString()); notifier.postNotification(msg); }