use of org.openkilda.model.Meter in project open-kilda by telstra.
the class ValidationServiceImpl method validateMeters.
@Override
public ValidateMetersResult validateMeters(SwitchId switchId, List<MeterSpeakerData> presentMeters, List<MeterSpeakerData> expectedMeterSpeakerData) {
log.debug("Validating meters on switch {}", switchId);
Switch sw = switchRepository.findById(switchId).orElseThrow(() -> new SwitchNotFoundException(switchId));
boolean isESwitch = Switch.isNoviflowESwitch(sw.getOfDescriptionManufacturer(), sw.getOfDescriptionHardware());
List<MeterInfoEntry> actualMeters = presentMeters.stream().map(meter -> convertMeter(switchId, meter)).collect(toList());
List<MeterInfoEntry> expectedMeters = expectedMeterSpeakerData.stream().map(meter -> convertMeter(switchId, meter)).collect(toList());
ValidateMetersResult result = comparePresentedAndExpectedMeters(isESwitch, actualMeters, expectedMeters);
if (!result.getMissingMeters().isEmpty() && log.isErrorEnabled()) {
log.error("On switch {} the following meters are missed: {}", switchId, metersIntoLogRepresentation(result.getMissingMeters()));
}
if (!result.getExcessMeters().isEmpty() && log.isWarnEnabled()) {
log.warn("On switch {} the following meters are excessive: {}", switchId, metersIntoLogRepresentation(result.getExcessMeters()));
}
if (!result.getMisconfiguredMeters().isEmpty() && log.isWarnEnabled()) {
for (MeterInfoEntry meter : result.getMisconfiguredMeters()) {
log.warn("On switch {} meter {} is misconfigured: {}", switchId, meter.getMeterId(), getMisconfiguredMeterDifferenceAsString(meter.getExpected(), meter.getActual()));
}
}
return result;
}
Aggregations