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());
}
}
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);
}
}
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);
}
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);
}
Aggregations