Search in sources :

Example 1 with InfoMessage

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

the class SpeakerBolt method makeSwitchMessage.

protected String makeSwitchMessage(ISwitchImpl sw, SwitchState state) throws IOException {
    SwitchInfoData data = new SwitchInfoData(sw.getDpid().toString(), state, // TODO: need to create these on the fly
    "192.168.0.1", "sw" + sw.getDpid().toString(), "Simulated Switch", "SimulatorTopology");
    InfoMessage message = new InfoMessage(data, Instant.now().toEpochMilli(), UUID.randomUUID().toString(), null);
    return Utils.MAPPER.writeValueAsString(message);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage)

Example 2 with InfoMessage

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

the class CacheBolt method doWork.

/**
 * {@inheritDoc}
 */
@Override
public void doWork(Tuple tuple) {
    if (CtrlAction.boltHandlerEntrance(this, tuple))
        return;
    logger.trace("State before: {}", state);
    String json = tuple.getString(0);
    String source = tuple.getSourceComponent();
    // TODO: Eliminate the inefficiency introduced through the hack
    try {
        logger.info("Received cache data={}", tuple);
        BaseMessage bm = MAPPER.readValue(json, BaseMessage.class);
        if (bm instanceof InfoMessage) {
            InfoMessage message = (InfoMessage) bm;
            InfoData data = message.getData();
            if (data instanceof NetworkInfoData) {
                logger.debug("Storage content message {}", json);
                handleNetworkDump(data, tuple);
                isReceivedCacheInfo = true;
            } else if (!isReceivedCacheInfo) {
                logger.debug("Cache message fail due bolt not initialized: " + "component={}, stream={}, tuple={}", tuple.getSourceComponent(), tuple.getSourceStreamId(), tuple);
            } else if (data instanceof SwitchInfoData) {
                logger.info("Cache update switch info data: {}", data);
                handleSwitchEvent((SwitchInfoData) data, tuple);
            } else if (data instanceof IslInfoData) {
                logger.info("Cache update isl info data: {}", data);
                handleIslEvent((IslInfoData) data, tuple);
            } else if (data instanceof PortInfoData) {
                logger.info("Cache update port info data: {}", data);
                handlePortEvent((PortInfoData) data, tuple);
            } else if (data instanceof FlowInfoData) {
                logger.info("Cache update flow data: {}", data);
                FlowInfoData flowData = (FlowInfoData) data;
                handleFlowEvent(flowData, tuple);
            } else if (data instanceof NetworkTopologyChange) {
                logger.info("Switch flows reroute request");
                NetworkTopologyChange topologyChange = (NetworkTopologyChange) data;
                handleNetworkTopologyChangeEvent(topologyChange, tuple);
            } else {
                logger.error("Skip undefined info data type {}", json);
            }
        } else {
            logger.error("Skip undefined message type {}", json);
        }
    } catch (CacheException exception) {
        logger.error("Could not process message {}", tuple, exception);
    } catch (IOException exception) {
        logger.error("Could not deserialize message {}", tuple, exception);
    } finally {
        if (isReceivedCacheInfo) {
            outputCollector.ack(tuple);
        } else {
            outputCollector.fail(tuple);
        }
    }
    logger.trace("State after: {}", state);
}
Also used : NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) FlowInfoData(org.openkilda.messaging.info.flow.FlowInfoData) BaseMessage(org.openkilda.messaging.BaseMessage) CacheException(org.openkilda.messaging.error.CacheException) InfoMessage(org.openkilda.messaging.info.InfoMessage) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) InfoData(org.openkilda.messaging.info.InfoData) FlowInfoData(org.openkilda.messaging.info.flow.FlowInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) NetworkInfoData(org.openkilda.messaging.info.discovery.NetworkInfoData) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) IOException(java.io.IOException) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) NetworkTopologyChange(org.openkilda.messaging.info.event.NetworkTopologyChange)

Example 3 with InfoMessage

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

the class CacheBolt method sendPortCachedEvent.

private void sendPortCachedEvent(List<PortInfoData> ports) {
    ports.forEach(portInfoData -> {
        String correlationId = UUID.randomUUID().toString();
        InfoMessage message = new InfoMessage(portInfoData, System.currentTimeMillis(), correlationId, Destination.WFM);
        try {
            outputCollector.emit(StreamType.OFE.toString(), new Values(MAPPER.writeValueAsString(message)));
            logger.info("Isl discovery request sent from CacheBolt with correlationId {}", correlationId);
        } catch (JsonProcessingException e) {
            logger.error("Error during serializing PortInfoData", e);
        }
    });
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 4 with InfoMessage

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

the class CacheBolt method emitFlowCrudMessage.

private void emitFlowCrudMessage(InfoData data, Tuple tuple, String correlationId) throws IOException {
    Message message = new InfoMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    outputCollector.emit(StreamType.WFM_DUMP.toString(), tuple, new Values(MAPPER.writeValueAsString(message)));
    logger.info("Flow command message sent");
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) BaseMessage(org.openkilda.messaging.BaseMessage) Message(org.openkilda.messaging.Message) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values)

Example 5 with InfoMessage

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

the class CacheBolt method emitFlowMessage.

private void emitFlowMessage(InfoData data, Tuple tuple, String correlationId) throws IOException {
    Message message = new InfoMessage(data, System.currentTimeMillis(), correlationId, Destination.TOPOLOGY_ENGINE);
    outputCollector.emit(StreamType.TPE.toString(), tuple, new Values(MAPPER.writeValueAsString(message)));
    logger.info("Flow command message sent");
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) CommandMessage(org.openkilda.messaging.command.CommandMessage) BaseMessage(org.openkilda.messaging.BaseMessage) Message(org.openkilda.messaging.Message) InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values)

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