Search in sources :

Example 1 with SwitchState

use of org.openkilda.messaging.info.event.SwitchState in project open-kilda by telstra.

the class CacheBolt method onSwitchUp.

private void onSwitchUp(SwitchInfoData sw, Tuple tuple) throws IOException {
    logger.info("Switch {} is {}", sw.getSwitchId(), sw.getState().getType());
    if (networkCache.cacheContainsSwitch(sw.getSwitchId())) {
        SwitchState prevState = networkCache.getSwitch(sw.getSwitchId()).getState();
        networkCache.updateSwitch(sw);
        if (prevState == SwitchState.CACHED) {
            String switchId = sw.getSwitchId();
            List<PortInfoData> ports = cacheWarmingService.getPortsForDiscovering(switchId);
            logger.info("Found {} links for discovery", ports.size());
            sendPortCachedEvent(ports);
            List<? extends CommandData> commands = cacheWarmingService.getFlowCommands(switchId);
            sendFlowCommands(commands);
        }
    } else {
        networkCache.createSwitch(sw);
    }
}
Also used : SwitchState(org.openkilda.messaging.info.event.SwitchState) PortInfoData(org.openkilda.messaging.info.event.PortInfoData)

Aggregations

PortInfoData (org.openkilda.messaging.info.event.PortInfoData)1 SwitchState (org.openkilda.messaging.info.event.SwitchState)1