Search in sources :

Example 1 with OFMeterConfig

use of org.projectfloodlight.openflow.protocol.OFMeterConfig in project open-kilda by telstra.

the class RecordHandler method dumpMeters.

private void dumpMeters(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
    try {
        logger.debug("Get all meters for switch {}", switchId);
        ISwitchManager switchManager = context.getSwitchManager();
        List<OFMeterConfig> meterEntries = switchManager.dumpMeters(DatapathId.of(switchId.toLong()));
        List<MeterEntry> meters = meterEntries.stream().map(OfMeterConverter::toMeterEntry).collect(Collectors.toList());
        SwitchMeterEntries response = SwitchMeterEntries.builder().switchId(switchId).meterEntries(meters).build();
        sender.accept(response);
    } catch (UnsupportedSwitchOperationException e) {
        logger.info("Meters not supported: {}", switchId);
        sender.accept(new SwitchMeterUnsupported(switchId));
    } catch (SwitchNotFoundException e) {
        logger.info("Dumping switch meters is unsuccessful. Switch {} not found", switchId);
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(switchId.toString()).buildData();
        sender.accept(errorData);
    } catch (SwitchOperationException e) {
        logger.error("Unable to dump meters", e);
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump meters").buildData();
        sender.accept(errorData);
    }
}
Also used : SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) MeterEntry(org.openkilda.messaging.info.meter.MeterEntry) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) SwitchMeterUnsupported(org.openkilda.messaging.info.meter.SwitchMeterUnsupported) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 2 with OFMeterConfig

use of org.projectfloodlight.openflow.protocol.OFMeterConfig in project open-kilda by telstra.

the class RecordHandler method dumpRuleManagerMeters.

private void dumpRuleManagerMeters(SwitchId switchId, java.util.function.Consumer<MessageData> sender) {
    try {
        logger.debug("Get all meters for switch {}", switchId);
        ISwitchManager switchManager = context.getSwitchManager();
        DatapathId datapathId = DatapathId.of(switchId.toLong());
        List<OFMeterConfig> meterEntries = switchManager.dumpMeters(datapathId);
        IOFSwitch iofSwitch = switchManager.lookupSwitch(datapathId);
        boolean inaccurate = featureDetectorService.detectSwitch(iofSwitch).contains(SwitchFeature.INACCURATE_METER);
        List<MeterSpeakerData> meters = meterEntries.stream().map(entry -> org.openkilda.floodlight.converter.rulemanager.OfMeterConverter.INSTANCE.convertToMeterSpeakerData(entry, inaccurate)).collect(Collectors.toList());
        MeterDumpResponse response = MeterDumpResponse.builder().switchId(switchId).meterSpeakerData(meters).build();
        sender.accept(response);
    } catch (UnsupportedSwitchOperationException e) {
        logger.info("Meters not supported: {}", switchId);
        sender.accept(new SwitchMeterUnsupported(switchId));
    } catch (SwitchNotFoundException e) {
        logger.info("Dumping switch meters is unsuccessful. Switch {} not found", switchId);
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(switchId.toString()).buildData();
        sender.accept(errorData);
    } catch (SwitchOperationException e) {
        logger.error("Unable to dump meters", e);
        ErrorData errorData = anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription("Unable to dump meters").buildData();
        sender.accept(errorData);
    }
}
Also used : MirrorConfig(org.openkilda.model.MirrorConfig) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) GroupModifyCommand(org.openkilda.floodlight.command.group.GroupModifyCommand) SwitchMeterUnsupported(org.openkilda.messaging.info.meter.SwitchMeterUnsupported) OfFlowStatsMapper(org.openkilda.floodlight.converter.OfFlowStatsMapper) DeleteMeterRequest(org.openkilda.messaging.command.flow.DeleteMeterRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage) MULTITABLE_POST_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_POST_INGRESS_DROP_COOKIE) Map(java.util.Map) DeleteRulesAction(org.openkilda.messaging.command.switches.DeleteRulesAction) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) SwitchGroupEntries(org.openkilda.messaging.info.rule.SwitchGroupEntries) PortStatus(org.openkilda.model.PortStatus) SetupBfdSessionDispatcher(org.openkilda.floodlight.kafka.dispatcher.SetupBfdSessionDispatcher) InvalidMeterIdException(org.openkilda.floodlight.error.InvalidMeterIdException) AliveResponse(org.openkilda.messaging.AliveResponse) MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE) MessageContext(org.openkilda.messaging.MessageContext) CookieType(org.openkilda.model.cookie.CookieBase.CookieType) GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) CommandProcessorService(org.openkilda.floodlight.service.CommandProcessorService) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) ROUND_TRIP_LATENCY_RULE_COOKIE(org.openkilda.model.cookie.Cookie.ROUND_TRIP_LATENCY_RULE_COOKIE) ReinstallServer42FlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest) LLDP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INGRESS_COOKIE) BaseSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.BaseSpeakerCommandsRequest) InstallIngressFlow(org.openkilda.messaging.command.flow.InstallIngressFlow) Command(org.openkilda.floodlight.command.Command) SwitchTrackingService(org.openkilda.floodlight.switchmanager.SwitchTrackingService) PortDescription(org.openkilda.messaging.info.switches.PortDescription) BaseInstallFlow(org.openkilda.messaging.command.flow.BaseInstallFlow) TransitFlowLoopSegmentInstallCommand(org.openkilda.floodlight.command.flow.transit.TransitFlowLoopSegmentInstallCommand) ModifyGroupResponse(org.openkilda.messaging.info.switches.ModifyGroupResponse) SpeakerCommand(org.openkilda.floodlight.command.SpeakerCommand) SwitchPortsDescription(org.openkilda.messaging.info.switches.SwitchPortsDescription) DumpGroupsForFlowHsRequest(org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest) FlowEndpoint(org.openkilda.model.FlowEndpoint) GroupDumpResponse(org.openkilda.messaging.info.group.GroupDumpResponse) CorrelationContextClosable(org.openkilda.floodlight.utils.CorrelationContext.CorrelationContextClosable) NetworkCommandData(org.openkilda.messaging.command.discovery.NetworkCommandData) ErrorType(org.openkilda.messaging.error.ErrorType) SERVER_42_ISL_RTT_OUTPUT_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_OUTPUT_COOKIE) MeterDumpResponse(org.openkilda.messaging.info.meter.MeterDumpResponse) IOException(java.io.IOException) FeatureDetectorService(org.openkilda.floodlight.service.FeatureDetectorService) InstallTransitLoopFlow(org.openkilda.messaging.command.flow.InstallTransitLoopFlow) PortStatusData(org.openkilda.messaging.info.stats.PortStatusData) InstallIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.InstallIslDefaultRulesCommand) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) InstallSharedFlow(org.openkilda.messaging.command.flow.InstallSharedFlow) PortConfigurationResponse(org.openkilda.messaging.info.switches.PortConfigurationResponse) DeleteGroupRequest(org.openkilda.messaging.command.switches.DeleteGroupRequest) GroupInstallCommand(org.openkilda.floodlight.command.group.GroupInstallCommand) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SpeakerCommandReport(org.openkilda.floodlight.command.SpeakerCommandReport) OneSwitchFlowInstallCommand(org.openkilda.floodlight.command.flow.ingress.OneSwitchFlowInstallCommand) DumpMetersForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest) ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) FlowSegmentResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentResponseFactory) OfPortDescConverter(org.openkilda.floodlight.converter.OfPortDescConverter) PingRequestDispatcher(org.openkilda.floodlight.kafka.dispatcher.PingRequestDispatcher) SwitchFeature(org.openkilda.model.SwitchFeature) FlowSegmentSyncResponseFactory(org.openkilda.floodlight.command.flow.FlowSegmentSyncResponseFactory) DeleteGroupResponse(org.openkilda.messaging.info.switches.DeleteGroupResponse) LLDP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_COOKIE) OneSwitchMirrorFlowInstallCommand(org.openkilda.floodlight.command.flow.ingress.OneSwitchMirrorFlowInstallCommand) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) SwitchRulesInstallRequest(org.openkilda.messaging.command.switches.SwitchRulesInstallRequest) RemoveIslDefaultRulesCommand(org.openkilda.messaging.payload.switches.RemoveIslDefaultRulesCommand) OFFlowStatsEntry(org.projectfloodlight.openflow.protocol.OFFlowStatsEntry) InstallIngressMirrorFlow(org.openkilda.messaging.command.flow.InstallIngressMirrorFlow) ModifyGroupRequest(org.openkilda.messaging.command.switches.ModifyGroupRequest) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) CommandContext(org.openkilda.floodlight.command.CommandContext) Objects(java.util.Objects) MacAddress(org.openkilda.model.MacAddress) MULTITABLE_EGRESS_PASS_THROUGH_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_EGRESS_PASS_THROUGH_COOKIE) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) ARP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_VXLAN_COOKIE) DumpRulesForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest) ARP_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INGRESS_COOKIE) SwitchPortStatusData(org.openkilda.messaging.info.stats.SwitchPortStatusData) MULTITABLE_TRANSIT_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_TRANSIT_DROP_COOKIE) SERVER_42_FLOW_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_TURNING_COOKIE) RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) CATCH_BFD_RULE_COOKIE(org.openkilda.model.cookie.Cookie.CATCH_BFD_RULE_COOKIE) HashSet(java.util.HashSet) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) ImmutableList(com.google.common.collect.ImmutableList) MULTITABLE_INGRESS_DROP_COOKIE(org.openkilda.model.cookie.Cookie.MULTITABLE_INGRESS_DROP_COOKIE) MAPPER(org.openkilda.messaging.Utils.MAPPER) BroadcastStatsRequestDispatcher(org.openkilda.floodlight.kafka.dispatcher.BroadcastStatsRequestDispatcher) ConnectModeResponse(org.openkilda.messaging.info.switches.ConnectModeResponse) SharedSegmentType(org.openkilda.model.cookie.FlowSharedSegmentCookie.SharedSegmentType) POST_INGRESS_TABLE_ID(org.openkilda.floodlight.switchmanager.SwitchManager.POST_INGRESS_TABLE_ID) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) Logger(org.slf4j.Logger) EgressFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.egress.EgressFlowSegmentInstallCommand) MeterModifyCommand(org.openkilda.floodlight.command.meter.MeterModifyCommand) LLDP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_INPUT_PRE_DROP_COOKIE) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterId(org.openkilda.model.MeterId) OfInstallException(org.openkilda.floodlight.error.OfInstallException) CommandDispatcher(org.openkilda.floodlight.kafka.dispatcher.CommandDispatcher) FlowDumpResponse(org.openkilda.messaging.info.flow.FlowDumpResponse) GroupId(org.openkilda.model.GroupId) DROP_VERIFICATION_LOOP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_VERIFICATION_LOOP_RULE_COOKIE) VERIFICATION_UNICAST_VXLAN_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_VXLAN_RULE_COOKIE) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) RemoveBfdSessionDispatcher(org.openkilda.floodlight.kafka.dispatcher.RemoveBfdSessionDispatcher) DeleteMeterResponse(org.openkilda.messaging.info.switches.DeleteMeterResponse) SwitchFlowEntries(org.openkilda.messaging.info.rule.SwitchFlowEntries) DiscoverIslCommandData(org.openkilda.messaging.command.discovery.DiscoverIslCommandData) IngressMirrorFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.ingress.IngressMirrorFlowSegmentInstallCommand) BroadcastWrapper(org.openkilda.messaging.command.BroadcastWrapper) RulesContext(org.openkilda.floodlight.model.RulesContext) IKafkaProducerService(org.openkilda.floodlight.service.kafka.IKafkaProducerService) EgressMirrorFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.egress.EgressMirrorFlowSegmentInstallCommand) FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) Set(java.util.Set) OfFlowConverter(org.openkilda.floodlight.converter.rulemanager.OfFlowConverter) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) CorrelationContext(org.openkilda.floodlight.utils.CorrelationContext) MeterModifyCommandRequest(org.openkilda.messaging.command.flow.MeterModifyCommandRequest) ConsumerRecord(org.apache.kafka.clients.consumer.ConsumerRecord) PortsCommandData(org.openkilda.messaging.command.discovery.PortsCommandData) Message(org.openkilda.messaging.Message) InstallServer42IngressFlow(org.openkilda.messaging.command.flow.InstallServer42IngressFlow) MeterEntry(org.openkilda.messaging.info.meter.MeterEntry) MessageData(org.openkilda.messaging.MessageData) RemoveIslDefaultRulesResult(org.openkilda.messaging.info.discovery.RemoveIslDefaultRulesResult) ArrayList(java.util.ArrayList) SpeakerDataResponse(org.openkilda.floodlight.api.response.SpeakerDataResponse) InstallIngressLoopFlow(org.openkilda.messaging.command.flow.InstallIngressLoopFlow) LLDP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_TRANSIT_COOKIE) GroupRemoveCommand(org.openkilda.floodlight.command.group.GroupRemoveCommand) DiscoverPathCommandData(org.openkilda.messaging.command.discovery.DiscoverPathCommandData) AliveRequest(org.openkilda.messaging.AliveRequest) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) DROP_RULE_COOKIE(org.openkilda.model.cookie.Cookie.DROP_RULE_COOKIE) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) InstallRulesAction(org.openkilda.messaging.command.switches.InstallRulesAction) TRANSIT_TABLE_ID(org.openkilda.floodlight.switchmanager.SwitchManager.TRANSIT_TABLE_ID) InstallGroupRequest(org.openkilda.messaging.command.switches.InstallGroupRequest) InstallEgressMirrorFlow(org.openkilda.messaging.command.flow.InstallEgressMirrorFlow) VERIFICATION_UNICAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_UNICAST_RULE_COOKIE) FlowCommandException(org.openkilda.floodlight.error.FlowCommandException) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) InstallIslDefaultRulesResult(org.openkilda.messaging.info.discovery.InstallIslDefaultRulesResult) FlowRemoveResponse(org.openkilda.messaging.info.flow.FlowRemoveResponse) FlowSegmentWrapperCommand(org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand) VERIFICATION_BROADCAST_RULE_COOKIE(org.openkilda.model.cookie.Cookie.VERIFICATION_BROADCAST_RULE_COOKIE) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) IngressFlowLoopSegmentInstallCommand(org.openkilda.floodlight.command.flow.ingress.IngressFlowLoopSegmentInstallCommand) DumpMetersRequest(org.openkilda.messaging.command.switches.DumpMetersRequest) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) IngressFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand) ARP_POST_INGRESS_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_COOKIE) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) LoggerFactory(org.slf4j.LoggerFactory) InstallTransitFlow(org.openkilda.messaging.command.flow.InstallTransitFlow) ARP_INPUT_PRE_DROP_COOKIE(org.openkilda.model.cookie.Cookie.ARP_INPUT_PRE_DROP_COOKIE) InstallOneSwitchMirrorFlow(org.openkilda.messaging.command.flow.InstallOneSwitchMirrorFlow) DumpGroupsForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpGroupsForSwitchManagerRequest) SwitchRulesDeleteRequest(org.openkilda.messaging.command.switches.SwitchRulesDeleteRequest) BaseFlow(org.openkilda.messaging.command.flow.BaseFlow) SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) InstallGroupResponse(org.openkilda.messaging.info.switches.InstallGroupResponse) PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) MeterConfig(org.openkilda.model.MeterConfig) ConnectModeRequest(org.openkilda.messaging.command.switches.ConnectModeRequest) TypeReference(com.fasterxml.jackson.core.type.TypeReference) ModifyFlowMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyFlowMeterForSwitchManagerRequest) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) LLDP_POST_INGRESS_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_VXLAN_COOKIE) ModifyMeterResponse(org.openkilda.messaging.info.switches.ModifyMeterResponse) FlowReinstallResponse(org.openkilda.messaging.info.flow.FlowReinstallResponse) IngressServer42FlowInstallCommand(org.openkilda.floodlight.command.flow.ingress.IngressServer42FlowInstallCommand) InfoData(org.openkilda.messaging.info.InfoData) OfGroupConverter(org.openkilda.floodlight.converter.rulemanager.OfGroupConverter) TransitFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.transit.TransitFlowSegmentInstallCommand) String.format(java.lang.String.format) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) InstallEgressFlow(org.openkilda.messaging.command.flow.InstallEgressFlow) DumpRulesRequest(org.openkilda.messaging.command.switches.DumpRulesRequest) List(java.util.List) INGRESS_TABLE_ID(org.openkilda.floodlight.switchmanager.SwitchManager.INGRESS_TABLE_ID) FlowSegmentMetadata(org.openkilda.floodlight.model.FlowSegmentMetadata) FlowInstallResponse(org.openkilda.messaging.info.flow.FlowInstallResponse) Optional(java.util.Optional) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) CommandData(org.openkilda.messaging.command.CommandData) DeleterMeterForSwitchManagerRequest(org.openkilda.messaging.command.switches.DeleterMeterForSwitchManagerRequest) Getter(lombok.Getter) ARP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.ARP_POST_INGRESS_ONE_SWITCH_COOKIE) Cookie(org.openkilda.model.cookie.Cookie) SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) ARP_TRANSIT_COOKIE(org.openkilda.model.cookie.Cookie.ARP_TRANSIT_COOKIE) ErrorMessageBuilder.anError(org.openkilda.floodlight.kafka.ErrorMessageBuilder.anError) SERVER_42_ISL_RTT_TURNING_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_TURNING_COOKIE) OfMeterConverter(org.openkilda.floodlight.converter.OfMeterConverter) SwitchId(org.openkilda.model.SwitchId) SwitchRulesResponse(org.openkilda.messaging.info.switches.SwitchRulesResponse) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ErrorData(org.openkilda.messaging.error.ErrorData) LLDP_POST_INGRESS_ONE_SWITCH_COOKIE(org.openkilda.model.cookie.Cookie.LLDP_POST_INGRESS_ONE_SWITCH_COOKIE) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) SwitchMeterUnsupported(org.openkilda.messaging.info.meter.SwitchMeterUnsupported) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) MeterDumpResponse(org.openkilda.messaging.info.meter.MeterDumpResponse) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) FlowCommandErrorData(org.openkilda.messaging.error.rule.FlowCommandErrorData) ErrorData(org.openkilda.messaging.error.ErrorData)

Example 3 with OFMeterConfig

use of org.projectfloodlight.openflow.protocol.OFMeterConfig in project open-kilda by telstra.

the class MeterVerifyCommand method handleMeterStats.

private MeterSchema handleMeterStats(List<OFMeterConfigStatsReply> meterStatResponses) {
    Optional<OFMeterConfig> target = Optional.empty();
    for (OFMeterConfigStatsReply meterConfigReply : meterStatResponses) {
        target = findMeter(meterConfigReply);
        if (target.isPresent()) {
            break;
        }
    }
    if (!target.isPresent()) {
        throw maskCallbackException(new SwitchMissingMeterException(getSw().getId(), meterConfig.getId()));
    }
    boolean isInaccurate = getSwitchFeatures().contains(SwitchFeature.INACCURATE_METER);
    MeterSchema schema = MeterSchemaMapper.INSTANCE.map(getSw().getId(), target.get(), isInaccurate);
    validateMeterConfig(schema, isInaccurate);
    return schema;
}
Also used : MeterSchema(org.openkilda.model.of.MeterSchema) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) SwitchMissingMeterException(org.openkilda.floodlight.error.SwitchMissingMeterException) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig)

Example 4 with OFMeterConfig

use of org.projectfloodlight.openflow.protocol.OFMeterConfig in project open-kilda by telstra.

the class SwitchManagerTest method mockGetMetersRequest.

private void mockGetMetersRequest(List<Long> meterIds, boolean supportsPkts, long rate, long burstSize) throws Exception {
    List<OFMeterConfig> meterConfigs = new ArrayList<>(meterIds.size());
    for (Long meterId : meterIds) {
        OFMeterBandDrop bandDrop = mock(OFMeterBandDrop.class);
        expect(bandDrop.getRate()).andStubReturn(rate);
        expect(bandDrop.getBurstSize()).andStubReturn(burstSize);
        OFMeterConfig meterConfig = mock(OFMeterConfig.class);
        expect(meterConfig.getEntries()).andStubReturn(Collections.singletonList(bandDrop));
        expect(meterConfig.getMeterId()).andStubReturn(meterId);
        Set<OFMeterFlags> flags = ImmutableSet.of(OFMeterFlags.STATS, OFMeterFlags.BURST, supportsPkts ? OFMeterFlags.PKTPS : OFMeterFlags.KBPS);
        expect(meterConfig.getFlags()).andStubReturn(flags);
        replay(bandDrop, meterConfig);
        meterConfigs.add(meterConfig);
    }
    OFMeterConfigStatsReply statsReply = mock(OFMeterConfigStatsReply.class);
    expect(statsReply.getEntries()).andStubReturn(meterConfigs);
    ListenableFuture<List<OFMeterConfigStatsReply>> ofStatsFuture = mock(ListenableFuture.class);
    expect(ofStatsFuture.get(anyLong(), anyObject())).andStubReturn(Collections.singletonList(statsReply));
    replay(statsReply, ofStatsFuture);
    expect(iofSwitch.writeStatsRequest(isA(OFMeterConfigStatsRequest.class))).andStubReturn(ofStatsFuture);
}
Also used : OFMeterFlags(org.projectfloodlight.openflow.protocol.OFMeterFlags) OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) ArrayList(java.util.ArrayList) EasyMock.anyLong(org.easymock.EasyMock.anyLong) OFMeterBandDrop(org.projectfloodlight.openflow.protocol.meterband.OFMeterBandDrop) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig)

Example 5 with OFMeterConfig

use of org.projectfloodlight.openflow.protocol.OFMeterConfig in project open-kilda by telstra.

the class SwitchManagerTest method dumpMetersTimeoutException.

@Test
public void dumpMetersTimeoutException() throws SwitchOperationException, InterruptedException, ExecutionException, TimeoutException {
    ListenableFuture<List<OFMeterConfigStatsReply>> ofStatsFuture = createMock(ListenableFuture.class);
    expect(ofStatsFuture.get(anyLong(), anyObject())).andThrow(new TimeoutException());
    expect(ofSwitchService.getActiveSwitch(dpid)).andStubReturn(iofSwitch);
    expect(switchDescription.getManufacturerDescription()).andStubReturn("");
    expect(iofSwitch.getSwitchDescription()).andStubReturn(switchDescription);
    expect(iofSwitch.getOFFactory()).andStubReturn(ofFactory);
    expect(iofSwitch.writeStatsRequest(isA(OFMeterConfigStatsRequest.class))).andStubReturn(ofStatsFuture);
    replay(ofSwitchService, iofSwitch, switchDescription, ofStatsFuture);
    List<OFMeterConfig> meters = switchManager.dumpMeters(dpid);
    assertNotNull(meters);
    assertTrue(meters.isEmpty());
}
Also used : OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) Collections.singletonList(java.util.Collections.singletonList) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Aggregations

OFMeterConfig (org.projectfloodlight.openflow.protocol.OFMeterConfig)15 ImmutableList (com.google.common.collect.ImmutableList)11 ArrayList (java.util.ArrayList)11 List (java.util.List)11 Test (org.junit.Test)6 Collections.singletonList (java.util.Collections.singletonList)5 Collectors.toList (java.util.stream.Collectors.toList)5 OFMeterConfigStatsRequest (org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest)5 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)4 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)4 MeterConfig (org.openkilda.model.MeterConfig)4 OFMeterConfigStatsReply (org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply)4 TimeoutException (java.util.concurrent.TimeoutException)3 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)3 AbstractSpeakerCommandTest (org.openkilda.floodlight.command.AbstractSpeakerCommandTest)3 SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)3 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)3 MessageContext (org.openkilda.messaging.MessageContext)3 MeterId (org.openkilda.model.MeterId)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2