Search in sources :

Example 1 with SwitchConnect

use of org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect in project open-kilda by telstra.

the class SwitchMonitor method processConnectNotification.

private void processConnectNotification(SpeakerSwitchView speakerData, String region, ConnectionsCollection connects) {
    boolean isActive = connects.isEmpty() && SwitchConnectMode.READ_WRITE == connects.getMode();
    SwitchConnect update = makeSwitchConnect(isActive, speakerData);
    SwitchConnect current = connects.put(region, update);
    if (current != null) {
        connects.put(region, mergeAvailabilityEntries(current, update));
    } else {
        acquireRegion(speakerData, region, update, connects.getMode());
    }
}
Also used : SwitchConnect(org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect)

Example 2 with SwitchConnect

use of org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect in project open-kilda by telstra.

the class SwitchMonitor method swapActiveReadWriteRegion.

private void swapActiveReadWriteRegion(String currentRegion, boolean isRegionOffline) {
    Iterator<String> iter = readWriteConnects.listRegions().iterator();
    if (iter.hasNext()) {
        String targetRegion = iter.next();
        log.info("Change {} active region for {} from \"{}\" to \"{}\"", SwitchConnectMode.READ_WRITE, switchId, currentRegion, targetRegion);
        SwitchConnect target = readWriteConnects.get(targetRegion);
        if (target == null) {
            // it must never happen, but if it happen better throw something meaningful
            throw new IllegalStateException(String.format("Switch %s availability data for %s corrupted", SwitchConnectMode.READ_WRITE, switchId));
        }
        readWriteConnects.put(targetRegion, target.buildActiveVariant());
        carrier.regionUpdateNotification(new RegionMappingSet(switchId, targetRegion, true));
        carrier.sendSwitchAvailabilityUpdateNotification(switchId, makeDump());
    } else {
        log.info("All {} connection to the switch {} have lost", SwitchConnectMode.READ_WRITE, switchId);
        carrier.regionUpdateNotification(new RegionMappingRemove(switchId, currentRegion, true));
        carrier.sendSwitchDisconnectNotification(switchId, makeDump(), isRegionOffline);
    }
}
Also used : RegionMappingSet(org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingSet) RegionMappingRemove(org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingRemove) SwitchConnect(org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect)

Example 3 with SwitchConnect

use of org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect in project open-kilda by telstra.

the class SwitchMonitor method processDisconnectNotification.

private void processDisconnectNotification(SwitchInfoData notification, String region, ConnectionsCollection connects) {
    SwitchConnect entry = connects.remove(region);
    if (entry == null) {
        log.error("Got disconnect notification for {} in region {}, but there is no data about such connect (know " + "connections: {})", switchId, region, formatConnections());
        reportNotificationDrop(notification, region);
        return;
    }
    loseRegion(region, entry, connects.getMode(), false);
}
Also used : SwitchConnect(org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect)

Example 4 with SwitchConnect

use of org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect in project open-kilda by telstra.

the class SwitchMonitor method makeSwitchConnect.

private SwitchConnect makeSwitchConnect(boolean isActive, SpeakerSwitchView speakerData) {
    IpSocketAddress switchAddress = null;
    IpSocketAddress speakerAddress = null;
    if (speakerData != null) {
        switchAddress = speakerData.getSwitchSocketAddress();
        speakerAddress = speakerData.getSpeakerSocketAddress();
    }
    return new SwitchConnect(isActive, clock.instant(), switchAddress, speakerAddress);
}
Also used : SwitchConnect(org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect) IpSocketAddress(org.openkilda.model.IpSocketAddress)

Aggregations

SwitchConnect (org.openkilda.wfm.topology.floodlightrouter.model.SwitchConnect)4 IpSocketAddress (org.openkilda.model.IpSocketAddress)1 RegionMappingRemove (org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingRemove)1 RegionMappingSet (org.openkilda.wfm.topology.floodlightrouter.model.RegionMappingSet)1