Search in sources :

Example 56 with InfoMessage

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

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

the class SpeakerBoltTest method testAddSwitchValues.

@Test
public void testAddSwitchValues() throws Exception {
    List<Values> values = speakerBolt.addSwitch(switchMessage);
    assertEquals(3, values.size());
    int count = 0;
    for (Values value : values) {
        InfoMessage infoMessage = mapper.readValue((String) value.get(1), InfoMessage.class);
        if (count < 2) {
            assertThat(infoMessage.getData(), instanceOf(SwitchInfoData.class));
            SwitchInfoData sw = (SwitchInfoData) infoMessage.getData();
            assertEquals("00:00:" + dpid, sw.getSwitchId());
        } else {
            assertThat(infoMessage.getData(), instanceOf(PortInfoData.class));
            PortInfoData port = (PortInfoData) infoMessage.getData();
            assertEquals("00:00:" + dpid, port.getSwitchId());
            if (port.getPortNo() == localLinkPort) {
                assertEquals(PortChangeType.UP, port.getState());
            } else {
                assertEquals(PortChangeType.DOWN, port.getState());
            }
        }
        count++;
    }
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Values(org.apache.storm.tuple.Values) PortInfoData(org.openkilda.messaging.info.event.PortInfoData) SwitchInfoData(org.openkilda.messaging.info.event.SwitchInfoData) Test(org.junit.Test)

Example 58 with InfoMessage

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

the class CacheTopologyTest method sendFlowUpdate.

private static void sendFlowUpdate(ImmutablePair<Flow, Flow> flow) throws IOException {
    System.out.println("Flow Topology: Send Flow Creation Request");
    String correlationId = UUID.randomUUID().toString();
    FlowInfoData data = new FlowInfoData(flow.getLeft().getFlowId(), flow, FlowOperation.CREATE, correlationId);
    // TODO: as part of getting rid of OutputTopic, used TopoDiscoTopic. This feels wrong for
    // Flows.
    InfoMessage message = new InfoMessage(data, System.currentTimeMillis(), correlationId);
    sendMessage(message, topology.getConfig().getKafkaTopoCacheTopic());
}
Also used : FlowInfoData(org.openkilda.messaging.info.flow.FlowInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage)

Example 59 with InfoMessage

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

the class CacheTopologyTest method sendNetworkDump.

private static void sendNetworkDump(NetworkInfoData data) throws IOException {
    System.out.println("Topology-Engine: Send Network Dump");
    InfoMessage info = new InfoMessage(data, 0, UUID.randomUUID().toString(), Destination.WFM_CACHE);
    sendMessage(info, topology.getConfig().getKafkaTopoCacheTopic());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage)

Example 60 with InfoMessage

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

the class CacheTopologyTest method cacheReceivesFlowTopologyUpdatesAndSendsToTopologyEngine.

@Test
public void cacheReceivesFlowTopologyUpdatesAndSendsToTopologyEngine() throws Exception {
    System.out.println("Flow Update Test");
    teConsumer.clear();
    sendFlowUpdate(thirdFlow);
    ConsumerRecord<String, String> flow = teConsumer.pollMessage();
    assertNotNull(flow);
    assertNotNull(flow.value());
    InfoMessage infoMessage = objectMapper.readValue(flow.value(), InfoMessage.class);
    FlowInfoData infoData = (FlowInfoData) infoMessage.getData();
    assertNotNull(infoData);
    assertEquals(thirdFlow, infoData.getPayload());
}
Also used : FlowInfoData(org.openkilda.messaging.info.flow.FlowInfoData) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest)

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