Search in sources :

Example 21 with CommandData

use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.

the class RerouteBolt method handleCommandMessage.

private void handleCommandMessage(CommandMessage commandMessage) {
    CommandData commandData = commandMessage.getData();
    String correlationId = getCommandContext().getCorrelationId();
    if (commandData instanceof RerouteAffectedFlows) {
        rerouteService.rerouteAffectedFlows(this, correlationId, (RerouteAffectedFlows) commandData);
    } else if (commandData instanceof RerouteAffectedInactiveFlows) {
        rerouteService.rerouteInactiveAffectedFlows(this, correlationId, ((RerouteAffectedInactiveFlows) commandData).getSwitchId());
    } else if (commandData instanceof RerouteInactiveFlows) {
        rerouteService.rerouteInactiveFlows(this, correlationId, (RerouteInactiveFlows) commandData);
    } else if (commandData instanceof FlowRerouteRequest) {
        rerouteService.processRerouteRequest(this, correlationId, (FlowRerouteRequest) commandData);
    } else if (commandData instanceof YFlowRerouteRequest) {
        rerouteService.processRerouteRequest(this, correlationId, (YFlowRerouteRequest) commandData);
    } else {
        unhandledInput(getCurrentTuple());
    }
}
Also used : YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) YFlowRerouteRequest(org.openkilda.messaging.command.yflow.YFlowRerouteRequest) RerouteAffectedFlows(org.openkilda.messaging.command.reroute.RerouteAffectedFlows) CommandData(org.openkilda.messaging.command.CommandData) RerouteInactiveFlows(org.openkilda.messaging.command.reroute.RerouteInactiveFlows) RerouteAffectedInactiveFlows(org.openkilda.messaging.command.reroute.RerouteAffectedInactiveFlows)

Example 22 with CommandData

use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.

the class SwitchPortsSpout method nextTuple.

@Override
public void nextTuple() {
    final long now = now();
    if (now - lastTickTime > frequency) {
        CommandData data = new PortsCommandData(REQUESTER);
        logger.debug("emitting PortsCommandData: {}", data);
        String correlationId = format("SwitchPortsSpout-%s", UUID.randomUUID().toString());
        collector.emit(new Values(correlationId, data, correlationId));
        if (now - lastTickTime > frequency * 2) {
            logger.warn("long tick for PortsCommandData - {}ms", now - lastTickTime);
        }
        lastTickTime = now;
    }
    org.apache.storm.utils.Utils.sleep(1);
}
Also used : PortsCommandData(org.openkilda.messaging.command.discovery.PortsCommandData) Values(org.apache.storm.tuple.Values) CommandData(org.openkilda.messaging.command.CommandData) PortsCommandData(org.openkilda.messaging.command.discovery.PortsCommandData)

Example 23 with CommandData

use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.

the class PingRequestTest method serializeLoop.

@Test
public void serializeLoop() throws Exception {
    Ping ping = new Ping((short) 100, new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10));
    PingRequest origin = new PingRequest(ping);
    CommandMessage wrapper = new CommandMessage(origin, System.currentTimeMillis(), getClass().getSimpleName());
    serializer.serialize(wrapper);
    CommandMessage decodedWrapper = (CommandMessage) serializer.deserialize();
    CommandData decoded = decodedWrapper.getData();
    Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) Ping(org.openkilda.messaging.model.Ping) SwitchId(org.openkilda.model.SwitchId) CommandData(org.openkilda.messaging.command.CommandData) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 24 with CommandData

use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.

the class RouterBolt method handleInput.

@Override
protected void handleInput(Tuple input) throws PipelineException {
    String key = input.getStringByField(MessageKafkaTranslator.FIELD_ID_KEY);
    Message message = pullValue(input, FIELD_ID_PAYLOAD, Message.class);
    if (message instanceof CommandMessage) {
        if (active) {
            log.debug("Received command message {}", message);
            CommandMessage command = (CommandMessage) message;
            CommandData data = command.getData();
            if (data instanceof BaseRequest) {
                BaseRequest baseRequest = (BaseRequest) data;
                processRequest(input, key, baseRequest);
            }
        }
    } else if (message instanceof InfoMessage || message instanceof ErrorMessage) {
        log.debug("Received hub response message {}", message);
        emitWithContext(SpeakerWorkerBolt.INCOME_STREAM, input, new Values(key, message));
    } else {
        unhandledInput(input);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) BaseRequest(org.openkilda.messaging.nbtopology.request.BaseRequest) LinksBaseRequest(org.openkilda.messaging.nbtopology.request.LinksBaseRequest) SwitchesBaseRequest(org.openkilda.messaging.nbtopology.request.SwitchesBaseRequest) FeatureTogglesBaseRequest(org.openkilda.messaging.nbtopology.request.FeatureTogglesBaseRequest) FlowsBaseRequest(org.openkilda.messaging.nbtopology.request.FlowsBaseRequest) KildaConfigurationBaseRequest(org.openkilda.messaging.nbtopology.request.KildaConfigurationBaseRequest) Values(org.apache.storm.tuple.Values) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 25 with CommandData

use of org.openkilda.messaging.command.CommandData in project open-kilda by telstra.

the class SpeakerWorkerBolt method onRequestTimeout.

@Override
public void onRequestTimeout(Tuple request) throws PipelineException {
    String key = pullKey(request);
    CommandData commandData = pullValue(request, MessageKafkaTranslator.FIELD_ID_PAYLOAD, CommandData.class);
    log.debug("Send timeout error to hub {}", key);
    ErrorData errorData = new ErrorData(ErrorType.OPERATION_TIMED_OUT, String.format("Timeout for waiting response on command %s", commandData), "Error in SpeakerWorker");
    ErrorMessage errorMessage = new ErrorMessage(errorData, System.currentTimeMillis(), key);
    emitResponseToHub(request, new Values(key, errorMessage, pullContext(request)));
}
Also used : Values(org.apache.storm.tuple.Values) CommandData(org.openkilda.messaging.command.CommandData) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) ErrorData(org.openkilda.messaging.error.ErrorData)

Aggregations

CommandData (org.openkilda.messaging.command.CommandData)35 CommandMessage (org.openkilda.messaging.command.CommandMessage)14 Values (org.apache.storm.tuple.Values)12 Message (org.openkilda.messaging.Message)11 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)11 InfoData (org.openkilda.messaging.info.InfoData)7 Test (org.junit.Test)6 InfoMessage (org.openkilda.messaging.info.InfoMessage)6 DiscoverIslCommandData (org.openkilda.messaging.command.discovery.DiscoverIslCommandData)5 DumpGroupsForFlowHsRequest (org.openkilda.messaging.command.switches.DumpGroupsForFlowHsRequest)5 DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)5 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)5 SwitchId (org.openkilda.model.SwitchId)5 IOException (java.io.IOException)4 List (java.util.List)4 DiscoverPathCommandData (org.openkilda.messaging.command.discovery.DiscoverPathCommandData)4 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)4 ErrorData (org.openkilda.messaging.error.ErrorData)4 NetworkCommandData (org.openkilda.messaging.command.discovery.NetworkCommandData)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3