Search in sources :

Example 1 with SpeakerDataResponse

use of org.openkilda.floodlight.api.response.SpeakerDataResponse in project open-kilda by telstra.

the class ControllerToSpeakerSharedProxyBolt method handleRegionNotFoundError.

private void handleRegionNotFoundError(CommandMessage commandMessage, SwitchId switchId) {
    String errorDetails = String.format("Switch %s not found", switchId.toString());
    ErrorData errorData = new ErrorData(ErrorType.NOT_FOUND, errorDetails, errorDetails);
    ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), commandMessage.getCorrelationId(), null);
    Tuple input = getCurrentTuple();
    if (commandMessage.getData() instanceof DumpRulesForFlowHsRequest || commandMessage.getData() instanceof DumpMetersForFlowHsRequest) {
        MessageContext messageContext = new MessageContext(commandMessage);
        SpeakerDataResponse result = new SpeakerDataResponse(messageContext, errorData);
        // FIXME(surabujin): there is no subscriber on this stream now
        getOutput().emit(Stream.FLOWHS_WORKER, input, makeFlowHsWorkerTuple(commandMessage.getCorrelationId(), result));
    } else if (commandMessage.getData() instanceof DumpRulesForSwitchManagerRequest || commandMessage.getData() instanceof DumpMetersForSwitchManagerRequest || commandMessage.getData() instanceof InstallFlowForSwitchManagerRequest || commandMessage.getData() instanceof RemoveFlowForSwitchManagerRequest || commandMessage.getData() instanceof ReinstallDefaultFlowForSwitchManagerRequest) {
        getOutput().emit(Stream.KILDA_SWITCH_MANAGER, input, makeSwitchManagerTuple(commandMessage.getCorrelationId(), errorMessage));
    } else if (commandMessage.getData() instanceof DumpSwitchPortsDescriptionRequest || commandMessage.getData() instanceof DumpPortDescriptionRequest || commandMessage.getData() instanceof DumpRulesRequest || commandMessage.getData() instanceof DumpMetersRequest || commandMessage.getData() instanceof DeleteMeterRequest || commandMessage.getData() instanceof PortConfigurationRequest) {
        getOutput().emit(Stream.NORTHBOUND_REPLY, input, makeNorthboundTuple(commandMessage.getCorrelationId(), errorMessage));
    } else {
        log.error("Unable to lookup region for message: {}. switch is not tracked.", commandMessage);
    }
}
Also used : RemoveFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) DumpPortDescriptionRequest(org.openkilda.messaging.command.switches.DumpPortDescriptionRequest) SpeakerDataResponse(org.openkilda.floodlight.api.response.SpeakerDataResponse) DumpMetersRequest(org.openkilda.messaging.command.switches.DumpMetersRequest) PortConfigurationRequest(org.openkilda.messaging.command.switches.PortConfigurationRequest) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) DumpMetersForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest) DumpRulesRequest(org.openkilda.messaging.command.switches.DumpRulesRequest) DumpSwitchPortsDescriptionRequest(org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) MessageContext(org.openkilda.messaging.MessageContext) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) DumpRulesForSwitchManagerRequest(org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest) DeleteMeterRequest(org.openkilda.messaging.command.flow.DeleteMeterRequest) ErrorData(org.openkilda.messaging.error.ErrorData) Tuple(org.apache.storm.tuple.Tuple)

Example 2 with SpeakerDataResponse

use of org.openkilda.floodlight.api.response.SpeakerDataResponse in project open-kilda by telstra.

the class SpeakerWorkerForDumpsBolt method onAsyncResponse.

@Override
protected void onAsyncResponse(Tuple requestTuple, Tuple responseTuple) throws Exception {
    String key = pullKey();
    Object payload = responseTuple.getValueByField(FIELD_ID_PAYLOAD);
    if (payload instanceof SpeakerDataResponse) {
        SpeakerDataResponse dataResponse = (SpeakerDataResponse) payload;
        emitResponseToHub(getCurrentTuple(), new Values(key, dataResponse.getData(), getCommandContext()));
    } else {
        log.debug("Unknown response received: {}", payload);
    }
}
Also used : Values(org.apache.storm.tuple.Values) SpeakerDataResponse(org.openkilda.floodlight.api.response.SpeakerDataResponse)

Aggregations

SpeakerDataResponse (org.openkilda.floodlight.api.response.SpeakerDataResponse)2 Tuple (org.apache.storm.tuple.Tuple)1 Values (org.apache.storm.tuple.Values)1 MessageContext (org.openkilda.messaging.MessageContext)1 DeleteMeterRequest (org.openkilda.messaging.command.flow.DeleteMeterRequest)1 InstallFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest)1 ReinstallDefaultFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest)1 RemoveFlowForSwitchManagerRequest (org.openkilda.messaging.command.flow.RemoveFlowForSwitchManagerRequest)1 DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)1 DumpMetersForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpMetersForSwitchManagerRequest)1 DumpMetersRequest (org.openkilda.messaging.command.switches.DumpMetersRequest)1 DumpPortDescriptionRequest (org.openkilda.messaging.command.switches.DumpPortDescriptionRequest)1 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)1 DumpRulesForSwitchManagerRequest (org.openkilda.messaging.command.switches.DumpRulesForSwitchManagerRequest)1 DumpRulesRequest (org.openkilda.messaging.command.switches.DumpRulesRequest)1 DumpSwitchPortsDescriptionRequest (org.openkilda.messaging.command.switches.DumpSwitchPortsDescriptionRequest)1 PortConfigurationRequest (org.openkilda.messaging.command.switches.PortConfigurationRequest)1 ErrorData (org.openkilda.messaging.error.ErrorData)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1