Search in sources :

Example 11 with ValidateMetersResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult in project open-kilda by telstra.

the class SwitchSyncFsmTest method getModifyDefaultMetersWithFlowMeters.

@Test
public void getModifyDefaultMetersWithFlowMeters() {
    ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId((long) MeterId.MIN_FLOW_METER_ID).build());
    ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
    ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, EMPTY_VALIDATE_RULES_RESULT, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
    SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
    assertTrue(fsm.getModifyDefaultMeters().isEmpty());
}
Also used : MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) Test(org.junit.Test)

Example 12 with ValidateMetersResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult in project open-kilda by telstra.

the class SwitchSyncFsmTest method getModifyDefaultMetersWithMissingRulesTest.

@Test
public void getModifyDefaultMetersWithMissingRulesTest() {
    ValidateRulesResult validateRulesResult = new ValidateRulesResult(newHashSet(COOKIE_1), newHashSet(), newHashSet(), newHashSet(COOKIE_2));
    ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId(METER_ID_1).build(), MeterInfoEntry.builder().cookie(COOKIE_2).meterId(METER_ID_2).build(), MeterInfoEntry.builder().cookie(COOKIE_3).meterId(METER_ID_3).build());
    ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
    ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, validateRulesResult, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
    SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
    List<Long> modifyMeters = fsm.getModifyDefaultMeters();
    assertEquals(1, modifyMeters.size());
    assertEquals(METER_ID_3, modifyMeters.get(0).longValue());
}
Also used : ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) SwitchValidateRequest(org.openkilda.messaging.command.switches.SwitchValidateRequest) ValidationResult(org.openkilda.wfm.topology.switchmanager.model.ValidationResult) Test(org.junit.Test)

Example 13 with ValidateMetersResult

use of org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult in project open-kilda by telstra.

the class SwitchSyncFsm method finished.

protected void finished(SwitchSyncState from, SwitchSyncState to, SwitchSyncEvent event, Object context) {
    ValidateRulesResult validateRulesResult = validationResult.getValidateRulesResult();
    ValidateMetersResult validateMetersResult = validationResult.getValidateMetersResult();
    ValidateGroupsResult validateGroupsResult = validationResult.getValidateGroupsResult();
    ValidateLogicalPortsResult validateLogicalPortsResult = Optional.ofNullable(validationResult.getValidateLogicalPortsResult()).orElse(ValidateLogicalPortsResult.newEmpty());
    RulesSyncEntry rulesEntry = new RulesSyncEntry(new ArrayList<>(validateRulesResult.getMissingRules()), new ArrayList<>(validateRulesResult.getMisconfiguredRules()), new ArrayList<>(validateRulesResult.getProperRules()), new ArrayList<>(validateRulesResult.getExcessRules()), installedRulesCookies, request.isRemoveExcess() ? union(removedFlowRulesCookies, removedDefaultRulesCookies) : removedDefaultRulesCookies);
    MetersSyncEntry metersEntry = null;
    if (validationResult.isProcessMeters()) {
        metersEntry = new MetersSyncEntry(validateMetersResult.getMissingMeters(), validateMetersResult.getMisconfiguredMeters(), validateMetersResult.getProperMeters(), validateMetersResult.getExcessMeters(), validateMetersResult.getMissingMeters(), request.isRemoveExcess() ? validateMetersResult.getExcessMeters() : emptyList());
    }
    List<Integer> installedGroupsIds = missingGroups.stream().map(GroupInstallContext::getMirrorConfig).map(MirrorConfig::getGroupId).map(GroupId::intValue).collect(Collectors.toList());
    List<Integer> modifiedGroupsIds = misconfiguredGroups.stream().map(GroupInstallContext::getMirrorConfig).map(MirrorConfig::getGroupId).map(GroupId::intValue).collect(Collectors.toList());
    GroupSyncEntry groupEntry = GroupSyncEntry.builder().proper(validateGroupsResult.getProperGroups()).misconfigured(validateGroupsResult.getMisconfiguredGroups()).missing(validateGroupsResult.getMissingGroups()).excess(validateGroupsResult.getExcessGroups()).installed(mapToGroupEntryList(installedGroupsIds, validateGroupsResult.getMissingGroups())).modified(mapToGroupEntryList(modifiedGroupsIds, validateGroupsResult.getMisconfiguredGroups())).removed(mapToGroupEntryList(excessGroups, validateGroupsResult.getExcessGroups())).build();
    LogicalPortsSyncEntry logicalPortsEntry = LogicalPortsSyncEntry.builder().proper(validateLogicalPortsResult.getProperLogicalPorts()).misconfigured(validateLogicalPortsResult.getMisconfiguredLogicalPorts()).excess(validateLogicalPortsResult.getExcessLogicalPorts()).missing(validateLogicalPortsResult.getMissingLogicalPorts()).installed(validateLogicalPortsResult.getMissingLogicalPorts()).removed(validateLogicalPortsResult.getExcessLogicalPorts()).build();
    SwitchSyncResponse response = new SwitchSyncResponse(switchId, rulesEntry, metersEntry, groupEntry, logicalPortsEntry);
    InfoMessage message = new InfoMessage(response, System.currentTimeMillis(), key);
    carrier.cancelTimeoutCallback(key);
    carrier.response(key, message);
}
Also used : ValidateRulesResult(org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult) MetersSyncEntry(org.openkilda.messaging.info.switches.MetersSyncEntry) RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) ValidateMetersResult(org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult) ValidateGroupsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateGroupsResult) MirrorConfig(org.openkilda.model.MirrorConfig) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) ValidateLogicalPortsResult(org.openkilda.wfm.topology.switchmanager.model.ValidateLogicalPortsResult) GroupSyncEntry(org.openkilda.messaging.info.switches.GroupSyncEntry) LogicalPortsSyncEntry(org.openkilda.messaging.info.switches.LogicalPortsSyncEntry)

Aggregations

ValidateMetersResult (org.openkilda.wfm.topology.switchmanager.model.ValidateMetersResult)13 Test (org.junit.Test)8 ValidationService (org.openkilda.wfm.topology.switchmanager.service.ValidationService)7 MeterId (org.openkilda.model.MeterId)6 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)6 MeterInfoEntry (org.openkilda.messaging.info.switches.MeterInfoEntry)4 ValidateRulesResult (org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult)4 ArrayList (java.util.ArrayList)2 SwitchValidateRequest (org.openkilda.messaging.command.switches.SwitchValidateRequest)2 Cookie (org.openkilda.model.cookie.Cookie)2 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)2 LagLogicalPortRepository (org.openkilda.persistence.repositories.LagLogicalPortRepository)2 SwitchRepository (org.openkilda.persistence.repositories.SwitchRepository)2 ValidationResult (org.openkilda.wfm.topology.switchmanager.model.ValidationResult)2 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 Arrays (java.util.Arrays)1