Search in sources :

Example 51 with InfoMessage

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

the class CrudBolt method handleDumpRequest.

private void handleDumpRequest(CommandMessage message, Tuple tuple) {
    List<Flow> flows = flowCache.dumpFlows().stream().map(this::buildFlowResponse).collect(Collectors.toList());
    logger.info("Dump flows: {}", flows);
    Values northbound = new Values(new InfoMessage(new FlowsResponse(flows), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 52 with InfoMessage

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

the class CrudBolt method handleStatusRequest.

private void handleStatusRequest(String flowId, CommandMessage message, Tuple tuple) throws IOException {
    ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
    FlowState status = flow.getLeft().getState();
    logger.info("Status flow: {}={}", flowId, status);
    Values northbound = new Values(new InfoMessage(new FlowStatusResponse(new FlowIdStatusPayload(flowId, status)), message.getTimestamp(), message.getCorrelationId(), Destination.NORTHBOUND));
    outputCollector.emit(StreamType.RESPONSE.toString(), tuple, northbound);
}
Also used : FlowState(org.openkilda.messaging.payload.flow.FlowState) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 53 with InfoMessage

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

the class CrudBolt method handleStateRequest.

/**
 * This method changes the state of the Flow. It sets the state of both left and right to the
 * same state.
 *
 * It is currently called from 2 places - a failed update (set flow to DOWN), and a STATUS
 * update from the TransactionBolt.
 */
private void handleStateRequest(String flowId, FlowState state, Tuple tuple) throws IOException {
    ImmutablePair<Flow, Flow> flow = flowCache.getFlow(flowId);
    logger.info("State flow: {}={}", flowId, state);
    flow.getLeft().setState(state);
    flow.getRight().setState(state);
    final String correlationId = UUID.randomUUID().toString();
    FlowInfoData data = new FlowInfoData(flowId, flow, FlowOperation.STATE, correlationId);
    InfoMessage infoMessage = new InfoMessage(data, System.currentTimeMillis(), correlationId);
    Values topology = new Values(Utils.MAPPER.writeValueAsString(infoMessage));
    outputCollector.emit(StreamType.STATUS.toString(), tuple, topology);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) Flow(org.openkilda.messaging.model.Flow)

Example 54 with InfoMessage

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

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

the class FlowMetricGenBolt method execute.

@Override
public void execute(Tuple input) {
    StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
    InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);
    if (!Destination.WFM_STATS.equals(message.getDestination())) {
        collector.ack(input);
        return;
    }
    LOGGER.debug("Flow stats message: {}={}, component={}, stream={}", CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
    FlowStatsData data = (FlowStatsData) message.getData();
    long timestamp = message.getTimestamp();
    String switchId = data.getSwitchId().replaceAll(":", "");
    try {
        for (FlowStatsReply reply : data.getStats()) {
            for (FlowStatsEntry entry : reply.getEntries()) {
                emit(entry, timestamp, switchId);
            }
        }
        collector.ack(input);
    } catch (ServiceUnavailableException e) {
        LOGGER.error("Error process: {}", input.toString(), e);
        // If we can't connect to Neo then don't know if valid input
        collector.fail(input);
    } catch (Exception e) {
        // We tried, no need to try again
        collector.ack(input);
    }
}
Also used : FlowStatsReply(org.openkilda.messaging.info.stats.FlowStatsReply) FlowStatsEntry(org.openkilda.messaging.info.stats.FlowStatsEntry) StatsComponentType(org.openkilda.wfm.topology.stats.StatsComponentType) FlowStatsData(org.openkilda.messaging.info.stats.FlowStatsData) InfoMessage(org.openkilda.messaging.info.InfoMessage) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException) MalformedURLException(java.net.MalformedURLException) FlowCookieException(org.openkilda.wfm.topology.FlowCookieException) ClientException(org.neo4j.driver.v1.exceptions.ClientException) ServiceUnavailableException(org.neo4j.driver.v1.exceptions.ServiceUnavailableException)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)87 Test (org.junit.Test)34 Values (org.apache.storm.tuple.Values)27 CommandMessage (org.openkilda.messaging.command.CommandMessage)21 Flow (org.openkilda.messaging.model.Flow)21 Message (org.openkilda.messaging.Message)20 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)19 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)19 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)13 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)12 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)12 IOException (java.io.IOException)9 SwitchInfoData (org.openkilda.messaging.info.event.SwitchInfoData)9 ErrorData (org.openkilda.messaging.error.ErrorData)8 InfoData (org.openkilda.messaging.info.InfoData)8 PortInfoData (org.openkilda.messaging.info.event.PortInfoData)8 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)8 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)8 NetworkInfoData (org.openkilda.messaging.info.discovery.NetworkInfoData)7 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)7