Search in sources :

Example 41 with Message

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

the class RouteAction method handle.

@Override
protected void handle() throws MessageFormatException, JsonProcessingException {
    KafkaMessage input = new KafkaMessage(getTuple());
    Message payload = input.getPayload();
    if (!(payload instanceof CtrlRequest)) {
        getLogger().debug(String.format("Skip foreign message (correlation-id: %s timestamp: %s)", payload.getCorrelationId(), payload.getTimestamp()));
        return;
    }
    handleMessage((CtrlRequest) payload);
}
Also used : Message(org.openkilda.messaging.Message) KafkaMessage(org.openkilda.wfm.protocol.KafkaMessage) CtrlRequest(org.openkilda.messaging.ctrl.CtrlRequest) KafkaMessage(org.openkilda.wfm.protocol.KafkaMessage)

Example 42 with Message

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

the class SwitchPortsSpout method nextTuple.

@Override
public void nextTuple() {
    Message message = buildPortsCommand(REQUESTER);
    logger.debug("emitting portsCommand: {}", message.toString());
    // Note that no tupleId which means this is an untracked tuple which is
    collector.emit(new Values(message));
    try {
        // required for the sleep
        Thread.sleep(frequency * 1000);
    } catch (InterruptedException e) {
        logger.error("Error sleeping");
    }
}
Also used : Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) Values(org.apache.storm.tuple.Values)

Example 43 with Message

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

the class SpeakerBolt method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute(Tuple tuple) {
    logger.debug("Ingoing tuple: {}", tuple);
    String request = tuple.getString(0);
    // String request = tuple.getStringByField("value");
    try {
        Message stats = Utils.MAPPER.readValue(request, Message.class);
        if (!Destination.WFM_STATS.equals(stats.getDestination()) || !(stats instanceof InfoMessage)) {
            return;
        }
        InfoMessage message = (InfoMessage) stats;
        final InfoData data = message.getData();
        if (data instanceof PortStatsData) {
            logger.debug("Port stats message: {}", new Values(request));
            outputCollector.emit(PORT_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof MeterConfigStatsData) {
            logger.debug("Meter config stats message: {}", new Values(request));
            outputCollector.emit(METER_CFG_STATS_STREAM, tuple, new Values(message));
        } else if (data instanceof FlowStatsData) {
            logger.debug("Flow stats message: {}", new Values(request));
            outputCollector.emit(FLOW_STATS_STREAM, tuple, new Values(message));
        }
    } catch (IOException exception) {
        logger.error("Could not deserialize message={}", request, exception);
    } finally {
        outputCollector.ack(tuple);
        logger.debug("Message ack: {}", request);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) AbstractTopology.fieldMessage(org.openkilda.wfm.topology.AbstractTopology.fieldMessage) MeterConfigStatsData(org.openkilda.messaging.info.stats.MeterConfigStatsData) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) InfoData(org.openkilda.messaging.info.InfoData) Values(org.apache.storm.tuple.Values) PortStatsData(org.openkilda.messaging.info.stats.PortStatsData) IOException(java.io.IOException)

Example 44 with Message

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

the class HealthCheckBolt method execute.

@Override
public void execute(Tuple input) {
    String request = input.getString(0);
    try {
        Message message = MAPPER.readValue(request, Message.class);
        if (message instanceof CommandMessage) {
            Values values = new Values(Utils.MAPPER.writeValueAsString(new InfoMessage(healthCheck, System.currentTimeMillis(), message.getCorrelationId(), Destination.NORTHBOUND)));
            collector.emit(Topic.HEALTH_CHECK, input, values);
        }
    } catch (IOException exception) {
        logger.error("Could not deserialize message: ", request, exception);
    } finally {
        collector.ack(input);
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) AbstractTopology.fieldMessage(org.openkilda.wfm.topology.AbstractTopology.fieldMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) IOException(java.io.IOException) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 45 with Message

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

the class CacheTopologyTest method getNetworkDump.

private NetworkDump getNetworkDump(ConsumerRecord<String, String> raw) throws IOException {
    Message responseGeneric = objectMapper.readValue(raw.value(), Message.class);
    CtrlResponse response = (CtrlResponse) responseGeneric;
    DumpStateResponseData data = (DumpStateResponseData) response.getData();
    CacheBoltState cacheState = (CacheBoltState) data.getState();
    return cacheState.getNetwork();
}
Also used : CacheBoltState(org.openkilda.messaging.ctrl.state.CacheBoltState) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) DumpStateResponseData(org.openkilda.messaging.ctrl.DumpStateResponseData) CtrlResponse(org.openkilda.messaging.ctrl.CtrlResponse)

Aggregations

Message (org.openkilda.messaging.Message)71 CommandMessage (org.openkilda.messaging.command.CommandMessage)55 InfoMessage (org.openkilda.messaging.info.InfoMessage)55 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)29 Test (org.junit.Test)25 IOException (java.io.IOException)11 Values (org.apache.storm.tuple.Values)10 CtrlRequest (org.openkilda.messaging.ctrl.CtrlRequest)6 CtrlResponse (org.openkilda.messaging.ctrl.CtrlResponse)6 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)6 CommandData (org.openkilda.messaging.command.CommandData)5 RequestData (org.openkilda.messaging.ctrl.RequestData)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 CommandWithReplyToMessage (org.openkilda.messaging.command.CommandWithReplyToMessage)4 DumpStateResponseData (org.openkilda.messaging.ctrl.DumpStateResponseData)4 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 BaseInstallFlow (org.openkilda.messaging.command.flow.BaseInstallFlow)3 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3