Search in sources :

Example 11 with InfoData

use of org.openkilda.messaging.info.InfoData 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 12 with InfoData

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

the class OpenTSDBFilterBoltTest method mockTuple.

private void mockTuple(long timestamp) throws Exception {
    InfoData infoData = new Datapoint(METRIC, timestamp, Collections.emptyMap(), VALUE);
    when(tuple.contains(eq("datapoint"))).thenReturn(true);
    when(tuple.getValueByField(eq("datapoint"))).thenReturn(infoData);
}
Also used : Datapoint(org.openkilda.messaging.info.Datapoint) InfoData(org.openkilda.messaging.info.InfoData)

Aggregations

InfoData (org.openkilda.messaging.info.InfoData)12 InfoMessage (org.openkilda.messaging.info.InfoMessage)8 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)5 IOException (java.io.IOException)4 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)4 Message (org.openkilda.messaging.Message)3 CommandMessage (org.openkilda.messaging.command.CommandMessage)3 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)3 FlowInfoData (org.openkilda.messaging.info.flow.FlowInfoData)3 Values (org.apache.storm.tuple.Values)2 BaseMessage (org.openkilda.messaging.BaseMessage)2 CommandData (org.openkilda.messaging.command.CommandData)2 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)2 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)2 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)2 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)2 FlowUpdateRequest (org.openkilda.messaging.command.flow.FlowUpdateRequest)2 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2