use of org.openkilda.messaging.model.SwitchAvailabilityEntry in project open-kilda by telstra.
the class SwitchFsm method persistSwitchConnections.
private void persistSwitchConnections(Switch sw, SwitchAvailabilityData availabilityData) {
List<SwitchAvailabilityEntry> goal;
if (availabilityData != null) {
goal = availabilityData.getConnections();
} else {
log.warn("Got \"null\" instead of {} availability data (treating it as an empty connections set)", switchId);
goal = Collections.emptyList();
}
Map<ConnectReference, SwitchConnect> extra = new HashMap<>();
for (SwitchConnect entry : switchConnectRepository.findBySwitchId(switchId)) {
extra.put(new ConnectReference(entry), entry);
}
for (SwitchAvailabilityEntry entry : goal) {
ConnectReference ref = new ConnectReference(entry);
persistSingleSwitchConnect(sw, entry, extra.remove(ref));
}
for (SwitchConnect connect : extra.values()) {
switchConnectRepository.remove(connect);
}
}
use of org.openkilda.messaging.model.SwitchAvailabilityEntry in project open-kilda by telstra.
the class SwitchMonitor method makeDump.
private SwitchAvailabilityData makeDump() {
SwitchAvailabilityData.SwitchAvailabilityDataBuilder builder = SwitchAvailabilityData.builder();
Set<String> readWriteRegions = new HashSet<>();
for (SwitchAvailabilityEntry entry : readWriteConnects.dump()) {
readWriteRegions.add(entry.getRegionName());
builder.connection(entry);
}
for (SwitchAvailabilityEntry entry : readOnlyConnects.dump()) {
if (readWriteRegions.contains(entry.getRegionName())) {
continue;
}
builder.connection(entry);
}
return builder.build();
}
Aggregations