Search in sources :

Example 1 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException 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 SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException 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 SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class SpeakerCommand method setup.

protected void setup(FloodlightModuleContext moduleContext) throws Exception {
    IOFSwitchService ofSwitchManager = moduleContext.getServiceImpl(IOFSwitchService.class);
    sessionService = moduleContext.getServiceImpl(SessionService.class);
    DatapathId dpId = DatapathId.of(switchId.toLong());
    sw = ofSwitchManager.getActiveSwitch(dpId);
    if (sw == null) {
        throw new SwitchNotFoundException(dpId);
    }
}
Also used : SessionService(org.openkilda.floodlight.service.session.SessionService) IOFSwitchService(net.floodlightcontroller.core.internal.IOFSwitchService) DatapathId(org.projectfloodlight.openflow.types.DatapathId) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException)

Example 4 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class FlowSegmentReport method assembleResponse.

private SpeakerResponse assembleResponse() {
    FlowErrorResponseBuilder errorResponse = makeErrorTemplate();
    try {
        raiseError();
        return makeSuccessReply();
    } catch (SwitchNotFoundException e) {
        errorResponse.errorCode(ErrorCode.SWITCH_UNAVAILABLE);
    } catch (SessionErrorResponseException e) {
        decodeError(errorResponse, e.getErrorResponse());
    } catch (SwitchMissingFlowsException e) {
        errorResponse.errorCode(ErrorCode.MISSING_OF_FLOWS);
        errorResponse.description(e.getMessage());
    } catch (SwitchOperationException e) {
        errorResponse.errorCode(ErrorCode.UNKNOWN);
        errorResponse.description(e.getMessage());
    } catch (Exception e) {
        log.error(String.format("Unhandled exception while processing command %s", command), e);
        errorResponse.errorCode(ErrorCode.UNKNOWN);
    }
    FlowErrorResponse response = errorResponse.build();
    log.error("Command {} have failed - {} {}", command, response.getErrorCode(), response.getDescription());
    return response;
}
Also used : SwitchMissingFlowsException(org.openkilda.floodlight.error.SwitchMissingFlowsException) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) FlowErrorResponse(org.openkilda.floodlight.flow.response.FlowErrorResponse) FlowErrorResponseBuilder(org.openkilda.floodlight.flow.response.FlowErrorResponse.FlowErrorResponseBuilder) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) SessionErrorResponseException(org.openkilda.floodlight.error.SessionErrorResponseException) SessionErrorResponseException(org.openkilda.floodlight.error.SessionErrorResponseException) SwitchMissingFlowsException(org.openkilda.floodlight.error.SwitchMissingFlowsException) SwitchOperationException(org.openkilda.floodlight.error.SwitchOperationException) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException)

Example 5 with SwitchNotFoundException

use of org.openkilda.floodlight.error.SwitchNotFoundException in project open-kilda by telstra.

the class SwitchManager method dumpMeterById.

/**
 * {@inheritDoc}
 */
@Override
public OFMeterConfig dumpMeterById(final DatapathId dpid, final long meterId) throws SwitchOperationException {
    OFMeterConfig meterConfig = null;
    IOFSwitch sw = lookupSwitch(dpid);
    if (sw == null) {
        throw new IllegalArgumentException(format("Switch %s was not found", dpid));
    }
    verifySwitchSupportsMeters(sw);
    OFFactory ofFactory = sw.getOFFactory();
    OFMeterConfigStatsRequest meterRequest = ofFactory.buildMeterConfigStatsRequest().setMeterId(meterId).build();
    try {
        ListenableFuture<List<OFMeterConfigStatsReply>> future = sw.writeStatsRequest(meterRequest);
        List<OFMeterConfigStatsReply> values = future.get(10, TimeUnit.SECONDS);
        if (values != null) {
            List<OFMeterConfig> result = values.stream().map(OFMeterConfigStatsReply::getEntries).flatMap(List::stream).collect(toList());
            meterConfig = result.size() >= 1 ? result.get(0) : null;
        }
    } catch (ExecutionException | TimeoutException e) {
        logger.error("Could not get meter config stats for {}.", dpid, e);
    } catch (InterruptedException e) {
        logger.error("Could not get meter config stats for {}.", dpid, e);
        Thread.currentThread().interrupt();
        throw new SwitchNotFoundException(dpid);
    }
    return meterConfig;
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFMeterConfigStatsRequest(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsRequest) OFMeterConfigStatsReply(org.projectfloodlight.openflow.protocol.OFMeterConfigStatsReply) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) SwitchNotFoundException(org.openkilda.floodlight.error.SwitchNotFoundException) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) ArrayList(java.util.ArrayList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Collectors.toList(java.util.stream.Collectors.toList) ExecutionException(java.util.concurrent.ExecutionException) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

SwitchNotFoundException (org.openkilda.floodlight.error.SwitchNotFoundException)15 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)9 DatapathId (org.projectfloodlight.openflow.types.DatapathId)9 ArrayList (java.util.ArrayList)8 SwitchOperationException (org.openkilda.floodlight.error.SwitchOperationException)8 UnsupportedSwitchOperationException (org.openkilda.floodlight.error.UnsupportedSwitchOperationException)8 ImmutableList (com.google.common.collect.ImmutableList)7 List (java.util.List)7 IKafkaProducerService (org.openkilda.floodlight.service.kafka.IKafkaProducerService)7 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)6 OFFlowStatsEntry (org.projectfloodlight.openflow.protocol.OFFlowStatsEntry)6 Arrays.asList (java.util.Arrays.asList)5 Collections.emptyList (java.util.Collections.emptyList)5 Collections.singletonList (java.util.Collections.singletonList)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeoutException (java.util.concurrent.TimeoutException)5 Collectors.toList (java.util.stream.Collectors.toList)5 InvalidMeterIdException (org.openkilda.floodlight.error.InvalidMeterIdException)5 OfInstallException (org.openkilda.floodlight.error.OfInstallException)5 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)5