Search in sources :

Example 1 with SwitchAvailabilityEntry

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);
    }
}
Also used : HashMap(java.util.HashMap) SwitchConnect(org.openkilda.model.SwitchConnect) SwitchAvailabilityEntry(org.openkilda.messaging.model.SwitchAvailabilityEntry)

Example 2 with SwitchAvailabilityEntry

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();
}
Also used : SwitchAvailabilityData(org.openkilda.messaging.model.SwitchAvailabilityData) SwitchAvailabilityEntry(org.openkilda.messaging.model.SwitchAvailabilityEntry) HashSet(java.util.HashSet)

Aggregations

SwitchAvailabilityEntry (org.openkilda.messaging.model.SwitchAvailabilityEntry)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 SwitchAvailabilityData (org.openkilda.messaging.model.SwitchAvailabilityData)1 SwitchConnect (org.openkilda.model.SwitchConnect)1