Search in sources :

Example 1 with GroupInfoEntry

use of org.openkilda.messaging.info.switches.GroupInfoEntry in project open-kilda by telstra.

the class ValidationServiceImpl method calculateMisconfiguredGroups.

private Set<GroupInfoEntry> calculateMisconfiguredGroups(Set<GroupInfoEntry> expected, Set<GroupInfoEntry> actual) {
    Set<GroupInfoEntry> misconfiguredGroups = new HashSet<>();
    Map<Integer, GroupInfoEntry> actualEntries = actual.stream().collect(Collectors.toMap(GroupInfoEntry::getGroupId, entry -> entry));
    for (GroupInfoEntry expectedEntry : expected) {
        GroupInfoEntry actualEntry = actualEntries.get(expectedEntry.getGroupId());
        if (actualEntry == null || actualEntry.equals(expectedEntry)) {
            continue;
        }
        List<BucketEntry> missingData = new ArrayList<>(expectedEntry.getGroupBuckets());
        missingData.removeAll(actualEntry.getGroupBuckets());
        List<BucketEntry> excessData = new ArrayList<>(actualEntry.getGroupBuckets());
        excessData.removeAll(expectedEntry.getGroupBuckets());
        misconfiguredGroups.add(actualEntry.toBuilder().missingGroupBuckets(missingData).excessGroupBuckets(excessData).build());
    }
    return misconfiguredGroups;
}
Also used : Arrays(java.util.Arrays) FlowPath(org.openkilda.model.FlowPath) ValidationService(org.openkilda.wfm.topology.switchmanager.service.ValidationService) LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) Map(java.util.Map) FlowMeterRepository(org.openkilda.persistence.repositories.FlowMeterRepository) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) ImmutableSet(com.google.common.collect.ImmutableSet) LogicalPortMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.LogicalPortMisconfiguredInfoEntry) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) MeterEntryConverter(org.openkilda.wfm.topology.switchmanager.mappers.MeterEntryConverter) Collection(java.util.Collection) Set(java.util.Set) GroupEntryConverter(org.openkilda.wfm.topology.switchmanager.mappers.GroupEntryConverter) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Entry(java.util.Map.Entry) Optional(java.util.Optional) Meter(org.openkilda.model.Meter) GroupInfoEntry(org.openkilda.messaging.info.switches.GroupInfoEntry) MeterMisconfiguredInfoEntry(org.openkilda.messaging.info.switches.MeterMisconfiguredInfoEntry) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) FlowMeter(org.openkilda.model.FlowMeter) LogicalPort(org.openkilda.messaging.model.grpc.LogicalPort) BucketEntry(org.openkilda.messaging.info.switches.GroupInfoEntry.BucketEntry) Function(java.util.function.Function) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException) ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) ImmutableList(com.google.common.collect.ImmutableList) Cookie(org.openkilda.model.cookie.Cookie) LogicalPortMapper(org.openkilda.wfm.topology.switchmanager.mappers.LogicalPortMapper) PersistenceManager(org.openkilda.persistence.PersistenceManager) ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult) LogicalPortType(org.openkilda.messaging.info.switches.LogicalPortType) Switch(org.openkilda.model.Switch) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Collectors.toList(java.util.stream.Collectors.toList) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchId(org.openkilda.model.SwitchId) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) LagLogicalPortRepository(org.openkilda.persistence.repositories.LagLogicalPortRepository) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Collections(java.util.Collections) GroupInfoEntry(org.openkilda.messaging.info.switches.GroupInfoEntry) ArrayList(java.util.ArrayList) BucketEntry(org.openkilda.messaging.info.switches.GroupInfoEntry.BucketEntry) HashSet(java.util.HashSet)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Sets (com.google.common.collect.Sets)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1